Commit Graph

868 Commits

Author SHA1 Message Date
Warner Losh
031beb4e23 sys: Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:58 -06:00
Warner Losh
685dc743dc sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:36 -06:00
Warner Losh
95ee2897e9 sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:11 -06:00
Vladimir Kondratyev
4b1712817e hid: Add child device parameter to HID methods
Some devices like Apple HID-over-SPI may contain more than one report
descriptors necessitating creation of multiple hidbus children.
Add indentificator of child devices to distinct them.
No functional changes intended.

Differential Revision:	https://reviews.freebsd.org/D41246
2023-08-03 19:10:50 +03:00
Wei Hu
17050a2b5b Hyper-V: vmbus: Prevent load/store reordering when access ring buffer index
When running VM on ARM64 Hyper-V, we have seen netvsc/hn driver hit
assert on reading duplicated network completion packets over vmbus
channel or one of the tx channels stalls completely. This seems to
caused by processor reordering the instructions when vmbus driver
reading or updating its channel ring buffer indexes.

Fix this by using load acquire and store release instructions to
enforce the order of these memory accesses.

PR:		271764
Reported by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Reviewed by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Tested by:	whu
Sponsored by:	Microsoft
2023-06-21 10:10:49 +00:00
Wei Hu
4f8c634de0 arm64 Hyper-V: enable Hyper-V SMP for ARM64
Vmbus_synic_setup() is invoked via vmbus_intrhook -> vmbus_doattach
-> smp_rendezvous. On !EARLY_AP_STARTUP (e.g., aarch64), SMP isn't
functional in intrhooks and smp_rendezvous() will just call
vmbus_synic_setup() on the boot processor. There's nothing that will
initialize the pcpu data on every other AP.

To fix it we need to use SI_SUB_SMP for vmbus_doattach(). With this
patch the vmbus interrupt should work on all arm64 cpus on HyperV.

Reported by:	kevans
Reviewed by:	kevans, whu
Tested by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Obtained from:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D40279
2023-06-07 08:24:13 +00:00
Andrew Turner
62f9bcf2b4 Switch to contigmalloc in the Hyper-V code
In the Hyper-V drivers we need to allocate buffers shared between the
host and guest. This memory has been allocated with bus_dma, however
it doesn't use this correctly, e.g. it is missing calls to
bus_dmamap_sync. Along with this on arm64 we need this memory to be
mapped with the correct memory type that bus_dma may not use.

Switch to contigmalloc to allocate this memory as this will correctly
allocate cacheable memory.

Reviewed by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D40227
2023-06-06 10:50:59 +01:00
Warner Losh
4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Justin Hibbits
4db5958a06 Mechanically convert if_hn(4) to IfAPI
Reviewed by:	zlei
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D37855
2023-05-02 14:34:47 -04:00
Robert Herndon
b086426bc2 hyperv: Fix Coverity issues in the Hyper-V driver
Summary:
Coverity reports the use of two uninitialized variables in the hyperv
driver. Examination shows the variables can be accessed while
uninitialized in error cases. Fix both.

CID: 1365235
CID: 1365236
Sponsored by: Dell Technologies
MFC after: 1w

Test Plan: Changes in use at $WORK

Reviewers: robert.herndon_dell.com, vangyzen, bret_ketchum_dell.com

Subscribers: imp, badger

Differential Revision: https://reviews.freebsd.org/D38551
2023-02-15 18:24:45 -06:00
Stefan Eßer
f20058955c sys/kbio.h: make pre-unicode keymap support optional
FreeBSD-9 had introduced support for the full set of Unicode
characters to the parsing and processing of keymap character tables.

This support has been extended to cover the table for accented
characters that are reached via dead key combinations in FreeBSD-13.2.

New ioctls have been introduced to support both the pre-Unicode and
the Unicode formats and keyboard drivers have been extended to support
those ioctls.

This commit makes the ABI compatibility functions in the kernel
optional and dependent on COMPAT_FREEBSD13 in -CURRENT.

