]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agobridge tests: test linking bridges with a gif tunnel
Kristof Provost [Wed, 21 Jul 2021 15:32:24 +0000 (17:32 +0200)]
bridge tests: test linking bridges with a gif tunnel

Fairly basic test case for using gif(4)'s ability to tunnel Ethernet
traffic between bridges.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 4b765ab4cda051a6d9ceb5fb9cac80c7f3b910bf)

2 years agotests: Enable net tests
Kristof Provost [Thu, 13 Feb 2020 14:09:09 +0000 (14:09 +0000)]
tests: Enable net tests

We have a number of tests in the net subdirectory that were not executed. List
the net directory so we run those tests.

(cherry picked from commit 475b483aeef96d8bf47159f06761104d92c58c8c)

2 years agoawk: merge fixes to metamode
Warner Losh [Sat, 31 Jul 2021 17:57:21 +0000 (11:57 -0600)]
awk: merge fixes to metamode

This is a partial MFC of c63c5ab001106/r349062. The whole thing doesn't
apply cleanly, but this bit, at least, is needed to fix metamode on
stable/12 after the changes to awk were merged from head. Rather than
risk breaking other things, I'm just merging the bit I know that's
needed. All build tools need to be in DEPENDOBJ so the dependency order
is correct and they get built with host tools.

Reported by: kp
Sponsored by: Netflix

2 years agosmartpqi: Maintenance commit of Microchip smartpqi
Papani Srikanth [Fri, 30 Jul 2021 23:49:53 +0000 (17:49 -0600)]
smartpqi: Maintenance commit of Microchip smartpqi

Newly added features and bug fixes in latest Microchip SmartPQI driver.

 1) Newly added TMF feature.
 2) Added newly Huawei & Inspur PCI ID's
 3) Fixed smartpqi driver hangs in Z-Pool while running on FreeBSD12.1
 4) Fixed flooding dmesg in kernel while the controller is offline during
    in ioctls.
 5) Avoided unnecessary host memory allocation for rcb sg buffers.
 6) Fixed race conditions while accessing internal rcb structure.
 7) Fixed where Logical volumes exposing two different names to the OS
    it's due to the system memory is overwritten with DMA stale data.
 8) Fixed dynamically unloading a smartpqi driver.
 9) Added device_shutdown callback instead of deprecated shutdown_final
    kernel event in smartpqi driver.
10) Fixed where Os is crashed during physical drive hot removal during
    heavy IO.
11) Fixed OS crash during controller lockup/offline during heavy IO.
12) Fixed coverity issues in smartpqi driver
13) Fixed system crash while creating and deleting logical volume in a
    continuous loop.
14) Fixed where the volume size is not exposing to OS when it expands.
15) Added HC3 pci id's.
16) Fixed compiler issues in 12.2 kernel.

Note: this is a direct commit, submitted by the vendor to support
stable/12

Reviewed by: imp, Murthy Bhat, Scott Benesh
Differential Revision: https://reviews.freebsd.org/D24428

2 years agoawk: remove proctab.c
Warner Losh [Mon, 12 Jul 2021 03:26:08 +0000 (21:26 -0600)]
awk: remove proctab.c

proctab.c is a generated file and never should have been committed to
the tree. This file has been added and removed a couple of times, most
recently added by me in my 2019 updates.

Sponsored by: Netflix

(cherry picked from commit 0c92d88c9180bf25187f01f1d7e419edea9a0fef)

2 years agopf: fix ABI breakage
Kristof Provost [Wed, 28 Jul 2021 09:24:44 +0000 (11:24 +0200)]
pf: fix ABI breakage

The introduction of synproxy support changed the size of struct
pf_status, which in turn broke the userspace ABI.

Revert the relevant change. More work is needed on the synproxy code to
keep and expose the counters, but in the mean time this restores the
ABI.

PR:             257469
MFC after:      3 days
Sponsored by:   Modirum MDPay

(cherry picked from commit da8d8b22e69c72f1d001d55b5eff5acbb0265cfc)

2 years agopf.conf.5: Document new 'match' keyword
Kristof Provost [Tue, 2 Mar 2021 19:34:41 +0000 (20:34 +0100)]
pf.conf.5: Document new 'match' keyword

Reviewed by: bcr
Obtained from: pfSense
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31117

(cherry picked from commit 0351b9875a3eb5eb4b502a4106b1917ce954e959)

2 years agopf tests: Test the match keyword
Kristof Provost [Tue, 2 Mar 2021 15:57:27 +0000 (16:57 +0100)]
pf tests: Test the match keyword

The new match keyword can currently only assign queues, so we can only
test it with ALTQ.
Set up a basic scenario where we use 'match' to assign ICMP traffic to a
slow queue, and confirm that it's really getting slowed down.

MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31116

(cherry picked from commit d363ebc78cbb50bc334d74fb5bb755af53c69ff0)

2 years agopf: match keyword support
Kristof Provost [Tue, 2 Mar 2021 15:01:04 +0000 (16:01 +0100)]
pf: match keyword support

Support the 'match' keyword.
Note that support is limited to adding queuing information, so without
ALTQ support in the kernel setting match rules is pointless.

For the avoidance of doubt: this is NOT full support for the match
keyword as found in OpenBSD's pf. That could potentially be built on top
of this, but this commit is NOT that.

MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31115

(cherry picked from commit ef950daa35d43dd396958ca28ce9de0514daf873)

2 years agoaltq tests: Basic ALTQ test
Kristof Provost [Sat, 23 Jan 2021 09:37:03 +0000 (10:37 +0100)]
altq tests: Basic ALTQ test

Activate ALTQ_HFSC, crudely check if it really limits bandwidth as we'd expect.

Reviewed by: donner@
Differential Revision: https://reviews.freebsd.org/D28303

(cherry picked from commit 16b3833344ad04194f10b567bc6fae829a52a850)

2 years agoaltq: Fix typo in features sysctl description
Kristof Provost [Tue, 26 Jan 2021 15:02:45 +0000 (16:02 +0100)]
altq: Fix typo in features sysctl description

Reported by: Jose Luis Duran

(cherry picked from commit 35dabb7b9cff601045b623aeca59ccc68930d520)

2 years agoAdd FEATURE sysctls for ALTQ disciplines
Kristof Provost [Sat, 23 Jan 2021 09:36:33 +0000 (10:36 +0100)]
Add FEATURE sysctls for ALTQ disciplines

This will allow userspace to more easily figure out if ALTQ is built
into the kernel and what disciplines are supported.

Reviewed by: donner@
Differential Revision: https://reviews.freebsd.org/D28302

(cherry picked from commit e111d79806fe3652bc85593ca77ee1b4ff85498d)

2 years agonvmecontrol: update copyright on passthru command
Warner Losh [Thu, 6 May 2021 22:05:42 +0000 (16:05 -0600)]
nvmecontrol: update copyright on passthru command

I wrote this code, not Intel, so put my copyright on this. I mistakenly
copied it for the initial commit.

Sponsored by: Netflix

(cherry picked from commit 6d6cca363392943689204f920fa2da9226e42056)

