]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years ago[PPC64] Fix rtld direct exec mode
luporl [Mon, 5 Aug 2019 13:22:02 +0000 (13:22 +0000)]
[PPC64] Fix rtld direct exec mode

Instead of restoring the saved values of argc, argv and envp,
these must be loaded from the stack that _rtld() modifies.

This fixes rtld direct exec mode.
E.g.: /libexec/ld-elf.so.1 /bin/ls

Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D21131

4 years agoAdd common firewall test suite
thj [Mon, 5 Aug 2019 11:47:34 +0000 (11:47 +0000)]
Add common firewall test suite

Add a common test suite for the firewalls included in the base system. The test
suite allows common test infrastructure to test pf, ipfw and ipf firewalls from
test files containing the setup for all three firewalls.

Add the pass block test for pf, ipfw and ipf. The pass block test checks the
allow/deny functionality of the firewalls tested.

Submitted by:   Ahsan Barkati
Sponsored by:   Google, Inc. (GSoC 2019)
Reviewed by:    kp
Approved by:    bz (co-mentor)
MFC after:      2 weeks
Differential Revision: https://reviews.freebsd.org/D21065

4 years agofrag6.c: rename ip6q[] to ipq6b[] and consistently use "bucket"
bz [Mon, 5 Aug 2019 11:01:12 +0000 (11:01 +0000)]
frag6.c: rename ip6q[] to ipq6b[] and consistently use "bucket"

The hash buckets array is called ip6q.  The data structure ip6q is a
description of different object, the one the array holds these days
(since r337776).  To clear some of this confusion, rename the array
to ip6qb.

When iterating over all buckets or addressing them directly, we
use at least the variables i, hash, and bucket.  To keep the
terminology consistent use the variable name "bucket" and always
make it an uint32_t and not sometimes an int.

No functional behaviour changes intended.

MFC after: 3 months
Sponsored by: Netflix

4 years agofrag6.c: re-order functions within file
bz [Mon, 5 Aug 2019 09:49:24 +0000 (09:49 +0000)]
frag6.c: re-order functions within file

Re-order functions within the file in preparation for an upcoming
code simplification.

No functional changes.

MFC after: 3 months
Sponsored by: Netflix

4 years agoRemove obsolete header file.
delphij [Mon, 5 Aug 2019 06:01:29 +0000 (06:01 +0000)]
Remove obsolete header file.

4 years agoEnable superpage promotion within the kernel pmap.
alc [Mon, 5 Aug 2019 02:44:04 +0000 (02:44 +0000)]
Enable superpage promotion within the kernel pmap.

Reviewed by: markj
X-MFC after: r350004
Differential Revision: https://reviews.freebsd.org/D21149

4 years agopowerpc: Get 32-bit AIM building with secure-PLT
jhibbits [Mon, 5 Aug 2019 01:37:18 +0000 (01:37 +0000)]
powerpc:  Get 32-bit AIM building with secure-PLT

The last few changes needed before 32-bit AIM builds with secure-PLT with
base GCC.  Because ofwcall32.S and swtch32.S were branching to the GOT it
could not use secure PLT.

4 years agoipfw: fix jail option after r348215
kevans [Mon, 5 Aug 2019 00:08:25 +0000 (00:08 +0000)]
ipfw: fix jail option after r348215

r348215 changed jail_getid(3) to validate passed-in jids as active jails
(as the function is documented to return -1 if the jail does not exist).
This broke the jail option (in some cases?) as the jail historically hasn't
needed to exist at the time of rule parsing; jids will get stored and later
applied.

Fix this caller to attempt to parse *av as a number first and just use it
as-is to match historical behavior. jail_getid(3) must still be used in
order for name arguments to work, but it's strictly a fallback in case we
weren't given a number.

Reported and tested by: Ari Suutari <ari stonepile fi>
Reviewed by: ae
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D21128

4 years agortld-elf: Remove x86 elf_rtld.x linker scripts.
kib [Sun, 4 Aug 2019 21:43:34 +0000 (21:43 +0000)]
rtld-elf: Remove x86 elf_rtld.x linker scripts.

First, amd64 version of the script cannot work at least due to the
wrong architecture specification.  Second, kernel can activate shared
objects for long time, due to PIE support.

It seems the intent was to allow ld-elf.so.1 to be build and used as
an executable.  Since we have direct exec mode implemented for dso
ld-elf.so.1, the non-functional and commented out scripts can be
finally removed.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agoFix 32-bit build again, post r350570.
jhibbits [Sun, 4 Aug 2019 20:00:39 +0000 (20:00 +0000)]
Fix 32-bit build again, post r350570.

Missed this part with my testing as well.  Pass the right type to
BUS_TRANSLATE_RESOURCE().

4 years agoFix 32-bit build post-r350570
jhibbits [Sun, 4 Aug 2019 19:55:43 +0000 (19:55 +0000)]
Fix 32-bit build post-r350570

The error message prints a rman_res_t, which is an uintmax_t.  Explicitly
cast, just for future-proofing, and use the correct format.

4 years agoFix the build after r350570.
jhibbits [Sun, 4 Aug 2019 19:47:02 +0000 (19:47 +0000)]
Fix the build after r350570.

Signed char cannot compare to values above 0x7f.  Use unsigned instead.

4 years agoAdd necessary bits for Linux KPI to work correctly on powerpc
jhibbits [Sun, 4 Aug 2019 19:28:10 +0000 (19:28 +0000)]
Add necessary bits for Linux KPI to work correctly on powerpc