The kbdcontrol command in -CURRENT and 13-STABLE (before 13.2) has
been made ABI compatible with old kernels to allow a new world to be
run on an old kernel (that does not have full Unicode support for
keymaps).

This commit is not to merged back to 12-STABLE or 13-STABLE. It is
part of review D38465, which has been split into 3 separate commits
due to different MFC and life-time requirements of either commit.

Approved by:	imp
Differential Revision:	https://reviews.freebsd.org/D38465
2023-02-14 14:03:28 +01:00
Stefan Eßer
4972fb9276 Support Unicode characters in keymap dead key tables
Support for Unicode characters had been added to the keyboard code,
but there are keymaps that have accented characters accessed via dead
key combinations, and those were still restricted to 8 bit codes.

This update to kbd.c adds support for Unicode characters and
compatibility code that allows a kbdcontrol command built from kbio.h
without these patches to work on a new kernel.

Compatibility code that allows a new kbdcontrol binary running on an
old kernel to load and display the dead key map will be committed in a
separate commit.

Reviewed by:	imp, brooks
Approved by:	brooks
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D38381
2023-02-06 23:48:47 +01:00
Yuri
e4d3f1e40a hv_hid: Hyper-V HID driver
Hyper-V HID driver using hidbus/hms.

Reviewed by:	wulf
MFC after:	1 week
PR:		221074
Differential revision:	https://reviews.freebsd.org/D38140
2023-02-05 18:32:08 +03:00
Elliott Mitchell
b02a397789 hyperv: purge EOL release compatibility
Remove FreeBSD 11 and earlier support

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/603
Differential Revision: https://reviews.freebsd.org/D35560
2023-02-04 09:13:09 -07:00
Wei Hu
c75ae52216 arm64: Hyper-V: vPCI: Fix typo and some indentations
Fix a typo and some indentation errors in the previous commits.

Reported by:	jrtc27
Fixes:	db247798c5 ("arm64: Hyper-V: vPCI: SPI MSI mapping for gic v3 acpi in arm64")
Fixes:	6e5b082cab ("arm64: Hyper-V: vPCI: Adding Hyper-V PCI protocol 1.4")
Sponsored by:	Microsoft
2023-02-01 17:34:19 +00:00
Wei Hu
ea11861e43 arm64: Hyper-V: vPCI: Enabling v-PCI in FreeBSD in ARM64 Hyper-V
This patch does remaining enablement in hyperv vpci driver to work
on arm64 Hyper-V. For that it required to use PCI protocol 1.4 and
corresponding different PCI message handling. Also new MSI allocation,
MSI-X mapping, release.

This is the last patch of total three patches to enalbe Hyper-V vPCI
support in arm64.

Reviewed by:	whu
Tested by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Obtained from:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D37958
2023-02-01 16:59:27 +00:00
Wei Hu
6e5b082cab arm64: Hyper-V: vPCI: Adding Hyper-V PCI protocol 1.4
This is enabling the PCI protocol 1.4 and corresponding structures
in order to support arm64 Hyper-V.

This is the 2nd of the three patches to enable Hyper-V vPCI support
in arm64.

Reviewed by:	whu
Tested by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Obtained from:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D37780
2023-02-01 16:00:10 +00:00
Vladimir Kondratyev
183088934a evdev: Extend EVIOCGRAB ioctl scope to cover kbd interface
of various keyboard drivers.
EVIOCGRAB ioctl execution on /dev/input/event# device node gains
exclusive access to this device to caller. It is used mostly for
development purposes and remote control software. See e.g.
https://reviews.freebsd.org/D30020 which is the reason of creation
of this change.
Keyboard grabbing is disabled in KDB and during panics.

MFC with:	4a0db5e292
Tested by:	corvink
Differential revision:	https://reviews.freebsd.org/D30542
2022-11-19 02:54:46 +03:00
Souradeep Chakrabarti
602861820d arm64: Hyper-V: making INTR MP Safe
Makeing the interrupt MP safe.