2 years agonvmecontrol: Report status from passthru commands
Warner Losh [Thu, 25 Mar 2021 07:41:53 +0000 (01:41 -0600)]
nvmecontrol: Report status from passthru commands

Report status from dword0 for passthru commands. Many commands report
some status or information here, so reporting it can help know what's
going on.

Sponsored by: Netflix

(cherry picked from commit 510a3da1477a917aa2aaf6b9e3cd6fd50dd13206)

2 years agoAdd SPDX tag.
Warner Losh [Thu, 28 Feb 2019 02:29:48 +0000 (02:29 +0000)]
Add SPDX tag.

(cherry picked from commit e96f6eda1b292c9d91051be0fbe7070a5f83a464)

2 years agonvmecontrol: document power command
Warner Losh [Sat, 10 Jul 2021 16:51:15 +0000 (10:51 -0600)]
nvmecontrol: document power command

The description of the power command is missing. While the synopsis is
present, there's no explanation. Add one.

Reviewed by: mav, chuck
PR: 237866
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31122

(cherry picked from commit 445b5554bf97254a0ead3d70f801871d62dcfb62)

2 years agonvmecontrol: fix typo (s/Managment/Management/)
Edward Tomasz Napierala [Fri, 7 May 2021 12:12:30 +0000 (13:12 +0100)]
nvmecontrol: fix typo (s/Managment/Management/)

Reported By: pstef

(cherry picked from commit 95a74ab4fb0879da270342bc98719b0e735694f3)

2 years agoFix 32-bit build post 6733401935f83754b4b2744bc3d33ef84b1271e0
Dimitry Andric [Fri, 8 Jan 2021 22:38:21 +0000 (23:38 +0100)]
Fix 32-bit build post 6733401935f83754b4b2744bc3d33ef84b1271e0

The general style in sbin/nvmecontrol apppears to print uint64_t types
using %j, so I'm using that instead of the more general (but admittedly
ugly) PRIu64.

(cherry picked from commit a82f07fc2e2456b0ddc847d611f56a3152a6f940)

2 years agonvme: coherently read status of completion records
Warner Losh [Fri, 2 Jul 2021 22:00:42 +0000 (16:00 -0600)]
nvme: coherently read status of completion records

Coherently read the phase bit of the status completion record. We loop
over the completion record array, looking for all the transactions in
the same phase that have been completed. In doing that, we have to be
careful to read the status field first, and if it indicates a complete
record, we need to read and process that record. Otherwise, the host
might be overtaken by device when reading this completion record,
leading to a mistaken belief that the record is in phase. This leads to
the code using old values and looking at an already completed entry, which
has no current tracker.

To work around this problem, we read the status and make sure it is in
phase, we then re-read the entire completion record guaranteeing it's
complete, valid, and consistent . In addition we resync the dmatag to
reflect changes since the prior loop for the bouncing dma case.

Reviewed by: jrtc27@, chuck@
Found by: jrtc27 (this fix is based in part on her D30995 fix)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31002

(cherry picked from commit aa0ab681ae755e01cd69435fab50f6852f248c42)

2 years agonvme: Fix alignment on nvme structures
Warner Losh [Fri, 2 Jul 2021 21:58:19 +0000 (15:58 -0600)]
nvme: Fix alignment on nvme structures

Remove __packed from nvme_command, nvme_completion and
nvme_dsm_trim. Add super-alignment to nvme_completion since it's always
at least that aligned in hardware (and in our existing uses of it
embedded in structures). It generates better code in
nvme_qpair_process_completions on riscv64 because otherwise the ABI
assumes a 4-byte alignment, and the same on all other platforms.

Reviewed by: jrtc27@, mav@, chuck@
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31001

(cherry picked from commit fea3cf1d6da0acf40bc1d3dadeeea7eeccbc10dd)

2 years agonvme: style nit
Warner Losh [Fri, 2 Jul 2021 21:58:14 +0000 (15:58 -0600)]
nvme: style nit

