]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agonetpfil tests: IPv6 dummynet queue test
Kristof Provost [Thu, 2 Sep 2021 13:40:51 +0000 (15:40 +0200)]
netpfil tests: IPv6 dummynet queue test

Same as the v4 test, but with IPv6.

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

(cherry picked from commit 12184311c16160464a36ae05b1cd8c5e3c24fbaa)

2 years agonetpfil tests: dummynet queue test
Kristof Provost [Thu, 2 Sep 2021 13:38:04 +0000 (15:38 +0200)]
netpfil tests: dummynet queue test

Test prioritisation and dummynet queues.
We need to give the pipe sufficient bandwidth for dummynet to work.
Given that we can't rely on the TCP connection failing alltogether, but
we can measure the effect of dummynet by imposing a time limit on a
larger data transfer.

If TCP is prioritised it'll get most of the pipe bandwidth and easily
manage to transfer the data in 3 seconds or less. When not prioritised
this will not succeed.

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

(cherry picked from commit cb6bfef9ca78623e33d2aef347dcee112a639103)

2 years agodummynet tests: pipe test for IPv6
Kristof Provost [Mon, 14 Jun 2021 19:24:59 +0000 (21:24 +0200)]
dummynet tests: pipe test for IPv6

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

(cherry picked from commit 5fda5913e16afac72f3f420e227803e33d4c1542)

2 years agoipfw: Introduce dnctl
Kristof Provost [Tue, 25 May 2021 14:54:32 +0000 (16:54 +0200)]
ipfw: Introduce dnctl

Introduce a link to the ipfw command, dnctl, for dummynet configuration.
dnctl only handles dummynet configuration, and is part of the effort to
support dummynet in pf.

/sbin/ipfw continues to accept pipe, queue and sched commands, but these can
now also be issued via the new dnctl command.

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

(cherry picked from commit 0b95680e077b7ef5bc6930c7c0f1a41106251d5d)

2 years agopf: remove unused function prototype
Kristof Provost [Tue, 7 Sep 2021 12:33:59 +0000 (14:33 +0200)]
pf: remove unused function prototype

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

(cherry picked from commit bb25e36e133bd723d5c5bdecf9f73452d597e100)

2 years agosctp: Fix iterator synchronization in sctp_sendall()
Mark Johnston [Tue, 7 Sep 2021 13:44:57 +0000 (09:44 -0400)]
sctp: Fix iterator synchronization in sctp_sendall()

- The SCTP_PCB_FLAGS_SND_ITERATOR_UP check was racy, since two threads
  could observe that the flag is not set and then both set it.  I'm not
  sure if this is actually a problem in practice, i.e., maybe there's no
  problem having multiple sends for a single PCB in the iterator list?
- sctp_sendall() was modifying sctp_flags without the inp lock held.

The change simply acquires the PCB write lock before toggling the flag,
fixing both problems.

Reviewed by: tuexen
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 173a7a4ee4fa8fbce6b4532d4d324bc72ee25fe0)

2 years agosctp: Remove an unused sctp_inpcb field
Mark Johnston [Tue, 7 Sep 2021 13:44:48 +0000 (09:44 -0400)]
sctp: Remove an unused sctp_inpcb field

This appears to be unused in usrsctp as well.  No functional change
intended.

Reviewed by: tuexen
Sponsored by: The FreeBSD Foundation

(cherry picked from commit e8e23ec127d44e04c9be1cba381eaa3aa1041ea5)

2 years agosctp: Fix races around sctp_inpcb_free()
Mark Johnston [Tue, 7 Sep 2021 13:44:12 +0000 (09:44 -0400)]
sctp: Fix races around sctp_inpcb_free()

sctp_close() and sctp_abort() disassociate the PCB from its socket.
As a part of this, they attempt to free the PCB, which may end up
lingering.  Fix some bugs in this area:

- For some reason, sctp_close() and sctp_abort() set
  SCTP_PCB_FLAGS_SOCKET_GONE using an atomic compare-and-set without the
  PCB lock held.  This is racy since sctp_flags is normally updated
  without atomics, using the PCB lock to synchronize.  So, the update
  can be lost, which can cause all sort of races with other SCTP
  components which look for the _GONE flag.  Fix the problem simply by
  acquiring the PCB lock in order to set the flag.  Note that we have to
  drop and re-acquire the lock again in sctp_inpcb_free(), but I don't
  see a good way around that for now.  If it's a real problem, the _GONE
  flag could be split out of sctp_flags and into a dedicated sctp_inpcb
  field.
- In sctp_inpcb_free(), load sctp_socket after acquiring the PCB lock,
  to avoid possible races with parallel sctp_inpcb_free() calls.
- Add an assertion sctp_inpcb_free() to verify that _ALLGONE is not set.

Reviewed by: tuexen
Sponsored by: The FreeBSD Foundation

(cherry picked from commit c17b531bedd10c7ebea08919fd73ee708ff37336)

2 years agolibc: Use the initial-exec TLS model
Mark Johnston [Fri, 16 Jul 2021 02:35:28 +0000 (22:35 -0400)]
libc: Use the initial-exec TLS model

This permits more efficient accesses of thread-local variables, which
are heavily used at least by jemalloc and locale-aware code.  Note that
on amd64 and i386, jemalloc's thread-local variables already have their
TLS model overridden by defining JEMALLOC_TLS_MODEL.

For now the change is applied only to tested platforms, but should in
principle be enabled everywhere.

PR: 255840
Suggested by: jrtc27
Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 9c97062b620137a1f7cad4c6b3fb030a396b3266)

2 years agodtrace.1: Document a couple of preprocessor-related options
Mark Johnston [Tue, 7 Sep 2021 18:03:23 +0000 (14:03 -0400)]
dtrace.1: Document a couple of preprocessor-related options

Suggested by: swills
Sponsored by: The FreeBSD Foundation

(cherry picked from commit a40c4ae8667772d7e4c4c3d8d8ae843e63c05019)

2 years agokqueue.2: Document the fact that EVFILT_READ can be used on kqueues
Mark Johnston [Tue, 7 Sep 2021 15:17:33 +0000 (11:17 -0400)]
kqueue.2: Document the fact that EVFILT_READ can be used on kqueues

Reviewed by: bcr, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit f756c911681d7730ca34c23b69dbdb6143965858)

2 years agodtrace.1: Document -x ldpath
Mark Johnston [Tue, 7 Sep 2021 15:18:28 +0000 (11:18 -0400)]
dtrace.1: Document -x ldpath

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 13d9437a6074b02770546d1ec329b306e1a0f30e)

2 years agog_label: Handle small sector sizes when tasting
Mark Johnston [Tue, 7 Sep 2021 13:46:58 +0000 (09:46 -0400)]
g_label: Handle small sector sizes when tasting

Make sure that the provider sector size is large enough to contain a
valid label before trying to read it.  We performed this check already
for most label types, but not for several filesystem labels.

Reported by: syzbot+f52918174cdf193ae29c@syzkaller.appspotmail.com
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 5402baa5b5d14819101e1e847df66b02cedf1639)

2 years agoixgbe: increase the timeout
Qiming Yang [Wed, 10 Jan 2018 16:04:33 +0000 (00:04 +0800)]
ixgbe: increase the timeout

