]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoMFC r350020 (by imp): Use a different approach to range check.
Alexander Motin [Thu, 8 Aug 2019 02:21:30 +0000 (02:21 +0000)]
MFC r350020 (by imp): Use a different approach to range check.

gcc hates dt < CC_DT_NONE since it can never be true when dt is an unsigned
type. Since that's a compiler choice and may be affected by weird stuff, instead
use (unsigned)dt > CC_DT_UNKNOWN to test for bounds error since that will work
regardless of the signedness of dt.

4 years agoMFC r350018: Implement a devtype command.
Alexander Motin [Thu, 8 Aug 2019 02:20:42 +0000 (02:20 +0000)]
MFC r350018: Implement a devtype command.

List the device's protocol. The returned value is one of the following:
        ata     direct attach ATA or SATA device
        satl    a SATA device attached via SAS
        scsi    A parallel SCSI or SAS
        nvme    A direct attached NVMe device
        mmcsd   A MMC or SD attached device

4 years agoMFC r350008 (by imp):
Alexander Motin [Thu, 8 Aug 2019 02:18:14 +0000 (02:18 +0000)]
MFC r350008 (by imp):
Use the more proper term of SATL instead of ATA_BEHIND_SCSI.

Most people know SAS attached SATA devices by the name SAT or SATL
(with the latter being a little more common). Change the device type
ATA_BEHIND_SCSI to SATL since it's more specific and meaningful.

4 years agoMFC r349964: Add device type NVME and device type MMCSD to get_device_type
Alexander Motin [Thu, 8 Aug 2019 02:17:24 +0000 (02:17 +0000)]
MFC r349964: Add device type NVME and device type MMCSD to get_device_type

For completeness, add nvme and mmc/sd devices to the list of device
types we know.

4 years agoMFC r349341: Use ata_param_fixup instead of a custom copy here
Alexander Motin [Thu, 8 Aug 2019 02:12:08 +0000 (02:12 +0000)]
MFC r349341: Use ata_param_fixup instead of a custom copy here

4 years agoMFC r349340 (by imp): Create ata_param_fixup
Alexander Motin [Thu, 8 Aug 2019 02:11:42 +0000 (02:11 +0000)]
MFC r349340 (by imp): Create ata_param_fixup

Create a common fixup routine to do the canonical fixup of the
ata_param fixup. Call it from both the ATA and the ATA over SCSI
paths.

4 years agoMFC r349339 (by imp):
Alexander Motin [Thu, 8 Aug 2019 02:11:08 +0000 (02:11 +0000)]
MFC r349339 (by imp):
Go ahead and completely fix the ata_params before calling the veto
function. This breaks nothing that uses it in the tree since
ata_params is ignored in storvsc_ada_probe_veto which is the only
in-tree consumer.

4 years agoMFC r349283 (by scottl):
Alexander Motin [Thu, 8 Aug 2019 02:08:09 +0000 (02:08 +0000)]
MFC r349283 (by scottl):
Refactor xpt_getattr() to make it more readable.  No outwardly
visible functional changes, though code flow was modified a bit
internally to lessen the need for goto jumps and chained if
conditionals.

4 years agoMFC r349010: Increase the timeout for READ NATIVE MAX
Alexander Motin [Thu, 8 Aug 2019 02:07:05 +0000 (02:07 +0000)]
MFC r349010: Increase the timeout for READ NATIVE MAX

READ NATIVE MAX can take longer than a second if the queued NCQ I/Os
take longer than a second to drain.

4 years agoMFC r348963: Minor white space changes.
Alexander Motin [Thu, 8 Aug 2019 02:06:23 +0000 (02:06 +0000)]
MFC r348963: Minor white space changes.

Remove trailing white space that's crept into this file.

4 years agoMFC r348786 (by chuck): Fix nda(4) PCIe link status output
Alexander Motin [Thu, 8 Aug 2019 02:04:29 +0000 (02:04 +0000)]
MFC r348786 (by chuck): Fix nda(4) PCIe link status output

Differentiate between PCI Express Endpoint devices and Root Complex
Integrated Endpoints in the nda driver. The Link Status and Capability
registers are not valid for Integrated Endpoints and should not be
displayed. The bhyve emulated NVMe device will advertise as being an
Integrated Endpoint.

4 years agoMFC r348110: Fix condition broken at r345815.
Alexander Motin [Thu, 8 Aug 2019 02:02:01 +0000 (02:02 +0000)]
MFC r348110: Fix condition broken at r345815.

4 years agoMFC r345815: Make cam_error_print() decode NVMe commands.
Alexander Motin [Thu, 8 Aug 2019 02:01:01 +0000 (02:01 +0000)]
MFC r345815: Make cam_error_print() decode NVMe commands.

4 years agoMFC r345817: Build NVMe CAM transport unrelated to NVMe SIM.
Alexander Motin [Thu, 8 Aug 2019 02:00:11 +0000 (02:00 +0000)]
MFC r345817: Build NVMe CAM transport unrelated to NVMe SIM.

Before this I suppose it was impossible load CAM-based NVMe as module.
Plus this appeared to be needed to build r345815 without NVMe driver.

4 years agoMFC r345363 (by imp): Make WD and WDC aliases for HGST.
Alexander Motin [Thu, 8 Aug 2019 00:33:23 +0000 (00:33 +0000)]
MFC r345363 (by imp): Make WD and WDC aliases for HGST.

HGST was bought by WDC. Over the years, it has sold different drives
branded as HGST, WD or WDC. All of them need the HGST workaround of
sending 4k-sized packets (or multiples of 4k). And the ones that don't
really need this aren't broken by this change. Submitter is the vendor
who has tested these changes on a number of drives. I've simplified it
slightly, since we don't need additional vendors for this at this
time.

4 years agoMFC r345060 (by 0mp): camcontrol.8: Bump date after r345051
Alexander Motin [Thu, 8 Aug 2019 00:32:22 +0000 (00:32 +0000)]
MFC r345060 (by 0mp): camcontrol.8: Bump date after r345051

4 years agoMFC r345051 (by imp): Add -l to camcontrol readcap.
Alexander Motin [Thu, 8 Aug 2019 00:31:00 +0000 (00:31 +0000)]
MFC r345051 (by imp): Add -l to camcontrol readcap.

The -l flag sends only the READ CAPACITY (16) sevice action. Normally
we send the READ CAPACITY (10) command, and only send RC16 when the
capacity is larger than 2TB (since that's the max RC10 can
report). However, some badly programmed drives report different
numbers for RC10 and RC16. This can be hard to diagnose, but generally
there's a "Logical block address out of range" error when RC16 reports
a larger number than RC10 and the RC10 number is the correct one. By
comparing the output of readcap with and without the -l argmuent, one
can determine if there's a mismatch and if the DA_Q_NO_RC16 quirk is
needed.

4 years agoMFC r344070 (by imp): Fix panic message.
Alexander Motin [Thu, 8 Aug 2019 00:29:39 +0000 (00:29 +0000)]
MFC r344070 (by imp): Fix panic message.

The panic message lead people to believe some userland CAM request had
caused a problem when in reallity it was for a kernel request (eg the
USER bit was cleared). Reword message. Also, improve a couple of
comments to reflect that the periph shouldn't be completely torn down
before we get here (so the path and sim pointers should be valid, but
aren't and the code is designed to be robust enough in the face of
that to give a specific panic message).

4 years agoMFC r343814 (by imp): Add quirk for Sansisk X400 drives
Alexander Motin [Thu, 8 Aug 2019 00:27:26 +0000 (00:27 +0000)]
MFC r343814 (by imp): Add quirk for Sansisk X400 drives