Put the { on the same line as the struct nvme_foo when we define these
structures. It's FreeBSD standard and these were inconsistent.

Sponsored by: Netflix

(cherry picked from commit 80a75155e1601bddc2c595c06ab6ea916c603071)

2 years agonvme: fix a race between failing the controller and failing requests
Warner Losh [Sat, 29 May 2021 05:01:52 +0000 (23:01 -0600)]
nvme: fix a race between failing the controller and failing requests

Part of the nvme recovery process for errors is to reset the
card. Sometimes, this results in failing the entire controller. When nda
is in use, we free the sim, which will sleep until all the I/O has
completed. However, with only one thread, the request fail task never
runs once the reset thread sleeps here. Create two threads to allow I/O
to fail until it's all processed and the reset task can proceed.

This is a temporary kludge until I can work out questions that arose
during the review, not least is what was the race that queueing to a
failure task solved. The original commit is vague and other error paths
in the same context do a direct failure. I'll investigate that more
completely before committing changing that to a direct failure. mav@
raised this issue during the review, but didn't otherwise object.

Multiple threads, though, solve the problem in the mean time until other
such means can be perfected.

Reviewed by: jhb@
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D30366

(cherry picked from commit f0f47121653e88197d8537572294b90f5aef7f17)

2 years agonvme: use config_intrhook_drain to avoid removable card races
Warner Losh [Thu, 11 Mar 2021 15:42:44 +0000 (08:42 -0700)]
nvme: use config_intrhook_drain to avoid removable card races

nvme drives are configured early in boot. However, a number of the configuration
steps takes which take a while, so we defer those to a config intrhook that runs
before the root filesystem is mounted. At the same time, the PCI hot plug wakes
up and tests the status of the card. It may decide that the card has gone away
and deletes the child. As part of that process nvme_detach is called. If this
call happens after the config_intrhook starts to run, but before it is finished,
there's a race where we can tear down the device's soft state while the
config_intrhook is still using it. Use the new config_intrhook_drain to
disestablish the hook. Either it will be removed w/o running, or the routine
will wait for it to finish. This closes the race and allows safe hotplug at any
time, even very early in boot.

Sponsored by: Netflix, Inc
Reviewed by: jhb, mav
Differential Revision: https://reviews.freebsd.org/D29006

(cherry picked from commit 8423f5d4c127f18e7500bc455bc7b6b1691385ef)

2 years agonvme: Make nvme_ctrlr_hw_reset static
Warner Losh [Mon, 8 Feb 2021 20:28:18 +0000 (13:28 -0700)]
nvme: Make nvme_ctrlr_hw_reset static

nvme_ctrlr_hw_reset is no longer used outside of nvme_ctrlr.c, so
make it static. If we need to change this in the future we can.

(cherry picked from commit dd2516fc078f15633ad5aedaad6de140cb491f80)

2 years agonvme: use NVME_GONE rather than hard-coded 0xffffffff
Warner Losh [Mon, 8 Feb 2021 20:08:48 +0000 (13:08 -0700)]
nvme: use NVME_GONE rather than hard-coded 0xffffffff

Make it clearer that the value 0xfffffff is being used to detect the device is
gone. We use it other places in the driver for other meanings.

(cherry picked from commit 9600aa31aa633bbb9e8a56d91a781d5a7ce2bff6)

2 years agofix big-endian platforms after 6733401935f8
Chuck Tuffli [Fri, 8 Jan 2021 22:36:37 +0000 (14:36 -0800)]
fix big-endian platforms after 6733401935f8

The NVMe byte-swap routines for big-endian platforms used memcpy() to
move the unaligned 64-bit value into a temp register to byte swap it.
Instead of introducing a dependency, manually byte-swap the values in
place.

Point hat: me

(cherry picked from commit e83fdf8bb391579fa422d34663cd8c1f82a00dc0)

2 years agonvmecontrol: add device self-test op and log page
Chuck Tuffli [Fri, 8 Jan 2021 17:19:37 +0000 (09:19 -0800)]
nvmecontrol: add device self-test op and log page

Add decoding of the Device Self-test log page and the ability to start
or abort a test.

Reviewed by: imp, mav
Tested by: Muhammad Ahmad <muhammad.ahmad@seagate.com>
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D27517

(cherry picked from commit 6733401935f83754b4b2744bc3d33ef84b1271e0)

2 years agonvme: Remove a wmb() that's not necessary.
Warner Losh [Fri, 4 Dec 2020 21:34:48 +0000 (21:34 +0000)]
nvme: Remove a wmb() that's not necessary.

bus_dmamap_sync() ensures that memory that's prepared for PREWRITE can
be DMA'd immediately after it returns. The details differ, but this
mirrors atomic thread release semantics, at least for the buffers
synced.

For non-x86 platforms, bus_dmamap_sync() has the right syncing and
fences. So in the past, wmb() had been omitted for them.

For x86 platforms, the memory ordering is already strong enough to
ensure DMA to the device sees the current contents. As such, we don't
need the wmb() here. It translates to an sfence which is only needed
for writes to regions that have the write combining attribute set or
when some exotic opcodes are used. The nvme driver does neither of
these. Since bus_dmamap_sync() includes atomic_thread_fence_rel, we
can be assured any optimizer won't reorder the bus_dmamap_sync and the
bus_space_write operations. The wmb() was a vestiage of the pre-busdma
version initially committed to the tree.

Reviewed by: kib@, gallatin@, chuck@, mav@
Differential Revision: https://reviews.freebsd.org/D27448

(cherry picked from commit 082905cad121bf6721606b6b9ba20a09bc6e56d0)

2 years agoNVME: Multiple busdma related fixes.
Michal Meloun [Wed, 2 Dec 2020 16:54:24 +0000 (16:54 +0000)]
NVME: Multiple busdma related fixes.

- in nvme_qpair_process_completions() do dma sync before completion buffer
  is used.
- in nvme_qpair_submit_tracker(), don't do explicit wmb() also for arm
  and arm64. Bus_dmamap_sync() on these architectures is sufficient to ensure
  that all CPU stores are visible to external (including DMA) observers.
- Allocate completion buffer as BUS_DMA_COHERENT. On not-DMA coherent systems,
  buffers continuously owned (and accessed) by DMA must be allocated with this
  flag. Note that BUS_DMA_COHERENT flag is no-op on DMA coherent systems
  (or coherent buses in mixed systems).

MFC after: 4 weeks
Reviewed by: mav, imp
Differential Revision: https://reviews.freebsd.org/D27446

(cherry picked from commit 8f9d5a8dbf4ea69c5f9a1e3a36e23732ffaa5c75)

2 years agoAlways use the __unused attribute even for potentially unused parameters.
Michal Meloun [Tue, 1 Dec 2020 08:52:13 +0000 (08:52 +0000)]
Always use the __unused attribute even for potentially unused parameters.

Requested by: ian, imp
MFC with: r368167

(cherry picked from commit cf7c06293236710cc33de029fccd1185cb38c5fb)

2 years agoUnbreak r368167 in userland. Decorate unused arguments.
Michal Meloun [Mon, 30 Nov 2020 14:51:48 +0000 (14:51 +0000)]
Unbreak r368167 in userland. Decorate unused arguments.

Reported by: kp, tuexen, jenkins, and many others
MFC with: r368167

(cherry picked from commit b2e9e573a392a973bea0ff180932913b7aa0eb66)

2 years agonvme: change namei_request_zone into a malloc type
Mateusz Guzik [Thu, 5 Nov 2020 21:44:58 +0000 (21:44 +0000)]
nvme: change namei_request_zone into a malloc type

Both the size (128 bytes) and ephemeral nature of allocations make it a great
fit for malloc.

A dedicated zone unnecessarily avoids sharing buckets with 128-byte objects.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D27103

(cherry picked from commit 71460dfcb275f0a2a20b39a332b0e1149c6e7e3f)

2 years agonvme: Remove compat code for older kernels
Warner Losh [Sat, 24 Oct 2020 01:59:01 +0000 (01:59 +0000)]
nvme: Remove compat code for older kernels

Remove code that supported pre-2011 kernels. CTLTYPE_S64 was defined
in rev 217616. All supported branches have it, so remove its compat
definition as OBE.

(cherry picked from commit 0fc1d2088169456d469b53ecbe7832349917c29d)

2 years agoUse symbolic names for asych events
Warner Losh [Mon, 31 Aug 2020 19:38:03 +0000 (19:38 +0000)]
Use symbolic names for asych events

Rather than |= 0x300, define and use asyn event names for the name
space changes and the firmware activations that we're asking for.

(cherry picked from commit 881534f09cccbf4bc749be22eb34ad57b5c13563)

2 years agoReport cpi->hba_* for nda(4) because why not.
Alexander Motin [Wed, 12 Aug 2020 20:05:43 +0000 (20:05 +0000)]
Report cpi->hba_* for nda(4) because why not.

MFC after: 1 week

2 years agoAdd KASSERT to ensure sane nsid.
Warner Losh [Fri, 1 May 2020 21:24:19 +0000 (21:24 +0000)]
Add KASSERT to ensure sane nsid.

All callers are currently filtering bad nsid to this function,
however, we'll have undefined behavior if that's not true. Add the
KASSERT to prevent that.

(cherry picked from commit d5cc572ce6009993fb3c4f6c887194b9ec3c9815)

2 years agoRename ns notification function...
Warner Losh [Fri, 1 May 2020 21:24:15 +0000 (21:24 +0000)]
Rename ns notification function...

This function is called whenever the namespace is added, deleted or
changes. Update the name to reflect that. No functional change.

(cherry picked from commit 950475ca2062b5d95efcf4d758cb5f33d7710aed)

2 years agoMake sure that we get the sbuf resources we need.
Warner Losh [Thu, 30 Apr 2020 00:43:11 +0000 (00:43 +0000)]
Make sure that we get the sbuf resources we need.

Since we're calling sbuf_new with NOWAIT, make sure it can allocate a
buffer to use. Don't print anything if we can't get it.

Noticed by: rpokala

(cherry picked from commit 4e6a434b6bb81a7ae80911ec6730ff79b9352a88)

2 years agoGenerate a devctl event for interesting events
Warner Losh [Thu, 30 Apr 2020 00:27:19 +0000 (00:27 +0000)]
Generate a devctl event for interesting events

When we reset the controller, and when the controller tells us about a
critical warning, send an event.

(cherry picked from commit 244b805397208842e4d8bbf1ad5b1b83dbcd4c91)

2 years agoFix the pattern for changing PermitRootLogin
Jose Luis Duran [Fri, 16 Jul 2021 17:11:47 +0000 (14:11 -0300)]
Fix the pattern for changing PermitRootLogin

The previous pattern had the (harmless) side-effect of duplicating the
entry in the config file.

No functional change intended.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/510

(cherry picked from commit 73358cd2cfccf9aafde069ffcb8185a0f3420ffd)

2 years agoawk: Make -F '' and -v FS="" behave the same
Warner Losh [Tue, 20 Jul 2021 04:47:30 +0000 (22:47 -0600)]
awk: Make -F '' and -v FS="" behave the same

IEEE Std 1003.1-2008 mandates that -F str be treated the same as -v
FS=str. For a null string, this was not the case. Since awk(1) documents
that a null string for FS has a specific behavior, make -F '' behave
consistently with -v FS="".

PR: 241441
Upstream issue: https://github.com/onetrueawk/awk/issues/127
Upstream pull request: https://github.com/onetrueawk/awk/pull/128
MFC After: 2 weeks
Sponsored by: Netflix

(cherry picked from commit a2e3e1187309f9404940b61ca49a93bd0536559d)

2 years agoawk: Remove last markings we have on awk
Warner Losh [Thu, 22 Jul 2021 02:24:57 +0000 (20:24 -0600)]
awk: Remove last markings we have on awk

We normally don't add $FreeBSD$ to contrib software. However, these
changes date back to the CVS era of source code management and have been
overlooked. Now that all these files are back to the same as the
upstream bsd-features branch, remove the FreeBSD specific changes, which
are now just $FreeBSD$ and the (FreeBSD) in the version string.

MFC After: 2 weeks
Sponsored by: Netflix

(cherry picked from commit 5ab82b00cca74feb9d047e9c8aa29e5118810edc)

2 years agoawk: revert to upstream behavior for ranges for gawk compatibility
Warner Losh [Thu, 22 Jul 2021 02:22:43 +0000 (20:22 -0600)]
awk: revert to upstream behavior for ranges for gawk compatibility

In 2005, FreeBSD changed one-true-awk to honor the locale's collating
order. This was billed as a temporary patch. It was also compatible with
the then-current behavior of gawk. That temporary patch has lasted 16
years now.

However, IEEE Std 1003.1-2008 changed the behaivor of ranges in regular
expressions outside of the "C" and "POSIX" locales to be undefined.

Starting in 2011, gawk 4.0 stopped using the locale for the range
regular expressions and used the traditional behavior only. The
maintainer had grown weary of answering why '[A-Z]' would sometimes
match lower-case expressions. The details about are explained here:
https://www.gnu.org/software/gawk/manual/html_node/Ranges-and-Locales.html

To restore compatibility with other implementaitons of awk, revert this
patch. FreeBSD is the odd-system out. It also has the nice side effect
of eliminating the last of our differences with upstream one-true-awk.

Reviewed by: cy, rgrimes
MFC After: 2 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31114

(cherry picked from commit 628bd30ab5a492839b84dbf2aaf25848dae3866a)

2 years agotype: becauce -> because
Warner Losh [Thu, 22 Jul 2021 02:02:44 +0000 (20:02 -0600)]
type: becauce -> because

Noticed by: Piotr P. Stefaniak
Sponsored by: Netflix

(cherry picked from commit 2b720db8d409f6fcdffa7f06b1d8c1b981435a83)

2 years agonanobsd: fix typo in NANO_WORLDDIR
Yann Kerherve [Tue, 20 Jul 2021 17:10:28 +0000 (11:10 -0600)]
nanobsd: fix typo in NANO_WORLDDIR

Reviewed by: imp
PR: 257299

(cherry picked from commit 5a9e5a5111af59dbc96383fcd73129e31648e017)

2 years agoawk: Reduce diffs with upstream to almost nothing.
Warner Losh [Fri, 9 Jul 2021 03:51:24 +0000 (21:51 -0600)]
awk: Reduce diffs with upstream to almost nothing.

In the merge of 20210215, I left two merge conflicts #if 0'd by mistake
to check later rather than resolve them as part of the merge.  This code
turns out to be from the original one-true-awk import and not FreeBSD
specific, so remove them.

Remove a extra definition of HAT.

Remove a stylistic change that also appears to be a mismerge along the
way.

Remove FREEBSD-upgrade. Nobody has updated it since the original 2007
cvs import. It talks about old CVS branches that never made it into svn,
let alone git. New imports will follow the standard practices now, so
there's nothing left to document.

Move README to README.md and copy the README.md from upstream over.

This leaves just the $FreeBSD$ lines (which remain for the stable/12
merge) and the strcoll part of ru@'s r201989/d98dd8e5f94c as the only
diffs with upstream. FreeBSD also still has its own man page, which I
don't plan on changing. Once this commit is merged to stable/12, I plan
no further merges to stable/12. Sometime after that I'll remove the
$FreeBSD$ lines to reduce the diffs even more (though i want to make
sure plans won't change first). I also plan to talk to upstream about
this change...

MFC After: 2 weeks
Sponsored by: Netflix

(cherry picked from commit f68a53dba933f9c1143863603f5a16fdbe5f070e)

2 years agopf tests: make killstate:match more robust
Kristof Provost [Tue, 27 Jul 2021 13:31:00 +0000 (15:31 +0200)]
pf tests: make killstate:match more robust

Only lists the states relevant to the connection we're killing.
Sometimes there are IPv6 related states (due to the usual IPv6
background traffic of router solicitations, DAD, ...) that causes us to
think we failed to kill the state, which in turn caused the test to fail
intermittently.

MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 4e860bd5da1423aac9aed0541c484ebf9c1d1621)

2 years agoixgbe: Fix the build
Kevin Bowling [Fri, 30 Jul 2021 02:32:22 +0000 (19:32 -0700)]
ixgbe: Fix the build

I forgot to amend my commit after dropping CTLFLAG_NEEDGIANT.

Reported by: jenkins
Fixes: 07ab33cfc108

2 years agoixgbe: Clean up ix_txrx
Kevin Bowling [Sun, 18 Jul 2021 06:24:28 +0000 (23:24 -0700)]
ixgbe: Clean up ix_txrx

The intention here is to reduce differences with D30072.
The only functional change is logical simplification in
ixgbe_rx_checksum.

Reviewed by: gallatin
Differential Revision: https://reviews.freebsd.org/D30074

(cherry picked from commit 51e46835e10a2628482deefc0efd356fb733337a)

2 years agoixgbe: Print FW NVM and Option ROM versions
Kevin Bowling [Fri, 16 Jul 2021 06:50:14 +0000 (23:50 -0700)]
ixgbe: Print FW NVM and Option ROM versions

It can be useful for system operators to see this kind of information
when correlating issues or requesting support from the OEM or Intel for
hardware and firmware issues.

Reviewed by: gallatin
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30178

(cherry picked from commit 7660e4ea5cb750ded38a0bd81cde2e2b130222df)

2 years agodd a new option (-H) to daemon(8) to catch SIGHUP and re-open output_file file when
Maxim Sobolev [Thu, 24 Sep 2020 02:44:58 +0000 (02:44 +0000)]
dd a new option (-H) to daemon(8) to catch SIGHUP and re-open output_file file when
received.

The default system log rotation mechanism (newsyslog(8)) requires ability to send
signal to a daemon in order to properly complete rotation of the logs in an "atomic"
manner without having to making a copy and truncating original file. Unfortunately
our built-in mechanism to convert "dumb" programs into daemons has no way to handle
this rotation properly. This change adds this ability, to be enabled by supplying -H
option in addition to the -o option.

PR: 255198
Reviewed by: markj, rpokala (manpages)

(cherry picked from commit 4cd407ec933b81d9d0f733532d29426416cccc06)

2 years agobsdinstall: Only show menu if there are more items to be installed
Renato Botelho [Thu, 22 Jul 2021 20:02:34 +0000 (16:02 -0400)]
bsdinstall: Only show menu if there are more items to be installed

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

(cherry picked from commit 95f0da5be1e3456c930f5f9538cbc099c65f2014)

2 years agofreebsd-tips: Use a fetchable URL as example
Li-Wen Hsu [Sun, 4 Jul 2021 14:00:46 +0000 (22:00 +0800)]
freebsd-tips: Use a fetchable URL as example

MFC after: 3 days

(cherry picked from commit ffe6afc4f0121f1909f2fa88694228f771dd3fcb)

freebsd-tips: Fix the description of fetch(1) to match the command

Reported by: jrtc27
MFC with: ffe6afc4f0121f1909f2fa88694228f771dd3fcb

(cherry picked from commit 167897510919a76740eca0d79713abbd088660fe)

2 years agoman7: Update FreeBSD.org URLs
Li-Wen Hsu [Sun, 4 Jul 2021 14:07:23 +0000 (22:07 +0800)]
man7: Update FreeBSD.org URLs

MFC after: 3 days

(cherry picked from commit 8dfb00245701a4f9290cd3a24e9bdcafa55a075b)

2 years agoshare/misc: Update FreeBSD.org URLs
Li-Wen Hsu [Sun, 4 Jul 2021 14:04:33 +0000 (22:04 +0800)]
share/misc: Update FreeBSD.org URLs

MFC after: 3 days

(cherry picked from commit 89c0640c7090d5dfbe46adbe50186399923f360f)

2 years agofreebsd-update: Update URL of supported platforms information
Li-Wen Hsu [Sun, 4 Jul 2021 13:45:08 +0000 (21:45 +0800)]
freebsd-update: Update URL of supported platforms information

MFC after: 3 days

(cherry picked from commit 86d0d3aadb48a9a917167078ed197a061179fa4f)

2 years ago[skip ci] correct a few SPDX license tags
Alan Somers [Wed, 7 Jul 2021 19:52:20 +0000 (13:52 -0600)]
[skip ci] correct a few SPDX license tags

These were all incorrectly labeled as 2-clause BSD licenses by a
semi-automated process, when in fact they are 3-clause.

Discussed with: pfg, imp
Sponsored by: Axcient

(cherry picked from commit 3874c0abb0afaea6adc24ac96dc9dc5043f2b69e)

2 years agofusefs: correctly set lock owner during FUSE_SETLK
Alan Somers [Thu, 20 May 2021 01:10:15 +0000 (19:10 -0600)]
fusefs: correctly set lock owner during FUSE_SETLK

During FUSE_SETLK, the owner field should uniquely identify the calling
process.  The fusefs module now sets it to the process's pid.
Previously, it expected the calling process to set it directly, which
was wrong.

libfuse also apparently expects the owner field to be set during
FUSE_GETLK, though I'm not sure why.

PR: 256005
Reported by: Agata <chogata@moosefs.pro>
Reviewed by: pfg
Differential Revision: https://reviews.freebsd.org/D30622

(cherry picked from commit 18b19f8c6e04935a63a951afe0e540674bc94455)

2 years agofusefs: ensure that FUSE ops' headers' unique values are actually unique
Alan Somers [Fri, 18 Jun 2021 00:04:59 +0000 (18:04 -0600)]
fusefs: ensure that FUSE ops' headers' unique values are actually unique

Every FUSE operation has a unique value in its header.  As the name
implies, these values are supposed to be unique among all outstanding
operations.  And since FUSE_INTERRUPT is asynchronous and racy, it is
desirable that the unique values be unique among all operations that are
"close in time".

Ensure that they are actually unique by incrementing them whenever we
reuse a fuse_dispatcher object, for example during fsync, write, and
listextattr.

PR: 244686
Reviewed by: pfg
Differential Revision: https://reviews.freebsd.org/D30810

(cherry picked from commit 5403f2c163f7e3d1adb9431d216f88d57cf9d74b)

2 years agofusefs: delete some dead code
Alan Somers [Thu, 24 Dec 2020 19:21:00 +0000 (19:21 +0000)]
fusefs: delete some dead code

The original fusefs GSoC project seems to have envisioned exchanging two
types of messages with FUSE servers.  Perhaps vectored and non-vectored?
But in practice only one type has ever been used.  Delete the other type.

Reviewed by: cem
Differential Revision: https://reviews.freebsd.org/D27770

(cherry picked from commit 4f4111d2c5ab64591b9e15dab4257d8187458fd1)

2 years agofusefs: also debug INIT operations in the test suite
Alan Somers [Thu, 17 Jun 2021 22:06:43 +0000 (16:06 -0600)]
fusefs: also debug INIT operations in the test suite

Reviewed by: pfg

(cherry picked from commit 77b040c993ba9d4844e36f1f5b057066a5b4015a)

2 years agofusefs: delete dead code
Alan Somers [Fri, 18 Jun 2021 00:14:57 +0000 (18:14 -0600)]
fusefs: delete dead code

It was always dead, accidentally included in SVN r345876.

Reviewed by: pfg

(cherry picked from commit b97c7abc1a1cee72ef62109add860c1e8e618efd)

2 years agoSimplify fuse_device_filt_write
gAlfonso-bit [Wed, 16 Jun 2021 19:45:04 +0000 (15:45 -0400)]
Simplify fuse_device_filt_write

It always returns 1, so why bother having a variable.

Pull Request: https://github.com/freebsd/freebsd-src/pull/478

(cherry picked from commit 9b876fbd504e5c718d8d0275b32d806ab14558c8)

2 years agofusefs: support EVFILT_WRITE on /dev/fuse
Alan Somers [Tue, 15 Jun 2021 23:17:28 +0000 (17:17 -0600)]
fusefs: support EVFILT_WRITE on /dev/fuse

/dev/fuse is always ready for writing, so it's kind of dumb to poll it.
But some applications do it anyway.  Better to return ready than EINVAL.

Reviewed by: emaste, pfg
Differential Revision: https://reviews.freebsd.org/D30784

(cherry picked from commit 7b8622fa220b9c08041102f638f848c48e022644)

2 years agofusefs: improve warnings about buggy FUSE servers
Alan Somers [Tue, 15 Jun 2021 20:24:05 +0000 (14:24 -0600)]
fusefs: improve warnings about buggy FUSE servers

The fusefs driver will print warning messages about FUSE servers that
commit protocol violations.  Previously it would print those warnings on
every violation, but that could spam the console.  Now it will print
each warning no more than once per lifetime of the mount.  There is also
now a dtrace probe for each violation.

Sponsored by: Axcient
Reviewed by: emaste, pfg
Differential Revision: https://reviews.freebsd.org/D30780

(cherry picked from commit 0b9a5c6fa1733e600dcdb3b9df3b3d0ad5996920)

2 years agopf: clean up syncookie callout on vnet shutdown
Kristof Provost [Tue, 20 Jul 2021 19:03:08 +0000 (21:03 +0200)]
pf: clean up syncookie callout on vnet shutdown

Ensure that we cancel any outstanding callouts for syncookies when we
terminate the vnet.

MFC after: 1 week
Sponsored by: Modirum MDPay

(cherry picked from commit 32271c4d383effeac7878201ef5cbdfaeedc3755)

2 years agopf: remove stray debug line
Kristof Provost [Tue, 20 Jul 2021 19:02:33 +0000 (21:02 +0200)]
pf: remove stray debug line

MFC after: 1 week
Sponsored by: Modirum MDPay

(cherry picked from commit 84db87b8dafd9e9970fd36ac48c11ffdc89d31d0)

2 years agopf: fix LINT build
Kristof Provost [Tue, 20 Jul 2021 14:48:35 +0000 (16:48 +0200)]
pf: fix LINT build

We failed to list the new pf_syncookies.c file in sys/conf/files. This
worked for the usual configurations, where pf is a module, but not for
LINT builds.

Reported by: lwhsu
MFC after: 1 week
Sponsored by: Modirum MDPay

(cherry picked from commit b972a7fa9e1e01367435a5699b71cc7b5e494fee)

2 years agopf tests: ensure syncookie does not create state
Kristof Provost [Wed, 30 Jun 2021 13:27:46 +0000 (15:27 +0200)]
pf tests: ensure syncookie does not create state

Test that with syncookies enabled pf does not create state for
connections before the remote peer has replied to the SYN|ACK message.

MFC after: 1 week
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D31142

(cherry picked from commit 27ab791a55191c0b6503391d411303b042b41047)

2 years agopf tests: Forwarding syncookie test
Kristof Provost [Wed, 2 Jun 2021 16:16:03 +0000 (18:16 +0200)]
pf tests: Forwarding syncookie test

Test syncookies on a forwarding host. That is, in a setup where the
machine (or vnet) running pf is not the same as the machine (or vnet)
running the server it's protecting.

MFC after: 1 week
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D31141

(cherry picked from commit 3be9301a7e4fbd630cbde1bd3e1b59ac726e21af)

2 years agopfctl: syncookie configuration
Kristof Provost [Wed, 26 May 2021 11:41:34 +0000 (13:41 +0200)]
pfctl: syncookie configuration

pfctl and libpfctl code required to enable/disable the syncookie
feature.

MFC after: 1 week
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D31140

(cherry picked from commit c69121c473d75abab55f9ade8e8138ac09c0942c)

2 years agopf: syncookie ioctl interface
Kristof Provost [Wed, 26 May 2021 08:18:19 +0000 (10:18 +0200)]
pf: syncookie ioctl interface

Kernel side implementation to allow switching between on and off modes,
and allow this configuration to be retrieved.

MFC after: 1 week
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D31139

(cherry picked from commit 231e83d3422ff58fe94de8375a9532a1726056ed)

2 years agopf: syncookie support
Kristof Provost [Thu, 20 May 2021 09:54:41 +0000 (11:54 +0200)]
pf: syncookie support

Import OpenBSD's syncookie support for pf. This feature help pf resist
TCP SYN floods by only creating states once the remote host completes
the TCP handshake rather than when the initial SYN packet is received.

This is accomplished by using the initial sequence numbers to encode a
cookie (hence the name) in the SYN+ACK response and verifying this on
receipt of the client ACK.

Reviewed by: kbowling
Obtained from: OpenBSD
MFC after: 1 week
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D31138

(cherry picked from commit 8e1864ed07121b479b95d7e3a5931a9e0ffd4713)

2 years agopf: factor out pf_synproxy()
Kristof Provost [Thu, 10 Jun 2021 13:49:09 +0000 (15:49 +0200)]
pf: factor out pf_synproxy()

MFC after: 1 week
Sponsored by: Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D31137

(cherry picked from commit ee9c3d38039eb29966e1f0b8f617bc564c078289)

2 years agoRevert "loader: support.4th resets the read buffer incorrectly"
Warner Losh [Mon, 26 Jul 2021 22:40:41 +0000 (16:40 -0600)]
Revert "loader: support.4th resets the read buffer incorrectly"

This reverts commit 9c1c02093b90ae49745a174eb26ea85dd1990eec. It seems
to have broken all old nextboot.conf files causing hangs on boot.

PR: 239315
Sponsored by: Netflix

(cherry picked from commit 4783fb730fa1cfdbe5c905bb23ac74f681e2df6b)

2 years agopf: embed a pointer to the lock in struct pf_kstate
Mateusz Guzik [Mon, 19 Jul 2021 12:40:25 +0000 (14:40 +0200)]
pf: embed a pointer to the lock in struct pf_kstate

This shaves calculation which in particular helps on arm.

Note using the & hack instead would still be more work.

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

(cherry picked from commit 907257d6967dd23506e69042c55bb1edc983c0ba)

2 years agopf: shrink struct pf_kstate
Mateusz Guzik [Mon, 19 Jul 2021 12:35:31 +0000 (14:35 +0200)]
pf: shrink struct pf_kstate

Makes room for a pointer.

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

(cherry picked from commit 9009d36afd1e0107e1e5b6988f49436087b3d474)

2 years agopf: add a comment to pf_kstate concerning compat with pf_state_cmp
Mateusz Guzik [Mon, 19 Jul 2021 12:17:33 +0000 (14:17 +0200)]
pf: add a comment to pf_kstate concerning compat with pf_state_cmp

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

(cherry picked from commit f9aa757d8d1e1bfc7951f462e92f00639256cad6)

2 years agopf: add a branch prediction to expire state check in pf_find_state
Mateusz Guzik [Mon, 19 Jul 2021 12:50:08 +0000 (14:50 +0200)]
pf: add a branch prediction to expire state check in pf_find_state

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

(cherry picked from commit 144ec0713daa532342a298fd888a1656ae24a62d)

2 years agoarm: dedup counter(9) address calculation
Mateusz Guzik [Mon, 19 Jul 2021 10:46:01 +0000 (10:46 +0000)]
arm: dedup counter(9) address calculation

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

(cherry picked from commit 78e3a168616dbe3a2c96efe568c960a1344f42e9)

2 years agoAdd __diagused
Mateusz Guzik [Thu, 15 Jul 2021 14:01:02 +0000 (14:01 +0000)]
Add __diagused

This can be used for variables which are only used with either
INVARIANTS or WITNESS. Without any annotation they run into dead store
warnings from cc --analyze and always annotating with __unused may hide
bad vars when it should not.

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

(cherry picked from commit b9296725cf99696b48926270a553044522d6e344)

2 years agopf: Remove unused arguments from pf_send_tcp()
Kristof Provost [Wed, 19 May 2021 18:33:28 +0000 (20:33 +0200)]
pf: Remove unused arguments from pf_send_tcp()

struct mbuf *replyto is not actually used (and only rarely provided).
The same applies to struct ifnet *ifp.

No functional change.

Reviewed by: mjg
MFC after: 1 week
Sponsored by:   Modirum MDPay
Differential Revision: https://reviews.freebsd.org/D31136

(cherry picked from commit 295f2d939d960e2bdf5c1499da3eb41618be05e6)

2 years agonfssvc: Zero the buffer copied out when NFSSVC_DUMPMNTOPTS is set
Mark Johnston [Fri, 16 Jul 2021 02:39:27 +0000 (22:39 -0400)]
nfssvc: Zero the buffer copied out when NFSSVC_DUMPMNTOPTS is set

Reported by: KMSAN
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 7a9bc8a82ec20f9208643f1615ea4ca1d0e5d933)