Increase SECRX_RDY polling frequency and semaphore timeout which
fixes the FWSW.PT check in ixgbe_mng_present().

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
Approved by: imp
Obtained from: DPDK (6175260d12cc22852cecf2fb7ecd95cdb07611b5)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit 5fd1f4be8d81a0019c632103121d68e2f20bc238)

2 years agoixgbe: cleanup spelling mistakes in comments
Guinan Sun [Thu, 9 Jul 2020 08:00:33 +0000 (08:00 +0000)]
ixgbe: cleanup spelling mistakes in comments

Several functions in the driver code have a weird function comment
formatting which uses two spaces instead of only one space for the main
function body.

This formatting will be mechanically fixed by sed in a future patch, but
doing so leads to some spelling warnings on that patch. Cleanup the
spelling mistakes that will be detected first. This way, it is easier to
verify the mechanical transformation done by sed in the following patch.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (fc75eee32037c1379e77e57031c1c353badd2272)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit 46981e903cf3e8e4a5bf7f6152f8ca5b92b37e07)

2 years agoixgbe: remove unnecessary return value check
Guinan Sun [Thu, 9 Jul 2020 08:00:38 +0000 (08:00 +0000)]
ixgbe: remove unnecessary return value check

Remove unnecessary return value check.

Signed-off-by: Jakub Chylkowski <jakubx.chylkowski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (4b0ee6529b7897c2a08dd56669f07ac1f46a8474)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit 3a89005394bc5d82ce9b6baa9e7f8dee362354ae)

2 years agoixgbe: create function to restart autoneg
Guinan Sun [Thu, 9 Jul 2020 08:00:36 +0000 (08:00 +0000)]
ixgbe: create function to restart autoneg

This patch is for restarting auto negotiation on PHY.

Signed-off-by: Jakub Chylkowski <jakubx.chylkowski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (664ea2614eafbec8eda5c86764ff047475a1e5c6)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit 80a39a2bda8208c716f614f792c8d9a3628d6c26)

2 years agoixgbe: add register definitions for NVM update
Guinan Sun [Thu, 9 Jul 2020 08:00:32 +0000 (08:00 +0000)]
ixgbe: add register definitions for NVM update

Added additional register for X550 and above device family.

Signed-off-by: Piotr Skajewski <piotrx.skajewski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (4a6847d78814b1c3df896efe31562643d419317d)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit ff8db817abbd348f0a7518ce32f0e52c6ab8e06e)

2 years agoixgbe: move increments after evaluations
Guinan Sun [Thu, 9 Jul 2020 08:00:35 +0000 (08:00 +0000)]
ixgbe: move increments after evaluations

The retry variable was being incremented before it was evaluated by the
subsequent conditional against the maximum retries to figure out which
message to print.  So we'll move the increment op to the end.

Signed-off-by: Jeb Cramer <jeb.j.cramer@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (390445ec30b4c52a3d2887c3d2a202d9cf37ea8e)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit dc11ba4eb3fe5cce615f361de83e85e07005ca24)

2 years agoixgbe: remove whitespace in function comments
Kevin Bowling [Tue, 7 Sep 2021 03:26:44 +0000 (20:26 -0700)]
ixgbe: remove whitespace in function comments

Remove unnecessary extra whitespace on all function comments, replacing
' *  ' with ' * '.

This was done automatically via sed using the following transformation:

  sed 's/^ \*  / * /'

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (40023f73c76579e58a859dab87b4c30278eb2e48)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit 4cdc5e12a849871e4e8062a62a31f28545901d84)

2 years agoixgbe: support DCB registers dump
Xiaoyun Li [Mon, 17 Sep 2018 09:28:13 +0000 (17:28 +0800)]
ixgbe: support DCB registers dump

Add support for DCB registers dump.

Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Approved by: imp
Obtained from: DPDK (36a036bc6fdd0da74576a39ab74e50954598ba82)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit 9e65ae746da23e1affdf66adb8944656a9da003c)

2 years agoixgbe: update X550 SFP identification
Xiaoyun Li [Mon, 17 Sep 2018 09:28:12 +0000 (17:28 +0800)]
ixgbe: update X550 SFP identification

Use ixgbe_identify_sfp_module_X550em to update SFP identification
flow. ixgbe_identify_sfp_module_X550em includes specific checks for
X550 about supported SFP modules.

Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Approved by: imp
Obtained from: DPDK (175bedb0cc8f801be3050fa35b8d8d0971cea7cc)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit 0a4f0befab9d3a048232b00bea77bf3da20cfdd0)

2 years agoixgbe: Update copyright to 2020
Kevin Bowling [Tue, 7 Sep 2021 03:11:44 +0000 (20:11 -0700)]
ixgbe: Update copyright to 2020

Synced to the ixgbe shared code with DPDK shared code which has local
fixes on top of "not-released-cid-ixgbe.2020.06.09.tar.gz"

Approved by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit 8455e365f77f5b66ac9521dbcd690f79345ce147)

2 years agoixgbe: remove dead code
Ferruh Yigit [Tue, 30 Jun 2020 14:45:54 +0000 (15:45 +0100)]
ixgbe: remove dead code

The question around getting rid of the assignments seems lived
long enough, if they are not needed until now, we can drop them.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Approved by: imp
Obtained from: DPDK (a6395d471e14e5a7432875dad8fb3533238c5167)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit 0b487fb4547ad1a939be0d523e555557c94b7cd1)

2 years agoixgbe: replace an operation in X550 setup
Xiaoyun Li [Mon, 17 Sep 2018 09:28:11 +0000 (17:28 +0800)]
ixgbe: replace an operation in X550 setup

Replace "=" operation with "|=" operation to only set the intended
register bits.

Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Approved by: imp
Obtained from: DPDK (1b665ccd9cd73499e934b807bec2fd77193912ef)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit c85b6f2901e7804105ca1d6d41cc5eb9a60474b8)

2 years agoixgbe: Use C99 bool types
Kevin Bowling [Tue, 7 Sep 2021 02:54:22 +0000 (19:54 -0700)]
ixgbe: Use C99 bool types

Approved by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit 79b36ec91decc18d062fc428e2fd34d41aba0630)

2 years agoixgbe: add FW recovery mode check
Xiaoyun Li [Mon, 17 Sep 2018 09:28:10 +0000 (17:28 +0800)]
ixgbe: add FW recovery mode check

Add FM NVM recovery mode check. Allow the software to detect this.

Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Approved by: imp
Obtained from: DPDK (5fb0a9acbb844b21691568c0014866e0e887bd19)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit b622bdb4ebdfc6dfe1a332fcc912426559c829f3)

2 years agoixgbe: add typecast for type mismatch
Guinan Sun [Thu, 9 Jul 2020 08:00:37 +0000 (08:00 +0000)]
ixgbe: add typecast for type mismatch

Add typecast for type mismatch.

Signed-off-by: Jakub Chylkowski <jakubx.chylkowski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (d8e52b2cf771c31b523b46852fd86225b5a2c721)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit 994dd6328c66fc277438ad51ed074f3c52096147)