Certain versions of Sandisk x400 firmware can hang under extremely
heavly load of large I/Os for prolonged periods of time. Newer /
current versions work fine, and should be used where possible. Where
not possible, this quirk ensures that I/O requests are limited to 128k
to avoids the bug, even under extreme load. Since MAXPHYS is 128k,
only users with custom kernels are at risk on the older firmware.
Once all known users of the older firmware have upgraded, this quirk
will be removed.

4 years agoMFC r342866 (by imp): Add NO_SYNC_CACHE quirk for PENTAX cameras
Alexander Motin [Thu, 8 Aug 2019 00:23:11 +0000 (00:23 +0000)]
MFC r342866 (by imp): Add NO_SYNC_CACHE quirk for PENTAX cameras

PR: 93389

4 years agoMFC r341769 (by imp):
Alexander Motin [Thu, 8 Aug 2019 00:22:15 +0000 (00:22 +0000)]
MFC r341769 (by imp):
Send a START UNIT command when a disk responds with an ASC of 04/1C.
This will hopefully spin up a disk that's in low-power mode.

4 years agoMFC r340452 (by imp):
Alexander Motin [Thu, 8 Aug 2019 00:19:45 +0000 (00:19 +0000)]
MFC r340452 (by imp):
Introduce scsi_ata_setfeatures() as a convenient way to make
a passthru ATA SETFEATURES command.

4 years agoMFC r340448 (by imp): Remove trailing white space in advance of other changes.
Alexander Motin [Thu, 8 Aug 2019 00:18:36 +0000 (00:18 +0000)]
MFC r340448 (by imp): Remove trailing white space in advance of other changes.

4 years agoMFC r340024 (by imp): Add comments explaining what hold/unhold do
Alexander Motin [Thu, 8 Aug 2019 00:17:16 +0000 (00:17 +0000)]
MFC r340024 (by imp): Add comments explaining what hold/unhold do

They act as a simple one-deep semaphore to keep open/close/probe from
running at the same time to avoid races that creates.

4 years agoMFC r346995:
Mark Johnston [Wed, 7 Aug 2019 20:36:36 +0000 (20:36 +0000)]
MFC r346995:
Add a few regression tests for mlock(2).

4 years agoMFC r347366:
Emmanuel Vadot [Wed, 7 Aug 2019 19:18:32 +0000 (19:18 +0000)]
MFC r347366:

dts: Import files from Linux 5.1

4 years agoMFC r341404-r341405, r344699, r347024, r347442
Emmanuel Vadot [Wed, 7 Aug 2019 18:35:59 +0000 (18:35 +0000)]
MFC r341404-r341405, r344699, r347024, r347442

r341404 by andreast:
Add rule to build the dtb for the rock64 board.

Reviewed by: manu@

r341405 by andreast:
Build the dtb for the rock64 board.

Reviewed by: manu@

r344699:
arm64: rockchip: rk3399_pll: Fix the recalc function

The plls frequency are now correctly calculated in fractional mode
and integer mode.
While here add some debug printfs (disabled by default)
Tested with powerd on the little cluster on a RockPro64.

r347024:
dtb: Include RK3399 RockPro64 DTS in kernel build

The DTS for this board is already present in sys/gnu/dts/arm64/rockchip/
and just needs to be enabled.

Submitted by: alex@wied.io
Differential Revision: https://reviews.freebsd.org/D19823

r347442:
arm64: rockchip: Don't always put PLL to normal mode

We used to put every PLL in normal mode (meaning that the output would
be the result of the PLL configuration) instead of slow mode (the output
is equal to the external oscillator frequency, 24-26Mhz) but this doesn't
work for most of the PLLs as when we put them into normal mode the registers
configuring the output frequency haven't been set.
Add a normal_mode member in clk_pll_def/clk_pll_sc struct and if it's true
we then set the PLL to normal mode.
For now only set it to the LPLL and BPLL (Little cluster PLL and Big cluster
PLL respectively).

Reviewed by: ganbold
Differential Revision: https://reviews.freebsd.org/D20174

4 years agoMFC r341381-r341383, r341385, r343950, r344527, r344576-r344580, r344585, r344589...
Emmanuel Vadot [Wed, 7 Aug 2019 18:26:32 +0000 (18:26 +0000)]
MFC r341381-r341383, r341385, r343950, r344527, r344576-r344580, r344585, r344589-r344590, r344623, r344626-r344627

r341381:
arm64: rockchip: Add RK3399_CLK_PLL

PLLs on the RK3399 are different than the ones on the RK3328.
Add a new type and some dedicated recalc and set_freq functions.
Rename the RK3328 dedicated rk_clk_pll function with rk3328_ prefix.

r341382:
arm64/rockchip: add RK3399 support

Add CRU (Clock and Reset Unit) driver for RK3399.
Add support in rk_pinctrl driver.

Submitted by:  Greg V <greg@unrelenting.technology> (Original version)
Differential Revision: https://reviews.freebsd.org/D16732

r341383:
arm64: rockchip: rk_i2c: Use correct clock

While here add RK3399 support and call clk_set_assigned to set the correct
clock set in the DTS.

r341385:
arm64: rockchip: rk805: Add basic support for RK808 PMIC

RK808 PMIC is the companion chip for RK3399 SoC.
Add basic regulator support in RK805 since they are similar.

r343950:
arm64: Fix compile when removing SOC_ROCKCHIP_* options

Make every rockchip file depend on the multiple soc_rockchip options
While here make rk_i2c and rk_gpio depend on their device options.

Reported by: sbruno

r344527:
arm64: rockchip: clk: Set the write mask when setting the clock mux

RockChip clocks have a write mask in the upper 16bits of the mux register
which wasn't set in the set_mux function.
Also the wrong parent was tested instead of the real current one, when
switch parent, test with the current one before.

Pointy Hat:    manu

r344576:
arm64: rockchip: clk: rk_clk_composite: Properly use the mask bits

RockChip clocks register have a write mask in the upper 16 bits, if a 1
is present the corresponding bit in the lower 16 ones is set.
Use this instead of always setting the mask to 0xFFFF0000.
This avoids a read of the register.
While here add some debug printf useful for debuging clock problems

r344577:
arm64: rockchip: clk: ARM CLK improvement

RockChip clocks register have a write mask in the upper 16 bits, if a 1
is present the corresponding bit in the lower 16 ones is set.
Use this instead of always setting the mask to 0xFFFF0000.
This avoids a read of the register.
While here set the parent after changing its freqeuncy, this reduce the time
between changing the parent and changing the divider for the arm clock.

r344578:
arm64: rockchip: rk3328_pll: Multiple improvement

RockChip clocks register have a write mask in the upper 16 bits, if a 1
is present the corresponding bit in the lower 16 ones is set.
Use this instead of always setting the mask to 0xFFFF0000.
This avoids a read of the register.
While here, when switching PLL frequency, first switch it to slow mode.
When set to slow mode the PLL clock will be the external oscillator.
Changing the PLL parameters while its output is used can cause hang (sometimes).

r344579:
arm64: rockchip: rk805: Add LDO regulators

Add the 3 LDO regulator found in the RK805 Power Management IC.

r344580:
 arm64: rockchip: rk805: Map the regulator

No map function was provided before so every regulator lookup resolved
the regulator with id 1, as it uses the default mapper, which is wrong.
Correctly map the regulators.
While here remove some debug printfs and make them disable by default.

r344585:
arm64: rockchip: rk_pinctrl: Fix two banks in RK3328

The last two banks don't have 3 bits for the pin function but only 2.
This fixes eMMC on the Rock64.

r344589:
arm64: rockchip: rk3399_pll: Switch to slow mode when changing the freq

Like r344578 but for RK3399.
This solve some hangs when switching between frequency.

r344590:
arm64: rockchip: rk3399_pll: Fix copy paste

RK3399 PLLs don't have mode_reg, use the correct register.

