Commit graph

120843 commits

Author SHA1 Message Date
Andrew Turner 6d9e17fc83 Count the number of children in the GICv3 ACPI attachment. This is needed
later for assigning IRQ vector space.

Sponsored by:	DARPA, AFRL
Sponsored by:	Cavium (Hardware)
2018-03-02 13:04:21 +00:00
Hans Petter Selasky 86ba49a722 Implement more lockdep stubs in the LinuxKPI.
MFC after:	1 week
Submitted by:	Johannes Lundberg <johalun0@gmail.com>
Sponsored by:	Mellanox Technologies
Sponsored by:	Limelight Networks
2018-03-02 08:59:53 +00:00
Hans Petter Selasky 8554bc585b Implement ktime_get_raw() function in the LinuxKPI.
MFC after:	1 week
Submitted by:	Johannes Lundberg <johalun0@gmail.com>
Sponsored by:	Mellanox Technologies
Sponsored by:	Limelight Networks
2018-03-02 08:58:32 +00:00
Hans Petter Selasky d901abf167 Implement wait_on_bit() function macro in the LinuxKPI.
MFC after:	1 week
Submitted by:	Johannes Lundberg <johalun0@gmail.com>
Sponsored by:	Mellanox Technologies
Sponsored by:	Limelight Networks
2018-03-02 08:56:15 +00:00
Hans Petter Selasky 9555cfd2b2 Rename callout member in struct timer_list to match the one in struct
delayed_work in the LinuxKPI. This allows the timer_pending() function
macro to be used with delayed work structures.

No functional nor structural change.

MFC after:	1 week
Submitted by:	Johannes Lundberg <johalun0@gmail.com>
Sponsored by:	Mellanox Technologies
Sponsored by:	Limelight Networks
2018-03-02 08:52:27 +00:00
Conrad Meyer 90575a0ec9 g_label_ufs: Fix typo from r330264
Reported by:	O. Hartmann <o.hartmann AT walstatt.org>
Sponsored by:	Dell EMC Isilon
2018-03-02 06:02:54 +00:00
Kirk McKusick efbf396426 This change is some refactoring of Mark Johnston's changes in r329375
to fix the memory leak that I introduced in r328426. Instead of
trying to clear up the possible memory leak in all the clients, I
ensure that it gets cleaned up in the source (e.g., ffs_sbget ensures
that memory is always freed if it returns an error).

The original change in r328426 was a bit sparse in its description.
So I am expanding on its description here (thanks cem@ and rgrimes@
for your encouragement for my longer commit messages).

In preparation for adding check hashing to superblocks, r328426 is
a refactoring of the code to get the reading/writing of the superblock
into one place. Unlike the cylinder group reading/writing which
ends up in two places (ffs_getcg/ffs_geom_strategy in the kernel
and cgget/cgput in libufs), I have the core superblock functions
just in the kernel (ffs_sbfetch/ffs_sbput in ffs_subr.c which is
already imported into utilities like fsck_ffs as well as libufs to
implement sbget/sbput). The ffs_sbfetch and ffs_sbput functions
take a function pointer to do the actual I/O for which there are
four variants:

    ffs_use_bread / ffs_use_bwrite for the in-kernel filesystem

    g_use_g_read_data / g_use_g_write_data for kernel geom clients

    ufs_use_sa_read for the standalone code (stand/libsa/ufs.c
	but not stand/libsa/ufsread.c which is size constrained)

    use_pread / use_pwrite for libufs

Uses of these interfaces are in the UFS filesystem, geoms journal &
label, libsa changes, and libufs. They also permeate out into the
filesystem utilities fsck_ffs, newfs, growfs, clri, dump, quotacheck,
fsirand, fstyp, and quot. Some of these utilities should probably be
converted to directly use libufs (like dumpfs was for example), but
there does not seem to be much win in doing so.

Tested by: Peter Holm (pho@)
2018-03-02 04:34:53 +00:00
Ian Lepore 35e313cfe8 Add a function to retrieve the EFI realtime clock capabilities. 2018-03-01 22:57:14 +00:00
Eitan Adler 58dcf3ff97 sys/sys: Use a more common spelling of 'dirent'
Submitted by:	Domagoj Stolfa <domagoj.stolfa@gmail.com>
MFC After:	3 days
2018-03-01 22:38:21 +00:00
Wojciech Macek 4ffd72e34c PowerNV: Initial support for OPAL I2C transfers
Add I2C OPAL driver and a set of dummy-ones to allow
all I2C things on Power8 to attach.