2 years agodevd: remove pccard entries
Warner Losh [Thu, 15 Jul 2021 22:17:33 +0000 (16:17 -0600)]
devd: remove pccard entries

The pccard entries are now obsolete, remove them.

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

(cherry picked from commit a53541355645080cb6d94466f5363db0941da4fa)

2 years agonvme: Enable interrupts after qpair fully constructed
Warner Losh [Thu, 15 Jul 2021 22:17:23 +0000 (16:17 -0600)]
nvme: Enable interrupts after qpair fully constructed

To guard against the ill effects of a spurious interrupt during
construction (or one that was bogusly pending), enable interrupts after
the qpair is completely constructed. Otherwise, we can die with null
pointer dereferences in nvme_qpair_process_completions. This has been
observed in at least one pre-release NVMe drive where the MSIX interrupt
fired while the queue was being created, before we'd started the NVMe
controller card.

The alternative of only turning on the interrupts after the rest was
tried, but was insufficient to work around this bug and made the code
more complicated w/o benefit.

Reviewed by: mav, chuck
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31182

(cherry picked from commit fc9a0840231770bc7e7dcfe4616babdc6d4389a6)

2 years agoboot: fix OBJS to not include BTX's crt0.o
Warner Losh [Thu, 6 May 2021 19:05:09 +0000 (13:05 -0600)]
boot: fix OBJS to not include BTX's crt0.o