r344623:
arm64: rockchip: clk_pll: Multiple improvement

Remove the mode_val from the clock definition as it's a bit unreadable.
Use mode_shift to represent which bit control the mode in the register.
Simplify some case where we can avoid a register read before changing it.
Set the PLL back to normal mode after the PLL have stabilized.

Discussed with:  mmel

r344626:
arm64: rockchip: rk3399_clk: Add sd clock definitions

r344627:
mmc: dwmmc: Match on "rockchip,rk3288-dw-mshc" compatible

This is the common denominator for rockchip compatible from RK3288 to RK3399.
The other compatible are generally present in the DTS but the controllers
are the same.

4 years agoMFC r341141-r341143, r341255
Emmanuel Vadot [Wed, 7 Aug 2019 18:16:28 +0000 (18:16 +0000)]
MFC r341141-r341143, r341255

r341141:
rk_clk_composite: Fix set_mux

Pointy Hat:   manu

r341142:
Add RK805 PMIC Support

RK805 is the companion PMIC for RK3328 SoC.
Add a driver for it with most of it's regulators supported.

r341143:
arm64: Add rk_i2c and rk805 to GENERIC

r341255:
arm64: rockchip: armclk: Do not change parent freq if CLK_SET_DRYRUN is set

4 years agoMFC r350568:
Cy Schubert [Wed, 7 Aug 2019 01:08:57 +0000 (01:08 +0000)]
MFC r350568:

Resolve ipfilter kld unload issues related to VNET jails.

When the ipfilter kld is loaded, used within VNET jail, and unloaded,
then subsequent loading, use, and unloading of another packet filters
will cause the subsequently loaded netpfil kld's to panic.

The scenario is as follows:

cd /usr/tests/sys/netpfil/common

kldunload ipl
kldunload pfsync
kldunload ipfw

kyua test pass_block

kldload ipl
kyua test pass_block
kldunload ipl

kldload pfsync
kyua test pass_block
kldunload pfsync
-- page fault panic occurs here --

Reported by: "Ahsan Barkati" <ahsanbarkati@g.....com> via kp@
Discussed with: kp@
Tested by: kp@

4 years agoMFC r350567:
Cy Schubert [Wed, 7 Aug 2019 01:03:35 +0000 (01:03 +0000)]
MFC r350567:

Returning an uninitialized error is a bad thing.

4 years agoMFC r350645: Correct ICMPv6/MLDv2 out-of-bounds memory access
Ed Maste [Tue, 6 Aug 2019 17:13:41 +0000 (17:13 +0000)]
MFC r350645: Correct ICMPv6/MLDv2 out-of-bounds memory access

Previously the ICMPv6 input path incorrectly handled cases where an
MLDv2 listener query packet was internally fragmented across multiple
mbufs.

admbugs: 921
Submitted by: jtl
Reported by: CJD of Apple
Approved by: so
Security: CVE-2019-5608

4 years agoMFC r350635: bsnmp: add asn1 message length validation
Ed Maste [Tue, 6 Aug 2019 16:11:16 +0000 (16:11 +0000)]
MFC r350635: bsnmp: add asn1 message length validation

admbugs: 780
Submitted by: Guido Vranken, bz
Reported by: Guido Vranken
Approved by: so
Security:       CVE-2019-5610

4 years agoMFC r350544:
Mark Johnston [Tue, 6 Aug 2019 14:39:02 +0000 (14:39 +0000)]
MFC r350544:
Add bzip2recover.1.

4 years agoMFC r350432:
Mark Johnston [Tue, 6 Aug 2019 14:38:44 +0000 (14:38 +0000)]
MFC r350432:
Merge r3778 and r3779 from ELFToolchain.

4 years agoMFC r350514:
Mark Johnston [Tue, 6 Aug 2019 14:38:16 +0000 (14:38 +0000)]
MFC r350514:
Add an MLINK for daemonfd(3).

4 years agoMFC r350513:
Mark Johnston [Tue, 6 Aug 2019 14:37:57 +0000 (14:37 +0000)]
MFC r350513:
Fix formatting.

4 years agoMFC r348179-r348182
Emmanuel Vadot [Tue, 6 Aug 2019 12:19:09 +0000 (12:19 +0000)]
MFC r348179-r348182

r348179:
allwinner: aw_ccu: Add some debug printfs (disabled by default)

Also print information about setting frequency at boot under bootverbose

r348180:
arm: allwinner: clk: Add new clock aw_clk_frac

Add a clock driver for clock that can either be used in integer mode
with one N factor and one M divider or in fractional mode where the
output frequency is chosen between two predifined output.

r348181:
arm: allwinner: clk: Use the new frac clock

Some clocks used the NM type but this clock is for the ones with the
formula "clk = clkin / n / m" and not "clk = clkin * n / m"
Use the new frac clock for them.

r348182:
arm: allwinner: Remove frac mode from NM clk

We have a correct clock type aw_clk_frac now for this.

4 years agoMFC r347489-r347491, r347512
Emmanuel Vadot [Tue, 6 Aug 2019 12:12:29 +0000 (12:12 +0000)]
MFC r347489-r347491, r347512

r347489:
allwinner: clk: prediv_mux: Init the current parent

Do not init the first parent but read the clock register to find
it's current parent and init this one.

r347490:
allwinner: clk: sun8i_r: Correct resets

The i2c reset wasn't defined and some bits where wrong, correct them.

r347491:
twsi: Calculate the clock param based on the bus frequency

Instead of precalculating the different speed, respect the bus frequency
and calculate the clock register parameter based on it.
If the platform didn't register the core clk, fallback on the precomputed
values (This is likely do be the case on Marvell boards).

r347512:
arm: allwinner: aw_clk_nm: Don't reparent the clock if we didn't ask

When looking for the best frequency don't change the clock parent if the
clock wasn't configured to do that.

4 years agoMFC 350618:
John Baldwin [Mon, 5 Aug 2019 22:04:16 +0000 (22:04 +0000)]
MFC 350618:
Validate guest-supplied length of headers for TSO transmit requests.

When transmitting a large TCP packet, the final transmit descriptor
includes the length of the protocol headers to be duplicated on each
segment.  The device model was trusting the guest-supplied value
without validating it.  A value of zero would result in the guest
being able to indirect a garbage pointer on the stack to overwrite
arbitrary memory in the bhyve process.  A value that was non-zero but
too small for the requested parameters resulted in the device model
reading and writing values beyond the end of the on-stack buffer used
to hold the template header.

To fix, validate the supplied length and drop requests to transmit
packets that would overflow the header buffer.  While here, initialize
the header pointer to NULL as a preventive measure so that any access
to an unallocated template header crashes they hypervisor
deterministically.

While here, only read the TCP sequence number if the packet being
split is a TCP packet.  The e1000 logic supports a segmentation of UDP
frames, and while UDP segmentation requires this part of the header to
be valid (so there is no buffer overflow), only reading the field when
needed is cleaner.

admbugs: 918
Reported by: Reno Robert <renorobert@gmail.com>
Approved by: so
Security: CVE-2019-5609

4 years agoMFC r350425: printf(1): Note that \c only works in %b strings
Jilles Tjoelker [Mon, 5 Aug 2019 20:19:38 +0000 (20:19 +0000)]
MFC r350425: printf(1): Note that \c only works in %b strings

PR: 238313

4 years agoMFC r347362:
Emmanuel Vadot [Mon, 5 Aug 2019 18:59:53 +0000 (18:59 +0000)]
MFC r347362:

dtb: allwinner: Add the pinebook dtb to the build

4 years agoMFC r346334, r346787-r346789, r347017
Emmanuel Vadot [Mon, 5 Aug 2019 18:27:25 +0000 (18:27 +0000)]
MFC r346334, r346787-r346789, r347017