Reviewed by:	andrew
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D37222
2022-11-04 10:20:16 +00:00
Souradeep Chakrabarti
654749832b arm64: Hyper-V: fixing hung issue during Hyper-V initialization
In non-Hyper-V systems during Hyper-V initialization, system
initialization was getting hung, as hyperv_identify(),
was returning successful irrespective of the type of the platform.

Reviewed by:	andrew, whu
Fixes:	9729f076e4
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D37219
2022-11-01 14:13:50 +00:00
Souradeep Chakrabarti
9729f076e4 arm64: Hyper-V: enablement for ARM64 in Hyper-V (Part 3, final)
This is the last part for ARM64 Hyper-V enablement. This includes
commone files and make file changes to enable the ARM64 FreeBSD
guest on Hyper-V. With this patch, it should be able to build
the ARM64 image and install it on Hyper-V.

Reviewed by:	emaste, andrew, whu
Tested by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D36744
2022-10-27 13:53:22 +00:00
Souradeep Chakrabarti
d16d0b6b19 Hyper-V: Code refactor to avoid redundancy of MSR values on x86 and arm64
Refactor the code to put split the MSR values for x86 and arm64
Hyper-V. Code not yet built. This is one of several patches for
the arm64 Hyper-V enablement.

Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D37103
2022-10-26 03:50:59 +00:00
Wei Hu
2db785aa01 arm64: Hyper-V: fix couple more commit errors caused by duplicated lines
Remove those duplicated lines.

Reported by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Fixes:		6cf00ef80c
Sponsored by:	Microsoft
2022-10-24 08:14:25 +00:00
Wei Hu
443e6eccbd arm64: Hyper-V: fix a commit error caused duplicated lines in vmbus_aarch64.c
Remove those duplicated lines.

Reported by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Fixes:	6cf00ef80c
Sponsored by:	Microsoft
2022-10-21 11:09:17 +00:00
Souradeep Chakrabarti
3f8f02b2ab arm64: Hyper-V: enablement for ARM64 in Hyper-V (Part 2)
This is the second part of the ARM64 Hyper-V enablement.
These changes here are mostly with Make, release changes and also
changes required in vmbus.c hyperv.c and common files in hyperv.

Reviewed by:	whu
Tested by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D36467
2022-10-21 09:46:22 +00:00
Souradeep Chakrabarti
0c38e1c338 arm64: Hyper-V: vmbus: use the IRQ resource from vmbus_res
In ARM64 gen2 Hyper-V, use IRQ resource from vmbus_res, which is owning
the IRQ for current device tree. It allows the MMIO resource to be
successfully allocated for vmbus from parent acpi_syscontainer.
Reviewed by:	whu
Tested by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D37064
2022-10-21 08:40:32 +00:00
Souradeep Chakrabarti
6cf00ef80c arm64: enablement for ARM64 in Hyper-V (Part 1)
The changes are to refactor the code of vmbus.c and hyperv.c to keep minimal
arch specific codes there and have them in separate files in x86/ arm64/ .
x86 is a new directory, which contains codes for x86 / x86_64. Instead of
repeating the same codes in existing amd64/ and i386/, this approach reduced
the repetition. This is first of three patches for Hyper-V enablement.

Reviewed by:	whu
Tested by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D36466
2022-09-29 10:14:41 +00:00
John Baldwin
f49fd63a6a kmem_malloc/free: Use void * instead of vm_offset_t for kernel pointers.
Reviewed by:	kib, markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D36549
2022-09-22 15:09:19 -07:00
Wei Hu
6f7b1310b6 Hyper-V: storvsc: relax a couple more kasserts
Seems these kasserts don't work well on ARM64

Fixes:	0af5a0cd27
Sponsored by:	Microsoft
2022-09-08 04:22:26 +00:00
Wei Hu
0af5a0cd27 Hyper-V: storvsc: relax a kassert check
On ARM64 this kassert check could cause unnecessary panic.