According to comments in the Makefile, to make pxeboot work we need to
have crt0.o first. This is needed because the simplified loader in
pxeboot assumes that the startup code is at offset 0 in this binary. In
normal booting, the start address can be obtained from headers of the
binary, but since pxeboot encodes this as a pure binary, it has no way
of knowing where that is and assumes 0. Added comments to that effect
in the Makefile.

We've done this by adding it to OBJS before all the other .o's are
added. However, there's a problem. This also adds it to the CLEANFILES
variable, which causes it to be removed from multiple places. The
dependencies may also cause it to be re-built at a time that's after
boot2 is built. This causes installs to fail because at install time
boot2 is considered to be out of date and the programs to rebuild it are
no longer in the path.

Cope with this problem by just adding it to LDFLAGS instead.

Glanced at by: kevans ("I thought that went in ages ago")
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D28876

(cherry picked from commit e713d3a013882893fceb84dd14569052271497a9)

2 years agonanobsd: Bump rescue size to 8GB
Warner Losh [Thu, 15 Jul 2021 22:11:15 +0000 (16:11 -0600)]
nanobsd: Bump rescue size to 8GB

Bump the rescue size from 1.2GB to just shy of 8GB as things have grown
somewhat. Also make it possible to build rescue somewhere other than
/usr/src.

