Commit Graph

237573 Commits

Author SHA1 Message Date
Mark Johnston
c7dc361d6f Clear pad bytes in the struct exported by kern.ntp_pll.gettime.
Reported by:	Thomas Barabosch, Fraunhofer FKIE
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2018-11-20 20:32:10 +00:00
Niclas Zeising
bd62da641d Enable evdev on ppc32
Enable evdev on ppc32 as well, similar to what was done i386 and amd64 in
r340387 and ppc64 in r340632.

Evdev can be used by X and is used by wayland to handle input devices.

Approved by:	jhibbits
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D18049
2018-11-20 19:31:02 +00:00
Andrey V. Elsukov
5786c6b9f9 Make multiline APPLY_MASK() macro to be function-like.
Reported by:	cem
MFC after:	1 week
2018-11-20 18:38:28 +00:00
Mark Johnston
9ed1e4ecd4 Plug a trivial memory leak.
CID:		1396911
MFC with:	r340485
2018-11-20 18:13:18 +00:00
Mark Johnston
79dd8f690a Avoid clobbering a user-specified -g value after r340547.
CID:		1396919
MFC with:	r340547
2018-11-20 18:10:56 +00:00
Ed Maste
02c4bf4391 stand: remove CLANG_NO_IAS from btx and gptboot
Many components under stand/ had CLANG_NO_IAS added when Clang's
Integrated Assembler (IAS) did not handle .codeNN directives.  Clang
gained support quite some time ago, and we can now build stand/ with
IAS.

Note that in some cases there are small differences in the generated
output, so CLANG_NO_IAS should be removed only after testing (or after
finding no differences in the output).

PR:		205250, 233094
Sponsored by:	The FreeBSD Foundation
2018-11-20 16:54:42 +00:00
Mateusz Guzik
30e0cf499f tmpfs: use unr64 for inode numbers
Sponsored by:	The FreeBSD Foundation
2018-11-20 15:14:30 +00:00
Mark Johnston
cafcdfd00f Handle kernel superpage mappings in pmap_remove_l2().
PR:		233088
Reviewed by:	alc, andrew, kib
Tested by:	sbruno
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D17981
2018-11-20 15:12:37 +00:00
Mateusz Guzik
737037f6c0 pipe: use unr64
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18054
2018-11-20 14:59:27 +00:00
Mateusz Guzik
435bef7a2f Implement unr64
Important users of unr like tmpfs or pipes can get away with just
ever-increasing counters, making the overhead of managing the state
for 32 bit counters a pessimization.

Change it to an atomic variable. This can be further sped up by making
the counts variable "allocate" ranges and store them per-cpu.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18054
2018-11-20 14:58:41 +00:00
Konstantin Belousov
abfc3b2fef rtld: when immediate bind mode is requested, process irelocs in PLT
immediately after other PLT relocs.

Otherwise, if the object has relro page, we write to readonly page,
and we would need to use mprotect(2) two more times to fix it.  Note
that resolve_object_ifunc() does nothing when called second time, so
there is no need to avoid existing call.

Reported and tested by:	emaste
PR:	233333
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2018-11-20 14:52:43 +00:00
Tijl Coosemans
7df0e7beb7 Fix another user address dereference in linux_sendmsg syscall.
This was hidden behind the LINUX_CMSG_NXTHDR macro which dereferences its
second argument.  Stop using the macro as well as LINUX_CMSG_FIRSTHDR.  Use
the size field of the kernel copy of the control message header to obtain
the next control message.

PR:		217901
MFC after:	2 days
X-MFC-With:	r340631
2018-11-20 14:18:57 +00:00
Mateusz Piotrowski
0a05369d45 ports(7): Do not mention deprecated WITH_OPENSSL_PORT.
Reviewed by:	eadler
Approved by:	krion (mentor, implicit), mat (mentor, implicit)
Differential Revision:	https://reviews.freebsd.org/D18045
2018-11-20 10:01:56 +00:00
Warner Losh
68f57679d6 Ensure that all values of ns, us and ms work for {n,u,m}stosbt
Integer overflows and wrong constants limited the accuracy of these
functions and created situatiosn where sbttoXs(Xstosbt(Y)) != Y. This
was especailly true in the ns case where we had millions of values
that were wrong.