2 years agoixgbe: wait for link after copper MAC setup
Ashijeet Acharya [Fri, 24 May 2019 09:30:15 +0000 (11:30 +0200)]
ixgbe: wait for link after copper MAC setup

After setting up the link on x552/X557-AT 10GBASE-T NICs, sometimes the
link does not get set up properly and as a result all the subsequent
calls to ixgbe_check_link() from ixgbe_dev_link_update_share() fail.

Introduce a delay time of 1s in ixgbe_setup_mac_link_t_X550em() before
beginning to set up the external PHY link speed to ensure that the
controller can acquire the link.

Signed-off-by: Ashijeet Acharya <ashijeet.acharya@6wind.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Approved by: imp
Obtained from: DPDK (d31b95860d8e9dd7c6e242bd08baaac00a9714f0)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit d5bbb5500cf2ebeae078cb6ae38ecd4b15ec7f6d)

2 years agoixgbe: check host interface return status
Guinan Sun [Thu, 9 Jul 2020 08:00:44 +0000 (08:00 +0000)]
ixgbe: check host interface return status

Writing to read-only fields returns a non-OK Return Status
for shadow RAM write command for X550.
This information was previously discarded.

Signed-off-by: Stanislaw Grzeszczak <stanislaw.a.grzeszczak@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (db18e37090a3b9af47d6a6886248520f6b220bf9)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit c1a56b6f5ffd6f3180a654d058c1783ccb808e8b)

2 years agoixgbe: initialize data field in struct buffer
Guinan Sun [Thu, 9 Jul 2020 08:00:40 +0000 (08:00 +0000)]
ixgbe: initialize data field in struct buffer

While sending request using ixgbe_hic_unlocked() the data field in
buffer struct is not used. It is set when the struct is overwritten by
FW to deliver the response. To not pass random data to FW the whole
structure should be zeroed before use.

Signed-off-by: Krzysztof Galazka <krzysztof.galazka@intel.com>
Signed-off-by: Piotr Pietruszewski <piotr.pietruszewski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (40543be5376ca415b2a7e196315d0555725b8bdf)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit b3ebe337ffa06b0f1f460bf8f1e42fb55db77d0b)

2 years agoixgbe: fix x550em 10G NIC link status
Guinan Sun [Thu, 9 Jul 2020 08:00:30 +0000 (08:00 +0000)]
ixgbe: fix x550em 10G NIC link status

With the NVM image for x550em XFI will not report
the auto-negotiation feature correctly. The auto-negotiation
should be "No" for supports and advertised items.
At the same time update speed makes it support 1G and 10G.

Signed-off-by: Piotr Skajewski <piotrx.skajewski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (fb03b51da940f1d56d701776fd85a0dfc1ace098)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit 8e9f1b239dc00a2375af87c48321f85a1e37c14e)

2 years agoixgbe: fix maximum wait time in comment
Xiaolong Ye [Thu, 15 Nov 2018 07:20:05 +0000 (15:20 +0800)]
ixgbe: fix maximum wait time in comment

As the code has changed the max wait time to 1000ms, the comment should
be changed accordingly.

Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Approved by: imp
Obtained from: DPDK (73247f1ced303c16987bb366d38a2d8a0fc40db4)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit 96ef6eb3ae9d622906fb838c82ede3074f864cdc)

2 years agoixgbe: wait longer for link after fiber MAC setup
Matthew Smith [Mon, 16 Jul 2018 16:36:04 +0000 (11:36 -0500)]
ixgbe: wait longer for link after fiber MAC setup

After setting up the link on a fiber port, the maximum wait time for
the link to come up is 500 ms in ixgbe_setup_mac_link_multispeed_fiber().
On an x550 SFP+ port, this is often not sufficiently long for the link
to come up. This can result in never being able to retrieve accurate
link status for the port using rte_eth_link_get_nowait().

Increase the maximum wait time in ixgbe_setup_mac_link_multispeed_fiber()
to 1 s.

Signed-off-by: Matthew Smith <mgsmith@netgate.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Approved by: imp
Obtained from: DPDK (64f1c8539c8ce99214b9eb1fb728a2c6745f3300)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit aaa3af802f90d93fdffb99100fe56f0bc3dda119)

2 years agoixgbe: fix host interface shadow RAM read
Guinan Sun [Thu, 9 Jul 2020 08:00:28 +0000 (08:00 +0000)]
ixgbe: fix host interface shadow RAM read

Host interface Shadow RAM Read (0x31) command response
buffer length should be stored in two bytes, instead of one byte.
This patch fixes it.

Signed-off-by: Mateusz Kowalski <mateusz.kowalski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (713fc4dd340e5eadd3bfa9a468446afaa5188624)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit 31a23e3eb5314a6b5929e980a0810803adfaad1f)

2 years agoixgbe: fix response to apply-update command
Guinan Sun [Thu, 9 Jul 2020 08:00:29 +0000 (08:00 +0000)]
ixgbe: fix response to apply-update command

For the "Apply Update" command the firmware does not
given an response. For this command, success should
be return.

Signed-off-by: Mateusz Kowalski <mateusz.kowalski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (03b09c71c0c6c516ce05cad8e8aa75e8b9e14fba)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit c966c431c764c493fafbe65b717243a3c0b291be)

2 years agoixgbe: improve log about autoneg being disabled
Guinan Sun [Thu, 9 Jul 2020 08:00:41 +0000 (08:00 +0000)]
ixgbe: improve log about autoneg being disabled

On ESXi OS, when user disables auto negotiation, the following log
appears: "(unsupported) Flow control autoneg is disabled".
It is true that auto negotiation is disabled but it is
not necessarily true that it is not supported.

Signed-off-by: Jakub Chylkowski <jakubx.chylkowski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (ab6ac48d483ef7f906b90f45182f2ddf3254d876)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit f511cd22586a9c0358b86334a51e3db60ca2db01)

2 years agoixgbe: add IPv6 mask for flow director
Guinan Sun [Thu, 9 Jul 2020 08:00:42 +0000 (08:00 +0000)]
ixgbe: add IPv6 mask for flow director

Write FDIRIP6M register to allow flow director filter
to set ipv6 rules without setting ipv6 source/destination address.

Signed-off-by: Piotr Skajewski <piotrx.skajewski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (21feefa2fcd5899ee26a10be405c17c0a1109860)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit c4f73d5d6a6c0117e08a03920cce69202865ba13)

2 years agoixgbe: fix infinite recursion on PCIe link down
Guinan Sun [Thu, 9 Jul 2020 08:00:31 +0000 (08:00 +0000)]
ixgbe: fix infinite recursion on PCIe link down

In some corner cases the functions ixgbe_clear_rar_generic and
ixgbe_clear_vmdq_generic may call one another leading to infinite
recursion.

When ixgbe_clear_vmdq_generic is called with IXGBE_CLEAR_VMDQ_ALL
flag, it's going to clear MPSAR registers, and proceed to call
ixgbe_clear_rar_generic, which in turn will clear the RAR registers,
and recursively call back ixgbe_clear_vmdq_generic. Normally, the
latter would detect that MPSAR registers have already been cleared
and terminate the recursion.