Sponsored by: Netflix

(cherry picked from commit 998abf5a1274609f9b74b3301dc0dabe659bd36b)

2 years agonanobsd: default to -j $hw.ncpu
Warner Losh [Thu, 15 Jul 2021 22:07:51 +0000 (16:07 -0600)]
nanobsd: default to -j $hw.ncpu

For paralllel builds, default to using all the CPUs on the system. The
old default of -j 3 was too few.

Sponsored by: Netflix

(cherry picked from commit 7e3a794be3752d21fe760cfb2a38665532c4b6b4)

2 years agonanobsd: Use gpart and create code image before full disk image
Arrigo Marchiori [Thu, 15 Jul 2021 22:06:51 +0000 (16:06 -0600)]
nanobsd: Use gpart and create code image before full disk image

The attached patch brings two main changes to the nanobsd script:
 1- gpart is used instead of fdisk;
 2- the code image is created first, and then used to ``assemble'' the
    full disk image.

The patch was first proposed on the freebsd-embedded list:
http://lists.freebsd.org/pipermail/freebsd-embedded/2012-June/001580.html
and is currently under discussion:
http://lists.freebsd.org/pipermail/freebsd-embedded/2014-January/002216.html

Another effect is that the -f option ("suppress code slice extraction")
now imples the -i option ("suppress disk image build").

