summaryrefslogtreecommitdiff
path: root/sys/dev/hyperv
AgeCommit message (Collapse)Author
2025-12-23Hyper-V: hn: just call vf's ioctl when changing mtuWei Hu
When changing mtu, if a vf is attached to the netvsc interface, just calling its ioctl to change vf's mtu is good enough. Tested by: whu MFC after: 3 days Sponsored by: Microsoft
2025-12-09bus_alloc_resource: Pass rid by value to BUS_ALLOC_RESOURCE DEVMETHODJohn Baldwin
The wrapper functions such as bus_alloc_resource_any() still support passing the rid by value or pointer, but the underlying implementation now passes by value. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D53402
2025-11-22hn: use newly exposed RSS hash key API rather than ad-hoc hashingAndrew Gallatin
Differential Revision: https://reviews.freebsd.org/D53099 Sponsored by: Netflix
2025-10-28hyper-v: Fix a couple of typos in kernel messagesGordon Bergling
- s/tranparent/transparent/ - s/Unknow/Unknown/ - s/qury/query/ MFC after: 1 week
2025-07-10vmbus: Avoid gratuitous ifdef and use more generic implementation insteadJessica Clarke
Checking for __LP64__ is non-portable as it assumes that ILP32 and LP64 are the only two ABIs that exist, but CheriBSD supports an additional ABI where long is still 64-bit but pointers are 128-bit capabilities, and thus __LP64__ is not defined. We could change this to check the value of __SIZEOF_LONG__, since the code here only cares about that aspect of the ABI, however in this instance, the only real reason an ifdef is used at all is to be able to get log2(sizeof(u_long)), but if we instead multiply and divide rather than shift, and let the compiler optimise that to a shift, we can just use sizeof(u_long) instead. Note also that VMBUS_EVTFLAGS_MAX could always just have been defined as VMBUS_EVTFLAGS_SIZE / sizeof(u_long). Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D50630
2025-06-21newbus: replace leftover device unit wildcardsAhmad Khalifa
Reviewed by: imp, jhb Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D50913
2025-06-11machine/stdarg.h -> sys/stdarg.hBrooks Davis
Switch to using sys/stdarg.h for va_list type and va_* builtins. Make an attempt to insert the include in a sensible place. Where style(9) was followed this is easy, where it was ignored, aim for the first block of sys/*.h headers and don't get too fussy or try to fix other style bugs. Reviewed by: imp Exp-run by: antoine (PR 286274) Pull Request: https://github.com/freebsd/freebsd-src/pull/1595
2025-05-08Remove remaining mentions of pr_usrreq.Dag-Erling Smørgrav
When struct pr_usrreq was folded into struct protosw and the function pointers it contained were renamed from pru_* to pr_* in 2022, a number of references to the old names in comments and error messages were missed. Chase them down and fix them. Sponsored by: Klara, Inc. Sponsored by: NetApp, Inc. Reviewed by: kevans, glebius Differential Revision: https://reviews.freebsd.org/D50190
2025-03-31hyperv/storvsc: Avoid conditional asserts in storvsc_xferbuf_prepare()Mark Johnston
whu@ cannot reproduce the assertion failure which led to these ifdefs being added in the first place, and since they appear wrong, i.e., the assertions ought to apply to all platforms, let's remove them. This reverts commits 0af5a0cd2788efce9f444f4f781357d317bb0bb1 and 6f7b1310b6fe36f9bb653d3e97bc257adced3a2b. PR: 285681 Tested by: whu MFC after: 2 weeks
2025-03-31hyperv/storvsc: Fix busdma constraintsMark Johnston
- The BUS_DMA_KEEP_PG_OFFSET flag is needed, since storvsc_xferbuf_prepare() assumes that only the first segment may have a non-zero offset, and that all following segments are page-sized and -aligned. - storvsc_xferbuf_prepare() handles 64-bit bus addresses, so avoid unneeded bouncing on i386. PR: 285681 Reported by: dim Tested by: dim, whu MFC after: 2 weeks
2025-02-04Hyper-V: hn: rewrite hn rsc swtich to avoid sysctl hangWei Hu
Changing the rsc_switch flag using sysctl to turn rsc on or off could hang. The orignal code sends request to host to get the mtu setting. Sometimes the host fails to reply, causing the thread to sleep forever waiting for the host response. Use existing cached mtu from hn device instead to avoid calling host. Reported by: whu Tested by: whu MFC after: 1 week
2025-01-24sys: make the kernel metadata pointer globalAhmad Khalifa
The way we got the kernel metadata pointer was by calling preload_search_by_type with one of the following three: "elf kernel", "elf32 kernel" and "elf64 kernel". Which one(s) we used wasn't consistent though. Sometimes we would only try "elf kernel", and other times we would try one of the latter two if the first failed. However, the loader only ever sets "elf kernel" as the kernel type. Now, the kmdp is a global, preload_kmdp, and it's initialized using preload_initkmdp in machdep.c (or machdep_boot.c on arm/64). preload_initkmdp takes a single boolean argument that tells us whether not finding the kmdp is fatal or not. Reviewed by: imp, kib Pull Request: https://github.com/freebsd/freebsd-src/pull/1394
2025-01-02Use bus_generic_detach instead of device_delete_children in detachJohn Baldwin
While here, check for errors from bus_generic_detach and move it to the start of detach if necessary. Differential Revision: https://reviews.freebsd.org/D47969
2024-12-06Replace calls to bus_generic_attach with bus_attach_childrenJohn Baldwin
Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47675
2024-12-06Replace calls to bus_generic_probe with bus_identify_childrenJohn Baldwin
Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47674
2024-11-29tcp: extend the use of the th_flags accessor functionRichard Scheffenegger
Formally, there are 12 bits for TCP header flags. Use the accessor functions in more (kernel) places. No functional change. Reviewed By: cc, #transport, cy, glebius, #iflib, kbowling Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D47063
2024-10-15sys: Use the new arm_smccc_invoke macrosAndrew Turner
Simplify the calls into the SMCCC firmware with the new arm_smccc_invoke* macros. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D46987
2024-10-01hyperv: call smp_targeted_tlb_shootdown_native() with pinKonstantin Belousov
Sponsored by: The FreeBSD Foundation MFC after: 1 week
2024-07-26Deprecate contigfree(9) in favour of free(9)Bjoern A. Zeeb
As of 9e6544dd6e02c46b805d11ab925c4f3b18ad7a4b contigfree(9) is no longer needed and should not be used anymore. We leave a wrapper for 3rd party code in at least 15.x but remove (almost) all other cases from the tree. This leaves one use of contigfree(9) untouched; that was the original trigger for 9e6544dd6e02 and is handled in D45813 (to be committed seperately later). Sponsored by: The FreeBSD Foundation Reviewed by: markj, kib Tested by: pho (10h stress test run) Differential Revision: https://reviews.freebsd.org/D46099
2024-07-24newbus: globally replace device_add_child(..., -1) with DEVICE_UNIT_ANYWarner Losh
Sponsored by: Netflix
2024-07-18Retire non-NEW_PCIB code and remove config optionJessica Clarke
All architectures enable NEW_PCIB in DEFAULTS (arm being the most recent to do so in 121be555997b (arm: Set NEW_PCIB in DEFAULTS rather than a subset of kernel configs")), so it's time we removed the legacy code that no longer sees much testing and has a significant maintenance burden. Reviewed by: jhb, andrew, emaste Differential Revision: https://reviews.freebsd.org/D32954
2024-06-15Hyper-V: move memory alloc call for tlb hypercall out of smp_rendezvousWei Hu
The allocation call could result in sleep lock violation if it is in smp_rendezvous. Move it out. Also move the pcpu memory pointer to vmbus_pcpu_data since it is only used on Hyper-V. PR: 279738 Reported by: gbe Fixes: 2b887687edc25bb4553f0d8a1183f454a85d413d MFC after: 2 weeks Sponsored by: Microsoft
2024-06-11Hyper_V: add a boot parameter to tlb flush hypercallWei Hu
Add boot parameter hw.vmbus.tlb_hcall for tlb flush hypercall. By default it is set to 1 to allow hyercall tlb flush. It can be set to 0 in loader.conf to turn off hypercall and use system provided tlb flush routine. The change also changes flag in the per cpu contiguous memory allocation to no wait to avoid panic happened some cases which there are no enough contiguous memery available at boot time. Reported by: gbe Tested by: whu MFC after: 1 week Fixes: 2b887687edc25bb4553f0d8a1183f454a85d413d Sponsored by: Microsoft
2024-06-10Hyper-V: remove unused alloc_pcpu_ptr()Wei Hu
Fixes: 2b887687edc25bb4553f0d8a1183f454a85d413d Sponsored by: Microsoft
2024-06-07Hyper-V: TLB flush enlightment using hypercallSouradeep Chakrabarti
Currently FreeBSD uses IPI based TLB flushing for remote TLB flushing. Hyper-V allows hypercalls to flush local and remote TLB. The use of Hyper-V hypercalls gives significant performance improvement in TLB operations. This patch set during test has shown near to 40 percent TLB performance improvement. Also this patch adds rep hypercall implementation as well. Reviewed by: whu, kib Tested by: whu Authored-by: Souradeep Chakrabarti <schakrabarti@microsoft.com> Co-Authored-by: Erni Sri Satya Vennela <ernis@microsoft.com> MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D45521
2024-03-14hyperv/hn: Don't return error when setting media to autoselectMark Peek
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
2024-03-13new-bus: Remove the 'rid' and 'type' arguments from BUS_RELEASE_RESOURCEJohn Baldwin
The public bus_release_resource() API still accepts both forms, but the internal kobj method no longer passes the arguments. Implementations which need the rid or type now use rman_get_rid() or rman_get_type() to fetch the value from the allocated resource. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44131
2024-03-13new-bus: Remove the 'rid' and 'type' arguments from BUS_*ACTIVATE_RESOURCEJohn Baldwin
The public bus_activate/deactivate_resource() API still accepts both forms, but the internal kobj methods no longer pass the arguments. Implementations which need the rid or type now use rman_get_rid() or rman_get_type() to fetch the value from the allocated resource. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44130
2024-03-13new-bus: Remove the 'type' argument from BUS_ADJUST_RESOURCEJohn Baldwin
The public bus_adjust_resource() API still accepts both forms, but the internal kobj method no longer passes the argument. Implementations which need the type now use rman_get_type() to fetch the value from the allocated resource. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44128
2024-03-08Hyper-V: vPCI: fix cpu id mis-mapping in vmbus_pcib_map_msi()Wei Hu
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. Reported by: NetApp Tested by: whu MFC after: 1 week
2024-02-24if_hn: Fix two typos in source code commentsGordon Bergling
- s/managment/management/ - s/transacion/transaction/ Obtained from: NetBSD MFC after: 3 days
2024-01-23hyperv vmbus_pcib: Use pci_domain_*_bus for PCI_RES_BUS resourcesJohn Baldwin
Specifically for bus_activate/adjust/deactivate_bus methods. Differential Revision: https://reviews.freebsd.org/D43431
2024-01-16sockets: make pr_shutdown fully protocol specific methodGleb Smirnoff
Disassemble a one-for-all soshutdown() into protocol specific methods. This creates a small amount of copy & paste, but makes code a lot more self documented, as protocol specific method would execute only the code that is relevant to that protocol and nothing else. This also fixes a couple recent regressions and reduces risk of future regressions. The extended KPI for the new pr_shutdown removes need for the extra pr_flush which was added for the sake of SCTP which could not perform its shutdown properly with the old one. Particularly for SCTP this change streamlines a lot of code. Some notes on why certain parts of code were copied or were not to certain protocols: * The (SS_ISCONNECTED | SS_ISCONNECTING | SS_ISDISCONNECTING) check is needed only for those protocols that may be connected or disconnected. * The above reduces into only SS_ISCONNECTED for those protocols that always connect instantly. * The ENOTCONN and continue processing hack is left only for datagram protocols. * The SOLISTENING(so) block is copied to those protocols that listen(2). * sorflush() on SHUT_RD is copied almost to every protocol, but that will be refactored later. * wakeup(&so->so_timeo) is copied to protocols that can make a non-instant connect(2), can SO_LINGER or can accept(2). There are three protocols (netgraph(4), Bluetooth, SDP) that did not have pr_shutdown, but old soshutdown() would still perform sorflush() on SHUT_RD for them and also wakeup(9). Those protocols partially supported shutdown(2) returning EOPNOTSUP for SHUT_WR/SHUT_RDWR, now they fully lost shutdown(2) support. I'm pretty sure netgraph(4) and Bluetooth are okay about that and SDP is almost abandoned anyway. Reviewed by: tuexen Differential Revision: https://reviews.freebsd.org/D43413
2023-12-27netvsc: Fix typo (triple S)Jose Luis Duran
Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/955
2023-12-27hvsock: Fix a typo in a source code commentGordon Bergling
- s/recieved/received/ MFC after: 3 days
2023-11-30sockets: don't malloc/free sockaddr memory on getpeername/getsocknameGleb Smirnoff
Just like it was done for accept(2) in cfb1e92912b4, use same approach for two simplier syscalls that return socket addresses. Although, these two syscalls aren't performance critical, this change generalizes some code between 3 syscalls trimming code size. Following example of accept(2), provide VNET-aware and INVARIANT-checking wrappers sopeeraddr() and sosockaddr() around protosw methods. Reviewed by: tuexen Differential Revision: https://reviews.freebsd.org/D42694
2023-11-30sockets: don't malloc/free sockaddr memory on accept(2)Gleb Smirnoff
Let the accept functions provide stack memory for protocols to fill it in. Generic code should provide sockaddr_storage, specialized code may provide smaller structure. While rewriting accept(2) make 'addrlen' a true in/out parameter, reporting required length in case if provided length was insufficient. Our manual page accept(2) and POSIX don't explicitly require that, but one can read the text as they do. Linux also does that. Update tests accordingly. Reviewed by: rscheff, tuexen, zlei, dchagin Differential Revision: https://reviews.freebsd.org/D42635
2023-11-26sys: Automated cleanup of cdefs and other formattingWarner Losh
Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
2023-11-02Hyper-V: vmbus: Add NULL check for vmbus_resZhenlei Huang
QEMU emulates Hyper-V [1] but lacks the emulation for vmbus_res, thus no coherence information is available. Add NULL check for it and fallback to no coherence. This will prevent FreeBSD guests from panic on QEMU with the Hyper-V enlightenment hv-synic enabled. For real Hyper-V, both gen1 and gen2 have vmbus_res then they are not affected by this change. 1. https://www.qemu.org/docs/master/system/i386/hyperv.html PR: 274810 Reviewed by: mhorne, emaste, delphij, whu Diagnosed by: mhorne Fixes: e7a9817b8d32 Hyper-V: vmbus: implementat bus_get_dma_tag in vmbus Insta-MFC approved by: re (delphij) for 14.0-RC4 Differential Revision: https://reviews.freebsd.org/D42414
2023-10-20Hyper-V: vmbus: check if signaling host is needed in vmbus_rxbr_readWei Hu
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 MFC after: 3 days Sponsored by: Microsoft
2023-10-13bpf: Add IfAPI analogue for bpf_peers_present()Justin Hibbits
An interface's bpf could feasibly not exist, in which case bpf_peers_present() would panic from a NULL pointer dereference. Solve this by adding a new IfAPI that could deal with a NULL bpf, if such could occur in the network stack. Reviewed by: zlei Sponsored by: Juniper Networks, Inc. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D42082
2023-10-13Revert "bpf: Add IfAPI analogue for bpf_peers_present()"Justin Hibbits
This reverts commit c81dd8e5fe72d0c7ec055c8621bb2da3a3627abf. Commit message needs revised.
2023-10-13bpf: Add IfAPI analogue for bpf_peers_present()Justin Hibbits
An interface's bpf could feasibly not exist, in which case bpf_peers_present() would panic from a NULL pointer dereference. Solve this by adding a new IfAPI that includes a NULL check. Since this API is used in only a handful of locations, it reduces the the NULL check scope over inserting the check into bpf_peers_present(). Sponsored by: Juniper Networks, Inc. MFC after: 1 week
2023-09-14Hyper-V: vmbus: implementat bus_get_dma_tag in vmbusSouradeep Chakrabarti
In ARM64 Hyper-V UFS filesystem is getting corruption and those corruptions are consistently happening just after hitting a page boundary. It is unable to correctly read disk blocks into buffers that are not aligned to 512-byte boundaries. It happens because storvsc needs physically contiguous memory which may not be the case when bus_dma needs to create a bounce buffer. This can happen when the destination is not cache-line aligned. Hyper-V VMs have VMbus synthetic devices and PCI pass-thru devices that are added dynamically via the VMbus protocol and are not represented in the ACPI DSDT. Only the top level VMbus node exists in the DSDT. As such, on ARM64 these devices don't pick up coherence information and default to not hardware coherent. PR: 267654, 272666 Reviewed by: andrew, whu Tested by: lwhsu MFC after: 3 days Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D41728
2023-09-11hyperv/vmbus: Flip a message to only be emitted on failureLi-Wen Hsu
This message is not very useful when things are working well. Flip its meaning and let it only be emitted on failure. While here, pet style(9). Reviewed by: mhorne, whu Differential Revision: https://reviews.freebsd.org/D41788
2023-09-04Hyper-V: hn: use VF's capabilities when it is attachedWei Hu
Current code in hn/netvsc tries to merge (logical AND) VF and its own capability bits when a VF is attached. This results in losing some key VF features, especially in tx path. For example, the VF's txcsum, rxcsum or tso bits could be lost if any of these are not in hn/netvsc's own capablility field. Actually when VF is attached, hn just needs to use VF's caps as all the tx packets would be forwarded to the VF interface. Fix this problem by doing so. Reported by: whu Tested by: whu MFC after: 3 days Sponsored by: Microsoft
2023-08-16sys: Remove $FreeBSD$: one-line sh patternWarner Losh
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16sys: Remove $FreeBSD$: one-line .c patternWarner Losh
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16sys: Remove $FreeBSD$: two-line .h patternWarner Losh
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-03hid: Add child device parameter to HID methodsVladimir Kondratyev
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