However, when PCIe link is down, and before the driver has had the
opportunity to shut itself down, all register reads return 0xFFFFFFFF,
and all register writes fail silently. In such case, because
ixgbe_clear_vmdq_generic blindly assumes that clearing MPSAR registers
succeeded, it's going to always call ixgbe_clear_rar_generic, which
in turn will always call back ixgbe_clear_vmdq_generic, creating
infinite recursion.

This patch re-reads MPSAR register values after they had been cleared.
In case of PCIe link failure, the values read will be non-zero, which
will terminate the recursion. On the other hand, under normal
circumstances the value read from MPSAR registers is going to be equal
to the value previously written, so this patch is expected not to cause
any regressions.

Signed-off-by: Robert Konklewski <robertx.konklewski@intel.com>
Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
Reviewed-by: Wei Zhao <wei.zhao1@intel.com>
Approved by: imp
Obtained from: DPDK (2d04b9e856125197ec8e967471426d56ab7efcf0)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit 8270b7174c48417a4d5f3effa4a4f4588205e687)

2 years agoixgbe: clear all queues on VF reset
Simon Ellmann [Thu, 17 Dec 2020 17:14:52 +0000 (18:14 +0100)]
ixgbe: clear all queues on VF reset

ixgbe devices support up to 8 Rx and Tx queues per virtual function.
Currently, the registers of only seven queues are set to default when
resetting a VF.

Signed-off-by: Simon Ellmann <simon.ellmann@tum.de>
Acked-by: Haiyue Wang <haiyue.wang@intel.com>
Approved by: imp
Obtained from: DPDK (d2565b347915def3a0f3c68bde6824acf096a0e6)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31621

(cherry picked from commit 7165504a17682dc8c96d44c65319bf73c89f7f10)

2 years agoapr: Merge r1889604, r1807975 from trunk:
Joe Orton [Fri, 2 Jul 2021 11:10:33 +0000 (11:10 +0000)]
apr: Merge r1889604, r1807975 from trunk:

* random/unix/sha2.c (apr__SHA256_Final, apr__SHA256_End): Fix parameter
  buffer lengths to match declaration, avoiding GCC 11 warning.
  (no functional change)

Bounds-check human-readable date fields (credit: Stefan Sperling)

Submitted by: jorton, niq
Reviewed by: jorton

git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1891198 13f79535-47bb-0310-9956-ffa450edef68

2 years agolinux: make sure to zero the l_siginfo structure for ptrace(2)
Edward Tomasz Napierala [Tue, 8 Jun 2021 09:18:29 +0000 (10:18 +0100)]
linux: make sure to zero the l_siginfo structure for ptrace(2)

Reported By: dchagin
Sponsored By: EPSRC

(cherry picked from commit f102b61d0ecffc6d9cc322fa7a48e0927391421b)

2 years agonetinet: prevent NULL pointer dereference in in_aifaddr_ioctl()
Artem Khramov [Tue, 24 Aug 2021 14:26:35 +0000 (17:26 +0300)]
netinet: prevent NULL pointer dereference in in_aifaddr_ioctl()

It appears that maliciously crafted ifaliasreq can lead to NULL
pointer dereference in in_aifaddr_ioctl(). In order to replicate
that, one needs to

1. Ensure that carp(4) is not loaded

2. Issue SIOCAIFADDR call setting ifra_vhid field of the request
   to a negative value.

A repro code would look like this.

int main() {
    struct ifaliasreq req;
    struct sockaddr_in sin, mask;
    int fd, error;

    bzero(&sin, sizeof(struct sockaddr_in));
    bzero(&mask, sizeof(struct sockaddr_in));

    sin.sin_len = sizeof(struct sockaddr_in);
    sin.sin_family = AF_INET;
    sin.sin_addr.s_addr = inet_addr("192.168.88.2");

    mask.sin_len = sizeof(struct sockaddr_in);
    mask.sin_family = AF_INET;
    mask.sin_addr.s_addr = inet_addr("255.255.255.0");

    fd = socket(AF_INET, SOCK_DGRAM, 0);
    if (fd < 0)
        return (-1);

    memset(&req, 0, sizeof(struct ifaliasreq));
    strlcpy(req.ifra_name, "lo0", sizeof(req.ifra_name));
    memcpy(&req.ifra_addr, &sin, sin.sin_len);
    memcpy(&req.ifra_mask, &mask, mask.sin_len);
    req.ifra_vhid = -1;

    return ioctl(fd, SIOCAIFADDR, (char *)&req);
}

To fix, discard both positive and negative vhid values in
in_aifaddr_ioctl, if carp(4) is not loaded. This prevents NULL pointer
dereference and kernel panic.

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

(cherry picked from commit 620cf65c2bc4035a07e1152da419a4e60d36ff9b)

2 years agotop(1): indicate how to reset grep string
John Grafton [Tue, 7 Sep 2021 17:39:59 +0000 (13:39 -0400)]
top(1): indicate how to reset grep string

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

(cherry picked from commit 4ccbbe5f0689513de4399d6dad43e85d97ad9cde)

2 years agotop(1): support command name and argument grepping
John Grafton [Wed, 16 Jun 2021 19:40:21 +0000 (15:40 -0400)]
top(1): support command name and argument grepping

Obtained from:  OpenBSD
Reviewed by: imp@
Pull Request: https://github.com/freebsd/freebsd-src/pull/479

(cherry picked from commit a00d703f2f438b199d3933d19d535540586b7792)

2 years agoMissed line from 7af4475a6e31.
Alexander Motin [Fri, 3 Sep 2021 02:25:16 +0000 (22:25 -0400)]
Missed line from 7af4475a6e31.

MFC after: 2 weeks

(cherry picked from commit 5d9e5a7edfb5a2256be1c6433aaef32433cdd14e)

2 years agovmd(4): Major driver refactoring
Alexander Motin [Fri, 3 Sep 2021 00:58:02 +0000 (20:58 -0400)]
vmd(4): Major driver refactoring

 - Re-implement pcib interface to use standard pci bus driver on top of
vmd(4) instead of custom one.
 - Re-implement memory/bus resource allocation to properly handle even
complicated configurations.
 - Re-implement interrupt handling to evenly distribute children's MSI/
MSI-X interrupts between available vmd(4) MSI-X vectors and setup them
to be handled by standard OS mechanisms with minimal overhead, except
sharing when unavoidable.

Successfully tested on Dell XPS 13 laptop with Core i7-1185G7 CPU (VMD
device ID 0x9a0b) and single NVMe SSD, dual-booting with Windows 10.

Successfully tested on Supermicro X11DPI-NT motherboard with Xeon(R)
Gold 6242R CPUs (VMD device ID 0x201d), simultaneously handling NVMe
SSD on one PCIe port and PLX bridge with 3 NVMe and 1 AHCI SSDs on
another.  Handles SSD hot-plug (except Optane 905p for some reason,
which are not detected until manual bus rescan) and enabled IOMMU
(directly connected SSDs work, but ones connected to the PLX fail
without errors from IOMMU).

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.
Differential revision: https://reviews.freebsd.org/D31762

(cherry picked from commit 7af4475a6e31202a865b1dd3727018659b44470f)

2 years agovmd_bus: Fix typo in comment
Neel Chauhan [Sat, 17 Jul 2021 21:31:57 +0000 (14:31 -0700)]
vmd_bus: Fix typo in comment

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