imp@ applied Patch by hand to new legacy.sh, plus tweaked for NANO_LOG vs
NANO_OBJ confusion in original.

PR: 186030
Reviewed by: imp@
Differential Revision: https://reviews.freebsd.org/D31102

(cherry picked from commit 587c054bea0f652fdbd86baf5807f21c904ac2ad)

2 years agoloader: make sure CPUTYPE is ignored when building
Warner Losh [Thu, 15 Jul 2021 03:06:08 +0000 (21:06 -0600)]
loader: make sure CPUTYPE is ignored when building

CPUTYPE?=native causes -march=native to be added to the command
line. When the host machine is haswell, this causes some versions of
clang to generate code that can't execute in the efi boot loader
environment. Set _CPUCFLAGS= to undo what's done bsd.cpu.mk. bsd.cpu.mk
is included too early to control with NO_CPU_CFLAGS here. The only other
option is to put that in all the Makefiles, and this is less tedious and
error prone.

PR: 194641
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31187
MFC After: 1 week

(cherry picked from commit 7a0c0ff7ee25ff1efa3dbedcb20d2c80178639cc)

2 years agoRemove incorrect __restricted labels from strcspn
Alfonso Gregory [Wed, 14 Jul 2021 21:48:35 +0000 (15:48 -0600)]
Remove incorrect __restricted labels from strcspn

strcspn should never have had the __restrict keywords. While both of
these strings are const, it may have unindended side effects. While this
is the kernel, the POSIX definition also omits restrict.

Reviewed by: imp@
Pull Request: https://github.com/freebsd/freebsd-src/pull/497