TODO: better async token management

Submitted by:          Wojciech Macek <wma@semihalf.com>
Obtained from:         Semihalf
Sponsored by:          IBM, QCM Technologies
2018-03-01 14:11:07 +00:00
Ed Maste 023b850b62 Rationalize license text on Linuxolator files
Many licenses on Linuxolator files contained small variations from the
standard FreeBSD license text.  To avoid license proliferation switch to
the standard 2-clause FreeBSD license for those files where I have
permission from each of the listed copyright holders.  Additional files
still waiting on permission from others are listed in review D14210.

Approved by:    dchagin, rdivacky, sos
MFC after:	1 week
MFC with:	r329370
Sponsored by:	The FreeBSD Foundation
2018-03-01 13:52:18 +00:00
Hans Petter Selasky b44247b1a9 Correct the return value from flush_work() and flush_delayed_work() in the
LinuxKPI to comply more with Linux. This fixes an issue when these functions
are used in waiting loops.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2018-03-01 10:31:51 +00:00
Justin Hibbits 5903f5954a Fix the psl_userset32 definition.
It should be based on psl_userset, not psl_kernset.  As kernset, it would
inherit kernel config, including privilege level.
2018-03-01 04:44:17 +00:00
Conrad Meyer fadd3f8a66 pci_ioctl: Avoid returning uninitialized error value if user provided empty buffer
In the weird case where the user-provided buffer was zero bytes, we could break
out of PCIOCGETCONF and return without initializing error.  In this case,
initialize error to zero -- we successfully did nothing, as requested.

Reported by:	Coverity
Sponsored by:	Dell EMC Isilon
2018-03-01 01:49:36 +00:00
Conrad Meyer 893daee680 psm(4): Always initialize used values in debug print
'status' array passed to get_mouse_status() is usually uninitialized by
callers.

Fully populating it with values in get_mouse_status() can fail due to
read_aux_data().

Additionally, nothing in API constrains 'len' to be >= 3.  In practice,
every caller passes three, so perhaps that argument should just be removed.
Refactoring is a larger change, though.

Remove use of potentially uninitialized values by:
1. Only printing 3 debug statuses if the passed array was at least
   'len' >= 3;
2. Populating 'status' array up to first three elements, if read_aux_data()
   failed.

No functional change intended.

Reported by:	Coverity
Sponsored by:	Dell EMC Isilon
2018-03-01 00:58:59 +00:00
Conrad Meyer d4e6557bae ffs: softdep_disk_write_complete: Quiesce spurious Coverity warning
Coverity cannot determine that handle_written_indirdep() does not access
uninitialized 'sbp' when flags argument is zero.

So, simply move the initialization slightly sooner to silence the warning.

No functional change.

Reported by:	Coverity
Sponsored by:	Dell EMC Isilon
2018-03-01 00:29:52 +00:00
Kyle Evans b5cdd987a8 Revert r328964: if_awg: Skip emac reset if configured for internal PHY
This broke EFI boots consistently, and emac reset is sometimes needed if
things get into a bad state -- this won't be done without a full powercycle.
2018-02-28 20:51:21 +00:00
Emmanuel Vadot 6151aa3860 RK3188: Mark it NO_UNIVERSE
This is an old kernel so mark it as NO_UNIVERSE so it's not built by
the universe rule or tinderbox.
2018-02-28 19:08:52 +00:00
Emmanuel Vadot 2f88239958 dwmmc_rockchip: Add ifdefs on EXT_RESOURCES
The old RK3188 kernel config uses dwmmc but isn't compiled with EXT_RESOURCES.
Add ifdefs around code using EXT_RESOURCES code.

Reported by:	rpokala
2018-02-28 19:05:25 +00:00
Alexander Motin 14e084ada5 Add support for Enhanced Gen 5 (16Gb) and Gen 6 (32Gb) QLogic FC HBAs.
MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2018-02-28 16:24:32 +00:00
Andrew Turner e9c0572e4c Allow releasing APs to take more time, as long as we are making progress.
On large core count machines this can be slow while all the CPUs update
the online counter.

