aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/hyperv
Commit message (Collapse)AuthorAgeFilesLines
* hyperv/hn: Don't return error when setting media to autoselectMark Peek2024-03-311-1/+2
| | | | | | | | | | | | | | Setting media to autoselect would always return EOPNOTSUPP. As autoselect is the only valid media, this change now returns success instead. PR: 264253 Reported by: Prakash Shiva <prakashs0234@gmail.com> Reviewed by: Dexuan Cui <decui microsoft com>, whu Approved by: whu MFC after: 2 weeks (cherry picked from commit 63a7c4be4ad524629292eee659d6542f1c5e9c21)
* Hyper-V: vPCI: fix cpu id mis-mapping in vmbus_pcib_map_msi()Wei Hu2024-03-111-1/+9
| | | | | | | | | | | | | | | | | | | The msi address contains apic id. The code in vmbus_pcib_map_msi() treats it as cpu id, which could cause mis-configuration of msix IRQs, leading to missing interrupts for SRIOV devices. This happens when apic id is not the same as cpu id on certain large VM sizes with multiple numa domains in Azure. Fix this issue by correctly mapping apic ids to cpu ids. On vPCI version before 1.4, it only supports up to 64 vcpus for msi/msix interrupt. This change also adds a check and returns error if the vcpu_id is greater than 63. (cherry picked from commit 999174ba03642fa63c9654752993a62db461afc9) Reported by: NetApp Tested by: whu Sponsored by: Microsoft
* if_hn: Fix two typos in source code commentsGordon Bergling2024-02-272-2/+2
| | | | | | | | | - s/managment/management/ - s/transacion/transaction/ Obtained from: NetBSD (cherry picked from commit 61b88a230bac766f55984d8d33b98845d2b0d1a9)
* hv_kbd: Fix build with EVDEV_SUPPORT kernel option disabled.Vladimir Kondratyev2024-01-271-2/+1
| | | | | | | Reported by: olivier PR: 268653 (cherry picked from commit 55eb41bb1fb69429330ea415fb463735ae08da64)
* hvsock: Fix a typo in a source code commentGordon Bergling2024-01-071-1/+1
| | | | | | - s/recieved/received/ (cherry picked from commit 6dc7bf0c5ce9ce0b77b0f7b9293467babc685abe)
* Hyper-V: vmbus: check if signaling host is needed in vmbus_rxbr_readWei Hu2023-10-203-4/+19
| | | | | | | | | | | | | | | | | | | It is observed that netvsc's send rings could stall on the latest Azure Boost platforms. This is due to vmbus_rxbr_read() routine doesn't check if host is waiting for more room to put data, which leads to host side sleeping forever on this vmbus channel. The problem was only observed on the latest platform because the host requests larger buffer ring room to be available, which causes the issue to happen much more easily. Fix this by adding check in the vmbus_rxbr_read call and signaling the host in the callers if check returns positively. Reported by: NetApp Tested by: whu Sponsored by: Microsoft (cherry picked from commit 49fa9a64372b087cfd66459a20f4ffd25464b6a3)
* sys: Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-231-1/+0
| | | | | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/ Similar commit in current: (cherry picked from commit 031beb4e239b)
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-2324-48/+0
| | | | | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/ Similar commit in current: (cherry picked from commit 685dc743dc3b)
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-2326-52/+0
| | | | | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/ Similar commit in current: (cherry picked from commit 95ee2897e98f)
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-07-256-6/+6
| | | | | | | | | | | 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 (cherry picked from commit 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
* hv_hid: Hyper-V HID driverYuri2023-03-311-0/+564
| | | | | | | | | | | Hyper-V HID driver using hidbus/hms. Reviewed by: wulf MFC after: 1 week PR: 221074 Differential revision: https://reviews.freebsd.org/D38140 (cherry picked from commit e4d3f1e40ab3327e4ff6f689f54a64bd2ebc0568)
* Support Unicode characters in keymap dead key tablesStefan Eßer2023-02-091-0/+1
| | | | | | | | | | | | | | | | | | | | | 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 (cherry picked from commit 4972fb9276389fb87a790b415b1161cff395884c)
* evdev: Extend EVIOCGRAB ioctl scope to cover kbd interfaceVladimir Kondratyev2022-12-241-0/+2
| | | | | | | | | | | | 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. (cherry picked from commit 183088934a6c4384e45ac6d01c04754e0d7a991c)
* hv_kbd: Add support for K_XLATE and K_CODE modes for gen 2 VMsVladimir Kondratyev2022-12-242-56/+273
| | | | | | That fixes disabled keyboard input after Xorg server has been stopped. (cherry picked from commit e4643aa4c4ffd385a5be635a488cf10fb6d6cf68)
* hv_kbd: Add evdev protocol support for gen 2 VMsVladimir Kondratyev2022-12-242-1/+94
| | | | (cherry picked from commit c2a159286c7694306fde8c161af47a220e1a76f2)
* hyperv: Remove a double word in a source code commentGordon Bergling2022-09-071-1/+1
| | | | | | - s/the the/the/ (cherry picked from commit 26d6e38604494539ee96935e9fd6cfa1341bf6e2)
* hyperv: Fix a typo in a source code commentGordon Bergling2022-09-071-1/+1
| | | | | | - s/Unsupport/Unsupported/ (cherry picked from commit 630c51774523274cb3f616aefd0be7b747dca991)
* Use KERNEL_PANICKED() in more placesMitchell Horne2022-06-231-1/+1
| | | | | | | | | | | | 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 (cherry picked from commit 35eb9b10c265a27ce1f80a6eb74887240c7f4305)
* Create wrapper for Giant taken for newbusWarner Losh2022-06-211-2/+2
| | | | | | | | | | | | | 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 (cherry picked from commit c6df6f5322f7004c71216391e1c0b374d853704a)
* hyperv storvsc: Don't abuse struct sglist to hold virtual addresses.John Baldwin2022-05-111-33/+31
| | | | | | | | | | | | | 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 (cherry picked from commit 53e938e408be78a45c82012ca7a7be50b216159b)
* Hyper-V: hn: Enter network epoch when requiredMichael Tuexen2021-12-101-0/+8
| | | | | PR: 254695 (cherry picked from commit 26d79d40a74fc804c76acd88a1f8f10f9827a2b3)
* if_hn: Fix a few typos in comments and a sysctl descriptionGordon Bergling2021-12-031-3/+3
| | | | | | - s/segement/segment/ (cherry picked from commit b15a632c418f6532fe7c3002b4085c61b1e278b0)
* Hyper-V: vPCI: Prepopulate device barsWei Hu2021-11-301-0/+43
| | | | | | | | | | | | | | | | | | In recent Hyper-V releases on Windows Server 2022, vPCI code does not initialize the last 4 bit of device bar registers. This behavior change could result weird problems cuasing PCI code failure when configuring bars. Just write all 1's to those bars whose probed values are not the same as current read ones. This seems to make Hyper-V vPCI and pci_write_bar() to cooperate correctly on these releases. Reported by: khng@freebsd.org Tested by: khng@freebsd.org MFC after: 2 weeks Sponsored by: Microsoft (cherry picked from commit 75412a521f60d4b0393c730ffb284e7c6ff9d2de)
* hyperv: Register the MSR-based timecounter during SI_SUB_HYPERVISORMark Johnston2021-11-221-9/+7
| | | | | | | | | | | | | This reverts commit 9ef7df022a46 ("hyperv: Register hyperv_timecounter later during boot") and adds a comment explaining why the timecounter needs to be registered as early as it is. PR: 259878 Fixes: 9ef7df022a46 ("hyperv: Register hyperv_timecounter later during boot") Reviewed by: kib Sponsored by: The FreeBSD Foundation (cherry picked from commit ed6a9452be01c1b7805d0a7311211b8cf381a9dd)
* hyperv: Register hyperv_timecounter later during bootMark Johnston2021-11-011-2/+8
| | | | | | | | | | | | | | | | | | Previously the MSR-based timecounter was registered during SI_SUB_HYPERVISOR, i.e., very early during boot, and before SI_SUB_LOCK. After commit 621fd9dcb2d8 this triggers a panic since the timecounter list lock is not yet initialized. The hyperv timecounter does not need to be registered so early, so defer that to SI_SUB_DRIVERS, at the same time the hyperv TSC timecounter is registered. Reported by: whu Approved by: whu Fixes: 621fd9dcb2d8 ("timecounter: Lock the timecounter list") Sponsored by: The FreeBSD Foundation (cherry picked from commit 9ef7df022a467776aa616b92fe5783e4261e84c6)
* pvclock: Add vDSO supportAdam Fenn2021-10-101-0/+2
| | | | (cherry picked from commit d4b2d3035a23d5dc468d41151487a8299bf45cdc)
* socket: Rename sb(un)lock() and interlock with listen(2)Mark Johnston2021-10-071-18/+13
| | | | | | | | | | | | | | | | | | | | | | In preparation for moving sockbuf locks into the containing socket, provide alternative macros for the sockbuf I/O locks: SOCK_IO_SEND_(UN)LOCK() and SOCK_IO_RECV_(UN)LOCK(). These operate on a socket rather than a socket buffer. Note that these locks are used only to prevent concurrent readers and writters from interleaving I/O. When locking for I/O, return an error if the socket is a listening socket. Currently the check is racy since the sockbuf sx locks are destroyed during the transition to a listening socket, but that will no longer be true after some follow-up changes. Modify a few places to check for errors from sblock()/SOCK_IO_(SEND|RECV)_LOCK() where they were not before. In particular, add checks to sendfile() and sorflush(). Reviewed by: tuexen, gallatin Sponsored by: The FreeBSD Foundation (cherry picked from commit f94acf52a408316ed61ba94705d7ec0a69ba5ec8)
* netvsc: Fix a typo in a commentGordon Bergling2021-10-061-1/+1
| | | | | | - s/prefered/preferred/ (cherry picked from commit 9ebd651b58502f0572a7832d088f53f7a2ad00a5)
* socket: De-duplicate SBLOCKWAIT() definitionsMark Johnston2021-09-211-1/+0
| | | | | | Sponsored by: The FreeBSD Foundation (cherry picked from commit fa0463c384b652e1e962d5e8e70396e6a876f01b)
* hyperv: Fix vmbus after the i386 4/4 splitMark Johnston2021-06-221-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | The vmbus ISR needs to live in a trampoline. Dynamically allocating a trampoline at driver initialization time poses some difficulties due to the fact that the KENTER macro assumes that the offset relative to tramp_idleptd is fixed at static link time. Another problem is that native_lapic_ipi_alloc() uses setidt(), which assumes a fixed trampoline offset. Rather than fight this, move the Hyper-V ISR to i386/exception.s. Add a new HYPERV kernel option to make this optional, and configure it by default on i386. This is sufficient to make use of vmbus(4) after the 4/4 split. Note that vmbus cannot be loaded dynamically and both the HYPERV option and device must be configured together. I think this is not too onerous a requirement, since vmbus(4) was previously non-functional. Reported by: Harry Schmalzbauer <freebsd@omnilan.de> Tested by: Harry Schmalzbauer <freebsd@omnilan.de> Reviewed by: whu, kib Sponsored by: The FreeBSD Foundation (cherry picked from commit 97993d1ebf592ac6689a498d5d0d2afb46758680)
* Consistently use the SOLISTENING() macroMark Johnston2021-06-211-1/+1
| | | | | | | | | | | Some code was using it already, but in many places we were testing SO_ACCEPTCONN directly. As a small step towards fixing some bugs involving synchronization with listen(2), make the kernel consistently use SOLISTENING(). No functional change intended. Sponsored by: The FreeBSD Foundation (cherry picked from commit f4bb1869ddd2bca89b6b6bfaf4d866efdd9243cf)
* hyperv: register intr handler as usermode-mapped if loaded as moduleKonstantin Belousov2021-06-121-0/+16
| | | | (cherry picked from commit fe7d7ac40881c9d01a54bf57fff71a3af199f237)
* storvsc: fix auto-sense reportingAndriy Gapon2021-05-211-1/+2
| | | | | | | | | | | | | I saw a situation where the driver set CAM_AUTOSNS_VALID on a failed ccb even though SRB_STATUS_AUTOSENSE_VALID was not set in the status. The actual sense data remained all zeros. The problem seems to be that create_storvsc_request() always sets hv_storvsc_request::sense_info_len, so checking for sense_info_len != 0 is not enough to determine if any auto-sense data is actually available. Sponsored by: CyberSecure (cherry picked from commit 8afecefd57c5ac95200f43227cd00f265154acee)
* Add missing sockaddr length and family validation to various protocolsMark Johnston2021-05-171-0/+9
| | | | | | | | | | | | | | | Several protocol methods take a sockaddr as input. In some cases the sockaddr lengths were not being validated, or were validated after some out-of-bounds accesses could occur. Add requisite checking to various protocol entry points, and convert some existing checks to assertions where appropriate. Reported by: syzkaller+KASAN Reviewed by: tuexen, melifaro Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29519 (cherry picked from commit f161d294b92732df6254a89f393ab24999e122bf)
* Hyper-V: hn: Initialize the internal field of per packet info on tx pathWei Hu2021-03-291-0/+1
| | | | | | | | | | | | | | | The RSC support feature introduced a bit field "rm_internal" in struct rndis_pktinfo with total size unchanged. The guest does not use this field in the tx path. However we need to initialize it to zero in case older hosts which are not aware of this field. Fixes: a491581f ("Hyper-V: hn: Enable vSwitch RSC support") MFC after: 2 weeks Sponsored by: Microsoft (cherry picked from commit 805dbff6c36a6cd84491aa53a02315fa025734cc)
* Hyper-V: hn: Enable vSwitch RSC support in hn netvsc driverWei Hu2021-03-296-89/+263
| | | | | | | | | | | | | | | | | Receive Segment Coalescing (RSC) in the vSwitch is a feature available in Windows Server 2019 hosts and later. It reduces the per packet processing overhead by coalescing multiple TCP segments when possible. This happens mostly when TCP traffics are among different guests on same host. This patch adds netvsc driver support for this feature. The patch also updates NVS version to 6.1 as needed for RSC enablement. MFC after: 2 weeks Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D29075 (cherry picked from commit a491581f3f8df07cdff0236bd556895205929af4)
* Hyper-V: hn: Store host hash value in flowidWei Hu2021-03-291-4/+15
| | | | | | | | | | | | When rx packet contains hash value sent from host, store it in the mbuf's flowid field so when the same mbuf is on the tx path, the hash value can be used by the host to determine the outgoing network queue. MFC after: 2 weeks Sponsored by: Microsoft (cherry picked from commit 80f39bd95f22322152709ea5fae3a3c546044c9c)
* hyperv/vmbus: avoid crash, panic if vbe fb info is missingBradley T. Hughes2020-12-101-17/+15
| | | | | | | | | | | | | | Do not assume that VBE framebuffer metadata can be used. Like with the EFI fb metadata, it may be null, so we should take care not to dereference the null vbefb pointer. This avoids a panic when booting -CURRENT on a gen1 VM in Azure. Approved by: tsoome Sponsored by: Miles AS Differential Revision: https://reviews.freebsd.org/D27533 Notes: svn path=/head/; revision=368513
* fix vmbus_fb_mmio_res after r368168Toomas Soome2020-11-301-2/+3
| | | | | | | mixed efifb versus vbefb struct use did slip in by mistake. Notes: svn path=/head/; revision=368169
* Add VT driver for VBE framebuffer deviceToomas Soome2020-11-301-9/+25
| | | | | | | | | | | | | | | Implement vt_vbefb to support Vesa Bios Extensions (VBE) framebuffer with VT. vt_vbefb is built based on vt_efifb and is assuming similar data for initialization, use MODINFOMD_VBE_FB to identify the structure vbe_fb in kernel metadata. struct vbe_fb, is populated by boot loader, and is passed to kernel via metadata payload. Differential Revision: https://reviews.freebsd.org/D27373 Notes: svn path=/head/; revision=368168
* Hyper-V: hn: Relinquish cpu in HN_LOCK to avoid deadlockWei Hu2020-10-151-1/+6
| | | | | | | | | | | | | | | | The try lock loop in HN_LOCK put the thread spinning on cpu if the lock is not available. It is possible to cause deadlock if the thread holding the lock is sleeping. Relinquish the cpu to work around this problem even it doesn't completely solve the issue. The priority inversion could cause the livelock no matter how less likely it could happen. A more complete solution may be needed in the future. Reported by: Microsoft, Netapp MFC after: 2 weeks Sponsored by: Microsoft Notes: svn path=/head/; revision=366721
* Hyper-V: pcib: Check revoke status during device attachWei Hu2020-10-151-12/+66
| | | | | | | | | | | | | | | It is possible that the vmbus pcib channel is revoked during attach path. The attach path could be waiting for response from host and this response will never arrive since the channel has already been revoked from host point of view. Check this situation during wait complete and return failed if this happens. Reported by: Netapp MFC after: 2 weeks Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D26486 Notes: svn path=/head/; revision=366720
* Hyper-V: storvsc: Enhance srb_status code handling.Wei Hu2020-08-312-24/+168
| | | | | | | | | | | | | | | | | | | | In hv_storvsc_io_request() when coring, prevent changing of the send channel from the base channel to another one. storvsc_poll always probes on the base channel. Based upon conversations with Microsoft, changed the handling of srb_status codes. Most we should never get, others yes. All are treated as retry-able except for two. We should not get these statuses, but if we ever do, the I/O state is not known. Submitted by: Alexander Sideropoulos <Alexander.Sideropoulos@netapp.com> Reviewed by: trasz, allanjude, whu MFC after: 1 week Sponsored by: Netapp Inc Differential Revision: https://reviews.freebsd.org/D25756 Notes: svn path=/head/; revision=364984
* Prevent framebuffer mmio space from being allocated to other devices on HyperV.Wei Hu2020-07-301-0/+57
| | | | | | | | | | | | | | | | | | On Gen2 VMs, Hyper-V provides mmio space for framebuffer. This mmio address range is not useable for other PCI devices. Currently only efifb driver is using this range without reserving it from system. Therefore, vmbus driver reserves it before any other PCI device drivers start to request mmio addresses. PR: 222996 Submitted by: weh@microsoft.com Reported by: dmitry_kuleshov@ukr.net Reviewed by: decui@microsoft.com Sponsored by: Microsoft Notes: svn path=/head/; revision=363689
* Socket AF_HYPERV should return failure when it is not running on HyperVWei Hu2020-05-221-0/+15
| | | | | | | | Reported by: pho Sponsored by: Microsoft Notes: svn path=/head/; revision=361360
* Fix i386 build for r361275Li-Wen Hsu2020-05-202-7/+9
| | | | | | | kponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=361278
* HyperV socket implementation for FreeBSDWei Hu2020-05-209-16/+2569
| | | | | | | | | | | | | | This change adds Hyper-V socket feature in FreeBSD. New socket address family AF_HYPERV and its kernel support are added. Submitted by: Wei Hu <weh@microsoft.com> Reviewed by: Dexuan Cui <decui@microsoft.com> Relnotes: yes Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D24061 Notes: svn path=/head/; revision=361275
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-261-4/+8
| | | | | | | | | | | | | | | | | | | r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718 Notes: svn path=/head/; revision=358333
* Although most of the NIC drivers are epoch ready, due to peer pressureGleb Smirnoff2020-02-241-2/+1
| | | | | | | | | | | | | | | | | | | switch over to opt-in instead of opt-out for epoch. Instead of IFF_NEEDSEPOCH, provide IFF_KNOWSEPOCH. If driver marks itself with IFF_KNOWSEPOCH, then ether_input() would not enter epoch when processing its packets. Now this will create recursive entrance in epoch in >90% network drivers, but will guarantee safeness of the transition. Mark several tested drivers as IFF_KNOWSEPOCH. Reviewed by: hselasky, jeff, bz, gallatin Differential Revision: https://reviews.freebsd.org/D23674 Notes: svn path=/head/; revision=358301
* hyperv: Add Hygon Dhyana support.Konstantin Belousov2020-02-131-0/+1
| | | | | | | | | Submitted by: Pu Wen <puwen@hygon.cn> MFC after: 1 week Differential revision: https://reviews.freebsd.org/D23563 Notes: svn path=/head/; revision=357871