(cherry picked from commit 56d33e86b74b197a36f42255824b56715c96a596)

2 years agoFix pmbr issues > 2TB
Emrion [Tue, 13 Jul 2021 20:37:59 +0000 (14:37 -0600)]
Fix pmbr issues > 2TB

These issues have low impact because they require precise circumstances
to trigger one of them. The disk must be > 2 TiB in size and either:
- The primary GPT header is dammaged.
- The freebsd-boot partiton is located farther than the first 2 TiB of
  the disc and one of its sectors takes place at a lba value that makes
  the higher 32 bits of this very value change.
Errors and corrections folow:
- decl and incl don't affect CF, so replace with subl/addl $1
- repe uses %cx, so move size to it with movw
- moving a 64-bit value with %cx of 2 (should be 4) so addresses
  > 2TB will work.

PR: 233180
Reviewed by: imp@ (applied patch using description in bug)
Differential Revision: https://reviews.freebsd.org/D31100

(cherry picked from commit 0ca9f1d4a3b772036309fb1c14262ec77c674c5d)

2 years agocam_iosched: use tunable flag and make a bool really a bool
Warner Losh [Tue, 13 Jul 2021 06:00:33 +0000 (00:00 -0600)]
cam_iosched: use tunable flag and make a bool really a bool

kern.cam.do_dynamic_iosched is really a bool, so change its type to
bool. While I'm here, also use the CTLFLAG_TUN flag instead of a
separate tunable line for it and kern.cam.iosched_alpha_bits.

MFC After: 1 week
Sponsored by: Netflix

(cherry picked from commit a065ccb2804fae834a7c66e29b726ea3dbbceace)

2 years agoFix potential NULL pointer dereference of device physical path
Young Xiao [Tue, 21 May 2019 07:36:29 +0000 (15:36 +0800)]
Fix potential NULL pointer dereference of device physical path

In ata_dev_advinfo() and nvme_dev_advinfo(), if the physical path is
being stored and there is a malloc failure (malloc(9) is called with
M_NOWAIT), we could wind up in a situation where the device's
physpath_len is set to the length the user provided, but the physpath
itself is NULL.

If another context then comes in to fetch the physical path value, we
would wind up trying to memcpy a NULL pointer into the caller's buffer.

So, set the physpath_len to 0 when we free the physpath on entry into
the store case for the physical path.  Reset the length to a non-zero
value only after we've successfully malloced a buffer to hold it.

This code mirrors scsi_xpt.c does already as well.

Signed-off-by: Young Xiao <92siuyang@gmail.com>
Reviewed by: imp
PR: 238014

(cherry picked from commit 431ddd94360a9e86c91294eaa2c7b859911984b7)

2 years agoloader: support.4th resets the read buffer incorrectly
John Hood [Sun, 11 Jul 2021 14:44:12 +0000 (08:44 -0600)]
loader: support.4th resets the read buffer incorrectly

Large nextboot.conf files (over 80 bytes) are not read correctly by the
Forth loader, causing file parsing to abort, and nextboot configuration
fails to apply.

Simple repro:

nextboot -e foo=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
shutdown -r now

That will cause the bug to cause a parse failure but shouldn't otherwise
affect the boot.  Depending on your loader configuration, you may also
have to set beastie_disable and/or reduce the number of modules loaded
to see the error on a small console screen.  12.0 or CURRENT users will
also have to explicitly use the Forth loader instead of the Lua loader.
The error will look something like:

Warning: syntax error on file /boot/loader.conf.local
foo="xxxxxxxxxxxxxxnextboot_enable="YES"
                                    ^
/boot/support.4th has crude file I/O buffering, which uses a buffer
'read_buffer', defined to be 80 bytes by the 'read_buffer_size'
constant.  The loader first tastes nextboot.conf, reading and parsing
the first line in it for nextboot_enable="YES".  If this is true, then
it reopens the file and parses it like other loader .conf files.

Unfortunately, the file I/O buffering code does not fully reset the
buffer state in the reset_line_reading word.  If the last file was read
to the end, that doesn't matter; the file buffer is treated as empty
anyway.  But in the nextboot.conf case, the loader will not read to the
end of file if it is over 80 bytes, and the file buffer may be reused
when reading the next file.  When the file is reread, the corrupt text
may cause file parsing to abort on bad syntax (if the corrupt line has
<>2 quotes in it), the wrong variable to be set, no variable to be set
at all, or (if the splice happens to land at a line ending) something
approximating normal operation.

The bug is very old, dating back to at least 2000 if not before, and is
still present in 12.0 and CURRENT r345863 (though it is now hidden by
the Lua loader by default).

Suggested one-line attached.  This does change the behavior of the
reset_line_reading word, which is exported in the line-reading
dictionary (though the export is not documented in loader man pages).
But repo history shows it was probably exported for the PNP support
code, which was never included in the loader build, and was removed 5
months ago.

One thing that puzzles me: how has this bug gone unnoticed/unfixed for
nearly 2 decades?  I find it hard to believe that nobody's tried to do
something interesting with nextboot, like load a kernel and filesystem,
which is what I'm doing.

PR: 239315
Reviewed by: imp

(cherry picked from commit 9c1c02093b90ae49745a174eb26ea85dd1990eec)

2 years agomips: Implement basic pmap_kenter_device, pmap_kremove_device
Conrad Meyer [Thu, 16 May 2019 19:10:48 +0000 (19:10 +0000)]
mips: Implement basic pmap_kenter_device, pmap_kremove_device

Unbreak mips.BERI_DE4_SDROOT build, which uses device xdma. Device xdma
depends on the pmap_kenter_device APIs.

Reported by: tinderbox (local)
Sponsored by: Dell EMC Isilon

(cherry picked from commit fa3ac573a2f712393cebd195bf7331cff3d1b8fe)

2 years agoAdd 'gpio' since mmc now requires gpio_if.h.
John Baldwin [Thu, 16 Apr 2020 20:45:54 +0000 (20:45 +0000)]
Add 'gpio' since mmc now requires gpio_if.h.

(cherry picked from commit fdbb2410cb08214939b0b1570cc375f231abf63e)

2 years agoarm: add device syscon to TEGRA124
Mateusz Guzik [Wed, 21 Jul 2021 12:08:32 +0000 (12:08 +0000)]
arm: add device syscon to TEGRA124

Unbreaks the build.

This is a direct commit.

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

2 years agoarm: hide pc_mpidr behind #if __ARM_ARCH >= 6
Mateusz Guzik [Wed, 21 Jul 2021 12:06:34 +0000 (12:06 +0000)]
arm: hide pc_mpidr behind #if __ARM_ARCH >= 6

This is a direct commit.

Unbreaks the build of:
DB-78XXX
DB-88F5XXX
DB-88F6XXX
RT1310
LINT-V5
TS7800

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

2 years agoarm: add atomic_store_rel_64
Mateusz Guzik [Wed, 21 Jul 2021 12:05:38 +0000 (12:05 +0000)]
arm: add atomic_store_rel_64

This unbreaks building linux compat in tinderbox.

This is a direct commit.

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