Commit Graph

135632 Commits

Author SHA1 Message Date
Warner Losh
cabbfa3e07 pccard: Move power_if.m from pccard to cardbus
power_if.m is used by both pccard and cardbus. Move it into cardbus.
2021-01-07 17:05:29 -07:00
Mateusz Guzik
71bd18d373 fd: use seqc_read_notmodify when translating fds 2021-01-07 23:30:04 +00:00
Mateusz Guzik
20ac5cda96 fd: make fd/fp mandatory
They are both always passed anyway.
2021-01-07 23:30:04 +00:00
Mateusz Guzik
fee405e057 cache: stop checkpointing cn_flags
They are only modified, if ever, for the last component.
2021-01-07 23:29:52 +00:00
Mateusz Guzik
ac7715471c cache: stop checkpointing cn_nameptr
For aborts cn_nameptr is the same as cn_pnbuf. For partial results
the same cn_nameptr is to be used.
2021-01-07 23:29:38 +00:00
Mateusz Guzik
0f1fc3a31f cache: stop manipulating pathlen
It is a copy-pasto from regular lookup. Add debug to ensure the result
is the same.
2021-01-07 23:26:53 +00:00
Vladimir Kondratyev
a84b0e94cd hid: Add UPDATING entry and bump __FreeBSD_version
Reviewed by:	hselasky
Differential revision:	https://reviews.freebsd.org/D28019
2021-01-08 02:18:44 +03:00
Vladimir Kondratyev
d97d5c0ce8 hid: Import hidmap-based drivers written by Greg V
This change includes:

hpen    - Generic / MS Windows compatible HID pen tablet driver.
hgame   - Generic game controller and joystick driver.
xb360gp - Xbox360-compatible game controller driver.

Submitted by:	Greg V <greg_unrelenting.technology>
Reviewed by:	hselasky (as part of D27993)
2021-01-08 02:18:44 +03:00
Vladimir Kondratyev
afd590d9e5 hid: Import hidmap and bunch of drivers based on it
hidmap is a kernel module that maps HID input usages to evdev events.

Following dependent drivers is included in the commit:

hms       - HID mouse driver.
hcons     - Consumer page AKA Multimedia keys driver.
hsctrl    - System Controls page (Power/Sleep keys) driver.
ps4dshock - Sony DualShock 4 gamepad driver.

Reviewed by:	hselasky
Differential revision:	https://reviews.freebsd.org/D27993
2021-01-08 02:18:44 +03:00
Vladimir Kondratyev
3b2175fdb6 evdev: Implement fuzz.
Fuzz is used to filter noise from the event stream.
Upcoming gamepad drivers use it.

Reviewed by:	hselasky (as part of D27993)
2021-01-08 02:18:44 +03:00
Vladimir Kondratyev
9be6b22da9 hidraw(4): Add HIDRAW_MAKE_UHID_ALIAS kernel option
which installs /dev/uhid# alias to hidraw character device for
compatibility with some existing uhid(4) users like Firefox.
As side effect it renames traditional uhid(4) driver to hidraw
to make possible using of common unit number allocator.

Requested by:	Greg V <greg_unrelenting.technology>
Reviewed by:	hselasky (as part of D27992)
2021-01-08 02:18:44 +03:00
Vladimir Kondratyev
9477390796 hid: Import hidraw(4) - driver for access to raw HID device data
This driver provides raw access to HID devices through uhid(4)-compatible
interface and is based on pre-8.x uhid(4) code. Unlike uhid(4) it does
not take devices in to monopoly ownership and allows parallel access
from other drivers.

hidraw supports Linux's hidraw-compatible interface as well.

Reviewed by:	hselasky
Differential revision:	https://reviews.freebsd.org/D27992
2021-01-08 02:18:43 +03:00
Vladimir Kondratyev
2775d1d5d1 hkbd(4): Split driver lock on interrupt and syscons locks
This allows to mark HID-device interrupt handlers as MP-SAFE.
Atomics-based lockless key event queue with swi_giant taskqueue is used
to pass key-press events into Giant-protected system console.

Reviewed by:	hselasky (as part of D27991)
2021-01-08 02:18:43 +03:00
Vladimir Kondratyev
b93f6bfca3 hid: Port ukbd to HID and attach to build
Reviewed by:	hselasky
Differential revision:  https://reviews.freebsd.org/D27991
2021-01-08 02:18:43 +03:00
Vladimir Kondratyev
08d8840175 hid: Copy ukbd(4) to HID subsystem. 2021-01-08 02:18:43 +03:00
Vladimir Kondratyev
cb022db825 hid: Port multitouch hmt(4) driver to hidbus and attach to build
Reviewed by:	hselasky
Differential revision:	https://reviews.freebsd.org/D27990
2021-01-08 02:18:43 +03:00
Vladimir Kondratyev
b9b347e9bf hid: Copy wmt(4) to HID subsystem as a base to upcoming hmt(4) driver. 2021-01-08 02:18:43 +03:00
Vladimir Kondratyev
10fbbdfbbd hid: Import hconf(4) - digitizer configuration top-level collection support.
Reviewed by:	hselasky (as part of D27990)
2021-01-08 02:18:43 +03:00
Vladimir Kondratyev
01f2e864f7 hid: Import usbhid - USB transport backend for HID subsystem.
This change implements hid_if.m methods for HID-over-USB protocol [1].

Also, this change adds USBHID_ENABLED kernel option which changes
device_probe() priority and adds/removes PnP records to prefer usbhid
over ums, ukbd, wmt and other USB HID device drivers and vice-versa.

The module is based on uhid(4) driver.  It is disabled by default for
now due to conflicts with existing USB HID drivers.

[1] https://www.usb.org/sites/default/files/hid1_11.pdf

Reviewed by:	hselasky
Differential revision:	https://reviews.freebsd.org/D27893
2021-01-08 02:18:43 +03:00
Vladimir Kondratyev
b1f1b07f6d hid: Import iichid - I2C transport backend for HID subsystem
This implements hid_if.m methods for HID-over-I2C protocol [1].

Following kernel options are added:

IICHID_SAMPLING - Enable support for a sampling mode as interrupt
                  resource acquisition is not always possible in a case
                  of GPIO interrupts.
IICHID_DEBUG    - Enable debug output.

The module is based on prior Marc Priggemeyer work (D16698).

[1] http://download.microsoft.com/download/7/d/d/7dd44bb7-2a7a-4505-ac1c-7227d3d96d5b/hid-over-i2c-protocol-spec-v1-0.docx

Differential revision:	https://reviews.freebsd.org/D27892
2021-01-08 02:18:43 +03:00
Vladimir Kondratyev
e49fa9f6f3 hid: Import quirk subsystem.
hidquirk(4) is derived from usb_quirk(4) and inherits all its HID-related
functionality. It does not support ioctl(2) interface yet.