Instead, used fixed constants because there's no way to say ceil(X)
for integer math. Document what these crazy constants are.

Also, use a shift one fewer left to avoid integer overflow causing
incorrect results, and adjust the equasion accordingly. Document this.

Allow times >= 1s to be well defined for these conversion functions
(at least the Xstosbt). There's too many users in the tree that they
work for >= 1s.

This fixes a failure on boot to program firmware on the mlx4
NIC. There was a msleep(1000) in the code. Prior to my recent rounding
changes, msleep(1000) worked, but msleep(1001) did not because the old
code rounded to just below 2^64 and the new code rounds to just above
it (overflowing, causing the msleep(1000) to really sleep 1ms).

A test program to test all cases will be committed shortly. The test
exaustively tries every value (thanks to bde for the test).

Sponsored by: Netflix, Inc
Differential Revision: https://reviews.freebsd.org/D18051
2018-11-20 07:11:23 +00:00
Rick Macklem
75772b69f2 Improve sanity checking for the dircount hint argument to
NFSv3's ReaddirPlus and NFSv4's Readdir operations. The code
checked for a zero argument, but did not check for a very large value.
This patch clips dircount at the server's maximum data size.

MFC after:	1 week
2018-11-20 01:59:57 +00:00
Rick Macklem
778f29833b nfsm_advance() would panic() when the offs argument was negative.
The code assumed that this would indicate a corrupted mbuf chain, but
it could simply be caused by bogus RPC message data.
This patch replaces the panic() with a printf() plus error return.

MFC after:	1 week
2018-11-20 01:56:34 +00:00
Rick Macklem
1d171e7971 r304026 added code that started statistics gathering for an operation
before the operation number (the variable called "op") was sanity checked.
This patch moves the code down to below the range sanity check for "op".
2018-11-20 01:52:45 +00:00
Marius Strobl
3d62bdba63 Given that the idea of D15374 was to "make memmove a first class citizen",
provide a _MEMMOVE extension of _MEMCPY that deals with overlap based on
the previous bcopy(9) implementation and use the former for bcopy(9) and
memmove(9). This addresses my D15374 review comment, avoiding extra MOVs
in case of memmove(9) and trashing the stack pointer.
2018-11-20 00:08:33 +00:00
Thomas Munro
d1f84ec0a7 pom: Fix fencepost bugs.
Under some conditions pom would report "waning" and then "full", show
higher percentages than it should, and get confused by DST.  Fix.

Before:

  2018.01.30: The Moon is Waxing Gibbous (97% of Full)
  2018.01.31: The Moon is Waning Gibbous (100% of Full)
  2018.02.01: The Moon is Full
  2018.02.02: The Moon is Waning Gibbous (98% of Full)

After:

  2018.01.30: The Moon is Waxing Gibbous (96% of Full)
  2018.01.31: The Moon is Waxing Gibbous (99% of Full)
  2018.02.01: The Moon is Full
  2018.02.02: The Moon is Waning Gibbous (97% of Full)

PR:                    231705
Submitted by:          Andrew Gierth
Approved by:           allanjude (mentor)
MFC after:             2 weeks
Differential Revision: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=231705
2018-11-20 00:06:53 +00:00
Marius Strobl
f5d03775e0 For consistency within the front-end, prefer SDHCI_{READ,WRITE}_{2,4}()
to sdhci_acpi_{read,write}_{2,4}() in the sdhci_acpi_set_uhs_timing()
added in r340543.
2018-11-19 23:56:33 +00:00
Justin Hibbits
fe5e88fabf powerpc: Sync icache on SIGILL, in case of cache issues
The update of jemalloc to 5.1.0 exposed a cache syncing issue on a Freescale
e500 base system.  There was already code in the FPU emulator to address
this, but it was limited to a single static variable, and did not attempt to
sync the cache.  This pulls that out to the higher level program exception
handler, and syncs the cache.

If a SIGILL is hit a second time at the same address, it will be treated as
a real illegal instruction, and handled accordingly.
2018-11-19 23:54:49 +00:00
Ed Maste
06cf1308e4 rescue: set NO_SHARED in Makefile
The rescue binary is built statically via the Makefile generated by
crunchgen, but that does not trigger other shared/static logic in
bsd.prog.mk - in particular disabling retpolineplt with static linking.