Sponsored by:	DARPA, AFRL
Sponsored by:	Cavium (Hardware)
2018-02-28 16:03:40 +00:00
Andrew Turner cf0afdaab6 Count the number of GIC redistributors in the ACPI tables. The GICv3 driver
needs this to allocate memory, and connect the CPUs to the interrupt
controller.

Sponsored by:	DARPA, AFRL
Sponsored by:	Cavium (Hardware)
2018-02-28 15:25:47 +00:00
Andrew Turner 3d9294b0a1 Only check the ProducerConsumer flag on extended memory. As per the ACPI
6.0 spec 6.4.3.5 bit 0 is ignored on QWord, DWord, and Word Address Space
Descriptors, but not Extended Address Space Descriptors.

Reviewed by:	jhb
Sponsored by:	DARPA, AFRL
Sponsored by:	Cavium (Hardware)
Differential Revision:	https://reviews.freebsd.org/D14516
2018-02-28 15:18:31 +00:00
Andrew Turner 92457451f4 The Arm pl011 driver assumes it's running a devicetree based system.
It calls OF_* functions to check if it needs to implement workarounds.
This may not be the case on arm64 where we support both FDT and ACPI.
Fix this by checking if we are booting on FDT before calling these checks.

Reviewed by:	ian
Sponsored by:	DARPA, AFRL
Sponsored by:	Cavium (Hardware)
Differential Revision:	https://reviews.freebsd.org/D14515
2018-02-28 15:02:27 +00:00
Ed Maste e9093b66d5 Add kernel retpoline option for amd64
Retpoline is a compiler-based mitigation for CVE-2017-5715, also known
as Spectre V2, that protects against speculative execution branch target
injection attacks.

In this commit it is disabled by default, but will be changed in a
followup commit.

Reviewed by:	bdrewery (previous version)
MFC after:	3 days
Security:	CVE-2017-5715
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D14242
2018-02-28 14:57:45 +00:00
Michael Tuexen 1c714531e8 When checking the TCP fast cookie length, conststently also check
for the minimum length.

This fixes a bug where cookies of length 2 bytes (which is smaller
than the minimum length of 4) is provided by the server.

Sponsored by:	Netflix, Inc.
2018-02-27 22:12:38 +00:00
John Baldwin 6b554d26ed Move #include for rijndael.h out of x86-specific region.
The #include was added inside of the conditional by accident and the lack
of it broke non-x86 builds.

Reported by:	lwhsu (jenkins), andrew
2018-02-27 17:51:58 +00:00
Mark Johnston 3b8cf4acf0 Give the 0th domain's page daemon thread a consistent name.
Page daemon threads for other domains show up in ps(1) output as
"pagedaemon/domN", so let that be the case for domain 0 as well.

Submitted by:	Kevin Bowling <kevin.bowling@kev009.com>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D14518
2018-02-27 16:51:09 +00:00
Michal Meloun 4a744c0e9d Define meaning of remaining clock rounding flags combinations.
MFC after: 2 weeks
2018-02-27 16:08:08 +00:00
Michal Meloun 81cb170fea Switch to mainstream DTS for Raspberry Pi-B and Pi-2.
This is first step in attempt to make FreeBSD compatible with all variants of
RPi boards.

Reviewed by:	gonzo
MFC after:	3 weeks
2018-02-27 15:01:17 +00:00
Andriy Gapon f3b7b054dd add ZFS_ENTER protection to .zfs/snapshot vnode operations that need it
Those operations, zfsctl_snapdir_readdir and zfsctl_snapdir_getattr,
access the filesystem's objset and it can be unstable during operations
like receive and rollback.

MFC after:	2 weeks
2018-02-27 14:08:54 +00:00
Justin Hibbits 2d5320a818 Increase the size of a reservation granule for TLB locks
A reservation granule on PowerPC is a cache line.

On e500mc and derivatives a cacheline size is 64 bytes, not 32.  Allocate
the maximum size permitted, but only utilize the size that is needed.  On
e500v1 and e500v2 the reservation granule will still be 32 bytes.
2018-02-27 04:38:27 +00:00
Justin Hibbits 7fa00cd0ab Fix a minor typo. 2018-02-27 04:23:03 +00:00
Ian Lepore 665c7f6f1e Initialize all members of vm_page::md_page for armv4/5 systems. This fixes
a hang in SI_SUB_KMEM sysinit, and is apparently required after r323290.
Inspired by the commit message for r323676.