Reviewed by:	hselasky
Differential revision:	https://reviews.freebsd.org/D27890
2021-01-08 02:18:43 +03:00
Vladimir Kondratyev
2b4464b0b1 hid: Import hidbus(4)
This driver provides support for multiple HID driver attachments
to single HID transport backend. This ability existed in Net/OpenBSD
(uhidev and ihidev drivers) but has never been ported to FreeBSD.
Unlike Net/OpenBSD we do not use report number alone to distinct report
source but we follow MS way and use a top level collection (TLC) usage
index that report belongs to as a location key.

The driver performs child device autodiscovery based on HID report
descriptor data, proxying of HID requests from child devices to parent
transport backends and broadcasting of interrupts in backward direction.

Differential revision:	https://reviews.freebsd.org/D27888
2021-01-08 02:18:42 +03:00
Vladimir Kondratyev
961a3535db hid: Import HID transport method definitions and helper functions.
Create an abstract HID interface that provides hardware independent
access to HID capabilities and functions through the device tree.

hid_if.m resembles existing USBHID KPI and consist of next methods:

HID method		USBHID variant
-----------------------------------------------------------------------
hid_intr_setup		usbd_transfer_setup	(INTERRUPT IN xfer)
hid_intr_unsetup	usbd_transfer_unsetup	(INTERRUPT IN xfer)
hid_intr_start		usbd_transfer_start	(INTERRUPT IN xfer)
hid_intr_stop		usbd_transfer_drain	(INTERRUPT IN xfer)
hid_intr_poll		usbd_transfer_poll	(INTERRUPT IN xfer)

hid_get_rdesc		usbd_req_get_report_descriptor
hid_read		No direct analog. Not intended for common use.
hid_write		uhid(4) write()
hid_get_report		usbd_req_get_report
hid_set_report		usbd_req_set_report
hid_set_idle		usbd_req_set_idle
hid_set_protocol	usbd_req_set_protocol

This change is part of D27888
2021-01-08 02:18:42 +03:00
Vladimir Kondratyev
eead9017d2 hid: Chase for HID function name changes in existing USB HID drivers
Also hide shim code added in a previous commit under COMPAT_USBHID12.

Note: it is enough to add -DCOMPAT_USBHID12 to CFLAGS to compile old
code with new HID subsystem, but it is not enough to link it at runtime.
HID dependency has to be added explicitly with MODULE_DEPEND macro.

Reviewed by:	manu, hselasky (as part of D27887)
2021-01-08 02:18:42 +03:00
Vladimir Kondratyev
1975878673 hid: Import functions and constants required by new subsystem
This does an import of quirk stubs, debugging macros from USB code and
numerous usage constants used by dependent drivers.

Besides, this change renames some functions to get a better matching
with userland library and NetBSD/OpenBSD HID code. Namely:

- Old hid_report_size() renamed to hid_report_size_max()
- New hid_report_size() calculates size of given report rather than
  maximum size of all reports.
- hid_get_data_unsigned() renamed to hid_get_udata()
- hid_put_data_unsigned() renamed to hid_put_udata()

Compat shim functions are provided in usbhid.h to make possible compile
of legacy code unmodified after this change.

Reviewed by:	manu, hselasky
Differential revision:	https://reviews.freebsd.org/D27887
2021-01-08 02:18:42 +03:00
Vladimir Kondratyev
67de2db262 Factor-out hardware-independent part of USB HID support to new module
It will be used by the upcoming HID-over-i2C implementation.  Should be
no-op, except hid.ko module dependency is to be added to affected drivers.

Reviewed by:	hselasky, manu
Differential revision:	https://reviews.freebsd.org/D27867
2021-01-08 02:18:42 +03:00
Vladimir Kondratyev
1ffa5c63f4 Copy HID over USB support files to new sys/dev/hid directory 2021-01-08 02:18:42 +03:00
Vladimir Kondratyev
bc86103335 libkern/strcasestr.c: Drop xlocale support and connect to build.
Reviewed by:	markj, hselasky
Differential revision:	https://reviews.freebsd.org/D27866
2021-01-08 02:18:42 +03:00
Vladimir Kondratyev
92cf602e38 Copy strcasestr.c from libc to libkern. 2021-01-08 02:18:42 +03:00
Vladimir Kondratyev
3b8c8b35de evdev: Allow open() handler to be interrupted by a signal
It is possible that the client list lock is taken by other process for too
long due to e.g. IO timeouts. Allow user to terminate open() in this case.

Reviewed by:	markj (as part of D27865)
2021-01-08 02:18:42 +03:00
Vladimir Kondratyev
d276eae674 evdev: Make open(2) and close(3) handlers sleepable.
At the beginning of evdev there was a LOR between hardware driver's and
evdev client list locks as they were taken in different order at
driver's interrupt and evdev open()/close() handlers.

The LOR was fixed with introduction of evdev_register_mtx() function
which allowed to use a hardware driver's lock as evdev client list lock.
While this works good with PS/2 and USB, this does not work with I2C.
Unlike PS/2 and USB, I2C open()/close() handlers do unbound sleeps
while waiting for I2C bus to release and while performing IO.
This change uses epoch(9) for traversing evdev client list in interrupt
handler to avoid the LOR thus making possible to convert evdev client
list lock to sleepable sx.

While here add brief locking protocol description.

Reviewed by:	markj
Differential revision:	https://reviews.freebsd.org/D27865
2021-01-08 02:18:41 +03:00
Vladimir Kondratyev
5af73ad51b evdev: Remove useless "initial value" parameter from evdev_support_abs()
It can not be used for setting of state of multitouch events.
If necessary, use evdev_push_event() instead of it.
2021-01-08 02:18:41 +03:00
Vladimir Kondratyev
95e1f0d684 Allow HID report descriptor parser to return more then 1 usage per item
This handles parsing of following descriptor, containing array of
usages:

0x05, 0x01,        // Usage Page (Generic Desktop Ctrls)
0x09, 0x80,        // Usage (Sys Control)
0xA1, 0x01,        // Collection (Application)
0x75, 0x02,        //   Report Size (2)
0x95, 0x01,        //   Report Count (1)
0x15, 0x01,        //   Logical Minimum (1)
0x25, 0x03,        //   Logical Maximum (3)
0x09, 0x82,        //   Usage (Sys Sleep)
0x09, 0x81,        //   Usage (Sys Power Down)
0x09, 0x83,        //   Usage (Sys Wake Up)
0x81, 0x60,        //   Input (Data,Array,Abs)
0x75, 0x06,        //   Report Size (6)
0x81, 0x03,        //   Input (Const,Var,Abs)
0xC0,              // End Collection

Our current parser returns only first usage (Sys Sleep) and loses next
two. Set HID_ITEM_MAXUSAGE limit relatively low as existing code
usually allocates hid_item on stack.