Sponsored by:	Microsoft
2022-09-07 15:06:54 +00:00
Gordon Bergling
630c517745 hyperv: Fix a typo in a source code comment
- s/Unsupport/Unsupported/

MFC after:	3 days
2022-09-04 17:19:40 +02:00
Gordon Bergling
26d6e38604 hyperv: Remove a double word in a source code comment
- s/the the/the/

MFC after:	3 days
2022-09-04 13:49:47 +02:00
Gleb Smirnoff
e7d02be19d protosw: refactor protosw and domain static declaration and load
o Assert that every protosw has pr_attach.  Now this structure is
  only for socket protocols declarations and nothing else.
o Merge struct pr_usrreqs into struct protosw.  This was suggested
  in 1996 by wollman@ (see 7b187005d1), and later reiterated
  in 2006 by rwatson@ (see 6fbb9cf860).
o Make struct domain hold a variable sized array of protosw pointers.
  For most protocols these pointers are initialized statically.
  Those domains that may have loadable protocols have spacers. IPv4
  and IPv6 have 8 spacers each (andre@ dff3237ee5).
o For inetsw and inet6sw leave a comment noting that many protosw
  entries very likely are dead code.
o Refactor pf_proto_[un]register() into protosw_[un]register().
o Isolate pr_*_notsupp() methods into uipc_domain.c

Reviewed by:		melifaro
Differential revision:	https://reviews.freebsd.org/D36232
2022-08-17 11:50:32 -07:00
Wei Hu
795a997414 Hyper-V: storvsc: Call bus_dmamap_sync() for dma operations
Call bus_dmamap_sync() for related dma operations. This is required
on ARM64 architecture.

Tested by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
MFC after:	2 weeks
Sponsored by:	Microsoft
2022-08-15 07:05:43 +00:00
Mitchell Horne
35eb9b10c2 Use KERNEL_PANICKED() in more places
This is slightly more optimized than checking panicstr directly. For
most of these instances performance doesn't matter, but let's make
KERNEL_PANICKED() the common idiom.

Reviewed by:	mjg
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D35373
2022-06-02 10:15:43 -03:00
Gleb Smirnoff
4328318445 sockets: use socket buffer mutexes in struct socket directly
Since c67f3b8b78 the sockbuf mutexes belong to the containing socket,
and socket buffers just point to it.  In 74a68313b5 macros that access
this mutex directly were added.  Go over the core socket code and
eliminate code that reaches the mutex by dereferencing the sockbuf
compatibility pointer.

This change requires a KPI change, as some functions were given the
sockbuf pointer only without any hint if it is a receive or send buffer.

This change doesn't cover the whole kernel, many protocols still use
compatibility pointers internally.  However, it allows operation of a
protocol that doesn't use them.

Reviewed by:		markj
Differential revision:	https://reviews.freebsd.org/D35152
2022-05-12 13:22:12 -07:00
John Baldwin
c1cef544f7 hyperv: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-06 15:46:58 -07:00
John Baldwin
039880009a hyperv: Use __diagused for a variable only used in KASSERT(). 2022-04-13 16:08:20 -07:00
John Baldwin
b024faffa0 hyperv storvsc: Remove unused variables. 2022-04-06 16:45:28 -07:00
Wei Hu
5473dee730 Hyper-V: vPCI: Write back original BAR values after prepopulating bars
In vmbus_pcib_prepopulate_bars(), after writing all 1's to the
avialable device bars, those without being configured by device driver
are also set to its initialized values. However, this could cause
weird problem which results to device failure. The issue has been
reported to happen on LSI 9211-8i HBA card for DDA access on Hyper-V.
Writing back the orignal BAR values seem to work around this problem.