r346334:
arm: allwinner: Fix audio for Allwinner H3/H5

Due to three conditions the codec driver for Allwinner A10/A20 and H3/H5 did not work properly here:

    Wrong bit position for the analog audio reset
    Hardware Reset of codec was not de-asserted correctly
    Linux DTS file did not contain the address of the analog register the way as the driver was expecting it.

This patch proposes fixes for those three parts.

Submitted by: freebsdnewbie@freenet.de (Manuel Stühn)
Differential Revision: https://reviews.freebsd.org/D19910

r346787:
arm64: allwinner: Add compatible strings for clock devices used on both Allwinner H3 and H5

Allwinner H3 and H5 share many internal components, that's why they can
use the same drivers.
This patch adds the compatible strings to enable clock drivers
probing on Allwinner NanoPI NEO2 device.

Tested on: NanoPi NEO2 (by submitter), OrangePi PC2 (by manu)
Submitted by: Manuel Stühn (freebsdnewbie@freenet.de)
Differential Revision: https://reviews.freebsd.org/D20069

r346788:
arm64: allwinner: ccu_de2: Remove H5 compatible

We don't have the display engine driver commited in FreeBSD yet so it is
useless to expose the clocks yet (and also it have not been tested on H5).

Reported by: Manuel Stühn (freebsdnewbie@freenet.de)
PR:  237571

r346789:
arm: allwinner: a10: Correct pin functions

PB20 and PB21 alternate function 1 is i2c2 not i2c1

Reported by: Horiki Mori (yamori813@yahoo.co.jp)
PR:  237401

r347017:
arm64: Add support for NanoPI NEO2

Add overlay files and activate devicetree file for NanoPi NEO2 featuring
Allwinner H5 ARM64 core.
To enable sound, dma and codec drivers are enabled for build.

Submitted by: Manuel Stühn (freebsdnewbie@freenet.de)
Differential Revision: https://reviews.freebsd.org/D20129

4 years agoMFC r346298:
Emmanuel Vadot [Mon, 5 Aug 2019 18:17:03 +0000 (18:17 +0000)]
MFC r346298:

config: Only warn if duplicate option/device comes from the same file

This is useful for arm (possibly other arches too) where we want to have
a GENERIC kernel that only include files for the different SoC. Since
multiple SoCs/Board needs the same device we would need to do either :

    Include the device in a generic file
    Include the device in each file that really needs it

Option 1 works but if someone wants to create a specific kernel config
(which isn't uncommon for embedded system), he will need to add a lots
of nodevice to it.

Option 2 also works but produce a lots of warnings.

Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D19424

4 years agoMFC r346295, r346297
Emmanuel Vadot [Mon, 5 Aug 2019 18:13:13 +0000 (18:13 +0000)]
MFC r346295, r346297

r346295:
arm: Add kern_clocksource.c directly in files.arm

This files is needed and included in all our config so move it to a common
location.

r346297:
arm: Order files.arm to have cloudabi and annapurna sections

4 years agoMFC r346305, r346691-r346694, r346696-r346697
Emmanuel Vadot [Mon, 5 Aug 2019 18:05:22 +0000 (18:05 +0000)]
MFC r346305, r346691-r346694, r346696-r346697

r346305:
arm: allwinner: Makes more device optional

r346691:
arm: allwinner: Add pnpinfo for aw_sid and add module Makefile

r346692:
arm: allwinner: Add pnp info to aw_thermal and compile it as module too

r346693:
arm: allwinner: Add pnp info to axp81x and compile it as module too

r346694:
arm: allwinner: Add pnp info to aw_rtc and compile it as module too

r346696:
arm: allwinner: Add pnp info to if_awg and compile it as module too

While here make it depend on aw_sid as it's needed for mac generation.

r346697:
arm: allwinner: Add pnp info to aw_rsb and compile it as module too

4 years agoMFC r344633-r344634, r344638
Emmanuel Vadot [Mon, 5 Aug 2019 17:54:08 +0000 (17:54 +0000)]
MFC r344633-r344634, r344638

r344633:
usb_nop_xceiv: Add support for this pseudo device

This is a "fake" phy that handle regulator, clocks and reset gpio.
Only clock and regulator is supported for now.

Sponsored-by: Rubicon Communications, LCC ("Netgate")
r344634:
xhci_mv: Move the driver to generic_xhci

Marvell XHCI is in fact generic-xhci, so move the driver and
add the compatible string.
While here, get and enable the phy if the dtb provide one.
The xhci bindings state that phys should be in a 'phys' property but
Marvell DTS uses 'usb-phy', only add support for 'usb-phy' for now.

Sponsored-by: Rubicon Communications, LCC ("Netgate")
r344638:
Fix armv6/armv7 build after the move from xhci_mv to generic_xhci

4 years agoMFC r342008, r342010-r342020
Emmanuel Vadot [Mon, 5 Aug 2019 17:43:44 +0000 (17:43 +0000)]
MFC r342008, r342010-r342020

r342008:
fdt: Add support for simple-mfd bus

Quoting the binding Documentation :

"These devices comprise a nexus for heterogeneous hardware blocks containing
more than one non-unique yet varying hardware functionality."

Reviewed by: loos
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D17751

r342010:
arm64: Add new SoC type MARVELL_8K

Sponsored by: Rubicon Communications, LLC ("Netgate")

r342011:
arm64: mvebu_pinctrl: Add driver for Marvell Pinmux Controller

Add a driver compatible with Marvell mvebu-pinctrl and add ap806-pinctrl
support.

Sponsored by: Rubicon Communications, LCC ("Netgate")

r342012:
arm64: marvell: Add driver for Marvell Ap806 System Controller

The first two clocks are for the clusters and their frequencies can be
found reading a register. Then a fixed 1200Mhz clock is present and two
fixed clocks, 'mss' which is 1200 / 6 and 'sdio' which is 1200 / 3.

Sponsored by: Rubicon Communications, LLC ("Netgate")

r342013:
arm64: mv_gpio: Add Marvell 8K support

While here put the interrupts setup in it's own function

Sponsored by: Rubicon Communications, LCC ("Netgate")

r342014:
arm64: marvell: Add cp110 clock controller support

The cp110 clock controller controls the clocks and gate of the CP110
hardware block.

Every clock/gate are implemented except the NAND clock.

Sponsored by: Rubicon Communications, LLC ("Netgate")

r342015:
twsi: Clean up marvell part and add support for Marvell 7k/8k

Sponsored by: Rubicon Communications, LLC ("Netgate")

r342016:
arm64: Add mv_cp110_icu and mv_cp110_gicp

icu is a interrupt concentrator in the CP110 block and gicp
is a gic extension to allow interrupts in the CP block to be turned
into GIC SPI interrupts

Sponsored by: Rubicon Communications, LLC ("Netgate")

r342017:
sdhci_xenon: Add Marvell 8k compatible string

Sponsored by: Rubicon Communications, LLC ("Netgate")

r342018:
mv_gpio: Since it's also an interrupt controller, attach sooner

Sponsored by: Rubicon Communications, LLC ("Netgate")

r342019:
arm64: mv_cp110_icu: Fix build

r342020:
mv_thermal: Add thermal driver for AP806 and CP110 thermal sensor

Sponsored by: Rubicon Communications, LLC ("Netgate")

4 years agoMFC r346293:
Emmanuel Vadot [Mon, 5 Aug 2019 17:32:16 +0000 (17:32 +0000)]
MFC r346293:

allwinner: clk: Garbage collect old clock implementation

The old clocks are disconneted from the build since r337344.
Remove all those pseudo drivers. The only one remaining is for gmac
(the ethernet controller) so move it to sys/arm/allwinner.
While here remove a83t support from gmacclk as it is unneeded since r326114.

4 years agoMFC r346092, r346271-r346272
Emmanuel Vadot [Mon, 5 Aug 2019 17:23:23 +0000 (17:23 +0000)]
MFC r346092, r346271-r346272

r346092:
Import DTS files from Linux 5.0

r346271:
aw_rtc: Register the clocks

Since latest DTS update the rtc is supposed to register two clocks :

- osc32k (the 32k oscillator on the board that the RTC uses directly and
that other peripheral can use)
- iosc (the internal oscillator of the RTC when available which frequency
depend on the SoC revision)

Since we need the RTC before the proper clock control unit (because it uses
those clocks) attach it a BUS_PASS_BUS + MIDDLE and attach the clock control
unit at BUS_PASS_BUS + LAST for the SoC that requires it.

Tested On:      A20, H3, A64

r346272:
aw_syscon: Add a new compatible

Since 5.0 DTS the syscon controller have a new compatible as it
exports new subnodes, we currently only use it as a syscon provider
so just add the new compatible.

Tested On:  H3

4 years agoMFC r345948, r345951
Emmanuel Vadot [Mon, 5 Aug 2019 17:06:20 +0000 (17:06 +0000)]
MFC r345948, r345951

r345948:
twsi: Add interrupt mode

Add the ability to use interrupts for i2c message.
We still use polling for early boot i2c transfer (for PMIC
for example) but as soon as interrupts are available use them.
On Allwinner SoC >A20 is seems that polling mode is broken for some
reason, this is now fixed by using interrupt mode.
For Allwinner also fix the frequency calculation, the one in the code
was for when the APB frequency is at 48Mhz while it is at 24Mhz on most
(all?) Allwinner SoCs. We now support both cases.

While here add more debug info when it's compiled in.

Tested On: A20, H3, A64

r345951:
twsi: Use config_intrhook_oneshot instead of config_intrhook_establish

Suggested by: ian
X-MFC-With: 345948

4 years agoMFC r342924, r343749-r343750, r343874, r344893-r344895, r345711
Emmanuel Vadot [Mon, 5 Aug 2019 17:01:19 +0000 (17:01 +0000)]
MFC r342924, r343749-r343750, r343874, r344893-r344895, r345711

r342924:
dtb: allwinner: Add orangepi-pc to the build

PR: 226011
Submitted by: Greg V <greg@unrelenting.technology>

r343749:
release: arm64: rpi3: Install the RPI3B+ DTB file

We should use the correct DTB file otherwise the firmware uses
the RPI3B one.

r343750:
release: arm64: pine64-lts: Use the newly created u-boot-pine64-lts port

In U-Boot 2019.01 there is now a config for this board, use it for the
release image.

r343874:
mtree: Add dtb subdir to the mtree file

makefs will fails otherwise

Reported by: emaste

r344893:
arm: allwinner: Fix NM clock recalc

If the NM clock is using a fractional divider the formula isn't the same.

r344894:
arm64: allwinner: Add CCU DE2

The Display Engine 2 have it's own Clock and Control Unit, add support
for it.

r344895:
arm64: allwinner: a64: Add TCON clock

The tcon clock need a mux table for it's parent, for now just
list the parents twice.

r345711:
arm: allwinner: clk: Fix nm_recalc

When comparing best frequencies use the absolute value.
If we do not do that we end up choosing an always lower value than
the best one if the exact freq cannot be met.

4 years agoMFC r342936, r343873
Emmanuel Vadot [Mon, 5 Aug 2019 16:56:11 +0000 (16:56 +0000)]
MFC r342936, r343873

r342936:
Import DTS from Linux 4.20

r343873:
arm64: dtb: allwinner: Add the new pine64-lts dtb file to the build

X-MFC-With: r342936

4 years agoMFC r340987, r340989, r341254, r341269, r341333
Emmanuel Vadot [Mon, 5 Aug 2019 16:48:16 +0000 (16:48 +0000)]
MFC r340987, r340989, r341254, r341269, r341333

r340987:
arm64: Add evdev support to GENERIC

r340989:
regulator_fixed: Do not disable fixed regulator at probe

If the regulator is unused it will be disabled by the regulator_shutdown sysinit.

Tested on pinebook where the backlight is controlled by a fixed-regulator.
The regulator doesn't have a regulator-boot-on param (I'm gonna upstream this) and so we disable it at probe.
We later enable it but this cause the screen to go black.
Linux doesn't disable regulator at boot (at least for fixed-regulator) so better match this to have the same UX.