(cherry picked from commit 76fffd0a865374e1e09d8f61f36bfbda918da5c7)

2 years agovmd: Rename vmd_bus class to pci
Neel Chauhan [Fri, 16 Jul 2021 02:03:05 +0000 (19:03 -0700)]
vmd: Rename vmd_bus class to pci

This fixes a kernel panic when probing for vmd_bus on Intel TigerLake on
14-CURRENT. Apparently, vmd_bus is a type of PCI bus, but was registered
as a separate device class.

PR: 256915
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D31071

(cherry picked from commit ad1f608fb2f529baf028384bbe7e8fbbff5cbe23)

2 years agostand: Add MK_PIE=no to defs.mk
Warner Losh [Wed, 11 Aug 2021 16:59:28 +0000 (10:59 -0600)]
stand: Add MK_PIE=no to defs.mk

There's no need to build both pie and non-pie .o's for stand. There's
some other build thing with MK_BEAR_SSL=yes and/or MK_LOADER_VERIEXEC=yes
that causes the pie build to fail that the 'ar' stage now. Since we don't
need the PIE stuff and the non-PIE stuff, disable PIE for the boot loader.

Reviewed by: emaste
Sponsored by: Netflix

(cherry picked from commit 879675e9a0d84880cad9834e2ef98e8724c5532c)

2 years agortsx: Fix wakeup race similar to sdhci one fixed in 35547df5c786
Warner Losh [Tue, 10 Aug 2021 23:07:50 +0000 (17:07 -0600)]
rtsx: Fix wakeup race similar to sdhci one fixed in 35547df5c786

rtsx copied code from sdhci, and has the same wakeup race bug that was
fixed in 35547df5c786, so apply a similar fix here.

Sponsored by: Netflix

(cherry picked from commit 9339e7c0bd565506092bb0a2618ff32fb04bb2c4)

2 years agomk: WITH_FOO=no now generates a warning
Warner Losh [Thu, 10 Jun 2021 00:10:12 +0000 (18:10 -0600)]
mk: WITH_FOO=no now generates a warning

Many people are used to gnu configure's behavior of changing
--with-foo=no to --without-foo. At the same time, several folks have
WITH_FOO=no in their config files to enable this ironic form of the
option because of an old meme from IRC, a mailing list or the forums (I
forget which). Add a warning to allow to alert people w/o breaking POLA.

Reviewed by: allanjude, bdrewery, manu
MFC After: 2 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D30684

(cherry picked from commit f4d987cd137cb2d0d54a3e35d9258ca7c175d291)

2 years agoclock_gettime: Add Linux aliases for CLOCK_*
Warner Losh [Fri, 30 Jul 2021 23:11:43 +0000 (17:11 -0600)]
clock_gettime: Add Linux aliases for CLOCK_*

Linux standardized what we call CLOCK_{REALTIME,MONOTONIC}_FAST as
CLOCK_{REALTIME,MONOTONIC}_COARSE. In addition, Linux spells
CLOCK_UPTIME as CLOCK_BOOTTIME.

Add aliases to time.h and document these new aliases in
clock_gettime(2).

Reviewed by: vangyzen, kib (prior), dchagin (prior)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D30988

(cherry picked from commit 155f15118a77d2aeab7b177ada78c848778d7d80)

2 years agotime.h: reduce CLOCK_ namespace pollution, move to _clock_id.h
Warner Losh [Fri, 30 Jul 2021 23:10:56 +0000 (17:10 -0600)]
time.h: reduce CLOCK_ namespace pollution, move to _clock_id.h

Attempt to comply with the strict namespace pollution requirements of
_POSIX_C_SOURCE. Add guards to limit visitbility of CLOCK_ and TIMER_
defines as appropriate. Only define the CLOCK_ variables relevant to the
specific standards. Move all the sharing to sys/_clock_id.h and make
time.h and sys/time.h both include that rather than copy due to the
now large number of clocks and compat defines.

Please note: The old time.h previously used these newer dates:
CLOCK_REALTIME 199506
CLOCK_MONOTONIC 200112
CLOCK_THREAD_CPUTIME_ID 200112
CLOCK_PROCESS_CPUTIME_ID 200112

but glibc defines all of these for 199309. glibc uses this date for all
these values, however, only CLOCK_REALTIME was in IEEE 1003.1b. Add a
comment about this to document it. A large number of programs and
libraries assume that these will be defined for _POSIX_C_SOURCE =
199309.

In addition, leak CLOCK_UPTIME_FAST for the pocl package until it can be
updated to use a simple CLOCK_MONOTONIC.

Reviewed by: kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31056

(cherry picked from commit 7b797ba27a714594dac910035d857e653d566b19)

2 years agonanobsd: adopt dhcpd to latest conventions
Warner Losh [Fri, 30 Jul 2021 22:55:43 +0000 (16:55 -0600)]
nanobsd: adopt dhcpd to latest conventions

Adopt the dhcpd build to use nanobsd-build top level directory that
other nanobsd builds are using.

Sponsored by: Netflix

(cherry picked from commit 9ed1e98abfe470a958a55b4fc6d6391ca8e4478d)

2 years agocli.lua.8: make the command match the code
Warner Losh [Thu, 29 Jul 2021 02:53:18 +0000 (20:53 -0600)]
cli.lua.8: make the command match the code

It's disable-device, not device-disable

Spotted by: jrtc27
Sponsored by: Netflix

(cherry picked from commit 6b51baf6a8de7241a4e1b0c8436d70299cd55270)

2 years agolua loader: Add disable-device to disable a device.
Warner Losh [Wed, 28 Jul 2021 22:52:38 +0000 (16:52 -0600)]
lua loader: Add disable-device to disable a device.

disable-device fooX will set hint.foo.X.disabled=1 as a way to easily
disable a device attaching during boot.

Reviewed by: tsoome
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31297

(cherry picked from commit 07c4b78d0a1d26b6441cf3e52b917f20c932b9d0)

