]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoImport libxo-0.9.0:
Phil Shafer [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

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

6 years agoImplement initial MMC partitions support for MMCCAM.
Ilya Bakulin [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

6 years agoFix UP build.
Konstantin Belousov [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

6 years agoif_muge: only attach to LAN7800 Chip ID
Ed Maste [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

6 years agoMove preemption handling out of critical_exit.
Mateusz Guzik [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

6 years agoAdd new PIDs for Audio, CDCE, MTP, and Mass Storage, from
Edward Tomasz Napierala [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

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

6 years agoFix MMCCAM scanning for new cards.
Ilya Bakulin [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

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

6 years agoEnsure that "m" is initialized in vm_page_alloc_freelist_domain().
Mark Johnston [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

6 years agoHandle reserved memory with the no-map property.
Andrew Turner [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

6 years agoInitialize the dumper struct before calling set_dumper().
Mark Johnston [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

6 years agoAdd a SPD cache to speed up lookups.
Fabien Thomas [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

6 years agoUse __SCCSID for SCCS IDs in libkvm sources.
John Baldwin [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

6 years agoRevert r334035 for now. It breaks the boot on some boards as er expect to
Andrew Turner [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.

6 years agoTypo.
Mark Johnston [Tue, 22 May 2018 15:49:23 +0000 (15:49 +0000)]
Typo.

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

6 years agoFlush caches before initiating a microcode update on Intel CPUs.
Mark Johnston [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

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

No functional change intended.

MFC after: 2 weeks

6 years agosx: fixup a braino in r334024
Mateusz Guzik [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

6 years agointel-ucode-split: add -n flag to skip creating output files
Ed Maste [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

6 years agoPass the array length into regions_to_avail.
Andrew Turner [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.

6 years agoUse local unique labels inside most often used macros.
Konstantin Belousov [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

6 years agobus_dma(9): Correct arm64 BUS_DMA_COHERENT implementation note
Emmanuel Vadot [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

6 years agoFix double-load of %cr3 and double-copy of the stack frame for the
Konstantin Belousov [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

6 years agoRestore the ability to keep states after parent rule deletion.
Andrey V. Elsukov [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

6 years agoEnable IBRS when entering an interrupt handler from usermode.
Konstantin Belousov [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

6 years agoOnly set realmem based on memory where the EXFLAG_NOALLOC is unset. This
Andrew Turner [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

6 years agoOn ThunderX2 we need to be careful to only map the memory the firmware
Andrew Turner [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

6 years agobus_dma(9): arm64 implementation notes
Emmanuel Vadot [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.

6 years agoStop using the DMAP region to map ACPI memory.
Andrew Turner [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

6 years agoSwitch arm64 to use the same physmem code as 32-bit arm.
Andrew Turner [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

6 years agoImplement printf(3) family %m format string extension.
Konstantin Belousov [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

6 years agoAllow the 32-bit arm physmem code to work on arm64.
Andrew Turner [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

6 years agoCoalesce adjacent physical mappings.
Andrew Turner [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

6 years agoxen-blkback: do not use state 3 (XenbusStateInitialised)
Roger Pau Monné [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

6 years agoReduce sdt-related branch-fest in mi_switch.
Mateusz Guzik [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.

6 years agotop(1): increase size of 'status' buffer
Eitan Adler [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);

6 years agosx: port over writer starvation prevention measures from rwlock
Mateusz Guzik [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

6 years agorw: decrease writer starvation
Mateusz Guzik [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

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

MFC after: 3 days

6 years agoRevert: r334016
Marcelo 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.

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

6 years agoInclude atkbdc header where there are declared the prototype functions
Marcelo 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.

6 years agofix i386 builds after r334005 and r334009
Matt Macy [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

6 years agopmcstat: add option to not decode the leaf function in top mode
Matt Macy [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

6 years agoWe must free the variable str.
Marcelo 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

6 years agoAdd an IPMI attachment for PowerNV systems
Justin Hibbits [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.

6 years agoAdd a comment explaining the need of a global temporary variable
Justin Hibbits [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

6 years agoBasic OPAL sensor support for POWER9 platforms
Justin Hibbits [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

6 years agotop(1): unbreak build with gcc7; fix varargs
Eitan Adler [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

6 years agoCleanups related to debug exceptions on x86.
John Baldwin [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

6 years agosh: Split CNL syntax category to avoid a check on state[level].syntax
Jilles Tjoelker [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.

6 years agodevd: Always install devmatch.conf
Emmanuel Vadot [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

6 years agoaw_mmc: Correctly reset the mmc controller
Emmanuel Vadot [Mon, 21 May 2018 21:15:46 +0000 (21:15 +0000)]
aw_mmc: Correctly reset the mmc controller

Always disable FIFO access as we don't use it.
Rename some register bits so they are in sync with the register name.

While here add my copyright as I've probably wrote 70% of the code here.

6 years agoAdd Intel Spec Store Bypass Disable control.
Konstantin Belousov [Mon, 21 May 2018 21:08:19 +0000 (21:08 +0000)]
Add Intel Spec Store Bypass Disable control.

Speculative Store Bypass (SSB) is a speculative execution side channel
vulnerability identified by Jann Horn of Google Project Zero (GPZ) and
Ken Johnson of the Microsoft Security Response Center (MSRC)
https://bugs.chromium.org/p/project-zero/issues/detail?id=1528.
Updated Intel microcode introduces a MSR bit to disable SSB as a
mitigation for the vulnerability.

Introduce a sysctl hw.spec_store_bypass_disable to provide global
control over the SSBD bit, akin to the existing sysctl that controls
IBRS. The sysctl can be set to one of three values:
0: off
1: on
2: auto

Future work will enable applications to control SSBD on a per-process
basis (when it is not enabled globally).

SSBD bit detection and control was verified with prerelease microcode.

Security: CVE-2018-3639
Tested by: emaste (previous version, without updated microcode)
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

6 years agoAdd definition for Intel Speculative Store Bypass Disable MSR bits
Konstantin Belousov [Mon, 21 May 2018 21:07:13 +0000 (21:07 +0000)]
Add definition for Intel Speculative Store Bypass Disable MSR bits

Security: CVE-2018-3639
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

6 years agoPreserve other bits in IA32_SPEC_CTL MSR when changing the IBRS and
Konstantin Belousov [Mon, 21 May 2018 21:05:55 +0000 (21:05 +0000)]
Preserve other bits in IA32_SPEC_CTL MSR when changing the IBRS and
STIBP states.

Tested by: emaste (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

6 years agouchcom: extend hardware support to version 0x30
Andriy Gapon [Mon, 21 May 2018 21:04:31 +0000 (21:04 +0000)]
uchcom: extend hardware support to version 0x30

This change adds support for a UBS<->RS232 adapter based on CH340 (or an
analogue) that I own.  The device seems to have a newer internal version
(0x30) and the existing code incorrectly configures line control for it
resulting in garbled transmission.  The changes are based on what I
learned in Linux drivers for the same hardware.

Additional changes:
- use UCHCOM_REG_LCR1 / UCHCOM_REG_LCR2 instead of explicit 0x18 and
  0x25
- use NULL instead of 0 where a pointer is expected

Reviewed by: hselasky
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D15498

6 years agouchcom: remove UCHCOM_REG_BREAK2 alias of UCHCOM_REG_LCR1
Andriy Gapon [Mon, 21 May 2018 21:02:10 +0000 (21:02 +0000)]
uchcom: remove UCHCOM_REG_BREAK2 alias of UCHCOM_REG_LCR1

Also, add definitions for more bits of UCHCOM_REG_LCR1 as seen in the
Linux driver.  UCHCOM_LCR1_PARENB definition was different from that in
the Linux driver and clashed with newly added UCHCOM_LCR1_RX.  I took a
liberty to change UCHCOM_LCR1_PARENB to the Linux definition as it was
unused in the driver anyway.  This change should make
uchcom_cfg_set_break() easier to understand.

Approved by: hselasky
MFC after: 2 weeks

6 years agouchcom: reject parity and double stop bits as unsupported
Andriy Gapon [Mon, 21 May 2018 21:00:13 +0000 (21:00 +0000)]
uchcom: reject parity and double stop bits as unsupported

Reviewed by: hselasky
MFC after: 2 weeks

6 years agouchcom: add a hardware configuration tweak seen in Linux code
Andriy Gapon [Mon, 21 May 2018 20:59:15 +0000 (20:59 +0000)]
uchcom: add a hardware configuration tweak seen in Linux code

Reviewed by: hselasky
MFC after: 2 weeks

6 years agouchcom: add DPRINTF-s to aid debugging of the driver
Andriy Gapon [Mon, 21 May 2018 20:58:06 +0000 (20:58 +0000)]
uchcom: add DPRINTF-s to aid debugging of the driver

Reviewed by: hselasky
MFC after: 2 weeks

6 years agouchcom: report detected product based on USB product ID
Andriy Gapon [Mon, 21 May 2018 20:57:14 +0000 (20:57 +0000)]
uchcom: report detected product based on USB product ID

Product IDs are specified in vendor documents.  The previously used
device ID is not.  This is a cosmetic change.  No functionality depends
on those IDs.

Reviewed by: hselasky
MFC after: 2 weeks

6 years agoteken: Rename the "Set Cursor Style" sequence to match vt100.net docs
Jean-Sébastien Pédron [Mon, 21 May 2018 20:35:16 +0000 (20:35 +0000)]
teken: Rename the "Set Cursor Style" sequence to match vt100.net docs

This fixes inconsistencies with the rest of the `sequences` file.

No functional changes.

Requested by: ed

6 years agostop and restart kernel event timers in the suspend / resume cycle
Andriy Gapon [Mon, 21 May 2018 20:23:04 +0000 (20:23 +0000)]
stop and restart kernel event timers in the suspend / resume cycle

I have a system that is very unstable after resuming from suspend-to-RAM
but only if HPET is used as the event timer.  The theory is that SMM
code / firmware could be enabling HPET for its own uses and unexpected
interrupts cause a trouble for it.  Originally I wanted to solve the
problem in hpet_suspend() method, but that was insufficient as the event
timer could get reprogrammed again.

So, it's better, for my case and in general, to stop the event timer(s)
before entering the hardware suspend.

MFC after: 4 weeks
Differential Revision: https://reviews.freebsd.org/D15413

6 years agoFix grammar.
Konstantin Belousov [Mon, 21 May 2018 19:15:05 +0000 (19:15 +0000)]
Fix grammar.

Submitted by: alc
MFC after: 1 week

6 years agoAdd missed barrier for pm_gen/pm_active interaction.
Konstantin Belousov [Mon, 21 May 2018 18:41:16 +0000 (18:41 +0000)]
Add missed barrier for pm_gen/pm_active interaction.

When we issue shootdown IPIs, we first assign zero to pm_gens to
indicate the need to flush on the next context switch in case our IPI
misses the context, next we read pm_active. On context switch we set
our bit in pm_active, then we read pm_gen. It is crucial that both
threads see the memory in the program order, otherwise invalidation
thread might read pm_active bit as zero and the context switching
thread might read pm_gen as zero.

IA32 allows CPU for both reads to see zero. We must use the barriers
between write and read. The pm_active bit set is already locked, so
only the invalidation functions need it.

I never saw it in real life, or at least I do not have a good
reproduction case. I found this during code inspection when hunting
for the Xen TLB issue reported by cperciva.

Reviewed by: alc, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D15506

6 years agoAdd a somewhat ugly hack that makes OSX serial device node names
Edward Tomasz Napierala [Mon, 21 May 2018 17:33:52 +0000 (17:33 +0000)]
Add a somewhat ugly hack that makes OSX serial device node names
human-readable.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

6 years agoFix typo.
Edward Tomasz Napierala [Mon, 21 May 2018 16:50:27 +0000 (16:50 +0000)]
Fix typo.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

6 years agoImprove description strings for USB device-mode serial ports.
Edward Tomasz Napierala [Mon, 21 May 2018 16:33:13 +0000 (16:33 +0000)]
Improve description strings for USB device-mode serial ports.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

6 years agoRemove check for matching the rulenum, ruleid and rule pointer from
Andrey V. Elsukov [Mon, 21 May 2018 16:19:00 +0000 (16:19 +0000)]
Remove check for matching the rulenum, ruleid and rule pointer from
dyn_lookup_ipv[46]_state_locked(). These checks are remnants of not
ready to be committed code, and they are there by accident.
Due to the race these checks can lead to creating of duplicate states
when concurrent threads in the same time will try to add state for two
packets of the same flow, but in reverse directions and matched by
different parent rules.

Reported by: lev
MFC after: 3 days

6 years agoRestrict the faulting addresses we call pmap_fault from to just those that
Andrew Turner [Mon, 21 May 2018 16:14:53 +0000 (16:14 +0000)]
Restrict the faulting addresses we call pmap_fault from to just those that
may fault due to superpage mappings being changed.

Sponsored by: DARPA, AFRL

6 years agoinpcb: revert deferred inpcb free pending further review
Matt Macy [Mon, 21 May 2018 16:13:43 +0000 (16:13 +0000)]
inpcb: revert deferred inpcb free pending further review

6 years agoDon't pass a section cookie to CK for non-preemptible epoch sections.
Mark Johnston [Mon, 21 May 2018 16:03:51 +0000 (16:03 +0000)]
Don't pass a section cookie to CK for non-preemptible epoch sections.

They're only useful when multiple threads may share an epoch record,
and that can't happen with non-preemptible sections.

Reviewed by: mmacy
Differential Revision: https://reviews.freebsd.org/D15507

6 years agoUse USB Vendor Identifiers and Product Identifiers provided by V-USB
Edward Tomasz Napierala [Mon, 21 May 2018 15:06:19 +0000 (15:06 +0000)]
Use USB Vendor Identifiers and Product Identifiers provided by V-USB
(https://github.com/obdev/v-usb/blob/master/usbdrv/USB-IDs-for-free.txt).
Previously we were using an invalid (not assigned to us) VID.

Reviewed by: hselasky@
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

6 years agoOnly fillin data srucuture when actually stored.
Michael Tuexen [Mon, 21 May 2018 14:53:22 +0000 (14:53 +0000)]
Only fillin data srucuture when actually stored.

6 years agoDo the appropriate accounting when ip_output() fails.
Michael Tuexen [Mon, 21 May 2018 14:52:18 +0000 (14:52 +0000)]
Do the appropriate accounting when ip_output() fails.

6 years agoMake clear why there is an assignment, which is not necessary.
Michael Tuexen [Mon, 21 May 2018 14:51:20 +0000 (14:51 +0000)]
Make clear why there is an assignment, which is not necessary.

6 years agoPair CURVNET_SET and CURVNET_RESTORE in a block
Ed Maste [Mon, 21 May 2018 13:08:44 +0000 (13:08 +0000)]
Pair CURVNET_SET and CURVNET_RESTORE in a block

Per vnet(9), CURVNET_SET and CURVNET_RESTORE cannot be used as a single
statement for a conditional and CURVNET_RESTORE must be in the same
block as CURVNET_SET (or a subblock).

Reviewed by: andrew
Sponsored by: The FreeBSD Foundation

6 years agorelease: arm64: Use loader.efi as bootaa64.efi for RPI3 and PINE64
Emmanuel Vadot [Mon, 21 May 2018 11:58:02 +0000 (11:58 +0000)]
release: arm64: Use loader.efi as bootaa64.efi for RPI3 and PINE64

boot1.efi have some trouble to read MBR partitions, it needs them to be
aligned a certain way while loader.efi can cope with them either way.
We want to switch to loader.efi as the main efi loader everywhere, it seems
that arm64 using MBR partition will be the guinea pig.

Tested On: RPI3, Pine64
Reviewed by: imp
Approved by: gjb

6 years agoRevert r333968, it broke all archs but i386 and amd64
Ed Maste [Mon, 21 May 2018 11:56:07 +0000 (11:56 +0000)]
Revert r333968, it broke all archs but i386 and amd64

6 years agotop(1): fix build
Eitan Adler [Mon, 21 May 2018 09:43:50 +0000 (09:43 +0000)]
top(1): fix build

Remove 'top.local.hs'. This was not noticed since
/srv/obj/fbsd/srv/src/freebsd/svn/head/amd64.amd64/usr.bin/top/top.local.h
existed locally on my machine despite "make clean". Only fully removing
the objdir allowed me to observe the error directly.

Pointyhat to: me

6 years agotop(1): clean up some "const" related warnings
Eitan Adler [Mon, 21 May 2018 09:32:52 +0000 (09:32 +0000)]
top(1): clean up some "const" related warnings

This leaves at WARNS=6:
35 warnings in top.c
88 warnings in machine.c

all of which are either "incompatible-pointer-types-discards-qualifiers"
or "cast-qual"

6 years agotop(1): modernize a bit; reduce warnings
Eitan Adler [Mon, 21 May 2018 09:25:21 +0000 (09:25 +0000)]
top(1): modernize a bit; reduce warnings

- Replace caddr_t with "void *". This reduces
the number of warnings at WARNS=6
- use "static" where possible
- sprinkle const where possible

This leaves at WARNS=6:
35 warnings in top.c
88 warnings in machine.c
7 warnings in commands.c

all of which are either "incompatible-pointer-types-discards-qualifiers"
or "cast-qual"

6 years agoAdd missing va_end
Eitan Adler [Mon, 21 May 2018 09:21:42 +0000 (09:21 +0000)]
Add missing va_end

Reported by: andrew

6 years agoRevert r333969 which contained one too many changes
Eitan Adler [Mon, 21 May 2018 09:20:26 +0000 (09:20 +0000)]
Revert r333969 which contained one too many changes

6 years agotop(1): modernize a bit; reduce warnings
Eitan Adler [Mon, 21 May 2018 09:18:01 +0000 (09:18 +0000)]
top(1): modernize a bit; reduce warnings

- Replace caddr_t with "void *". This reduces
the number of warnings at WARNS=6
- use "static" where possible
- sprinkle const where possible

This leaves at WARNS=6:
35 warnings in top.c
72 warnings in machine.c
5 warnings in commands.c

all of which are either "incompatible-pointer-types-discards-qualifiers"
or "cast-qual"

6 years agoin(6)_mcast: Expand out vnet set / restore macro so that they work in a conditional...
Matt Macy [Mon, 21 May 2018 08:34:10 +0000 (08:34 +0000)]
in(6)_mcast: Expand out vnet set / restore macro so that they work in a conditional block

Reported by: zec at fer.hr

6 years agoensure that vnet is set when doing in_leavegroup
Matt Macy [Mon, 21 May 2018 07:12:06 +0000 (07:12 +0000)]
ensure that vnet is set when doing in_leavegroup

6 years agoamd64: annotate pti with __read_frequently
Mateusz Guzik [Mon, 21 May 2018 05:20:23 +0000 (05:20 +0000)]
amd64: annotate pti with __read_frequently

6 years agotop(1): add myself as a MAINTAIENR
Eitan Adler [Mon, 21 May 2018 05:00:19 +0000 (05:00 +0000)]
top(1): add myself as a MAINTAIENR

also fix some nits

6 years agotop(1): remove prime.c
Eitan Adler [Mon, 21 May 2018 04:51:43 +0000 (04:51 +0000)]
top(1): remove prime.c

This file was not connected to the build, and is better served by
primes(6) anyways.

6 years agotop(1): fix MIPS
Eitan Adler [Mon, 21 May 2018 04:47:13 +0000 (04:47 +0000)]
top(1): fix MIPS

I missed where the parentheses were.

Reported by: imp

6 years agotop(1): further unconditionally assume we're on FreeBSD
Eitan Adler [Mon, 21 May 2018 04:40:20 +0000 (04:40 +0000)]
top(1): further unconditionally assume we're on FreeBSD

6 years agotop(1): clean up in prep for const poisoning
Eitan Adler [Mon, 21 May 2018 04:32:14 +0000 (04:32 +0000)]
top(1): clean up in prep for const poisoning

- sprinkle "const" in a few obvious places
- remove "(void)" in front of lack-of-error-checked functions

6 years agotop(1): further unconditionally assume we're on FreeBSD
Eitan Adler [Mon, 21 May 2018 04:02:45 +0000 (04:02 +0000)]
top(1): further unconditionally assume we're on FreeBSD

6 years agotop(1): build with WARNS=3
Eitan Adler [Mon, 21 May 2018 03:58:15 +0000 (03:58 +0000)]
top(1): build with WARNS=3

This fixes everything but
-Wincompatible-pointer-types-discards-qualifiers

6 years agotop(1): fix several more warnings
Eitan Adler [Mon, 21 May 2018 03:36:16 +0000 (03:36 +0000)]
top(1): fix several more warnings

6 years agock: simplify interface with libkvm consumers by defining ck_queue types
Matt Macy [Mon, 21 May 2018 01:53:23 +0000 (01:53 +0000)]
ck: simplify interface with libkvm consumers by defining ck_queue types
as their queue.h equivalents if !_KERNEL