Differential Revision: https://reviews.freebsd.org/D17978

r341254:
extres: clk: Fix clk_set_assigned

ofw_bus_parse_xref_list_get_length doesn't returns the number of elements, fix this.
While here when setting the clock to the assigned freqeuncy, allow the clock
driver to round down or up the frequency as sometimes the exact frequency cannot
be obtain.

r341269:
release: arm64: Add opp dtbo to PINE* boards

r341333:
arm64: allwinner: Add 792Mhz frequency to sun50i-a64-opp

This is the frequency of the cpu on the Pinebook so add it to make
cpufreq find the current setting.
Note that this dtbo on the Pinebook doesn't work right now as u-boot
dtb doesn't have symbols and so it fails to apply. Linux 4.20 have
the dts and will be imported once taggued.

X-MFC with: r341268

4 years agoMFC r340845-r340848, r340971, r340981, r342076
Emmanuel Vadot [Mon, 5 Aug 2019 16:36:11 +0000 (16:36 +0000)]
MFC r340845-r340848, r340971, r340981, r342076

r340845:
Derive PHY class to new one specialized for USB PHY functions.

Submitted by: mmel

r340846:
aw_usbphy: Convert to usbphy subclass

Instead of routing the phy when enabling it, do the configuration
and routing in the phynode_usb_set_mode function.
While here, if we don't have a vbus detection method, enable the phy
if requested.

r340847:
a10_ehci: Always set the phy to host mode

r340848:
axp8xx: Rework the enable part and add the GPIOXLDO regulators

r340971:
aw_usbphy: Do not error if it's not phy 0

Only phy0 can switch between host/otg, do not error if we request
host mode on phy != 0.

X-MFC with: r340846

r340981:
release: arm64: Add PINEBOOK config

Add a configuration for PINEBOOK image.
Pinebook is a arm64 laptop based on a Pine64 board.

Since the usb trackpad need a quirk, add a common function for adding
quirk for arm board.
A default one is supplied as most board to not need quirks.

Reviewed by: gjb
Differential Revision: https://reviews.freebsd.org/D18337

r342076:
arm64: allwinner: axp81x: Fix double invertion for FLDO1

This fix booting on A64 boards when disabling the unused regulators at boot.
We did disable all the regulator handled by register 0x13 which of course contain
mandatory regulators for the board to be up.

Reported by: Mark Millard <marklmi@yahoo.com>
X-MFC-With: r340848

4 years agoMFC r350416:
Kristof Provost [Mon, 5 Aug 2019 15:24:05 +0000 (15:24 +0000)]
MFC r350416:

riscv: Fix copyin/copyout

r343275 introduced a performance optimisation to the copyin/copyout
routines by attempting to copy word-per-word rather than byte-per-byte
where possible.

This optimisation failed to account for cases where the buffer is longer
than XLEN_BYTES, but due to misalignment does not not allow for any
word-sized copies. E.g. a 9 byte buffer (with XLEN_BYTES == 8) which is
misaligned by 2 bytes. The code nevertheless did a single full-word
copy, which meant we copied too much data. This potentially clobbered
other data.

This is most easily demonstrated by a simple `sysctl -a`.

Fix it by not assuming that we'll always have at least one full-word
copy to do, but instead checking the remaining length first.

Sponsored by: Axiado