2 years agoloader: support.4th resets the read buffer incorrectly
John Hood [Wed, 28 Jul 2021 19:43:02 +0000 (13:43 -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.

Tested by: Gary Jennejohn
PR: 239315
MFC After: 3 weeks
Reviewed by: imp (and correctly applied this time)
Differential Revision: https://reviews.freebsd.org/D31328

(cherry picked from commit dbdf2b52f59df7374eb1f799b4df1b54e4502e40)

2 years agogenoffset: simplify and rewrite in sh
Warner Losh [Wed, 28 Jul 2021 19:47:05 +0000 (13:47 -0600)]
genoffset: simplify and rewrite in sh

genoffset used the fully generic ASSYM macro to generate the offsets
needed for the thread_lite structure. However, since these are offsets
into a structure, they will always be necessarily small and positive. As
such, just create a simple character array of the right size and use a
naming convention such that we can recover the field name, structure
name and type. Use nm -t d and sort -n to sort these into order, then
loop over the resutls to generate the thread_lite structure.

MFC After: 2 weeks
Reviewed by: kib, markj (earlier versions)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31203

(cherry picked from commit 824897a3aea5ca22db8cb7d5b404697a1de1210a)

2 years agogenassym.sh: Fix two minor issues found by shellcheck
Warner Losh [Wed, 28 Jul 2021 19:42:29 +0000 (13:42 -0600)]
genassym.sh: Fix two minor issues found by shellcheck

o Remove redunant $ in $(( )) expression.
o Quote arg passed to work so paths with spaces, etc will work.

MFC After: 2 weeks
Reviewed by: kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31335

(cherry picked from commit 46dd3ef0338ba2ad24d05bab2a614410cf17b017)

2 years agodevctl: don't publish the mount options
Warner Losh [Sat, 24 Jul 2021 15:03:53 +0000 (09:03 -0600)]
devctl: don't publish the mount options

Mount options aren't solely ASCII strings. In addition, experience to
date suggests that the mount options are much less useful than was
originally supposed and the mount flags suffice to make decisions. Drop
the reporting of options for the mount/remount/unmount events.

Reviewed by: markj
Reported by: KASAN
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31287

(cherry picked from commit 6475667f7b72f5eb8fcd045967c251e45e38e2a2)

2 years agogeom_disk: use a preallocated geom_event for disk destruction.
Warner Losh [Fri, 23 Jul 2021 21:21:02 +0000 (15:21 -0600)]
geom_disk: use a preallocated geom_event for disk destruction.

Preallocate a geom_event (using the new geom_alloc_event) when we create
a disk. When we create the disk, we're going to be in a sleepable
context, so we can always allocate this extra bit of memory. Then use
this preallocated memory to free the disk. CAM can try to free the disk
from an unsleepable context if there was I/O outstanding when the disk
was destroyted (say because the SIM said it had gone away). The I/O
context isn't sleepable. Rather than trying to invent a retry mechanism
and making sure all the other geom_disk consumers did it properly,
preallocating the event ensure that the geom_disk will be properly torn
down, even when there's memory pressure when the disk departs.

Reviewd by: jhb
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D30544

(cherry picked from commit 47aeda7b70555049eccd7f020365aec031f41c62)

2 years agogeom: create an API to allocate events, and use that storage to send them
Warner Losh [Fri, 23 Jul 2021 21:16:57 +0000 (15:16 -0600)]
geom: create an API to allocate events, and use that storage to send them

g_alloc_event will allocate storage for an opaque event. g_post_event_ep
can use memory returned by g_alloc_event to send an event from a context
that might not be able to allocate the event. Occasionally, we can
alloate memory when we create an object, but not while we're destroy
it. This allows one to allocate at creation time memory to use when
destorying the object.

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

(cherry picked from commit 380710a5c8c1fd638ec961351b75b667e91667c9)

2 years agokqueue: drain kqueue taskqueue if syscall tickled it
Konstantin Belousov [Mon, 6 Sep 2021 11:43:06 +0000 (14:43 +0300)]
kqueue: drain kqueue taskqueue if syscall tickled it

PR: 258310

(cherry picked from commit 98168a6e6c12dab8f608f6b5f5b0b175d2b87ef0)

2 years agolualoader: use more concise verbiage for autoboot
Kyle Evans [Wed, 8 Sep 2021 21:34:33 +0000 (16:34 -0500)]
lualoader: use more concise verbiage for autoboot

The behavior remains the same, but lualoader now uses the more concise
verbiage that forthloader used.  This is particularly important because
the previous line would exceed the right boundary of the menu and run
straight into space that would typically be allowed for the logo.

This makes it slightly easier to port logos from forthloader to
lualoader.

(cherry picked from commit ed107537b43cabf7a18e73a17856a9d9e170c6e9)

2 years agolualoader: allow brands to specify a shift
Kyle Evans [Wed, 8 Sep 2021 21:33:28 +0000 (16:33 -0500)]
lualoader: allow brands to specify a shift

Some brands will want to specify a shift to make sure they're properly
centered; let it happen.

(cherry picked from commit e19d9a9b6e44e15087a140a26ab3e24b07f6ba56)

2 years agolualoader: remove shadowed local from graphics:drawitem()
Kyle Evans [Wed, 8 Sep 2021 21:32:53 +0000 (16:32 -0500)]
lualoader: remove shadowed local from graphics:drawitem()

for loop vars are local already and distinct from this earlier
declaration; remove it.

(cherry picked from commit 763bcebe0b6d5e53e5c8940a677de662e5652b6d)

2 years agoAdd support for recording EC2 AMI Ids in SSM
Colin Percival [Fri, 27 Aug 2021 00:54:53 +0000 (17:54 -0700)]
Add support for recording EC2 AMI Ids in SSM

If SSMPREFIX is specified, AMI Ids will be recorded in the SSM
Parameter Store under the name
  ${SSMPREFIX}/${ARCH}/${FLAVOUR}/${ROOTFS}/${REVISION}/${BRANCH}
where ARCH is "amd64" or "arm64", FLAVOUR is "base" (but may have
other options in the future), ROOTFS is "ufs" (but may have other
options in the future), and REVISION and BRANCH have their normal
meanings.

FreeBSD will be using the public prefix "/aws/service/freebsd",
resulting in SSM Parameter names which look like
  /aws/service/freebsd/amd64/base/ufs/14.0/CURRENT

Relnotes: yes
Sponsored by: https://patreon.com/cperciva
MFC after: 2 weeks

(cherry picked from commit c5af0ac1a732491aab789dda0da368ff48497871)

2 years agoEC2: Tell gptboot to skip its 3 second wait
Colin Percival [Mon, 21 Jun 2021 22:35:16 +0000 (15:35 -0700)]
EC2: Tell gptboot to skip its 3 second wait

Nobody is going to hit a key to tell gptboot to select another disk,
so there's no point waiting.

(cherry picked from commit 524260db7683681c7deec9f1968c15a717317685)

2 years agopf: ensure states passed to pf_free_state() are always unlinked
Kristof Provost [Fri, 3 Sep 2021 07:36:19 +0000 (09:36 +0200)]
pf: ensure states passed to pf_free_state() are always unlinked

In pf_create_state() we can end up deleting the state immediately. This
can happen if we fail to map the relevant addresses or fail
normalization or fail to insert it into the state table.
If that happens we delete the state again with pf_free_state(). However,
this asserts that the state must be unlinked.

It's correct to simply set the state to PFTM_UNLINKED because we've not
yet linked it.

Submitted by: Mateusz Guzik <mjg@FreeBSD.org>
Reviewed by: scottl
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31752

(cherry picked from commit a0c64a443e4cae67a5eea3a61a47d746866de3ee)

2 years agodtrace: fix ipfw_rule_info_t translator
Andrey V. Elsukov [Thu, 2 Sep 2021 13:35:01 +0000 (16:35 +0300)]
dtrace: fix ipfw_rule_info_t translator

322e5efda8578b has changed field names in the struct ip_fw.
Use correct names in ipfw_rule_info_t translator in the ipfw.d script.

Reported by: Keith White <kwhite uottawa at gmail>

(cherry picked from commit 5c8e8e82aeaf3aa788acdd6cfca30ef09094230d)

2 years agolibarchive: import bugfix from upstream
Martin Matuska [Fri, 27 Aug 2021 10:51:01 +0000 (12:51 +0200)]
libarchive: import bugfix from upstream

Reworked bugfix for upstream issue #1566:
  Do not follow symlinks when processing the fixup list

(cherry picked from commit c577bdfce6b4451ab897bfe5013543e78a7f9b62)

2 years agolibarchive: import changes from upstream
Martin Matuska [Mon, 23 Aug 2021 00:54:15 +0000 (02:54 +0200)]
libarchive: import changes from upstream

Libarchive 3.5.2

New features:
  PR #1502: Support for PWB and v7 binary cpio formats
  PR #1509: Support of deflate algorithm in symbolic link decompression
            for ZIP archives

Important bugfixes:
  IS #1044: fix extraction of hardlinks to symlinks
  PR #1480: Fix truncation of size values during 7zip archive
            extraction on 32bit architectures
  PR #1504: fix rar header skiming
  PR #1514: ZIP excessive disk read - fix location of central directory
  PR #1520: fix double-free in CAB reader
  PR #1521: Fixed leak of rar before ending with error
  PR #1530: Handle short writes from archive_write_callback
  PR #1532: 7zip: Use compression settings from file also for file header
  IS #1566: do not follow symlinks when processing the fixup list

Relnotes: yes

(cherry picked from commit ddce862ad8594542e1fa1af9ffae7264e12ffd27)

2 years agoloader.efi: fix console output after BS off
Toomas Soome [Thu, 2 Sep 2021 21:17:32 +0000 (00:17 +0300)]
loader.efi: fix console output after BS off

When Boot Services (BS) are switched off, we can not use BS
functions any more. Since drawn console does implement our own
Blt(), we can use it to draw the console.

However, SimpleTextOutput protocol based console output must be
blocked.

Tested by inserting printf() after ExitBootServices() call.

(cherry picked from commit 4c7a3a70e047fbba2a3ce4a0168eaf2baddca76b)

2 years agocluster_write(): do not access buffer after it is released
Konstantin Belousov [Thu, 2 Sep 2021 04:04:23 +0000 (07:04 +0300)]
cluster_write(): do not access buffer after it is released

(cherry picked from commit 5cc82c563eda97b70120f06e9635ab6c1c24fecd)

2 years agoopenssh: regenerate freebsd-namespace.h
Ed Maste [Thu, 2 Sep 2021 01:54:57 +0000 (21:54 -0400)]
openssh: regenerate freebsd-namespace.h

For some reason poly64 was omitted when this file was last generated
(perhaps it was inlined by the Clang version then in use).

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit c7b4c21ee4615e2e418ab520abf6c026d6dae398)

2 years agoopenssh: disable libwrap (TCP wrappers) at configure time
Ed Maste [Thu, 2 Sep 2021 00:30:05 +0000 (20:30 -0400)]
openssh: disable libwrap (TCP wrappers) at configure time

We define LIBWRAP at build time in secure/usr.sbin/sshd/Makefile if
WITH_TCPWRAPPERS is in effect, so it should not be set in config.h.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 36cd1e5e8c216e0f67832d59d629f2910a02d4fc)