PR:		233336
Reported by:	Charlie Li
Sponsored by:	The FreeBSD Foundation
2018-11-19 22:18:18 +00:00
Navdeep Parhar
c7a20141cc cxgbe(4): Update T4/5/6 firmwares to 1.22.0.3.
Obtained from:	Chelsio Communications
MFC after:	2 months
Sponsored by:	Chelsio Communications
2018-11-19 21:59:07 +00:00
Ed Maste
1460870880 Avoid retpolineplt with static linking
Statically linked binaries linked with -zretpolineplt crash at startup
as lld produces a broken PLT.

PR:		233336
Sponsored by:	The FreeBSD Foundation
2018-11-19 20:48:47 +00:00
Benedict Reuschling
fd91f85934 Add a fortune describing how to upload a machine's dmesg information to the
NYCBUG database.

We want to encourage our users to upload their dmesgs so that the project can
get a better insight into what kind of hardware is run on. This helps in making
data-driven decisions about i.e., platform and driver support.

Note that dmesgs may contain sensitive information like hardware serial numbers,
hence uploading them without review is discouraged.

Reviewed by:		brooks, imp, allanjude
Approved by:		allanjude
MFC after:		5 days
Differential Revision:	https://reviews.freebsd.org/D17705
2018-11-19 20:45:49 +00:00
Alex Richardson
3b7e9bfef4 Add capsicum_helpers.h to -legacy if needed
This fixes bootstrap of capsicumized strings on FreeBSD 11.

Reviewed By:	oshogbo, bdrewery
Differential Revision: https://reviews.freebsd.org/D17971
2018-11-19 18:58:34 +00:00
Ben Widawsky
1a305bda15 acpi: fix acpi_ec_probe to only check EC devices
This patch utilizes the fixed_devclass attribute in order to make sure
other acpi devices with params don't get confused for an EC device.

The existing code assumes that acpi_ec_probe is only ever called with a
dereferencable acpi param. Aside from being incorrect because other
devices of ACPI_TYPE_DEVICE may be probed here which aren't ec devices,
(and they may have set acpi private data), it is even more nefarious if
another ACPI driver uses private data which is not dereferancable. This
will result in a pointer deref during boot and therefore boot failure.

On X86, as it stands today, no other devices actually do this (acpi_cpu
checks for PROCESSOR type devices) and so there is no issue. I ran into
this because I am adding such a device which gets probed before
acpi_ec_probe and sets private data. If ARM ever has an EC, I think
they'd run into this issue as well.

There have been several iterations of this patch. Earlier
iterations had ECDT enumerated ECs not call into the probe/attach
functions of this driver. This change was Suggested by: jhb@.

Reviewed by:    jhb
Approved by:	emaste (mentor)
Differential Revision:  https://reviews.freebsd.org/D16635
2018-11-19 18:29:03 +00:00
Edward Tomasz Napierala
a4f02d5d6d Make libthr(3) use sysconf(_SC_NPROCESSORS_CONF); this shaves off
two calls to sysctl(2) from the binary startup.

Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D18046
2018-11-19 18:24:08 +00:00
Edward Tomasz Napierala
3a9cdc5132 Make sysconf(_SC_PAGESIZE) return the value from getpagesize(3).
That avoids a syscall - getpagesize(3) gets the value from the ELF
aux strings.

Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D17989
2018-11-19 18:23:17 +00:00
Ed Maste
00bf4d2515 libc: forcibly disable BIND_NOW
Building libc WITH_BIND_NOW results in segfault at process start.  For
now force BIND_NOW off until the root cause can be identified and fixed.

PR:		233333
Sponsored by:	The FreeBSD Foundation
2018-11-19 18:12:39 +00:00
Mark Johnston
3d2a0fe762 Remove comments made obsolete by the ino64 work.
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2018-11-19 17:33:44 +00:00
Mariusz Zaborski
2863fd2f27 libcasper: provide compatibility with the old version of service
Some external tools like tcpdump(1) have upstream the changes with old limits
name. Because of that provide compatibility with the old names.