PowerPC, and possibly other architectures, use different address ranges for
PCI space vs physical address space, which is only mapped at resource
activation time, when the BAR gets written.  The DRM kernel modules do not
activate the rman resources, soas not to waste KVA, instead only mapping
parts of the PCI memory at a time.  This introduces a
BUS_TRANSLATE_RESOURCE() method, implemented in the Open Firmware/FDT PCI
driver, to perform this necessary translation without activating the
resource.

In addition to system KPI changes, LinuxKPI is updated to handle a
big-endian host, by adding proper endian swaps to the I/O functions.

Submitted by: mmacy
Reported by: hselasky
Differential Revision: https://reviews.freebsd.org/D21096

4 years agopowerpc: Enable the BUS_DMA_NOCACHE flag handling
jhibbits [Sun, 4 Aug 2019 19:25:23 +0000 (19:25 +0000)]
powerpc: Enable the BUS_DMA_NOCACHE flag handling

The flag handling was committed commented out 7 years ago.  It works, and is
needed for LinuxKPI-based DRM drivers.

Also mark a local as potentially unusable, as it's only really used when KTR
is enabled.

Submitted by: mmacy

4 years agoResolve ipfilter kld unload issues related to VNET jails.
cy [Sun, 4 Aug 2019 12:47:38 +0000 (12:47 +0000)]
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@
MFC after: 3 days

4 years agoReturning an uninitialized error is a bad thing.
cy [Sun, 4 Aug 2019 12:47:35 +0000 (12:47 +0000)]
Returning an uninitialized error is a bad thing.

MFC after: 3 days

4 years agoThere is no need to explicitly add zlib, we already have it in
delphij [Sun, 4 Aug 2019 04:51:32 +0000 (04:51 +0000)]
There is no need to explicitly add zlib, we already have it in
sys/conf/files.

4 years agoAdd `nvmecontrol sanitize` command.
mav [Sat, 3 Aug 2019 19:24:56 +0000 (19:24 +0000)]
Add `nvmecontrol sanitize` command.

It allows to delete all user data from NVM subsystem in one of 3 methods.
It is a close equivalent of SCSI SANITIZE command of `camcontrol sanitize`,
so I tried to keep arguments as close as possible.

While there, fix supported sanitize methods reporting in `identify`.

MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.

4 years agoFix format spec for ILP32.
kib [Sat, 3 Aug 2019 18:26:16 +0000 (18:26 +0000)]
Fix format spec for ILP32.

Sponsored by: The FreeBSD Foundation

4 years agoamd64: Streamline exceptions and interrupts handlers.
kib [Sat, 3 Aug 2019 17:07:04 +0000 (17:07 +0000)]
amd64: Streamline exceptions and interrupts handlers.

PTI-mode entry points were coded to set up the environment identical
to non-PTI entry and then fall-through to non-PTI handlers, mostly.
This has the drawback of requiring two more SWAPGS, first to access
PCPU, and then to return to the state expected by the non-PTI entry
point.

Eliminate the duplication by doing more in entry stubs both for PTI
and non-PTI, and adjusting the common code to expect that SWAPGS and
some minimal registers saving is done by entries.

Some less often used entries, in particular, #GP, #NP, and #SS, which
can fault on doreti, are left as is because there are basically four
variants of entrance, and they are not performance-critical,
esp. comparing with e.g. #PF or interrupts.

Reviewed by: markj (previous version)
Tested by: pho (previous version)
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agobhyve: Ignore MSI/MSI-X interrupts sent to non-active vCPUs in
kib [Sat, 3 Aug 2019 16:57:14 +0000 (16:57 +0000)]
bhyve: Ignore MSI/MSI-X interrupts sent to non-active vCPUs in
physical destination mode.

This is mostly a nop, because the vmm initializes all vCPUs up to
vm_maxcpus, so even if the target CPU is not active, lapic/vlapic code
still has the valid data to use.  As John notes, dropping such
interrupts more closely matches the real harware, which ignores all
interrupts for not started APs.

Reviewed by: jhb
admbugs: 837
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agofrag6.c: fix includes
bz [Sat, 3 Aug 2019 16:56:44 +0000 (16:56 +0000)]
frag6.c: fix includes

Bring back systm.h after r350532 and banish errno.h, time.h, and
machine/atomic.h.

Reported by: bde (Thank you!)
Pointyhat to: bz
MFC after: 12 weeks
X-MFC: with r350532
Sponsored by: Netflix

4 years agoAdd per hub sysctl to expose port information for phyisical form etc.
takawata [Sat, 3 Aug 2019 16:13:44 +0000 (16:13 +0000)]
Add per hub sysctl to expose port information for phyisical form etc.

Reviewed by:hselasky
Differential Revision: https://reviews.freebsd.org/D20865

4 years agoProperly validte arguments for route deletion
gnn [Sat, 3 Aug 2019 14:42:07 +0000 (14:42 +0000)]
Properly validte arguments for route deletion

Reported by: Liang Zhuo brightiup.zhuo@gmail.com
MFC after: 1 week

4 years agoCapsicumize ping6
asomers [Sat, 3 Aug 2019 13:53:14 +0000 (13:53 +0000)]
Capsicumize ping6

Add capsicum support to ping6, mostly copying the strategy used for ping.

Submitted by: Ján Sučan <jansucan@gmail.com>
Reviewed by: markj
MFC after: 2 weeks
Sponsored by: Google, inc. (Google Summer of Code 2019)
Differential Revision: https://reviews.freebsd.org/D21050