Reported by:	andreast@
2018-02-27 02:11:23 +00:00
Alexander Motin 731308d01d Allow physically non-contiguous chain frames allocation in mps(4)/mpr(4).
Chain frames required to satisfy all 2K of declared I/Os of 128KB each take
more then a megabyte of a physical memory, all of which existing code tries
allocate as physically contiguous.  This patch removes that physical
contiguousness requirement, leaving only virtual contiguousness.  I was
thinking about other ways of allocation, but the less granular allocation
becomes, the bigger is the overhead and/or complexity, reaching about 100%
overhead if allocate each frame separately.

The patch also bumps the chain frames hard limit from 2K to 16K.  It is more
than enough for the case of default REQ_FRAMES and MAXPHYS (the drivers will
allocate less than that automatically), while in case of increased MAXPHYS
it will control maximal memory usage.

Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D14420
2018-02-27 01:48:13 +00:00
Alexander Motin 060bac1db8 Add sysctls/tunables for dbuf cache size.
MFC after:	2 weeks
2018-02-27 01:36:43 +00:00
Ian Lepore 1d01310593 Remove obsolete options from these kernel configs. The functionality these
enabled is now on by default since r313330.
2018-02-27 00:30:10 +00:00
Ian Lepore e5c6bca6ba Add a hw.model sysctl oid for armv6/7 which reports the CPU model, similar
to what other arches (all except riscv and armv4/5) do.

Submitted by:	Hyun Hwang <hyun@caffeinated.codes>
Differential Revision:	https://reviews.freebsd.org/D14465
2018-02-26 23:58:56 +00:00
Emmanuel Vadot 925ee294ea rk_cru: Add missing break 2018-02-26 22:57:52 +00:00
John Baldwin db631975fe Don't overflow the ipad[] array when clearing the remainder.
After the auth key is copied into the ipad[] array, any remaining bytes
are cleared to zero (in case the key is shorter than one block size).
The full block size was used as the length of the zero rather than the
size of the remaining ipad[].  In practice this overflow was harmless as
it could only clear bytes in the following opad[] array which is
initialized with a copy of ipad[] in the next statement.

Sponsored by:	Chelsio Communications
2018-02-26 22:17:27 +00:00
John Baldwin 52f8c52677 Move ccr_aes_getdeckey() from ccr(4) to the cxgbe(4) driver.
This routine will also be used by the TOE module to manage TLS keys.

Sponsored by:	Chelsio Communications
2018-02-26 22:12:31 +00:00
John Baldwin 198729ea7d Fetch TLS key parameters from the firmware.
The parameters describe how much of the adapter's memory is reserved for
storing TLS keys.  The 'meminfo' sysctl now lists this region of adapter
memory as 'TLS keys' if present.

Sponsored by:	Chelsio Communications
2018-02-26 21:56:06 +00:00
Emmanuel Vadot a5091e03c5 dwmmc_rockchip: Add support for rk3328-dw-mshc
* Do not use pio mode like rk2928
* Change clocks frequency in update_ios

Tested-On:    Pine64 Rock64 (RK3328)
2018-02-26 21:29:01 +00:00
Emmanuel Vadot dd198e868a dwmmc: Add clock support and other improvements
* If compiled with EXT_RESOURCES look up the "biu" and "ciu" clocks in
  the DT
* Don't use custom property "bus-frequency" but the standard one
  "clock-frequency"
* Use the DT property max-frequency and fall back to 200Mhz if it don't exists
* Add more mmc caps suported by the controller
* Always ack all interrupts
* Subclassed driver can supply an update_ios so they can handle update
  the clocks accordingly
* Take care of the DDR bit in update_ios (no functional change since we
  do not support voltage change for now)
* Make use of the FDT bus-width property
2018-02-26 21:27:42 +00:00
Emmanuel Vadot 2a3d5e3364 rk3328: Add support for this SoC
* rk_cru is a cru driver that needs to be subclassed by
  the real CRU driver
* rk_clk_pll handle the pll type clock on RockChip SoC, it's only read
  only for now.
* rk_clk_composite handle the different composite clock types (with gate,
  with mux etc ...)