2 years agoopenssh: clarify krb5 use in freebsd-configure
Ed Maste [Thu, 2 Sep 2021 00:23:40 +0000 (20:23 -0400)]
openssh: clarify krb5 use in freebsd-configure

freebsd-configure.sh runs configure twice, --with-kerberos5 and
--without-kerberos5, in order to build a config.h that defaults to
kerberos5 disabled, and a small config file that represents the
differences.

Rename config.h.orig to config.h.kerberos5 to clarify the intent of this
script.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 5e4dd21fd60958ceef4e4fd14b000844b957287e)

2 years agoopenssh: tag generated file with @generated
Ed Maste [Thu, 2 Sep 2021 01:49:44 +0000 (21:49 -0400)]
openssh: tag generated file with @generated

Tools like Phabricator use the @generated tag to identify files that
may be excluded from review by default.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit b3e858f7622e7fb058c05f81abd657fc47c6f717)

2 years agollvm: Revert "[HardwareLoops] Change order of SCEV expression construction for InitLo...
Alfredo Dal'Ava Junior [Thu, 2 Sep 2021 17:54:31 +0000 (14:54 -0300)]
llvm: Revert "[HardwareLoops] Change order of SCEV expression construction for InitLoopCount."

Reverts llvm commit 42eaf4fe0adef3344adfd9fbccd49f325cb549ef, pointed
from bisect as source of regression that causes liblzma to compress/
uncompress incorrectly. It's know to affect powerpc64 BE only.

The patch unbreaks FreeBSD powerpc64 installation media, since
bsdinstall can't uncompress the *.txz produced by FreeBSD CI. It's
probably miscompiling other software bas well.

Upstream PR: https://bugs.llvm.org/show_bug.cgi?id=51714

Reviewed by: dim
MFC after: 2 days
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D31804

(cherry picked from commit f21fcae487026987f44154de981c03b69efbc945)

2 years agosctp: Implement sctp_inpcb_bind_locked()
Mark Johnston [Wed, 1 Sep 2021 14:04:47 +0000 (10:04 -0400)]
sctp: Implement sctp_inpcb_bind_locked()

This will be used by sctp_listen() to avoid dropping locks when
performing an implicit bind.  No functional change intended.

Reviewed by: tuexen
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 457abbb85794ad8b28d11a7cd44260eabdf3114d)

2 years agosctp: Release the socket reference when detaching an association
Mark Johnston [Wed, 1 Sep 2021 14:27:31 +0000 (10:27 -0400)]
sctp: Release the socket reference when detaching an association

Later in sctp_free_assoc(), when we clean up chunk lists,
sctp_free_spbufspace() is used to reset the byte count in the socket
send buffer.  However, if the PCB is going away, the socket may already
have been detached from the PCB, in which case this becomes a use-after
free.  Clear the socket reference from the association before detaching
it from the PCB, if the PCB has already lost its socket reference.

Reviewed by: tuexen
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 65f30a39e11bbbab927dbd2ca8de5ec5fc6af7ca)

2 years agosctp: Hold association locks across socket wakeups when freeing
Mark Johnston [Wed, 1 Sep 2021 14:27:51 +0000 (10:27 -0400)]
sctp: Hold association locks across socket wakeups when freeing

At this point we do not hold the inpcb lock, so the only thing holding
the socket reference live is the TCB lock, which needs to be acquired by
sctp_inpcb_free() in order to destroy associations.  Defer the unlock to
until after we dereference the socket reference.

Reported by: syzbot+1d0f2c4675de76a4cf1e@syzkaller.appspotmail.com
Reported by: syzbot+fabee77954fe69d3a5ad@syzkaller.appspotmail.com
Reviewed by: tuexen
Sponsored by: The FreeBSD Foundation

(cherry picked from commit d35be50f57797a400ff68a37777405029bf9730a)

2 years agosctp: Add macros to assert on inp info lock state
Mark Johnston [Wed, 1 Sep 2021 14:06:02 +0000 (10:06 -0400)]
sctp: Add macros to assert on inp info lock state

Reviewed by: tuexen
Sponsored by: The FreeBSD Foundation

(cherry picked from commit be8ee77e9edcb0bc8f94cb8695fc7fb49cc0a282)