4 years agoFix parameter check broken at r350057.
mav [Sat, 3 Aug 2019 04:30:28 +0000 (04:30 +0000)]
Fix parameter check broken at r350057.

MFC after: 2 weeks

4 years agoif_mxge: update zlib version 1.0.4 to 1.2.11.
delphij [Sat, 3 Aug 2019 03:36:18 +0000 (03:36 +0000)]
if_mxge: update zlib version 1.0.4 to 1.2.11.

PR: 229763
Submitted by: Yoshihiro Ota <ota j email ne jp>
Differential Revision: https://reviews.freebsd.org/D20272

4 years agoAdd more random bits from NVMe 1.4.
mav [Sat, 3 Aug 2019 02:36:35 +0000 (02:36 +0000)]
Add more random bits from NVMe 1.4.

MFC after: 2 weeks

4 years agopowerpc/powernv: Fix OPAL cfgread/cfgwrite error handling
jhibbits [Sat, 3 Aug 2019 01:55:51 +0000 (01:55 +0000)]
powerpc/powernv: Fix OPAL cfgread/cfgwrite error handling

Freeze clearing needs to heppen any time OPAL reads return either an error
(except OPAL_HARDWARE), AND any time it returns 0xff for all bytes.

For cfgwrite, any error that's not OPAL_HARDWARE should be cleaned up.

4 years agoDon't reset memory attributes when mapping physical addresses for ACPI.
jhb [Sat, 3 Aug 2019 01:36:05 +0000 (01:36 +0000)]
Don't reset memory attributes when mapping physical addresses for ACPI.

Previously, AcpiOsMemory was using pmap_mapbios which would always map
the requested address Write-Back (WB).  For several AMD Ryzen laptops,
the BIOS uses AcpiOsMemory to directly access the PCI MCFG region in
order to access PCI config registers.  This has the side effect of
remapping the MCFG region in the direct map as WB instead of UC
hanging the laptops during boot.

On the one laptop I examined in detail, the _PIC global method used to
switch from 8259A PICs to I/O APICs uses a pair of PCI config space
registers at offset 0x84 in the device at 0:0:0 to as a pair of
address/data registers to access an indirect register in the chipset
and clear a single bit to switch modes.

To fix, alter the semantics of pmap_mapbios() such that it does not
modify the attributes of any existing mappings and instead uses the
existing attributes.  If a new mapping is created, this new mapping
uses WB (the default memory attribute).

Special thanks to the gentleman whose name I don't have who brought
two affected laptops to the hacker lounge at BSDCan.  Direct access to
the affected systems permitted finding the root cause within an hour
or so.

PR: 231760, 236899
Reviewed by: kib, alc
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20327

4 years agoFlip REPRODUCIBLE_BUILD back to off by default in head.
jhb [Sat, 3 Aug 2019 01:06:17 +0000 (01:06 +0000)]
Flip REPRODUCIBLE_BUILD back to off by default in head.

Having the full uname output can be useful on head even with
unmodified trees or trees that newvers.sh fails to recognize as
modified.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D20895

4 years agoSet ISOPEN in namei flags when opening executable interpreters.
jhb [Sat, 3 Aug 2019 01:02:52 +0000 (01:02 +0000)]
Set ISOPEN in namei flags when opening executable interpreters.

These vnodes are explicitly opened via VOP_OPEN via
exec_check_permissions identical to the main exectuable image.
Setting ISOPEN allows filesystems to perform suitable checks in
VOP_LOOKUP (e.g. close-to-open consistency in the NFS client).

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

4 years agoMFC after: 3 days
cy [Fri, 2 Aug 2019 22:58:45 +0000 (22:58 +0000)]
MFC after: 3 days

4 years agoFix !INET build.
delphij [Fri, 2 Aug 2019 22:43:09 +0000 (22:43 +0000)]
Fix !INET build.

4 years agoBecause of AArch64's weak memory consistency model, we need to include a
alc [Fri, 2 Aug 2019 22:36:42 +0000 (22:36 +0000)]
Because of AArch64's weak memory consistency model, we need to include a
memory barrier between the stores for initializing a page table page and
the store for adding that page to the page table.  Otherwise, a page table
walk by another processor's MMU could see the page table page before it
sees the initialized entries.

Simplify pmap_growkernel().  In particular, eliminate an unnecessary TLB
invalidation.

Reviewed by: andrew, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D21126

4 years agoAdd bzip2recover.1.
markj [Fri, 2 Aug 2019 22:09:56 +0000 (22:09 +0000)]
Add bzip2recover.1.

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

4 years agoDecode few more NVMe log pages.
mav [Fri, 2 Aug 2019 20:16:21 +0000 (20:16 +0000)]
Decode few more NVMe log pages.

In particular: Changed Namespace List, Commands Supported and Effects,
Reservation Notification, Sanitize Status.

Add few new arguments to `nvmecontrol log` subcommand.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

4 years agoOnly check the blessings table for known LORs.
markj [Fri, 2 Aug 2019 18:01:47 +0000 (18:01 +0000)]
Only check the blessings table for known LORs.

Previously we would check for blessings before marking a given lock
pair as reversed, so each "reversed" lock acquisition would require
a linear scan of the table.  Instead, check the table after marking
the pair as reversed but before generating a report.

Reviewed by: jhb
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21135

4 years agoFix warnings about unused identifiers when compiling without RATELIMIT.
markj [Fri, 2 Aug 2019 15:19:11 +0000 (15:19 +0000)]
Fix warnings about unused identifiers when compiling without RATELIMIT.