Also tweak hid_locate() to support hid items with multiple usages.

Reviewed by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D27748
2021-01-08 02:18:41 +03:00
Vladimir Kondratyev
3f27092854 hid_locate: do not ignore constant items.
hid_locate() currently ignores all HID items which tagged as constant,
i.e. bit 0 of main item data is set to 1. See p.6.2.2.4 of
hid1_11.pdf [1]. Such an items are unconditionally treated as
byte-alignment padding. While that may be right decision for input and
output reports that is wrong for features reports. Feature reports can
contain constant capabilities e.g. 'Contact Count Maximum'.
See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=232040

Remove check for constant from hid_locate() to make possible parsing of
such a reports.

[1] https://www.usb.org/sites/default/files/documents/hid1_11.pdf

Reviewed by:	hselasky
Obtained from:	sysutils/iichid
Differential Revision:	https://reviews.freebsd.org/D27747
2021-01-08 02:18:41 +03:00
Kristof Provost
0fcb03fbac pf: Copy kif flags to userspace
This was overlooked in the pfi_kkif/pfi_kif splitup and as a result
userspace could no longer tell which interfaces had the skip flag
applied.

MFC after:	2 weeks
2021-01-07 22:26:05 +01:00
Matt Macy
81be655266 iflib: ensure that tx interrupts enabled and cleanups
Doing a 'dd' over iscsi will reliably cause stalls. Tx
cleaning _should_ reliably happen as data is sent.
However, currently if the transmit queue fills it will
wait until the iflib timer (hz/2) runs.

This change causes the the tx taskq thread to be run
if there are completed descriptors.

While here:

- make timer interrupt delay a sysctl

- simplify txd_db_check handling

- comment on INTR types

Background on the change:

Initially doorbell updates were minimized by only writing to the register
on every fourth packet. If txq_drain would return without writing to the
doorbell it scheduled a callout on the next tick to do the doorbell write
to ensure that the write otherwise happened "soon". At that time a sysctl
was added for users to avoid the potential added latency by simply writing
to the doorbell register on every packet. This worked perfectly well for
e1000 and ixgbe ... and appeared to work well on ixl. However, as it
turned out there was a race to this approach that would lockup the ixl MAC.
It was possible for a lower producer index to be written after a higher one.
On e1000 and ixgbe this was harmless - on ixl it was fatal. My initial
response was to add a lock around doorbell writes - fixing the problem but
adding an unacceptable amount of lock contention.

The next iteration was to use transmit interrupts to drive delayed doorbell
writes. If there were no packets in the queue all doorbell writes would be
immediate as the queue started to fill up we could delay doorbell writes
further and further. At the start of drain if we've cleaned any packets we
know we've moved the state machine along and we write the doorbell (an
obvious missing optimization was to skip that doorbell write if db_pending
is zero). This change required that tx interrupts be scheduled periodically
as opposed to just when the hardware txq was full. However, that just leads
to our next problem.

Initially dedicated msix vectors were used for both tx and rx. However, it
was often possible to use up all available vectors before we set up all the
queues we wanted. By having rx and tx share a vector for a given queue we
could halve the number of vectors used by a given configuration. The problem
here is that with this change only e1000 passed the necessary value to have
the fast interrupt drive tx when appropriate.

Reported by: mav@
Tested by: mav@
Reviewed by:    gallatin@
MFC after:      1 month
Sponsored by:   iXsystems
Differential Revision:  https://reviews.freebsd.org/D27683
2021-01-07 14:07:35 -08:00
Chuck Silvers
11403bdeb4 vfs: fix rangelock range in vn_rdwr() for IO_APPEND
vn_rdwr() must lock the entire file range for IO_APPEND
just like vn_io_fault() does for O_APPEND.

Reviewed by:	kib, imp, mckusick
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D28008
2021-01-07 13:37:35 -08:00
Mitchell Horne
40d0971bbe arm64: enable build of the ipmi module
Only ACPI attachment is supported for now, some others depend on the
presence of smbios(4) support, which we lack on arm64.

Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D28009
2021-01-07 15:45:25 -04:00
Alexander V. Chernikov
d68cf57b7f Refactor rt_addrmsg() and rt_routemsg().
Summary:
* Refactor rt_addrmsg(): make V_rt_add_addr_allfibs decision locally.
* Fix rt_routemsg() and multipath by accepting nexthop instead of interface pointer.
* Refactor rtsock_routemsg(): avoid accessing rtentry fields directly.
* Simplify in_addprefix() by moving prefix search to a separate  function.

Reviewers: #network

Subscribers: imp, ae, bz

Differential Revision: https://reviews.freebsd.org/D28011
2021-01-07 19:38:19 +00:00
Mitchell Horne
4979620ece armv8crypto: add AES-XTS support
A straightforward(ish) port from aesni(4). This implementation does not
perform loop unrolling on the input blocks, so this is left as a future
performance improvement.

Submitted by:	Greg V <greg AT unrelenting.technology>
Looks good:	jhb, jmg
Tested by:	mhorne
Differential Revision:	https://reviews.freebsd.org/D21017
2021-01-07 15:35:20 -04:00
Andrew Gallatin
a2fc8ade10 isci: use maxphys rather than 128KB to size s/g list
In the conversion into a tunable, we converted the
size of the s/g list used by the driver to be based
off of a hardcoded size of 128k rather than maxphys,
this caused performance problems for us.  Revert this
to use the maxphys tunable.

Note that this constant is used to size dynamically allocated
things, and not static data structs, so this is safe.

Reviewed By:    imp, kib, mav
Tested By:i     dhw
Differential Revision: https://reviews.freebsd.org/D28023
Sponsored by: Netflix
2021-01-07 12:45:46 -05:00
Ed Maste
f45f9ef051 arm64 GENERIC: sort to match amd64, to ease comparison
No functional change - only moved lines, changed whitespace, and
updated comments.

Reviewed by:	allanjude
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D28001
2021-01-07 10:01:48 -05:00
Hans Petter Selasky
ea0efc3704 Add support for PL2303HXN to uplcom(4).
Code changes in this commit were obtained from straight from OpenBSD's
uplcom.c with almost no modification, the list of chip names and USB
IDs was obtained from Linux.