Reported by:	emaste
2018-11-19 17:22:52 +00:00
Alan Cox
541a117532 Use swp_pager_isondev() throughout. Submitted by: ota@j.email.ne.jp
Change swp_pager_isondev()'s return type to bool.

Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D16712
2018-11-19 17:17:23 +00:00
Kyle Evans
6fc21012a3 bectl(8) tests: attempt to load the ZFS module
Observed in a CI test image, bectl_create test will run and be marked as
skipped because the module is not loaded. The first zpool invocation will
automagically load the module, but bectl_create is still skipped. Subsequent
tests all pass as expected because the module is now loaded and everything
is OK.

MFC after:	3 days
2018-11-19 17:09:57 +00:00
Kyle Evans
4ab5187d38 libbe(3): Handle non-ZFS rootfs better
If rootfs isn't ZFS, current version will emit an error claiming so and fail
to initialize libbe. As a consumer, bectl -r (undocumented) can be specified
to operate on a BE independently of whether on a UFS or ZFS root.

Unbreak this for the UFS case by only erroring out the init if we can't
determine a ZFS dataset for rootfs and no BE root was specified. Consumers
of libbe should take care to ensure that rootfs is non-empty if they're
trying to use it, because this could certainly be the case.

Some check is needed before zfs_path_to_zhandle because it will
unconditionally emit to stderr if the path isn't a ZFS filesystem, which is
unhelpful for our purposes.

This should also unbreak the bectl(8) tests on a UFS root, as is the case in
Jenkins' -test runs.

MFC after:	3 days
2018-11-19 16:47:21 +00:00
Niclas Zeising
4651a02f07 Enable evdev on ppc64
Enable evdev on ppc64 as well, similar to what was done for amd64 and i386
in r340387.

Evdev can be used by X and is used by wayland to handle input devices.

Approved by:	mmacy
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D18026
2018-11-19 15:36:58 +00:00
Tijl Coosemans
e3b385fc95 Do proper copyin of control message data in the Linux sendmsg syscall.
Instead of calling m_append with a user address, allocate an mbuf cluster
and copy data into it using copyin.  For the SCM_CREDS case, instead of
zeroing a stack variable and appending that to the mbuf, zero part of the
mbuf cluster directly.  One mbuf cluster is also the size limit used by
the FreeBSD sendmsg syscall (uipc_syscalls.c:sockargs()).

PR:		217901
Reviewed by:	kib
MFC after:	3 days
2018-11-19 15:31:54 +00:00
Hans Petter Selasky
90acd1d139 Minor code factoring. No functional change.
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2018-11-19 09:36:09 +00:00
Hans Petter Selasky
2205f61a31 Be more verbose when a sysctl fails to unregister.
Print name of sysctl in question.

MFC after:		1 week
Sponsored by:		Mellanox Technologies
2018-11-19 09:35:16 +00:00
Eugene Grosbein
d642b94209 Unbreak ng_source(4) for 64-bit platforms including amd64. 2018-11-19 07:27:50 +00:00
Stanislav Galabov
ef4e6c8fe8 Fix access to cpu_model[] in mtk_soc_set_cpu_model()
There may be cases where cpu_model[] may not be 32bit aligned, so it is
better to not try to access it as such in order to avoid unaligned access.