4 years agoFix one more atomic for i86
rrs [Fri, 2 Aug 2019 11:17:07 +0000 (11:17 +0000)]
Fix one more atomic for i86
Obtained from: mtuexen@freebsd.org

4 years agofrag6.c: make compile with gcc
bz [Fri, 2 Aug 2019 11:05:00 +0000 (11:05 +0000)]
frag6.c: make compile with gcc

Removing the prototype from the header and making the function static
in r350533 makes architectures using gcc complain "function declaration
isn't a prototype".  Add the missing void given the function has no
arguments.

Reported by: the CI machinery
Pointyhat to: bz
MFC after: 3 months
X-MFC with: r350533
Sponsored by: Netflix

4 years agofrag6.c: rename malloc type
bz [Fri, 2 Aug 2019 10:54:57 +0000 (10:54 +0000)]
frag6.c: rename malloc type

Rename M_FTABLE to M_FRAG6 as the former sounds very much like the former
"flowtable" rather than anything to do with fragments and reassembly.

While here, let malloc( , .. | M_ZERO) do the zeroing rather than calling
bzero() ourselves.

MFC after: 3 months
Sponsored by: Netflix

4 years agofrag6.c: remove dead code
bz [Fri, 2 Aug 2019 10:41:51 +0000 (10:41 +0000)]
frag6.c: remove dead code

Remove all the #if 0 and #if notyet blocks of dead code which have been
there for at least 18 years from what I can see.

No functional changes.

MFC after: 3 months
Sponsored by: Netflix

4 years agofrag6.c: move variables and sysctls into local file
bz [Fri, 2 Aug 2019 10:29:53 +0000 (10:29 +0000)]
frag6.c: move variables and sysctls into local file

Move the sysctls and the related variables only used in frag6.c
into the file and out of in6_proto.c.  That way everything belonging
together is in one place.

Sort the variables into global and per-vnet scopes and make
them static.  No longer export the (helper) function
frag6_set_bucketsize() now also file-local only.

Should be no functional changes, only reduced public KPI/KBI surface.

MFC after: 3 months
Sponsored by: Netflix

4 years agofrag6.c: sort includes
bz [Fri, 2 Aug 2019 10:06:54 +0000 (10:06 +0000)]
frag6.c: sort includes

Sort includes and remove duplicate kernel.h as well as the unneeded
systm.h.
Hide the mac framework incude behind #fidef MAC.

MFC after: 3 months
Sponsored by: Netflix

4 years agoIPv6 cleanup: kernel
bz [Fri, 2 Aug 2019 07:41:36 +0000 (07:41 +0000)]
IPv6 cleanup: kernel

Finish what was started a few years ago and harmonize IPv6 and IPv4
kernel names.  We are down to very few places now that it is feasible
to do the change for everything remaining with causing too much disturbance.

Remove "aliases" for IPv6 names which confusingly could indicate
that we are talking about a different data structure or field or
have two fields, one for each address family.
Try to follow common conventions used in FreeBSD.