Differential Revision: https://reviews.freebsd.org/D27952
Submitted by: tomli_tomli.me (Yifeng Li)
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking
2021-01-07 15:35:35 +01:00
Hans Petter Selasky
c834f30a0c Add new PCI ID for XHCI(4).
Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking
2021-01-07 15:35:35 +01:00
Alex Richardson
1f6612b444 Install dtrace.h and dependencies
This makes the minimum amount of changes to allow inclusion of dtrace.h
without all the solaris compatibility headers. Installing dtrace.h allows
compiling consumers of libdtrace (e.g. https://github.com/tmetsch/python-dtrace)
without requiring a copy of the source tree.
For python-dtrace I worked around this in 58019c9a12
but being able to build the library without installed sources would be
extremely useful.

Reviewed By:	gnn
Differential Revision: https://reviews.freebsd.org/D27884
2021-01-07 09:26:21 +00:00
Mateusz Guzik
f2b794e1e9 cache: unengrish the comment in previous commit
Reported by:	rpokala, brd
2021-01-06 23:46:05 +00:00
Marcin Wojtas
ca71c7e3bb arm64: QorIQ: gpio: return BUS_PROBE_DEFAULT
There is no reason this driver can't return default probe value.

Submitted by: Artur Rojek <ar@semihalf.com>
Reviewed by: emaste, mmel
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D26869
2021-01-06 22:37:38 +01:00
Marcin Wojtas
39c24889b0 arm64: QorIQ: gpio: Cleanup qoriq_gpio_* helpers
Replace various hw reg bit set/clear helpers with a universal
`qoriq_gpio_set` function.

Submitted by: Artur Rojek <ar@semihalf.com>
Reviewed by: mmel
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D26868
2021-01-06 22:37:21 +01:00
Marcin Wojtas
c76c36f95c arm64: QorIQ: gpio: Style cleanups
Make the code more conformant to style(9) and improve the general
readability.

This patch does not alter the driver logic.

Submitted by: Artur Rojek <ar@semihalf.com>
Reviewed by: mmel
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D26867
2021-01-06 22:37:13 +01:00
Mateusz Guzik
deabdc6868 cache: stop pre-checking seqc when starting the lookup
Tested by:	pho
2021-01-06 07:28:07 +00:00
Mateusz Guzik
c6d3272b73 vfs: add vn_seqc_read_notmodify 2021-01-06 07:28:07 +00:00
Mateusz Guzik
65f775157e seqc: add seqc_read_notmodify
The routine can be used when the caller does not expect to ever have to
wait for anything. Checking later with seqc_consistent retains all the
guarantees.
2021-01-06 07:28:06 +00:00
Mateusz Guzik
71a6a0b545 cache: skip checking for spurious slashes if possible
Tested by:	pho
2021-01-06 07:28:06 +00:00
Mateusz Guzik
33f3e81df5 cache: combine fast path enabled status into one flag
Tested by:	pho
2021-01-06 07:28:06 +00:00
Mateusz Guzik
dbbbc07cc3 cache: split handling of 0 and non-0 error codes
Tested by:	pho
2021-01-06 07:07:24 +01:00
Mateusz Guzik
a1a8f8ada1 cache: deinline state handling
The intent is to reduce branchfest when finishing the lookup.

Tested by:	pho
2021-01-06 07:05:22 +01:00
Mateusz Guzik
05803be000 cache: stop setting cn_nameptr on entry as matches cn_pnbuf already
While here tidy up other asserts.
2021-01-06 07:03:41 +01:00
Kristof Provost
fda7daf063 pfctl: Stop sharing pf_ruleset.c with the kernel
Now that we've split up the datastructures used by the kernel and
userspace there's essentually no more overlap between the pf_ruleset.c
code used by userspace and kernelspace.

Copy the userspace bits to the pfctl directory and stop using the kernel
file.

Reviewed by:	philip
MFC after:	2 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D27764
2021-01-05 23:35:37 +01:00
Kristof Provost
5a3b9507d7 pf: Convert pfi_kkif to use counter_u64
Improve caching behaviour by using counter_u64 rather than variables
shared between cores.

The result of converting all counters to counter(9) (i.e. this full
patch series) is a significant improvement in throughput. As tested by
olivier@, on Intel Xeon E5-2697Av4 (16Cores, 32 threads) hardware with
Mellanox ConnectX-4 MCX416A-CCAT (100GBase-SR4) nics we see:

x FreeBSD 20201223: inet packets-per-second
+ FreeBSD 20201223 with pf patches: inet packets-per-second
+--------------------------------------------------------------------------+
|                                                                        + |
| xx                                                                     + |
|xxx                                                                    +++|
||A|                                                                       |
|                                                                       |A||
+--------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   5       9216962       9526356       9343902     9371057.6     116720.36
+   5      19427190      19698400      19502922      19546509     109084.92
Difference at 95.0% confidence
        1.01755e+07 +/- 164756
        108.584% +/- 2.9359%
        (Student's t, pooled s = 112967)

Reviewed by:	philip
MFC after:	2 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D27763
2021-01-05 23:35:37 +01:00
Kristof Provost
26c841e2a4 pf: Allocate and free pfi_kkif in separate functions
Factor out allocating and freeing pfi_kkif structures. This will be
useful when we change the counters to be counter_u64, so we don't have
to deal with that complexity in the multiple locations where we allocate
pfi_kkif structures.

No functional change.

MFC after:	2 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D27762
2021-01-05 23:35:37 +01:00
Kristof Provost
320c11165b pf: Split pfi_kif into a user and kernel space structure
No functional change.

MFC after:	2 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D27761
2021-01-05 23:35:37 +01:00
Kristof Provost
c3adacdad4 pf: Change pf_krule counters to use counter_u64
This improves the cache behaviour of pf and results in improved
throughput.

MFC after:	2 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D27760
2021-01-05 23:35:37 +01:00
Kristof Provost
c7bdafe2f1 pf: Remove unused fields from pf_krule
The u_* counters are used only to communicate with userspace, as
userspace cannot use counter_u64. As pf_krule is not passed to userspace
these fields are now obsolete.

MFC after:	2 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D27759
2021-01-05 23:35:36 +01:00
Kristof Provost
e86bddea9f pf: Split pf_rule into kernel and user space versions
No functional change intended.

MFC after:	2 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D27758
2021-01-05 23:35:36 +01:00
Kristof Provost
dc865dae89 pf: Migrate pf_rule and related structs to pf.h
As part of the split between user and kernel mode structures we're
moving all user space usable definitions into pf.h.

No functional change intended.

MFC after:      2 weeks
Sponsored by:   Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D27757
2021-01-05 23:35:36 +01:00
Kristof Provost
fbbf270eef pf: Use counter_u64 in pf_src_node
Reviewd by:	philip
MFC after:      2 weeks
Sponsored by:   Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D27756
2021-01-05 23:35:36 +01:00
Kristof Provost
17ad7334ca pf: Split pf_src_node into a kernel and userspace struct
Introduce a kernel version of struct pf_src_node (pf_ksrc_node).

This will allow us to improve the in-kernel data structure without
breaking userspace compatibility.

Reviewed by:	philip
MFC after:	2 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D27707
2021-01-05 23:35:36 +01:00
Emmanuel Vadot
cb00fc7c4d arm64: genet: Add bcm2711-genet-v5 compatible
Later dtb from the RPI Foundation removed the brcm,genet-v5 compatible
for some unknown reason, add brcm,bcm2711-genet-v5 to the list of compatible
device for if_genet
2021-01-05 20:50:43 +01:00
Andrew Turner
a7d8bd8c23 Add missing structs to pmclog_entry
This is used to size allocations so needs to incude all log structs
to ensure its size is correct.

Sponsored by:	Innovate UK
2021-01-05 10:03:05 +00:00
Alan Cox
7beeacb27b Honor the vm page's PG_NODUMP flag on arm and i386.
Reviewed by:	kib, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D27949
2021-01-04 16:15:42 -06:00
Alexander V. Chernikov
9c0ff6a8bb Remove now-unused RT_GATEWAY* definitions.
They were used to simplify nexthop transition, hence not needed
 anymore.
2021-01-04 21:45:46 +00:00
Andrew Turner
12d053032b Support overflow count in hwpmc on arm64
We increment the overflow count when receiving an overflow interrupt
with special care to check if it happens while reading the event counter.

Sponsored by:	Innovate UK
2021-01-04 17:14:41 +00:00
Emmanuel Vadot
e5df46055a arm64: rockchip: rk_clk_mux: Tell the clk framework if we didn't change the clock
Otherwise the clk framework will not pass the freq change request to the clock
parents.
Fix d03fd8ede2
Reported by:	br
2021-01-04 17:30:00 +01:00
Mark Johnston
caf552a607 mvneta: Fix 64-bit MIB reads
It appears we must read MIB values as 2 4-byte words, lower address
first.  A single 8-byte MIB read returns the value with the lower 4
bytes copied into the upper 4 bytes, resulting in bogus byte counter
values.

Reviewed by:	mw
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC (Netgate)
Differential Revision:	https://reviews.freebsd.org/D27870
2021-01-04 08:32:54 -05:00
Mark Johnston
c4cceb1d0d md: Fix a race in mdstart_swap()
Release a grabbed page's busy state only after marking it as referenced.
Otherwise there exists a narrow window where the page could be freed
before the update.  Before r356902 this was not a problem since the
object lock was held.

Discussed with:	kib
Sponsored by:	The FreeBSD Foundation
2021-01-04 08:26:14 -05:00
Poul-Henning Kamp
ea70ab2387 Use the actual credentials to create the /dev/nmdm* devices.
This lets plain users create nmdm pairs, which is useful amongst
other things for running retro-computing emulators etc.
2021-01-04 13:18:47 +00:00
Oleksandr Tymoshenko
d03fd8ede2 rockchip: add audio-related clocks to the CRU driver
- Add I2S and CODEC clocks to CRU driver
- Add support for gate selection to frac clock
- Add setfreq support to mux clock

Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D27831
2021-01-03 16:50:42 -08:00
Mateusz Guzik
3814bea00a cache: drop the now spurious doomed check when crossing a mount point 2021-01-03 21:22:16 +00:00
Mateusz Guzik
33a195baf3 vfs: keep seqc unchanged as long as the vnode is accessible via SMR 2021-01-03 21:22:16 +00:00
Conrad Meyer
98689d0ffb libprivatezstd: Restrict symbol visibility similar to upstream
We have to relax three symbols to dynamically link zstd(1), but the rest
are the same.
2021-01-03 11:26:46 -08:00
Alan Somers
17a82e6af8 Fix vnode locking bug in fuse_vnop_copy_file_range
MFC-With:	92bbfe1f0d
Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D27938
2021-01-03 11:16:20 -07:00
Mark Johnston
214257da3a sendfile: Clear page pointers when handling a pager error
When INVARIANTS is configred, the sendfile_iodone() callback verifies
that pages attached to the sendfile header are wired, but we unwire all
such pages after a synchronous pager error, before calling
sendfile_iodone().

Reported by:	pho
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
2021-01-03 11:50:31 -05:00
Mark Johnston
2ce5eef6e2 cam: Remove Giant handling from cam_sim_alloc()
There are no non-MPSAFE SIM drivers left in the tree, verified with
coccinelle.

Reviewed by:	scottl, imp
Differential Revision:	https://reviews.freebsd.org/D27853
2021-01-03 11:50:31 -05:00
Mark Johnston
90f580b954 Ensure that dirent's d_off field is initialized
We have the d_off field in struct dirent for providing the seek offset
of the next directory entry.  Several filesystems were not initializing
the field, which ends up being copied out to userland.

Reported by:	Syed Faraz Abrar <faraz@elttam.com>
Reviewed by:	kib
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D27792
2021-01-03 11:50:31 -05:00
Mark Johnston
663de81f85 uma: Avoid unmapping direct-mapped slabs
startup_alloc() uses pmap_map() to map slabs used for bootstrapping the
VM.  pmap_map() may ignore the hint address and simply return a range
from the direct map.  In this case we must not unmap the range in
startup_free().

UMA uses bootstart and bootmem to track the range of KVA into which
slabs are mapped if the direct map is not used.  Unmap a startup slab
only if it was mapped into that range.

Reported by:	alc
Reviewed by:	alc, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D27885
2021-01-03 11:50:31 -05:00
Alan Somers
34477e25c1 fusefs: only check vnode locks with DEBUG_VFS_LOCKS
MFC-With:	37df9d3bba
Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D27939
2021-01-03 09:19:00 -07:00
Alan Somers
542711e520 Fix a vnode locking bug in fuse_vnop_advlock.
Must lock the vnode before accessing the fufh table.  Also, check for
invalid parameters earlier.  Bug introduced by r346170.

MFC after:	2 weeks

Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D27936
2021-01-03 09:16:23 -07:00
Conrad Meyer
bcae12b591 zstd: Fix non-FreeBSD CI libzstd build
Fix non-FreeBSD CI build after v1.4.8.  This definition was only used in
zstd(1), which isn't part of non-FreeBSD CI (I guess).  The ifdef was
added in v1.4.5 import.

Upstream does not currently support shared-linked zstd(1), but I have
proposed https://github.com/facebook/zstd/pull/2450 .  If that is
adopted, we can add -DZSTD_PROGRAMS_LINK_SHARED to our libzstd build and
drop some diffs.

Reported by:	uqs
2021-01-03 07:42:00 -08:00
Mateusz Guzik
82397d7919 vfs: denote vnode being a mount point with VIRF_MOUNTPOINT
Reviewed by:	kib (previous version)
Differential Revision:	https://reviews.freebsd.org/D27794
2021-01-03 06:50:06 +00:00
Mateusz Guzik
3e506a67bb vfs: add v_irflag accessors
Reviewed by:	kib (previous version)
Differential Revision:	https://reviews.freebsd.org/D27793
2021-01-03 06:50:06 +00:00
Mateusz Guzik
51bf55fa6c cache: stop checkpointing cn_namelen
The variable is recomputed by regular lookup from the get go.
2021-01-03 06:50:06 +00:00
Mateusz Guzik
7220a10b5b cache: predict on no spurious slashes in cache_fpl_handle_root
This is a step towards speculatively not handling them.
2021-01-03 06:50:06 +00:00
Mateusz Guzik
30a2fc91fa cache: postpone NAME_MAX check as it may be unnecessary 2021-01-03 06:50:06 +00:00
Mateusz Guzik
eca899bd5d cache: remove spurious null check in sdt probe 2021-01-03 06:50:06 +00:00
Alan Somers
1868a91fac Regenerate syscall files after addition of aio_writev/aio_readv 2021-01-02 19:57:58 -07:00
Alan Somers
022ca2fc7f Add aio_writev and aio_readv
POSIX AIO is great, but it lacks vectored I/O functions. This commit
fixes that shortcoming by adding aio_writev and aio_readv. They aren't
part of the standard, but they're an obvious extension. They work just
like their synchronous equivalents pwritev and preadv.

It isn't yet possible to use vectored aiocbs with lio_listio, but that
could be added in the future.

Reviewed by:    jhb, kib, bcr
Relnotes:       yes
Differential Revision: https://reviews.freebsd.org/D27743
2021-01-02 19:57:58 -07:00
Ryan Libby
486580c44c arm: fix atomic_testand{set,clear}_64 for ops on high bits
The fix in bd03acedb8 worked for 32-bit
ops, and for 64-bit ops for bit arguments of 0 - 95, but then was broken
for operations on the high 32 bits after that.

Reviewed by:	markj, mmel
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D27897
2021-01-02 18:09:37 -08:00
Mitchell Horne
65d1a4cfda Handle KDB_WHY_TRAP return on arm and mips
Upon exit from the debugger, checking the return code of kdb_trap()
allows one to retry the fatal page fault. This matches what is done on
all other architectures.

Reviewed by:	jhb (earlier version)
Differential Revision:	https://reviews.freebsd.org/D27535
2021-01-02 19:07:04 -04:00
Ryan Libby
82661227ed arm64: fix mask in atomic_testand{set,clear}_64
These macros generate both the 32- and 64-bit ops, but the mask was hard
coded for 32-bit ops, causing the 64-bit ops always to affect only the
low 32 bits.

PR:		252324
Reported by:	gbe, mmel
Reviewed by:	markj, mmel
Tested by:	mmel, rwatson
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D27886
2021-01-02 12:13:25 -08:00
Toomas Soome
3630506b9d loader: implement framebuffer console
Draw console on efi.
Add vbe framebuffer for BIOS loader (vbe off, vbe on, vbe list,
vbe set xxx).
autoload font (/boot/fonts) based on resolution and font size.
Add command loadfont (set font by file) and
variable screen.font (set font by size). Pass loaded font to kernel.

Export variables:
screen.height
screen.width
screen.depth

Add gfx primitives to draw the screen and put png image on the screen.
Rework menu draw to iterate list of consoles to enamble device specific
output.

Probably something else I forgot...

Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D27420
2021-01-02 21:41:36 +02:00
Michal Meloun
bd03acedb8 arm: Fix atomic_testand{set,clear}_32(). According to atomic (9), the bit position argument should be a modulo operand size. While I'm in, add missing implementation of atomic_testandclear_64(). For more details see https://reviews.freebsd.org/D27886
Discused with:	rlibby
MFC after:	3 weeks
2021-01-02 20:53:11 +01:00
Konstantin Belousov
51a9b978e7 nfs server: improve use of the VFS KPI
In particular, do not assume that vn_start_write() returns the same mp
as it was passed in, or never returns error.

Also be more accurate to return NULL vp and mp when error occured, to
catch wrong control flow easier.

Stop checking for NULL mp before calling vn_finished_write(), NULL mp
is handled transparently by the function.

Reviewed by:	rmacklem
Tested by:	pho
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D27881
2021-01-02 20:17:12 +02:00
Rick Macklem
dc78533a52 nfsd: fix NFSv4.0 seqid handling for ERELOOKUP
Commit 774a36851e fixed the NFS server so that it could handle
ERELOOKUP returns from VOP calls by redoing the operation/RPC.
However, for NFSv4.0, redoing an Open would increment
the open_owner's seqid multiple times, breaking the protocol.
This patch sets a new flag called ND_ERELOOKUP on the RPC when
a redo is in progress.  Then the code that increments the seqid
avoids the seqid increment/check when the flag is set, since
it indicates this has already been done for the Open.
2021-01-01 14:21:51 -08:00
Rick Macklem
774a36851e nfsd: fix NFS server for ERELOOKUP
r367672 modified UFS such that certain VOPs, such as
VOP_CREATE() will intermittently return ERELOOKUP.
When this happens, the entire system call, or NFS
operation in the case of the NFS server, must be redone.

This patch adds that support to the NFS server by rolling
back the state of the NFS request arguments and NFS
reply arguments mbuf lists to the condition they were
in before the operation and then redoing the operation.

Tested by:	pho
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D27875
2021-01-01 13:55:51 -08:00
Alan Somers
92bbfe1f0d fusefs: implement FUSE_COPY_FILE_RANGE.
This updates the FUSE protocol to 7.28, though most of the new features
are optional and are not yet implemented.

MFC after:	2 weeks
Relnotes:	yes
Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D27818
2021-01-01 10:18:23 -07:00
Michael Tuexen
a7aa5eea4f sctp: improve handling of aborted associations
Don't clear a flag, when the structure already has been freed.
Reported by:	syzbot+07667d16c96779c737b4@syzkaller.appspotmail.com
2021-01-01 15:59:10 +01:00
Jamie Gritton
b58a46347c jail: revert the attachment part of b4e87a6329
The change to kern_jail_set that was supposed to "also properly clean
up when attachment fails" didn't fix a memory leak but actually caused
a double free.  Back that part out, and leave the part that manages
allprison_lock state.
2020-12-31 19:55:49 -08:00
Mateusz Guzik
d71965127f tmpfs: use VNPASS when asserting on a vnode in tmpfs_read_pgcache 2021-01-01 03:23:01 +00:00
Mateusz Guzik
9997aedb8f ufs: use VNPASS when asserting on a vnode in ufs_read_pgcache 2021-01-01 03:14:11 +00:00
Mateusz Guzik
1365b5f86f cache: fold NCF_WHITE check into the rest
Tested by:	pho
2021-01-01 00:10:43 +00:00
Mateusz Guzik
d7c62d98c9 cache: call cache_fplookup_modifying in neg
Tested by:	pho
2021-01-01 00:10:43 +00:00
Mateusz Guzik
6fe7de1a25 cache: refactor cache_fpl_handle_root to fit the rest of the code better
Tested by:	pho
2021-01-01 00:10:43 +00:00
Mateusz Guzik
e17e01bd0e cache: refactor dot handling
Tested by:	pho
2021-01-01 00:10:43 +00:00
Mateusz Guzik
4651db56c7 cache: remove a branch from mount point checking
Tested by:	pho
2021-01-01 00:10:42 +00:00
Mateusz Guzik
0b5bd1afd8 cache: support lockless lookup of degenerate paths
Tested by:	pho
2021-01-01 00:10:42 +00:00
Mateusz Guzik
1d6eb97677 cache: save on branching when parsing the path by inserting a sentinel
Tested by:	pho
2021-01-01 00:10:42 +00:00
Mateusz Guzik
67297766b5 cache: hoist trailing slash and degenerate path handling out of the loop
Tested by:	pho
2021-01-01 00:10:42 +00:00
Mateusz Guzik
bb3a12f0e5 fd: inline pwd_get_smr
Tested by:	pho
2021-01-01 00:10:42 +00:00
John Baldwin
b4247e0cdf ddb: Display process flags (p_flag and p_flag2) in 'show proc'.
Reviewed by:	kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D27872
2020-12-31 16:01:52 -08:00
John Baldwin
3e06c7da02 Use kdb_thr_* to iterate over threads consistently in DDB.
The "findstack", "show all trace", and "show active trace" commands
were iterating over allproc to enumerate threads.  This missed threads
executing in exit1() after being removed from allproc.

Reviewed by:	kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D27829
2020-12-31 16:01:35 -08:00
John Baldwin
ae450907c6 Use kdb_thr_from_pid() in db_lookup_thread().
The code is identical, so this should be a no-op.

Reviewed by:	kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D27828
2020-12-31 16:01:27 -08:00
John Baldwin
825d234144 Don't check P_INMEM in kdb_thr_*().
Not all debugger operations that enumerate threads require thread
stacks to be resident in memory to be useful.  Instead, push P_INMEM
checks (if needed) into callers.

Reviewed by:	kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D27827
2020-12-31 16:01:12 -08:00
John Baldwin
9acce1c992 Enumerate processes via the pid hash table in kdb_thr_*().
Processes part way through exit1() are not included in allproc.  Using
allproc to enumerate processes prevented getting the stack trace of a
thread in this part of exit1() via ddb.

Reviewed by:	kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D27826
2020-12-31 16:00:54 -08:00
John Baldwin
4e7d1b527c Add a proc_off_p_hash helper variable.
This is used by kernel debuggers to enumerate processes via the pid
hash table.

Reviewed by:	kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D27825
2020-12-31 16:00:33 -08:00
John Baldwin
47877889f2 ddb ps: Use the pidhash to enumerate processes not in allproc.
Exiting processes that have been removed from allproc but are still
executing are not yet marked PRS_ZOMBIE, so they were not listed (for
example, if a thread panics during exit1()).  To detect these
processes, clear p_list.le_prev to NULL explicitly after removing a
process from the allproc list and check for this sentinel rather than
PRS_ZOMBIE when walking the pidhash.

While here, simplify the pidhash walk to use a single outer loop.

Reviewed by:	kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D27824
2020-12-31 16:00:05 -08:00
Jamie Gritton
b4e87a6329 jail: Clean up allprison_lock handing in kern_jail_set
Keep explicit track of the allprison_lock state during the final part
of kern_jail_set, instead of deducing it from the JAIL_ATTACH flag.

Also properly clean up when the attachment fails, fixing a long-
standing (though minor) memory leak.
2020-12-31 15:18:43 -08:00
Ryan Libby
942951ba46 uma dbg: catch more corruption with atomics
Use atomic testandset and testandclear to catch concurrent double free,
and to reduce the number of atomic operations.

Submitted by:	jeff
Reviewed by:	cem, kib, markj (all previous version)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D22703
2020-12-31 13:02:45 -08:00
Ryan Libby
ae4a8e5207 bitset: implement BIT_TEST_CLR_ATOMIC & BIT_TEST_SET_ATOMIC
That is, provide wrappers around the atomic_testandclear and
atomic_testandset primitives.

Submitted by:	jeff
Reviewed by:	cem, kib, markj
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D22702
2020-12-31 13:02:45 -08:00
Ed Maste
1e54857bd9 Stop defaulting to DWRAF2 in kernel compilation
After the removal of obsolete GDB 6.1.1 from the base system in
1c0ea326aa we no longer need to downgrade to DWARF2 debug info.

We will need to ensure that our tools (e.g. ctfconvert) handle DWARF5
prior to it becoming the default in the Clang and GCC versions we use.

Reported by:	jhb
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
2020-12-31 15:56:18 -05:00
Kyle Evans
202aea9c82 arm: tune vmparam.h towards a little more modern
An 8MB max stack size is quite limiting in today's world, and in-fact is
the *default* stack size for almost every other arch (including mips).

Raise the default to 4MB (should be pretty reasonable) and the max to 64MB.
NetBSD made a similar move back in 2015 and raised MAXDSIZ to 1856 at the
same time, so let's just roll that in as well. They later lowered it, but
eventually raised it back to 1856 in order to build rust.

This was noticed while looking at qemu-bsd-user's default stack sizes and
growth behavior (or lack thereof).

Reviewed by:	ian
Differential Revision:	https://reviews.freebsd.org/D27218
2020-12-31 11:13:13 -06:00
Kyle Evans
c4a0333b55 vt: restore tty when console is ungrabbed
When a break-to-debugger is triggered, kdb will grab the console and vt(4)
will generally switch back to ttyv0. If one issues a continue from the
debugger, then kdb will ungrab the console and the system rolls on.

This change adds a perhaps minor feature: when we're down to grab == 0 and
if vt actually switched away to ttyv0, switch back to the tty it was
previously on before the console was grabbed.

The justification behind this is that a typical flow is to work in
!ttyv0 to avoid console spam while occasionally dropping to ddb to inspect
system state before returning. This could easily enough be tossed behind
a sysctl or something if it's not generally appreciated, but I anticipate
indifference.

Reviewed by:	ray
Differential Revision:	https://reviews.freebsd.org/D27110
2020-12-31 11:10:11 -06:00
Kyle Evans
be46634337 vt: more carefully handle vt_allocate_keyboard grab work
vt_allocate_keyboard only needs to unwind the effects of keyboard-grabbing,
rather than any associated vt window action that may have also happened.

Split out the bits that do the keyboard work into *_noswitch equivalents,
and use those in keyboard allocation. This will be less error-prone when a
later change will offer up different window state behavior when the console
is ungrabbed.

Reviewed by:	ray
Differential Revision:	https://reviews.freebsd.org/D27110
2020-12-31 11:10:11 -06:00
Alan Somers
37df9d3bba fusefs: update FUSE protocol to 7.24 and implement FUSE_LSEEK
FUSE_LSEEK reports holes on fuse file systems, and is used for example
by bsdtar.

MFC after:	2 weeks
Relnotes:	yes
Reviewed by:	cem
Differential Revision: https://reviews.freebsd.org/D27804
2020-12-31 08:51:47 -07:00
Glen Barber
c3e89a30fd copyrights: Happy New Year 2021
Good riddance 2020.

Sponsored by:	Rubicon Communications, LLC (netgate.com)
2020-12-31 10:29:44 -05:00
Andrew Turner
80062279f7 Add pmu.h missed in 5e78bbb74a
Reported by:	rlibby
Sponsored by:	Innovate UK
2020-12-31 10:12:34 +00:00
Hans Petter Selasky
747feea146 Streamline the infiniband code according to the ethernet code.
Fix LINT-NOIP kernel build.

Submitted by:	rlibby @
Differential Revision:	https://reviews.freebsd.org/D27861
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2020-12-31 10:07:02 +01:00
John Baldwin
282381aa53 rsu: Don't modify read-only firmware block.
The firmware header loaded into an rsu(4) device has to be customized
to reflect device settings.  The driver was overwriting the header
from the shared firmware image before sending it to the device.  If
two devices attached at the same time with different settings, one
device could potentially get a corrupted header.  The recent changes
in a095390344 exposed this bug in the
form of a panic as the firmware blobs are now marked read-only in
object files and mapped read-only by the kernel.

To avoid the bug, change the driver to allocate a copy of the firmware
header on the stack that is initialized before writing it to the
device.

PR:		252163
Reported by:	vidwer+fbsdbugs@gmail.com
Tested by:	vidwer+fbsdbugs@gmail.com
Reviewed by:	hselasky, bz, emaste
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D27850
2020-12-30 15:21:35 -08:00
Alfredo Dal'Ava Junior
4f250d9436 [POWERPC64LE] enable IPMI using OPAL bus
Enable build of IPMI over OPAL on powerpc64le

Reviewed by:	bdragon
Sponsored by:	Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D27443
2020-12-30 22:55:53 -03:00
Justin Hibbits
76ff03aef7 powerpc: Fix copyin/copyout race condition
It's possible for a context switch, and CPU migration, to occur between
fetching the PCPU context and extracting the pc_curpcb.  This can cause
the fault handler to be installed for the wrong thread, leading to a
panic in copyin()/copyout().  Since curthread is already in %r13, just
use that directly, as GPRs are migrated, so there is no migration race
risk.
2020-12-30 23:45:44 +01:00
Justin Hibbits
6260bfb087 powerpc: Optimize copyinstr() to avoid repeatedly mapping user strings
Currently copyinstr() uses fubyte() to read each byte from userspace.
However, this means that for each byte, it calls pmap_map_user_ptr() to
map the string into memory.  This is needlessly wasteful, since the
string will rarely ever cross a segment boundary.  Instead, map a
segment at a time, and copy as much from that segment as possible at a
time.

Measured with the HPT pmap on powerpc64, this saves roughly 8% time on
buildkernel, and 5% on buildworld, in wallclock time.
2020-12-30 23:45:35 +01:00
Justin Hibbits
adf79abc35 Radix dump updates 2020-12-30 23:45:28 +01:00
Justin Hibbits
7d7f26f5b6 powerpc/radix_mmu: Apply errata fixes for POWER9 TLB invalidation bug
Found in Linux, the only apparent source of errata documentation.
2020-12-30 23:45:21 +01:00
Justin Hibbits
ac19bf854b powerpc/aim: Add machine check handler for TLB multihit
Handle TLB multi-hit the same as ERAT multi-hit, by flushing the full
TLB.
2020-12-30 23:45:10 +01:00
Alfredo Dal'Ava Junior
6d2254bc92 [POWERPC64LE] fix sysctl dev.opal_sensor.* on little-endian kernel
- fix values returned by 'sysctls dev.opal_sensor.*.sensor'
- fix missing 'dev.opal_sensor.*.sensor_[max|min]' on sysctl

Reviewed-by: 	jhibbits
Sponsored-by:	Eldorado Research Institute (eldorado.org.br)
Differential-Revision: 	https://reviews.freebsd.org/D27365
2020-12-30 22:00:28 -03:00
John Baldwin
6727847500 Don't try to adjust a TLS TOE socket that has been closed.
The handshake timer can race with another thread sending a FIN or RST
to close a TOE TLS socket.  Just bail from the timer without
rescheduling if the connection is closed when the timer fires.

Reported by:	Sony Arpita Das @ Chelsio QA
Reviewed by:	np
Differential Revision:	https://reviews.freebsd.org/D27583
2020-12-30 09:56:24 -08:00
Andrew Turner
5e78bbb74a Split out the FDT arm pmu attachment
This will allow us to add an ACPI attachment.

Submitted by:	Greg V <greg@unrelenting.technology> (earlier version)
Sponsored by:	Innovate UK
2020-12-30 16:11:02 +00:00
Michal Meloun
28482babd0 arm64: Use new arm_kernel_boothdr script for generating booti images. 2020-12-30 13:56:11 +01:00
Michal Meloun
59f46e34cf sys/tools: Add a tool for generating arm and arm64 kernel images.
This tool can generate kernel images without changing the offsets in
the final executable. It replaces the ELF header by properly sized zeroed
block then emits a relative jump to _start(for  'v7jump' or 'v8jump' option)
or the booti header (for 'v8booti' option) to the beginning of the converted file.
Submited by:	ian
2020-12-30 13:22:04 +01:00
Roger Pau Monné
4e4e43dc9e xen: allow limiting the amount of duplicated pending xenstore watches
Xenstore watches received are queued in a list and processed in a
deferred thread. Such queuing was done without any checking, so a
guest could potentially trigger a resource starvation against the
FreeBSD kernel if such kernel is watching any user-controlled xenstore
path.

Allowing limiting the amount of pending events a watch can accumulate
to prevent a remote guest from triggering this resource starvation
issue.

For the PV device backends and frontends this limitation is only
applied to the other end /state node, which is limited to 1 pending
event, the rest of the watched paths can still have unlimited pending
watches because they are either local or controlled by a privileged
domain.

The xenstore user-space device gets special treatment as it's not
possible for the kernel to know whether the paths being watched by
user-space processes are controlled by a guest domain. For this reason
watches set by the xenstore user-space device are limited to 1000
pending events. Note this can be modified using the
max_pending_watch_events sysctl of the device.

This is XSA-349.

Sponsored by:	Citrix Systems R&D
MFC after:	3 days
2020-12-30 11:18:26 +01:00
Roger Pau Monné
2ae75536d3 xen/xenstore: remove unused functions
Those helpers are not used, so remove them. No functional change.

Sponsored by:	Citrix Systems R&D
MFC after:	3 days
2020-12-30 11:18:25 +01:00