4 years agoMFC r350417:
Andrey V. Elsukov [Mon, 5 Aug 2019 07:49:02 +0000 (07:49 +0000)]
MFC r350417:
  Add ipfw_get_action() function to get the pointer to action opcode.

  ACTION_PTR() returns pointer to the start of rule action section,
  but rule can keep several rule modifiers like O_LOG, O_TAG and O_ALTQ,
  and only then real action opcode is stored.

  ipfw_get_action() function inspects the rule action section, skips
  all modifiers and returns action opcode.

  Use this function in ipfw_reset_eaction() and flush_nat_ptrs().

4 years agoMFC r350548:
Cy Schubert [Mon, 5 Aug 2019 00:32:57 +0000 (00:32 +0000)]
MFC r350548:

#include whitespace adjustments.

4 years agoMFC r350518: as: add deprecation notice to the man page
Ed Maste [Sun, 4 Aug 2019 20:40:47 +0000 (20:40 +0000)]
MFC r350518: as: add deprecation notice to the man page

In the future FreeBSD will ship without GNU binutils 2.17.50.  Add a
note advising users who require GNU as to install the binutils port
or package.

Note that on armv7, arm64, amd64, i386 we currently ship only two
binutils tools (as and objdump).  A deprecation notice was added to
objdump's man page some time ago.

PR: 233611
Sponsored by: The FreeBSD Foundation

4 years agoobjdump: update deprecation notice
Ed Maste [Sun, 4 Aug 2019 01:18:50 +0000 (01:18 +0000)]
objdump: update deprecation notice

MFC r350503: objdump: move deprecation notice to indended spot

r335217 added a deprecation notice to the source file for the objdump
man page, and r335219 added it to the rendered objdump.1, but in the
wrong spot.

MFC r350505: objdump: be explicit that GNU objdump that will be removed

We may install llvm-objdump as objdump (see review D18307) or just
provide no /usr/bin/objdump, but either way GNU objdump won't be
installed in the future.

Sponsored by: The FreeBSD Foundation

4 years agoMFC r350228:
Brooks Davis [Fri, 2 Aug 2019 20:31:02 +0000 (20:31 +0000)]
MFC r350228:

ata_xpt: Use the correct union member when accessing valid.

In principle this should not matter as it's a union and they point to
the same memory location but based on the code above we should be
accessing .sata and not .ata.

Submitted by: arichardson
Reviewed by: scottl, imp
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D21002

4 years agoMFC r350218:
Brooks Davis [Fri, 2 Aug 2019 20:24:04 +0000 (20:24 +0000)]
MFC r350218:

Be consistent about temporary variable use in adjacent loops.

Obtained from: CheriBSD
Sponsored by: DARPA, AFRL

4 years agoMFC: r350367
Rick Macklem [Fri, 2 Aug 2019 01:59:58 +0000 (01:59 +0000)]
MFC: r350367
Lock the vnode before calling ufs_bmap_seekdata().

r346932 replaced a call to vn_bmap_seekhole() with a call to
ufs_bmap_seekdata(). Although vn_bmap_seekhole() locks the vnode,
ufs_bmap_seekdata() assumes it is already locked.
This patch adds locking of the vnode before the ufs_bmap_seekdata() call.
If the vn_lock() call fails, it returns EBADF since that is the normal
error returned when a file system is forced dismounted and is already
listed as an error return in the lseek(2) man page.

Thanks go to Harry Schmalzbauer (freebsd@omnilan.de) for noting that
this MFC was required.

4 years agoMFC r350245
Andrew Gallatin [Fri, 2 Aug 2019 00:13:11 +0000 (00:13 +0000)]
MFC r350245

pciconf: report PCI Gen4 speeds

PCIe gen4 runs at 16GT/s.  Report this as
the speed of Gen4 links.

Reviewed by:    imp
Sponsored by:   Netflix

4 years agoMFC r350160:
Brooks Davis [Thu, 1 Aug 2019 23:28:54 +0000 (23:28 +0000)]
MFC r350160:

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
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D21004

4 years agoMFC r350183, r350359
Doug Moore [Thu, 1 Aug 2019 05:30:31 +0000 (05:30 +0000)]
MFC r350183, r350359

In trimming on startup, define swapon_trim() to invoke swapon before
closing the fd used for trimming so that a geli device isn't detached
before swapon is invoked.  Add comments to explain the reason for the
ordering of events.

Reviewed by: alc
Approved by: markj (mentor, implicit)

4 years agoMFC r350159:
Brooks Davis [Wed, 31 Jul 2019 18:40:43 +0000 (18:40 +0000)]
MFC r350159:

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
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D21001

4 years agoMFC r350158:
Brooks Davis [Wed, 31 Jul 2019 18:25:52 +0000 (18:25 +0000)]
MFC r350158:

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
Sponsored by: DARPA, AFRL

4 years agoMFC r350157:
Brooks Davis [Wed, 31 Jul 2019 17:56:07 +0000 (17:56 +0000)]
MFC r350157:

Use the __DECONST macro rather than hand rolling it.

Obtained from: CheriBSD
Sponsored by: DARPA, AFRL

4 years agoMFC r350143, r350148
Brooks Davis [Wed, 31 Jul 2019 17:01:23 +0000 (17:01 +0000)]
MFC r350143, r350148

r350143:
Chain Makefile.inc's so default are inherited as expected.

Remove unneeded or duplicate variables.

No functional change.

r350148:
Restore WARNS?=1 here.  I missed that libexec/bootpd/bootpgw existed.

Obtained from: CheriBSD
Sponsored by: DARPA, AFRL

4 years agoMFC r350336: if_tun(4): Add TUNGIFNAME
Kyle Evans [Wed, 31 Jul 2019 15:56:40 +0000 (15:56 +0000)]
MFC r350336: if_tun(4): Add TUNGIFNAME

This is effectively a direct commit to stable branches as tun/tap have been
merged in head. The code here is identical, just in a slightly different
context.

4 years agoMFC of 349589, 350070, 350071, 350096, and 350187
Kirk McKusick [Wed, 31 Jul 2019 00:16:12 +0000 (00:16 +0000)]
MFC of 349589, 350070, 350071, 350096, and 350187

Make filesystem-full messages limited per filesystem rather than systemwide
Add "untrusted" option to mount command
FS-14-UFS-3: when untrusted, valididate block pointers
In fsck_ffs, treat any inode with bad content as unknown

4 years agoMFC r350215: mptutil: emit a warning on big-endian architectures
Ed Maste [Tue, 30 Jul 2019 14:18:05 +0000 (14:18 +0000)]
MFC r350215: mptutil: emit a warning on big-endian architectures

It is known to be broken.

PR: 162513
Sponsored by: The FreeBSD Foundation

4 years agoMFC r346993
Ganbold Tsagaankhuu [Tue, 30 Jul 2019 12:17:11 +0000 (12:17 +0000)]
MFC r346993
Add a hw.model sysctl oid for arm64 which reports the CPU model similar to armv6/7.

4 years agoMFC r350064:
Cy Schubert [Tue, 30 Jul 2019 03:32:39 +0000 (03:32 +0000)]
MFC r350064:

As of upstream fil.c CVS r1.53 (March 1, 2009), prior to the import of
ipfilter 5.1.2 into FreeBSD-10, the fix for, 2580062 from/to targets
should be able to use any interface name, moved frentry.fr_cksum to
prior to frentry.fr_func thereby making this code redundant. After
investigating whether this fix to move fr_cksum was correct and if it
broke anything, it has been determined that the fix is correct and this
code is redundant. We remove it here.

4 years agoMFC r350362:
Dimitry Andric [Mon, 29 Jul 2019 18:02:48 +0000 (18:02 +0000)]
MFC r350362:

Pull in r366369 from upstream llvm trunk (by Francis Visoiu Mistrih):

  [CodeGen][NFC] Simplify checks for stack protector index checking

  Use `hasStackProtectorIndex()` instead of `getStackProtectorIndex()
  >= 0`.

Pull in r366371 from upstream llvm trunk (by Francis Visoiu Mistrih):

  [PEI] Don't re-allocate a pre-allocated stack protector slot

  The LocalStackSlotPass pre-allocates a stack protector and makes sure
  that it comes before the local variables on the stack.

  We need to make sure that later during PEI we don't re-allocate a new
  stack protector slot. If that happens, the new stack protector slot
  will end up being **after** the local variables that it should be
  protecting.

  Therefore, we would have two slots assigned for two different stack
  protectors, one at the top of the stack, and one at the bottom. Since
  PEI will overwrite the assigned slot for the stack protector, the
  load that is used to compare the value of the stack protector will
  use the slot assigned by PEI, which is wrong.

  For this, we need to check if the object is pre-allocated, and re-use
  that pre-allocated slot.

  Differential Revision: https://reviews.llvm.org/D64757

Pull in r367068 from upstream llvm trunk (by Francis Visoiu Mistrih):

  [CodeGen] Don't resolve the stack protector frame accesses until PEI

  Currently, stack protector loads and stores are resolved during
  LocalStackSlotAllocation (if the pass needs to run). When this is the
  case, the base register assigned to the frame access is going to be
  one of the vregs created during LocalStackSlotAllocation. This means
  that we are keeping a pointer to the stack protector slot, and we're
  using this pointer to load and store to it.

  In case register pressure goes up, we may end up spilling this
  pointer to the stack, which can be a security concern.

  Instead, leave it to PEI to resolve the frame accesses. In order to
  do that, we make all stack protector accesses go through frame index
  operands, then PEI will resolve this using an offset from sp/fp/bp.

  Differential Revision: https://reviews.llvm.org/D64759

Together, these fix a issue where the stack protection feature in LLVM's
ARM backend can be rendered ineffective when the stack protector slot is
re-allocated so that it appears after the local variables that it is
meant to protect, leaving the function potentially vulnerable to a
stack-based buffer overflow.

Reported by: andrew
Security: https://kb.cert.org/vuls/id/129209/

4 years agoMFC r350371
Andrew Rybchenko [Mon, 29 Jul 2019 09:34:47 +0000 (09:34 +0000)]
MFC r350371

sfxge(4): unify power of 2 alignment check macro

Substitute driver-defined IS_P2ALIGNED() with EFX_IS_P2ALIGNED()
defined in libefx.

Add type argument and cast value and alignment to one specified type.

Reported by:    Andrea Valsania <andrea.valsania at answervad.it>
Sponsored by:   Solarflare Communications, Inc.

4 years agoMFC r350370
Andrew Rybchenko [Mon, 29 Jul 2019 09:26:55 +0000 (09:26 +0000)]
MFC r350370

sfxge(4): fix align to power of 2 when align has smaller type

Substitute driver-defined P2ALIGN() with EFX_P2ALIGN() defined in
libefx.

Cast value and alignment to one specified type to guarantee result
correctness.

Reported by:    Andrea Valsania <andrea.valsania at answervad.it>
Sponsored by:   Solarflare Communications, Inc.

4 years agoMFC r350369
Andrew Rybchenko [Mon, 29 Jul 2019 09:25:16 +0000 (09:25 +0000)]
MFC r350369

sfxge(4): fix power of 2 round up when align has smaller type

Substitute driver-defined P2ROUNDUP() h with EFX_P2ROUNDUP()
defined in libefx.

Cast value and alignment to one specified type to guarantee result
correctness.

Reported by:    Andrea Valsania <andrea.valsania at answervad.it>
Sponsored by:   Solarflare Communications, Inc.

4 years agoMFC r350358:
Baptiste Daroussin [Mon, 29 Jul 2019 08:14:35 +0000 (08:14 +0000)]
MFC r350358:

Fix a bug introduced with parallel mounting of zfs

Incorporate a fix from zol:
https://github.com/zfsonlinux/zfs/commit/ab5036df1ccbe1b18c1ce6160b5829e8039d94ce

commit log from upstream:
 Fix race in parallel mount's thread dispatching algorithm

Strategy of parallel mount is as follows.

1) Initial thread dispatching is to select sets of mount points that
 don't have dependencies on other sets, hence threads can/should run
 lock-less and shouldn't race with other threads for other sets. Each
 thread dispatched corresponds to top level directory which may or may
 not have datasets to be mounted on sub directories.

2) Subsequent recursive thread dispatching for each thread from 1)
 is to mount datasets for each set of mount points. The mount points
 within each set have dependencies (i.e. child directories), so child
 directories are processed only after parent directory completes.

The problem is that the initial thread dispatching in
zfs_foreach_mountpoint() can be multi-threaded when it needs to be
single-threaded, and this puts threads under race condition. This race
appeared as mount/unmount issues on ZoL for ZoL having different
timing regarding mount(2) execution due to fork(2)/exec(2) of mount(8).
`zfs unmount -a` which expects proper mount order can't unmount if the
mounts were reordered by the race condition.

There are currently two known patterns of input list `handles` in
`zfs_foreach_mountpoint(..,handles,..)` which cause the race condition.

1) #8833 case where input is `/a /a /a/b` after sorting.
 The problem is that libzfs_path_contains() can't correctly handle an
 input list with two same top level directories.
 There is a race between two POSIX threads A and B,
  * ThreadA for "/a" for test1 and "/a/b"
  * ThreadB for "/a" for test0/a
 and in case of #8833, ThreadA won the race. Two threads were created
 because "/a" wasn't considered as `"/a" contains "/a"`.

2) #8450 case where input is `/ /var/data /var/data/test` after sorting.
 The problem is that libzfs_path_contains() can't correctly handle an
 input list containing "/".
 There is a race between two POSIX threads A and B,
  * ThreadA for "/" and "/var/data/test"
  * ThreadB for "/var/data"
 and in case of #8450, ThreadA won the race. Two threads were created
 because "/var/data" wasn't considered as `"/" contains "/var/data"`.
 In other words, if there is (at least one) "/" in the input list,
 the initial thread dispatching must be single-threaded since every
 directory is a child of "/", meaning they all directly or indirectly
 depend on "/".

In both cases, the first non_descendant_idx() call fails to correctly
determine "path1-contains-path2", and as a result the initial thread
dispatching creates another thread when it needs to be single-threaded.
Fix a conditional in libzfs_path_contains() to consider above two.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed by: Sebastien Roy <sebastien.roy@delphix.com>
Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
PR:  237517, 237397, 239243
Submitted by: Matthew D. Fuller <fullermd@over-yonder.net> (by email)

4 years agoMFC r350360:
Dimitry Andric [Mon, 29 Jul 2019 06:13:22 +0000 (06:13 +0000)]
MFC r350360:

Merge libcxxrt master f96846efbfd508f66d91fcbbef5dd808947c7f6d.