2 years agokevent: Fix races between timer detach and kqtimer_proc_continue()
Mark Johnston [Wed, 1 Sep 2021 18:18:58 +0000 (14:18 -0400)]
kevent: Fix races between timer detach and kqtimer_proc_continue()

- When detaching a knote, we need to double check the enqueued flag
  after acquiring the process lock, as kqtimer_proc_continue() may have
  toggled it.
- kqtimer_proc_continue() could in principle reschedule a stopped
  callout after filt_timerdetach() drains the callout.  So, we need to
  re-check.

Reported by: syzbot+4a4cebb3ec07892cb040@syzkaller.appspotmail.com
Reported by: syzbot+a9c04bc76078a3b7dd8d@syzkaller.appspotmail.com
Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit c511383de7a0325a80b9c5d2b8678b438db146dc)

2 years agopfctl: print counters in decimal
Kristof Provost [Sat, 4 Sep 2021 14:07:59 +0000 (16:07 +0200)]
pfctl: print counters in decimal

795d78a46713 pfctl: Don't use PRIu64 mistakenly changed these to be
printed as hexadecimal numbers.

Reported by: Florian Smeets
MFC after: 4 days
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 846a6e8f9ab25df4e06d28c05fb66060d803c9ba)

2 years agopfctl: Don't use PRIu64
Kristof Provost [Wed, 1 Sep 2021 16:18:26 +0000 (18:18 +0200)]
pfctl: Don't use PRIu64

Rather than PRIu64 we can just treat the data as uintmax_t, and use %jx
instead.

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

(cherry picked from commit 795d78a46713fc16153966e77f20da2f40aac2a3)

2 years agopf: import pf_set_protostate() from OpenBSD
Kristof Provost [Tue, 20 Jul 2021 16:38:16 +0000 (18:38 +0200)]
pf: import pf_set_protostate() from OpenBSD

to change a state's state (that term is overloaded in pf, protocol state
like ESTABLISHED for tcp here), don't do it directly, but go through a newly
introduced pf_set_protostate()

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

(cherry picked from commit ce3ea45047c7321bcfcf0cd31272f0e4359640f2)

2 years agopf: Add counters for syncookies
Kristof Provost [Sun, 29 Aug 2021 13:54:50 +0000 (15:54 +0200)]
pf: Add counters for syncookies

Count when we send a syncookie, receive a valid syncookie or detect a
synflood.

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

(cherry picked from commit 4cab80a8dfecdf16333a1113513e046b9f4dd7f6)

2 years agowsp(4): Add evdev support.
Vladimir Kondratyev [Tue, 24 Aug 2021 23:01:42 +0000 (02:01 +0300)]
wsp(4): Add evdev support.

Reviewed by: hselasky
Tested by: Greg V, Constantin Furst<constantin_AT_fuersten_DOT_info>
PR: 252236
Differential revision: https://reviews.freebsd.org/D31653

(cherry picked from commit 8d73071c47ff1f911bdaec6356f37feb4e3b7cb5)

2 years agowsp(4): Compact parameter structure.
Vladimir Kondratyev [Tue, 24 Aug 2021 22:59:48 +0000 (01:59 +0300)]
wsp(4): Compact parameter structure.

(cherry picked from commit 250ab004074df27372b9afb18003c1e39d79aff5)

2 years agoatp(4), wsp(4): Return correct priority from probe() method;
Vladimir Kondratyev [Tue, 24 Aug 2021 22:59:17 +0000 (01:59 +0300)]
atp(4), wsp(4): Return correct priority from probe() method;

(cherry picked from commit 9fa1201d60dc7004f11d950f0fbd277bdcdcaf2d)

2 years agoevdev: Add support for automatic MT protocol type A to type B conversion.
Vladimir Kondratyev [Tue, 24 Aug 2021 22:53:56 +0000 (01:53 +0300)]
evdev: Add support for automatic MT protocol type A to type B conversion.

(cherry picked from commit d056693d7bc6c1b5f2c1612e5b34807f173e21c7)

2 years agoevdev: Add implicit mode for touch tracking.
Vladimir Kondratyev [Tue, 24 Aug 2021 22:52:37 +0000 (01:52 +0300)]
evdev: Add implicit mode for touch tracking.

In implicit mode assignment of slot number and tracking id is performed
automatically on each synchronization requested by device driver.

This is done with creation of intermediate buffer for multitouch events.
This buffer holds untracked events until synchronization is requested by
device driver. It is needed as touch assigment requires
knowledges of all touch positions pushed in current and previous reports.

(cherry picked from commit f76051c7dabe952b75127a8031d87d78b603be20)

2 years agoevdev: Import support for touch-tracking.
Vladimir Kondratyev [Tue, 24 Aug 2021 22:50:53 +0000 (01:50 +0300)]
evdev: Import support for touch-tracking.

Touch tracking is a process of assignment of unique trackingID to each
initiated contact on the surface.  Keeping the trackingIDs persistent
across multitouch reports requires solving of so called Euclidian
Bipartite Matching problem.

This commit imports EBM-solver implementation based on Dinitz-Kronrod
algorithm to find minimum cost matching between contacts listed in two
consecutive reports.

Obtained from: OpenBSD

(cherry picked from commit 4c0a134e32a7f4dec556fea15c8de22f69864492)

2 years agoevdev: Make MT tracking IDs monotonically increasing sequence.
Vladimir Kondratyev [Tue, 24 Aug 2021 22:48:33 +0000 (01:48 +0300)]
evdev: Make MT tracking IDs monotonically increasing sequence.

(cherry picked from commit 66bd52f5e241bd2548015f847f12cdff69176c40)

2 years agoevdev: Give short aliases to items of evdev_mt_slot array
Vladimir Kondratyev [Tue, 24 Aug 2021 22:47:34 +0000 (01:47 +0300)]
evdev: Give short aliases to items of evdev_mt_slot array

with using of unioned anonymous structure.

Access to the same data by using different members of union generally
works despite it is not supported by C specs.

Also add helper function to report entire slot state.

(cherry picked from commit 059360287e3344f48f5a7839e2d6d54016b18b19)

2 years agoevdev: Normalize width and pressure of single touch compat events
Vladimir Kondratyev [Tue, 24 Aug 2021 22:46:49 +0000 (01:46 +0300)]
evdev: Normalize width and pressure of single touch compat events

to match Synaptics touchpad reporting range.

(cherry picked from commit 127e54deb6d8899e1dc1bc6251d512e19f21b0f1)

2 years agoevdev: force no fuzz for autogenerated single touch compat events.
Vladimir Kondratyev [Tue, 24 Aug 2021 22:45:50 +0000 (01:45 +0300)]
evdev: force no fuzz for autogenerated single touch compat events.

As fuzz has already been applied on multitouch event processing.
This allows to remove existing workaround for double fuzz procesing.

(cherry picked from commit 314913ed7c6e6e1b7c80a1063620f478961419b7)

2 years agoevdev: Send first active rather than 0-th slot state as ST report
Vladimir Kondratyev [Tue, 24 Aug 2021 22:45:16 +0000 (01:45 +0300)]
evdev: Send first active rather than 0-th slot state as ST report

(cherry picked from commit fbe17f9017e785dd564ce7fc5553a9136d3a0b03)