Sponsored by:	Smartcom - Bulgaria AD
2018-11-19 06:48:48 +00:00
Jayachandran C.
be7af100ad gitv3_its: fixes for multiple GIC ITS blocks
First pass of support for multiple GIC ITS blocks with ACPI.
Changes are to:
 * register the correct subset of interrupts with pic_register
   in case of ACPI.
 * initialize just the cpu interface for the first ITS, when
   domain information is not avialable. This has to be done
   until we split the per-CPU init to do LPI setup just once.
 * remove duplicate check for the GIC ITS domain, the sc_cpus
   are setup from domain, so the check again in per-CPU init
   seems unnecessary.

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D17841
2018-11-19 03:52:56 +00:00
Jayachandran C.
bd158cddc4 pci_host_generic : move activate/release to generic code
Now that the ACPI and FDT implementations for activating and
deactivating resources are the same, we can move it to
pci_host_generic.c.  No functional changes.

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D17793
2018-11-19 03:43:10 +00:00
Jayachandran C.
f916d05797 pci_host_generic, acpi_resource: drop unneeded code
Now that we are handling PCI resources in pci_host_generic_acpi.c, we
don't need these change (made by r336129)

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D17792
2018-11-19 03:34:15 +00:00
Jayachandran C.
185c34f7c8 acpica, pci_host_generic_acpi: redo pci_host_generic_acpi.c
This is a major update for pci_host_generic_acpi.c, the current
implementation has some gaps that are better fixed up in one go.
The changes are to:
 * Follow x86 method of not adding PCI resources to PCI host bridge in
   ACPI code. This has been moved to pci_host_generic_acpi.c, where we
   walk thru its resources of the host bridge and add them.
 * Fixup code in pci_host_generic_acpi.c to read all decoded ranges
   and update the 'ranges' property. This allows us to share most of
   the code with generic implementation (and the FDT one).
 * Parse and setup IO ranges and bus ranges when walking the resources
   above. Drop most of the changes related to this from acpica code.
 * Add the ECAM memory area as mem resource 0. Implement the logic to
   get the ECAM area from MCFG (using bus range which we now decode),
   or from _CBA (using _BBN/bus range). Drop aarch64 ifdefs from acpica
   code which did part of this.
 * Switch resource activation to similar code as FDT implementation,
   this can be moved into generic implementation in a later pass.
 * Drop the mechanism of using the 7th bit of bus number as the domain,
   this is not correct and will work only in very specific cases. Use
   _SEG as PCI domain and use the bus ranges of the host bridge to
   provide start bus number.

This commit should not make any functional change to dev/acpica/acpi.c
for other architectures, almost all the changes there are to revert
earlier additions in this file done for aarch64.

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D17791
2018-11-19 03:16:16 +00:00
Jayachandran C.
d4d6ad3f05 acpica: rework INTRNG interrupts
On arm64 (where INTRNG is enabled), the interrupts have to be mapped
with ACPI_BUS_MAP_INTR() before adding them as resources to devices.

The earlier code did the mapping before calling acpi_set_resource(),
which bypassed code that checked for PCI link interrupts.

To fix this, move the call to map interrupts into acpi_set_resource()
and that requires additional work to lookup interrupt properties.
The changes here are to:
 * extend acpi_lookup_irq_handler() to lookup an irq in the ACPI
   resources
 * create a helper function acpi_map_intr() which uses the updated
   acpi_lookup_irq_handler() to look up an irq, and then map it
   with ACPI_BUS_MAP_INTR()
 * use acpi_map_intr() in acpi_pcib_route_interrupt() to map
   pci link interrupts.

With these changes, we can drop the ifdefs in acpi_resource.c, and
we can also drop the call for mapping interrupts in generic_timer.c

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D17790
2018-11-19 03:02:47 +00:00
Jayachandran C.
697c57e5c7 pci_host_generic*: basic implementation of bus range
Both ACPI and FDT support bus ranges for pci host bridges. Update
pci_host_generic*.[ch] with a default implementation to support this.
This will be used in the next set of changes for ACPI based host
bridge. No functional changes in this commit.

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D17657
2018-11-19 02:55:18 +00:00
Jayachandran C.
ad785aafe3 pci_host_generic: allocate resources against devices
Fix up pci_host_generic.c and pci_host_generic_fdt.c to allocate
resources against devices that requested them. Currently the
allocation happens against the pcib, which is incorrect.

This is needed for the upcoming changes for fixing up
pci_host_generic_acpi.c

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D17656
2018-11-19 02:43:34 +00:00
Jayachandran C.
f3c5181ab9 pci_host_generic: remove unneeded ThunderX2 quirk
The current quirk implementation writes a fixed address to the PCI BAR
to fix a firmware bug. The PCI BARs are allocated by firmware and will
change depending on PCI devices present. So using a fixed address here
is not correct.

This quirk worked around a firmware bug that programmed the MSI-X bar
of the SATA controller incorrectly. The newer firmware does not have
this issue, so it is better to drop this quirk altogether.

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D17655
2018-11-19 02:38:02 +00:00
Kyle Evans
9c1535e9ab bectl(8): Add some regression tests
These tests operate on a file-backed zpool that gets created in the kyua
temp dir. root and ZFS support are both required for these tests. Current
tests cover create, destroy, export/import, jail, list (kind of), mount,
rename, and jail.

List tests should later be extended to cover formatting and the different
list flags, but for now only covers basic "are create/destroy actually
reflected properly"

MFC after:	3 days
2018-11-19 02:30:12 +00:00