Interesting fixes:
f96846e Fix std::size_t -> size_t to unbreak build against libc++ 6.0.0
6f4cfa2 Fix the uncaught exception count with rethrowing (PR 239265)
db54f53 Added C++14-specific operator delete (#47)

PR: 239265

4 years agoMFC r349800,r349801:
Fedor Uporov [Sat, 27 Jul 2019 19:29:23 +0000 (19:29 +0000)]
MFC r349800,r349801:

Fix misc fs fuzzing issues.

Reported by:    Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE
Reported as:    FS-22-EXT2-9: Denial of service in ftruncate-0 (ext2_balloc)
                FS-11-EXT2-6: Denial Of Service in write-1 (ext2_balloc)

4 years agoMFC r349969
Chuck Tuffli [Sat, 27 Jul 2019 17:59:30 +0000 (17:59 +0000)]
MFC r349969

bhyve: Create EUI64 for NVMe namespaces

Accept an IEEE Extended Unique Identifier (EUI-64) from the command
line for each NVMe namespace. If one isn't provided, it will create one
based on the CRC16 of:
 - the FreeBSD IEEE OUI
 - PCI bus, device/slot, function values
 - Namespace ID

Approved by: imp (mentor)

4 years agoMFC r348781
Chuck Tuffli [Sat, 27 Jul 2019 17:52:45 +0000 (17:52 +0000)]
MFC r348781

bhyve: Add PCIe Integrated Endpoint capability

Approved by: imp (mentor)

4 years agoMFC r345956
Chuck Tuffli [Sat, 27 Jul 2019 17:48:35 +0000 (17:48 +0000)]
MFC r345956

bhyve: Fix NVMe BAR size calculation

The NVMe specification defines bits 13:4 of BAR0 as Reserved (i.e. 0x0).
Most drivers do not enforce this, but the Windows NVMe driver does and
will refuse to start the device (i.e. error 10) if any of these bits are
set.

Approved by: imp (mentor)

4 years agoMFC r345957
Chuck Tuffli [Sat, 27 Jul 2019 17:43:59 +0000 (17:43 +0000)]
MFC r345957

bhyve: Fix NVMe data structure copy to guest

bhyve's NVMe emulation was transferring Identify data back to the guest
incorrectly causing memory corruptions. These corruptions resulted in
core dumps and other system level errors in the guest.

Approved by: imp (mentor)

4 years agoMFC r350182:
Mark Johnston [Sat, 27 Jul 2019 16:34:07 +0000 (16:34 +0000)]
MFC r350182:
Rename vm_page_{import,release}() to vm_page_zone_{import,release}().

4 years agoMFC r349841:
Mark Johnston [Sat, 27 Jul 2019 16:33:34 +0000 (16:33 +0000)]
MFC r349841:
Elide the vm_reserv_free_page() call when PG_PCPU_CACHE is set.

4 years agoMFC r349840:
Mark Johnston [Sat, 27 Jul 2019 16:33:11 +0000 (16:33 +0000)]
MFC r349840:
Add a per-CPU page cache per VM free pool.

4 years agoMFC r350310:
Mark Johnston [Sat, 27 Jul 2019 16:11:04 +0000 (16:11 +0000)]
MFC r350310:
Fix the turnstile_lock() KPI.

4 years agoMFC r349802 (from fsu@):
Pedro F. Giffuni [Fri, 26 Jul 2019 21:08:01 +0000 (21:08 +0000)]
MFC r349802 (from fsu@):

Add additional check for 'blocks per group' and 'fragments per group'
superblock fields.

These fields will not be equal only in case if bigalloc filesystem feature is
turned on.  This feature is not supported for now.

Reported by:    Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE
Reported as:    FS-27-EXT2-12: Denial of Service in openat-0 (vm_fault_hold/ext2_clusteracct)

4 years agoMFC r347695, r347696, r347697, r347957, r349326:
Konstantin Belousov [Fri, 26 Jul 2019 19:35:33 +0000 (19:35 +0000)]
MFC r347695, r347696, r347697, r347957, r349326:
Lockless delayed invalidation for amd64 pmap.

4 years agoMFC r344120:
Konstantin Belousov [Fri, 26 Jul 2019 10:13:48 +0000 (10:13 +0000)]
MFC r344120:
Unify i386 and amd64 getcontextx.c, and use ifuncs while there.

This is yet another attempt of the merge, previously done as r344436 and
reverted in r344463.  It is redone since ld was changed to ifunc-capable
linker on i386.

4 years agoMFC r349380, r349383, r349455: bectl(8)/libbe(3) fixes
Kyle Evans [Fri, 26 Jul 2019 01:49:58 +0000 (01:49 +0000)]
MFC r349380, r349383, r349455: bectl(8)/libbe(3) fixes

r349380:
libbe(3): mount: the BE dataset is mounted at /

Other parts of libbe(3) were fairly strict on the mountpoint property of the
BE dataset, and be_mount was not much better. It was improved in r347027 to
allow mountpoint=none for depth==0, but this bit was still sensitive to
mountpoint != / and mountpoint != none. Given that other parts of libbe(3)
no longer restrict the mountpoint property here, and the rest of the base
system is generally OK and will assume that a BE is mounted at /, let's do
the same.

r349383:
libbe(3): restructure be_mount, skip canmount check for BE dataset

Further cleanup after r349380; loader and kernel will both ignore canmount
on the root dataset as well, so we should not be so strict about it when
mounting it. be_mount is restructured to make it more clear that depth==0 is
special, and to not try fetching these properties that we won't care about.

r349455:
bectl(8): create non-recursive boot environments

bectl advertises that it has the ability to create recursive and
non-recursive boot environments. This patch implements that functionality
using the be_create_depth API provided by libbe. With this patch, bectl now
works as bectl(8) describes in regards to creating recursive/non-recursive
boot environments.

4 years agoMFC r348471: stand: zfs: Free bouncebuf on error path in vdev_read
Kyle Evans [Fri, 26 Jul 2019 01:47:20 +0000 (01:47 +0000)]
MFC r348471: stand: zfs: Free bouncebuf on error path in vdev_read

r344226 inadvertently added this path in which we return from failure on an
lseek and do not free bouncebuf on the way out.

4 years agoMFC r344226, r344234: stand: zfs memory corruption bug
Kyle Evans [Fri, 26 Jul 2019 01:45:00 +0000 (01:45 +0000)]
MFC r344226, r344234: stand: zfs memory corruption bug

r344226:
Fix memory corruption bug introduced in r325310

The bug occurred when a bounce buffer was used and the requested read
size was greater than the size of the bounce buffer.  This commit also
rewrites the read logic so that it is easier to systematically verify
all alignment and size cases.

r344234:
It turns out r344226 narrowed the overrun bug but did not eliminate it entirely

This commit fixes a remaining output buffer overrun in the
single-sector case when there is a non-zero tail.

4 years agoMFC r348328: bectl(8): Address Coverity complaints
Kyle Evans [Fri, 26 Jul 2019 01:35:06 +0000 (01:35 +0000)]
MFC r348328: bectl(8): Address Coverity complaints

CID 1400451: case 0 is missing a break/return and falling through to the
default case.  waitpid(0, ...) makes little sense in the child, we likely
wanted to terminate immediately.

CID 1400453: size argument uses sizeof(char **) instead of sizeof(char *)
and is assigned to a char **; sizeof's match but "this isn't a portable
assumption".

CID: 14004511400453

4 years agoMFC r350117:
Brooks Davis [Thu, 25 Jul 2019 20:01:24 +0000 (20:01 +0000)]
MFC r350117:

Include a mode when creating files with openat().

Reviewed by: asomers
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D20989

4 years agoMFC r350116:
Brooks Davis [Thu, 25 Jul 2019 17:33:44 +0000 (17:33 +0000)]
MFC r350116:

Document that setmode(3) is not thread safe.

In some circumstances, setmode(3) may call umask(2) twice to retrieve
the current mode and then restore it.  Between calls, the process will
have a umask of 0.

Reviewed by: markj
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D20982

4 years agoloader: ignore some variable settings if input unverified
Simon J. Gerraty [Thu, 25 Jul 2019 00:07:10 +0000 (00:07 +0000)]
loader: ignore some variable settings if input unverified

libsecureboot can tell us if the most recent file opened was
verfied or not.
If it's state is VE_UNVERIFIED_OK, skip if variable
matches one of the restricted prefixes.

MFC of r350099

Reviewed by: stevek
Sponsored by: Juniper Networks
Differential Revision: https://reviews.freebsd.org//D20909