Reported by:	Alexander Motin <mavbsd@gmail.com>
Tested by:	Mathias Kraut <krautmaster@gmail.com>
Fixes:		75412a521f Hyper-V: vPCI: Prepopulate device bars
MFC after:	1 month
2022-03-30 06:56:09 +00:00
Wei Hu
80c3eb7bc6 Hyper-V: hn: add switch to turn on and off RSC
Currently RSC offloading is enabled by default.
With this new change rsc will be disabled by default.
By using sysctl we can enable and disable it.

Reviewed by:	whu
Signed-off-by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Fixes:		a491581f3f Enable vSwitch RSC support in hn netvsc driver
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D34507
2022-03-15 08:12:22 +00:00
John Baldwin
53e938e408 hyperv storvsc: Don't abuse struct sglist to hold virtual addresses.
struct sglist is intended for holding S/G lists of physical address
ranges, not virtual address ranges.  GCC 9.x issues several warnings
due to casts between pointers and integers of different sizes as a
result (vm_paddr_t is 64-bits on i386).  Instead, add a local 'struct
hv_sglist' which uses an array of 'struct iovec' to hold the S/G list
of virtual address ranges.

Differential Revision:	https://reviews.freebsd.org/D31933
2022-01-31 17:11:27 -08:00
Gleb Smirnoff
644ca0846d domains: make domain_init() initialize only global state
Now that each module handles its global and VNET initialization
itself, there is no VNET related stuff left to do in domain_init().

Differential revision:	https://reviews.freebsd.org/D33541
2022-01-03 10:15:22 -08:00
Gleb Smirnoff
89128ff3e4 protocols: init with standard SYSINIT(9) or VNET_SYSINIT
The historical BSD network stack loop that rolls over domains and
over protocols has no advantages over more modern SYSINIT(9).
While doing the sweep, split global and per-VNET initializers.

Getting rid of pr_init allows to achieve several things:
o Get rid of ifdef's that protect against double foo_init() when
  both INET and INET6 are compiled in.
o Isolate initializers statically to the module they init.
o Makes code easier to understand and maintain.

Reviewed by:		melifaro
Differential revision:	https://reviews.freebsd.org/D33537
2022-01-03 10:15:21 -08:00
Warner Losh
f581847a72 hyperv: scanning locking is using the bus mtx
The scanning code uses Giant to coordinate its accesses to newbus as
well as to synchronize a little state within hyperv's vmbus. Switch to
the new bus_topo_* functions instead of referring to Giant explicitly.

Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D31840
2021-12-14 16:53:09 -07:00
Mateusz Guzik
a0f49d6768 hn: plug set-but-not-unused vars
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-12-10 12:09:26 +00:00
Warner Losh
c6df6f5322 Create wrapper for Giant taken for newbus
Create a wrapper for newbus to take giant and for busses to take it too.
bus_topo_lock() should be called before interacting with newbus routines
and unlocked with bus_topo_unlock(). If you need the topology lock for
some reason, bus_topo_mtx() will provide that.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D31831
2021-12-09 17:04:45 -07:00
Gleb Smirnoff
d74b7baeb0 ifnet_byindex() actually requires network epoch
Sweep over potentially unsafe calls to ifnet_byindex() and wrap them
in epoch.  Most of the code touched remains unsafe, as the returned
pointer is being used after epoch exit.  Mark that with a comment.

Validate the index argument inside the function, reducing argument
validation requirement from the callers and making V_if_index
private to if.c.

Reviewed by:		melifaro
Differential revision:	https://reviews.freebsd.org/D33263
2021-12-06 09:32:31 -08:00
Cy Schubert
db0ac6ded6 Revert "wpa: Import wpa_supplicant/hostapd commit 14ab4a816"
This reverts commit 266f97b5e9, reversing
changes made to a10253cffe.

A mismerge of a merge to catch up to main resulted in files being
committed which should not have been.
2021-12-02 14:45:04 -08:00
Cy Schubert
266f97b5e9 wpa: Import wpa_supplicant/hostapd commit 14ab4a816
This is the November update to vendor/wpa committed upstream 2021-11-26.

MFC after:      1 month
2021-12-02 13:35:14 -08:00