* Rename sin6p to sin6 as that is how it is spelt in most places.
* Remove "aliases" (#defines) for:
  - in6pcb which really is an inpcb and nothing separate
  - sotoin6pcb which is sotoinpcb (as per above)
  - in6p_sp which is inp_sp
  - in6p_flowinfo which is inp_flow
* Try to use ia6 for in6_addr rather than in6p.
* With all these gone  also rename the in6p variables to inp as
  that is what we call it in most of the network stack including
  parts of netinet6.

The reasons behind this cleanup are that we try to further
unify netinet and netinet6 code where possible and that people
will less ignore one or the other protocol family when doing
code changes as they may not have spotted places due to different
names for the same thing.

No functional changes.

Discussed with: tuexen (SCTP changes)
MFC after: 3 months
Sponsored by: Netflix

4 years agoFix typo in r350529.
mav [Fri, 2 Aug 2019 04:04:18 +0000 (04:04 +0000)]
Fix typo in r350529.

MFC after: 2 weeks

4 years agoAdd more new fields and values from NVMe 1.4.
mav [Fri, 2 Aug 2019 03:43:24 +0000 (03:43 +0000)]
Add more new fields and values from NVMe 1.4.

MFC after: 2 weeks

4 years agoUse ATTR_DBM even when hardware dirty bit management is not enabled.
markj [Thu, 1 Aug 2019 22:48:06 +0000 (22:48 +0000)]
Use ATTR_DBM even when hardware dirty bit management is not enabled.

The ARMv8 reference manual only states that the bit is reserved in
this case; following Linux's example, use it instead of a
software-defined bit for the purpose of indicating that a managed
mapping is writable.

Reviewed by: alc, andrew
MFC after: r350004
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21121

4 years agoRename function added in r350523 to make gcc happy.
mav [Thu, 1 Aug 2019 22:22:06 +0000 (22:22 +0000)]
Rename function added in r350523 to make gcc happy.

MFC after: 2 weeks

4 years agoAdd IOCTL to translate nvdX into nvmeY and NSID.
mav [Thu, 1 Aug 2019 21:44:07 +0000 (21:44 +0000)]
Add IOCTL to translate nvdX into nvmeY and NSID.

While very useful by itself, it also makes `nvmecontrol` not depend on
hardcoded device names parsing, that in its turn makes simple to take
nvdX (and potentially any other) device names as arguments.

Also added IOCTL bypass from nvdX to respective nvmeYnsZ makes them
interchangeable for management purposes.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

4 years agoIPv6 cleanup: netstat
bz [Thu, 1 Aug 2019 20:36:25 +0000 (20:36 +0000)]
IPv6 cleanup: netstat

Rename the variable for the in6_addr from in6p to ia6 to follow the
convention generally used in FreeBSD.

No functional changes.

MFC after: 3 months
Sponsored by: Netflix

4 years agoOpps use fetchadd_u64 not long to keep old 32 bit platforms
rrs [Thu, 1 Aug 2019 20:26:27 +0000 (20:26 +0000)]
Opps use fetchadd_u64 not long to keep old 32 bit platforms
happy.

4 years agoFix the reporting of multiple unknown parameters in an received INIT
tuexen [Thu, 1 Aug 2019 19:45:34 +0000 (19:45 +0000)]
Fix the reporting of multiple unknown parameters in an received INIT
chunk. This also plugs an potential mbuf leak.
Thanks to Felix Weinrank for reporting this issue found by fuzz-testing
the userland stack.

MFC after: 3 days

4 years agoInclude caph_rights_limit() in libegacy if need be.
markj [Thu, 1 Aug 2019 19:26:16 +0000 (19:26 +0000)]
Include caph_rights_limit() in libegacy if need be.

Reported by: jenkins
Sponsored by: The FreeBSD Foundation

4 years agoas: add deprecation notice to the man page
emaste [Thu, 1 Aug 2019 19:01:27 +0000 (19:01 +0000)]
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
Discussed with: jhb
MFC after: 1 week
Relnotes: Yes
Sponsored by: The FreeBSD Foundation

4 years agoCapsicumize size(1).
markj [Thu, 1 Aug 2019 18:57:37 +0000 (18:57 +0000)]
Capsicumize size(1).

Reviewed by: oshogbo
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21105

4 years agoCapsicumize readelf(1).
markj [Thu, 1 Aug 2019 18:57:08 +0000 (18:57 +0000)]
Capsicumize readelf(1).

Reviewed by: oshogbo
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21108

4 years agoCapsicumize addr2line(1).
markj [Thu, 1 Aug 2019 18:56:32 +0000 (18:56 +0000)]
Capsicumize addr2line(1).

Reviewed by: oshogbo
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21104

4 years agoAdd an MLINK for daemonfd(3).
markj [Thu, 1 Aug 2019 18:51:18 +0000 (18:51 +0000)]
Add an MLINK for daemonfd(3).

MFC after: 3 days

4 years agoFix formatting.
markj [Thu, 1 Aug 2019 18:51:06 +0000 (18:51 +0000)]
Fix formatting.

MFC after: 3 days

4 years agoOnly skip test cases sometimes failing in CI when they are running in CI
lwhsu [Thu, 1 Aug 2019 18:19:16 +0000 (18:19 +0000)]
Only skip test cases sometimes failing in CI when they are running in CI

Suggested by: jhb
Sponsored by: The FreeBSD Foundation

4 years agoreadelf: decode NT_GNU_PROPERTY_TYPE_0 / GNU_PROPERTY_X86_FEATURE_1_AND
emaste [Thu, 1 Aug 2019 17:59:56 +0000 (17:59 +0000)]
readelf: decode NT_GNU_PROPERTY_TYPE_0 / GNU_PROPERTY_X86_FEATURE_1_AND

These bits are used for Intel CET IBT/Shadow Stack.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20516

4 years agoRevert r349863 (ACPICA 20190703).
jkim [Thu, 1 Aug 2019 17:45:43 +0000 (17:45 +0000)]
Revert r349863 (ACPICA 20190703).

This commit caused boot failures on some systems.

Requested by: scottl

4 years agoiflib: Prevent kernel panic caused by loading driver with a specific interrupt config...
erj [Thu, 1 Aug 2019 17:37:25 +0000 (17:37 +0000)]
iflib: Prevent kernel panic caused by loading driver with a specific interrupt configuration

If a device has only 1 MSI-X interrupt available and does not support either
MSI or legacy interrupts, iflib_device_register() will fail, leak memory and
MSI resources, and the driver will not load. Worse, if another iflib-using
driver tries to unload afterwards, a kernel panic will occur because the
previous failed iflib driver loead did not properly call "taskqgroup_detach()"
during it's cleanup.

This patch is band-aid for this situation -- don't try allocating MSI or legacy
interrupts if a single MSI-X interrupt was allocated, but fail to load instead.
As well, during the cleanup, properly call taskqgroup_detach() on the admin
task to prevent panics when other iflib drivers unload.

This whole interrupt allocation process actually needs re-doing to properly
support devices with only a single MSI-X interrupt, devices that only support
MSI-X, non-PCI devices, and multiple non-MSIX interrupts, as well.

Signed-off-by: Eric Joyner <erj@freebsd.org>
Reviewed by: marius@
MFC after: 1 week
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D20747

4 years agoWhen responding with an ABORT to an INIT chunk containing a
tuexen [Thu, 1 Aug 2019 17:36:15 +0000 (17:36 +0000)]
When responding with an ABORT to an INIT chunk containing a
HOSTNAME parameter or a parameter with an illegal length, only
include an error cause indicating why the ABORT was sent.
This also fixes an mbuf leak which could occur.

MFC after: 3 days

4 years agoiflib: remove kobject class reference increment
erj [Thu, 1 Aug 2019 17:28:36 +0000 (17:28 +0000)]
iflib: remove kobject class reference increment

Commit message from Jake:
In iflib_register, the context is initialized as a kobject using the
device driver's "driver" kobject class. As part of this, the function
mistakenly increments the ref counter.

The ref counter is incremented twice, once in the code directly, and
once again by kobj_class_compile. However, there is no associated
decrement in the detach path. Because of this, the ref counter will
never go back down to zero, and thus the kobject method table will never
be released.

Remove this unnecessary reference count increment.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Submitted by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed by: jhb@, erj@
MFC after: 3 days
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D21125

4 years agoremove obsolete kernel debugging script
emaste [Thu, 1 Aug 2019 17:02:58 +0000 (17:02 +0000)]
remove obsolete kernel debugging script

For quite some time kgdb has been internally handling FreeBSD kernel
module state; add-on scripts and tools are not needed.  asf(8) served
a similar purpose to this script and was removed in r335222.

PR: 229046
Reported by: jhb
Sponsored by: The FreeBSD Foundation

4 years agoobjdump: be explicit that GNU objdump that will be removed
emaste [Thu, 1 Aug 2019 14:42:41 +0000 (14:42 +0000)]
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.

MFC after: 3 days

4 years agoTry to decrease the number of bugs in unionfs after the VV_TEXT flag removal.
kib [Thu, 1 Aug 2019 14:40:37 +0000 (14:40 +0000)]
Try to decrease the number of bugs in unionfs after the VV_TEXT flag removal.

- Provide unionfs_add_writecount() which passes the writecount to the
  lower or upper vnode as appropriate.
- In unionfs VOP_RECLAIM() implementation, annulate unionfs
  writecounts from upper or lower vnode.  It is not clear that it is
  always correct to remove the all references from either lower or
  upper vnode, but we currently do not track which vnode get how many
  refs anyway.

Reported and tested by: t_uemura@macome.co.jp
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoobjdump: move deprecation notice to indended spot in the man page
emaste [Thu, 1 Aug 2019 14:39:26 +0000 (14:39 +0000)]
objdump: move deprecation notice to indended spot in the man page

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 after: 3 days

4 years agoMake umtxq_check_susp() to correctly handle thread exit requests.
kib [Thu, 1 Aug 2019 14:34:27 +0000 (14:34 +0000)]
Make umtxq_check_susp() to correctly handle thread exit requests.

The check for P_SINGLE_EXIT was shadowed by the (P_SHOULDSTOP || traced) check.

Reported by: bdrewery (might be)
Reviewed by: markj
Tested by: pho
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D21124

4 years agoThis adds the third step in getting BBR into the tree. BBR and
rrs [Thu, 1 Aug 2019 14:17:31 +0000 (14:17 +0000)]
This adds the third step in getting BBR into the tree. BBR and
an updated rack depend on having access to the new
ratelimit api in this commit.

Sponsored by: Netflix Inc.
Differential Revision: https://reviews.freebsd.org/D20953

4 years agonewvers: append commit count to uname version string
emaste [Thu, 1 Aug 2019 14:13:04 +0000 (14:13 +0000)]
newvers: append commit count to uname version string

In a git world this provides a facsimile of a monotonically increasing
version number.  This might be refined further, but this provides a
starting point for investigation.

Reviewed by: cem
Relnotes: Yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20462

4 years agoacpi_resource.c: mention ThunderX2 firmware revision with issue
emaste [Thu, 1 Aug 2019 14:02:59 +0000 (14:02 +0000)]
acpi_resource.c: mention ThunderX2 firmware revision with issue

Presumably this will be fixed in the next version, and the workaround
could eventually be removed.  See r330113 and r346066 details.

4 years agotelnet: use asprintf for r349890 change
emaste [Thu, 1 Aug 2019 13:46:04 +0000 (13:46 +0000)]
telnet: use asprintf for r349890 change

Suggested by: imp
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation

4 years agoppp: correct echo-req magic number on big endian archs
emaste [Thu, 1 Aug 2019 13:42:58 +0000 (13:42 +0000)]
ppp: correct echo-req magic number on big endian archs

The magic number is a 32-bit quantity; use uint32_t to match hton's
return type and avoid sending zeros (upper 32 bits) on big-endian
architectures.

PR: 184141
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoAllow Kernel to link in both legacy libkern/zlib and new sys/contrib/zlib,
delphij [Thu, 1 Aug 2019 06:35:33 +0000 (06:35 +0000)]
Allow Kernel to link in both legacy libkern/zlib and new sys/contrib/zlib,
with an eventual goal to convert all legacl zlib callers to the new zlib
version:

 * Move generic zlib shims that are not specific to zlib 1.0.4 to
   sys/dev/zlib.
 * Connect new zlib (1.2.11) to the zlib kernel module, currently built
   with Z_SOLO.
 * Prefix the legacy zlib (1.0.4) with 'zlib104_' namespace.
 * Convert sys/opencrypto/cryptodeflate.c to use new zlib.
 * Remove bundled zlib 1.2.3 from ZFS and adapt it to new zlib and make
   it depend on the zlib module.
 * Fix Z_SOLO build of new zlib.

PR: 229763
Submitted by: Yoshihiro Ota <ota j email ne jp>
Reviewed by: markm (sys/dev/zlib/zlib_kmod.c)
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D19706

4 years agopowerpc/powernv: Only clear EEH freeze for some errors
jhibbits [Thu, 1 Aug 2019 03:59:25 +0000 (03:59 +0000)]
powerpc/powernv: Only clear EEH freeze for some errors

Only clear an EEH freeze if an error occurs.  However, if an OPAL_HARDWARE
error is returned, this indicates a hardware failure which cannot be
unfrozen, and instead needs a hardware reset.  Attempting to unfreeze a
broken PCH will result in console spam for each attempt.  To avoid the spam,
just don't do it.

4 years agopowerpc64/mmu: Use a SLIST for the PVO delete list, instead of a RB_TREE
jhibbits [Thu, 1 Aug 2019 03:55:58 +0000 (03:55 +0000)]
powerpc64/mmu: Use a SLIST for the PVO delete list, instead of a RB_TREE

Summary:
Although it's convenient to reuse the pvo_plist for deletion, RB_TREE
insertion and removal is not free, and can result in a lot of extra work
to rebalance the tree.  Instead, use a SLIST as a LIFO delete queue,
which gives us almost free insertion, deletion, and traversal.

Reviewed by: luporl
Differential Revision: https://reviews.freebsd.org/D21061

4 years agovmx: use C99 bool, not boolean_t
emaste [Thu, 1 Aug 2019 02:16:48 +0000 (02:16 +0000)]
vmx: use C99 bool, not boolean_t

Bhyve's vmm is a self-contained modern component and thus a good
candidate for use of C99 types.

Reviewed by: jhb, kib, markj, Patrick Mooney
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21036

4 years agoAdd an entry for the copy_file_range(2) syscall.
rmacklem [Wed, 31 Jul 2019 23:36:23 +0000 (23:36 +0000)]
Add an entry for the copy_file_range(2) syscall.

4 years agoWhen updating the user or group disk quotas for the return of inodes or
mckusick [Wed, 31 Jul 2019 22:44:58 +0000 (22:44 +0000)]
When updating the user or group disk quotas for the return of inodes or
disk blocks, set the FORCE flag in the call to chkiq() or chkdq() since
the user is always allowed to return resources and hence there is no need
to check the user's credential .

Reported by:    Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE
Reported as:    FS-1-UFS-1: Denial Of Service in mount (prison_priv_check)
Discussed with: kib
MFC:            1 week
Sponsored by:   Netflix

4 years agoSmall cleanup, no functional change intended.
tuexen [Wed, 31 Jul 2019 21:39:03 +0000 (21:39 +0000)]
Small cleanup, no functional change intended.

MFC after: 3 days

4 years agoConsistently cleanup mbufs in case of other memory errors.
tuexen [Wed, 31 Jul 2019 21:29:17 +0000 (21:29 +0000)]
Consistently cleanup mbufs in case of other memory errors.

MFC after: 3 days

4 years agoadd forgotten opening bracket "("
wosch [Wed, 31 Jul 2019 21:21:34 +0000 (21:21 +0000)]
add forgotten opening bracket "("

PR: 237514
Reviewed by: allanjude
MFC after: soon for 11.3 and 12 series
Differential Revision: https://reviews.freebsd.org/D21009

4 years ago[PPC64] Implement CAS
luporl [Wed, 31 Jul 2019 20:31:36 +0000 (20:31 +0000)]
[PPC64] Implement CAS

Guest PPC OSs running under a hypervisor may communicate the features they
support, in order for the hypervisor to expose a virtualized machine in the way
the client (guest OS) expects (see LoPAPR 1.1 - B.6.2.3).

This is done by calling the "/ibm,client-architecture-support" (CAS) method,
informing supported features in option vectors.  Until now, FreeBSD wasn't
using CAS, but instead relied on hypervisor/QEMU's defaults.

The problem is that, without CAS, it is very inconvenient to run POWER9 VMs on
a POWER9 host running with radix enabled.  This happens because, in this case,
the QEMU default is to present the guest OS a dual MMU (HPT/RPT), instead of
presenting a regular HPT MMU, as FreeBSD expects, resulting in an early panic.
The known workarounds required either changing the host to disable radix or
passing a flag to QEMU to run in a POWER8 compatible mode.

With CAS, FreeBSD is now able to communicate that it wants an HPT MMU,
independent of the host setup, which now makes FreeBSD work on POWER9/pseries,
with KVM enabled and without hugepages (support added in a previous commit).

As CAS is invoked through OpenFirmware's call-method interface, it needs to be
performed early, when OpenFirmware is still operational. Besides, now that FDT
is the default way to inspect the device tree on PPC, OFW call-method feature
will be unavailable by default, when control is passed to the kernel. Because
of this, the call to CAS is being performed at the loader, instead of at the
kernel.

To avoid regressions with old platforms, this change uses CAS only on
POWER8/POWER9.

Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D20827

4 years agoMake randomized stack gap between strings and pointers to argv/envs.
kib [Wed, 31 Jul 2019 20:23:10 +0000 (20:23 +0000)]
Make randomized stack gap between strings and pointers to argv/envs.

This effectively makes the stack base on the csu _start entry
randomized.

The gap is enabled if ASLR is for the ABI is enabled, and then
kern.elf{64,32}.aslr.stack_gap specify the max percentage of the
initial stack size that can be wasted for gap.  Setting it to zero
disables the gap, and max is capped at 50%.

Only amd64 for now.

Reviewed by: cem, markj
Discussed with: emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D21081

4 years agoAvoid conflicts with libc symbols in libthr jump table.
kib [Wed, 31 Jul 2019 20:04:39 +0000 (20:04 +0000)]
Avoid conflicts with libc symbols in libthr jump table.

In some corner cases of static linking and unexpected libraries order
on the linker command line, libc symbol might preempt the same libthr
symbol, in which case libthr jump table points back to libc causing
either infinite recursion or loop.  Handle all of such symbols by
using private libthr names for them, ensuring that the right pointers
are installed into the table.

In collaboration with: arichardson
PR: 239475
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D21088

4 years agognop: add note to the RELNOTES
oshogbo [Wed, 31 Jul 2019 19:32:39 +0000 (19:32 +0000)]
gnop: add note to the RELNOTES

Submitted by: markj

4 years agoAvoid conflicts with libc symbols in libthr jump table.
kib [Wed, 31 Jul 2019 19:27:20 +0000 (19:27 +0000)]
Avoid conflicts with libc symbols in libthr jump table.

In some corner cases of static linking and unexpected libraries order
on the linker command line, libc symbol might preempt the same libthr
symbol, in which case libthr jump table points back to libc causing
either infinite recursion or loop.  Handle all of such symbols by
using private libthr names for them, ensuring that the right pointers
are installed into the table.

In collaboration with: arichardson
PR: 239475
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D21088

4 years agoRegen.
kib [Wed, 31 Jul 2019 19:20:39 +0000 (19:20 +0000)]
Regen.

4 years agofreebsd32 shims for copy_file_range(2).
kib [Wed, 31 Jul 2019 19:20:05 +0000 (19:20 +0000)]
freebsd32 shims for copy_file_range(2).

Reviewed by: brooks, rmacklem (previous version)
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D21092

4 years agoFix handling of transient casueword(9) failures in do_sem_wait().
kib [Wed, 31 Jul 2019 19:16:49 +0000 (19:16 +0000)]
Fix handling of transient casueword(9) failures in do_sem_wait().

In particular, restart should be only done when the failure is
transient.  For this, recheck the count1 value after the operation.

Note that do_sem_wait() is older usem interface.

Reported and tested by: bdrewery
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agoFeature-complete NVMe Namespace Management.
mav [Wed, 31 Jul 2019 18:44:20 +0000 (18:44 +0000)]
Feature-complete NVMe Namespace Management.

This adds several previously missed but important subcommands to list
namespaces and controllers.  It also fixes few previously added but
just found with real testing to be broken subcommands.

Also while there, add possibility to explicitly specify nsid for
`nvmecontrol identify` subcommand.  It may be useful to specify nsids
not having own devices, for example 0xffffffff, or just newly created
ones.

MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.

4 years agognop: style nits
oshogbo [Wed, 31 Jul 2019 17:51:06 +0000 (17:51 +0000)]
gnop: style nits

4 years agognop: Introduce requests delay.
oshogbo [Wed, 31 Jul 2019 17:47:12 +0000 (17:47 +0000)]
gnop: Introduce requests delay.

This allows to simulated disk that is responding slowly to the IO requests.

Reviewed by: markj, bcr, pjd (previous version)
Differential Revision: https://reviews.freebsd.org/D21052

4 years agopf: zero (another) output buffer in pfioctl
emaste [Wed, 31 Jul 2019 16:58:09 +0000 (16:58 +0000)]
pf: zero (another) output buffer in pfioctl

Avoid potential structure padding leak.  r350294 identified a leak via
static analysis; although there's no report of a leak with the
DIOCGETSRCNODES ioctl it's a good practice to zero the memory.

Suggested by: kp
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

4 years ago[PPC64] Backport fix for missing IRELATIVE relocations
luporl [Wed, 31 Jul 2019 16:22:05 +0000 (16:22 +0000)]
[PPC64] Backport fix for missing IRELATIVE relocations

This is a backport of LLVM commit 8331f61a51a7a0a1efbf5ed398e181593023d151,
llvm-svn: 353981:

ELF: Allow GOT relocs pointing to non-preemptable ifunc to resolve to an
IRELATIVE where possible.

This is needed in order to make ifuncs work correctly on PPC64.

It fixes an issue with lld, in which it would skip emitting necessary IRELATIVE
relocations.  Without this change, indirect calls to ifuncs would result in a
segmentation fault, in static binaries or when defined in the main binary
(outside shared libraries).

This change also reverts the local
"Preserve relocations against ifuncs when -zifunc-noplt" commit and
replaces it by its upstream version, as part of the merge.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D21102

4 years agokern_shm_open: push O_CLOEXEC into caller control
kevans [Wed, 31 Jul 2019 15:16:51 +0000 (15:16 +0000)]
kern_shm_open: push O_CLOEXEC into caller control

The motivation for this change is to allow wrappers around shm to be written
that don't set CLOEXEC. kern_shm_open currently accepts O_CLOEXEC but sets
it unconditionally. kern_shm_open is used by the shm_open(2) syscall, which
is mandated by POSIX to set CLOEXEC, and CloudABI's sys_fd_create1().
Presumably O_CLOEXEC is intended in the latter caller, but it's unclear from
the context.

sys_shm_open() now unconditionally sets O_CLOEXEC to meet POSIX
requirements, and a comment has been dropped in to kern_fd_open() to explain
the situation and add a pointer to where O_CLOEXEC setting is maintained for
shm_open(2) correctness. CloudABI's sys_fd_create1() also unconditionally
sets O_CLOEXEC to match previous behavior.

This also has the side-effect of making flags correctly reflect the
O_CLOEXEC status on this fd for the rest of kern_shm_open(), but a
glance-over leads me to believe that it didn't really matter.

Reviewed by: kib, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D21119