* rk_clk_gate handle the RockChip gates
* rk_clk_mux handle the RockChip muxes (unused for now)
* Only clocks for supported devices are supported for now, the rest will be
  added when driver support comes
* The assigned-clock* property are not handled for now so we rely a lot on the
  bootloader to setup some initial values for some clocks.
2018-02-26 21:25:50 +00:00
Patrick Kelsey 1f13c23f3d Ensure signed comparison to avoid false trip of assert during VNET teardown.
Reported by:	lwhsu
MFC after:	1 month
2018-02-26 20:31:16 +00:00
John Baldwin 5f8754c077 Add a new variant of the GLA2GPA ioctl for use by the debug server.
Unlike the existing GLA2GPA ioctl, GLA2GPA_NOFAULT does not modify
the guest.  In particular, it does not inject any faults or modify
PTEs in the guest when performing an address space translation.

This is used by bhyve's debug server to read and write memory for
the remote debugger.

Reviewed by:	grehan
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D14075
2018-02-26 19:19:05 +00:00
David Bright 2b08b42bae iconv uses strlen directly on user supplied memory
`iconv_sysctl_add` from `sys/libkern/iconv.c` incorrectly limits the
size of user strings, such that several out of bounds reads could have
been possible.

static int
iconv_sysctl_add(SYSCTL_HANDLER_ARGS)
{
	struct iconv_converter_class *dcp;
	struct iconv_cspair *csp;
	struct iconv_add_in din;
	struct iconv_add_out dout;
	int error;

	error = SYSCTL_IN(req, &din, sizeof(din));
	if (error)
		return error;
	if (din.ia_version != ICONV_ADD_VER)
		return EINVAL;
	if (din.ia_datalen > ICONV_CSMAXDATALEN)
		return EINVAL;
	if (strlen(din.ia_from) >= ICONV_CSNMAXLEN)
		return EINVAL;
	if (strlen(din.ia_to) >= ICONV_CSNMAXLEN)
		return EINVAL;
	if (strlen(din.ia_converter) >= ICONV_CNVNMAXLEN)
		return EINVAL;
...

Since the `din` struct is directly copied from userland, there is no
guarantee that the strings supplied will be NULL terminated. The
`strlen` calls could continue reading past the designated buffer
sizes.

Declaration of `struct iconv_add_in` is found in `sys/sys/iconv.h`:

struct iconv_add_in {
	int	ia_version;
	char	ia_converter[ICONV_CNVNMAXLEN];
	char	ia_to[ICONV_CSNMAXLEN];
	char	ia_from[ICONV_CSNMAXLEN];
	int	ia_datalen;
	const void *ia_data;
};

Our strings are followed by the `ia_datalen` member, which is checked
before the `strlen` calls:

if (din.ia_datalen > ICONV_CSMAXDATALEN)

Since `ICONV_CSMAXDATALEN` has value `0x41000` (and is `unsigned`),
this ensures that `din.ia_datalen` contains at least 1 byte of 0, so
it is not possible to trigger a read out of bounds of the `struct`
however, this code is fragile and could introduce subtle bugs in the
future if the `struct` is ever modified.

PR:		207302
Submitted by:	CTurt <cturt@hardenedbsd.org>
Reported by:	CTurt <cturt@hardenedbsd.org>
Reviewed by:	jhb, vangyzen
MFC after:	1 week
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D14521
2018-02-26 18:23:36 +00:00
Kyle Evans cd78f5ff20 ofw_fdt: Simplify parts with new libfdt methods
libfdt now provides methods to iterate through subnodes and properties in a
convenient fashion.

Replace our ofw_fdt_{peer,child} searches with calls to their corresponding
libfdt methods. Rework ofw_fdt_nextprop to use the
fdt_for_each_property_offset macro, making it even more obvious what it's
doing.

No functional change intended.

Reviewed by:	nwhitehorn
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D14225
2018-02-26 14:00:23 +00:00
Olivier Houchard ed8bce2cd5 In do_ast, make sure the interrupts are enabled before calling ast().
We can reach that point with IRQs disabled, and calling ast() with IRQs 
disabled can lead to a deadlock.
This should fix the freezes on arm64 under load.

Reviewed by:	andrew
2018-02-26 13:12:51 +00:00