Commit Graph
2879 Commits
Author SHA1 Message Date
Kostiantyn Kostiuk 92b01344b9 pvpanic: Enforce driver isolation in INF files
Resolve: https://issues.redhat.com/browse/RHEL-26210

Signed-off-by: Kostiantyn Kostiuk <[email protected]>
2024-02-22 10:31:38 +02:00
Kostiantyn Kostiuk 6fa94d80e7 pvpanic: Remove WDF related INF section
Resolve: https://issues.redhat.com/browse/RHEL-26210

Signed-off-by: Kostiantyn Kostiuk <[email protected]>
2024-02-22 10:31:38 +02:00
Kostiantyn Kostiuk 2734840100 vioscsi: Enforce driver isolation in INF
Signed-off-by: Kostiantyn Kostiuk <[email protected]>
2024-02-17 07:53:37 +02:00
Kostiantyn Kostiuk 238d94ce08 fwcfg: Enforce driver isolation in INF
Signed-off-by: Kostiantyn Kostiuk <[email protected]>
2024-02-17 07:52:50 +02:00
Kostiantyn Kostiuk 2d00104956 fwcfg: Remove WDF related INF section
Signed-off-by: Kostiantyn Kostiuk <[email protected]>
2024-02-17 07:52:50 +02:00
Kostiantyn Kostiuk 71cf286456 viostor: Enforce driver isolation in INF
Signed-off-by: Kostiantyn Kostiuk <[email protected]>
2024-02-17 07:50:19 +02:00
Martin Drab 4f5a62fdb0 Enable WPP Event Tracing for both the WSK library and the test driver
The WPP Event Tracing can be disabled which means return to the good old DbgPrintEx routine. To disable WPP, the following steps need to be done:
- commenting the line `#define EVENT_TRACING` in project's trace.h file,
- setting the "Run Wpp Tracing" option in project settings to No.

Signed-off-by: Martin Drab <[email protected]>
2024-02-11 14:59:56 +02:00
Martin Drab f7f902a616 Implement a test driver demonstrating WSK capabilities
The leverages WSK to create a set of client and server threads. The server thread listen for connection and exchange a message with connecting clients. Cryptographic hash function (SHA256) is used to verify that message data are not damaged during their transmission.

Server threads are working in non-blocking mode. Such behavior is necessary in order to be able to cancel pending WskAccept calls since the viosock.sys driver does not permit their cancellation (unlike send/recv requests which ARE cancellable by design).

Signed-off-by: Martin Drab <[email protected]>
2024-02-11 14:59:56 +02:00
Martin Drab f84ea979af WSK: Let unsupported calls correctly report STATUS_NOT_IMPLEMENTED
The following routines are not implemented:
- WskControlClient
- WskInspectComplete
- WskConnectEx
- WskSendEd
- WskReceiveEx

ref: [WskInspectComplete](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wsk/nc-wsk-pfn_wsk_inspect_complete)
ref: [WskConnectEx](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wsk/nc-wsk-pfn_wsk_connect_ex)
Signed-off-by: Martin Drab <[email protected]>
2024-02-11 14:59:56 +02:00
Martin Drab f3f4c44a2a WSK: Implement WskBind
This call translates to an IOCTL_SOCKET_BIND request to the VIOSOCK driver, followed with IOCTL_SOCKET_LISTEN one if the socket in question is a listening one. This needs to be done because the WskListen function was not part of the WSK interface until Windows 10 version 1703.

Contrary to the TCP/IP WSK implementation in Windows, it is not necessary to call WskBind for non-listening sockets.

ref: https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wsk/nc-wsk-pfn_wsk_bind
Signed-off-by: Martin Drab <[email protected]>
2024-02-11 14:59:56 +02:00
Martin Drab d6cbe59b32 WSK: Implement WskAccept
If called at IRQL = PASSIVE_LEVEL, this call blocks until a connection is accepted. This is due to the fact that the VIOSOCK driver implements the accept() operation through an IRP_MJ_CREATE (ZwCreateFile) which is usually synchronous. To make WskAccept non-blocking, the client driver can call it at higher IRQL, the accept() call into the VIOSOCK driver is then deferred to a workitem.

ref: https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wsk/nc-wsk-pfn_wsk_accept
Signed-off-by: Martin Drab <[email protected]>
2024-02-11 14:59:56 +02:00
Martin Drab 2e60647368 WSK: Implement WskDisconnect
Only the zero value for the Flags argument is supported. The client driver may use the Buffer argument to send data before disconnecting from the remote end.

ref: [WskDisconnect](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wsk/nc-wsk-pfn_wsk_disconnect)
Signed-off-by: Martin Drab <[email protected]>
2024-02-11 14:59:56 +02:00
Martin Drab 4e75959cc3 WSK: Impelemnt WskReceive
Since the VIOSOCK driver does not support MDL chaining, one call to WskReceive fills at most one MDL of the WSK_BUF structure.

ref: [WskReceive](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wsk/nc-wsk-pfn_wsk_receive)
Signed-off-by: Martin Drab <[email protected]>
2024-02-11 14:59:56 +02:00
Martin Drab b2b308ee9e WSK: Implement VIoWskSend
Routines for building IRP_MJ_WRITE and IRP_MJ_WRITE IRPs are also par of this commit since the VIOSOCK driver implements send/recv operations through these requests. It is also necessary to deal with the fact that the WSK interface transfers send/recv buffers through WSK_BUF structures, very similar to WSABUF in usermode, that support MDL chaining. Since the VIOSOCK driver does not support MDL chaining, the WskSend initiates a sequence of IRP_MJ_WRITE requests, one for each MDL in the chain.

ref: [WskSend](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wsk/nc-wsk-pfn_wsk_send_to)
Signed-off-by: Martin Drab <[email protected]>
2024-02-11 14:59:56 +02:00
Martin Drab a938c84f97 WSK: Implement WskControlSocket
The implementation supports both synchronous (Irp == NULL) and asynchronous (Irp != NULL) modes of operation and can be used to get/set socket options and send IOCTLs.

ref: [WskControlSocket](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wsk/nc-wsk-pfn_wsk_control_socket)
Signed-off-by: Martin Drab <[email protected]>
2024-02-11 14:59:56 +02:00
Martin Drab 130cb650ad WSK: Implement WskConnect
Unlike the standard WSK interface (TCP/IP etc.), AF_VSOCK does not require to call WskBind before WskConnect. This also holds for the connect() call in usermode.

The client driver can use VMADDR_CID_ANY to connect to loopback.

ref: https://www.bing.com/search?q=wskconnect&cvid=6a21f40a81d8444a886dbae1cbb54e09&aqs=edge..69i57j0l8.1546j0j1&pglt=2083&FORM=ANSPA1&PC=U531
Signed-off-by: Martin Drab <[email protected]>
2024-02-11 14:59:56 +02:00
Martin Drab d0fbd73f51 WSK: Implement WskGetRemoteAddress
The library implements this call by forwarding it to the VIOSOCK driver as an IOCTL_SOCKET_GET_PEER_NAME request.

ref: [WskGetRemoteAddress](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wsk/nc-wsk-pfn_wsk_get_remote_address)
Signed-off-by: Martin Drab <[email protected]>
2024-02-11 14:59:56 +02:00
Martin Drab ef33fb8f89 WSK: Implement WskGetLocalAddress
The library implements this call by forwarding it to the VIOSOCK driver as an IOCTL_SOCKET_GET_SOCK_NAME request.

ref: [WskGetLocalAddress](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wsk/nc-wsk-pfn_wsk_get_local_address)
Signed-off-by: Martin Drab <[email protected]>
2024-02-11 14:59:56 +02:00
Martin Drab 8cec75f6d1 WSK: Add logic for sending IOCTL requests
Most of the work done by this WSK implementation consists of packing client driver's calls into IOCTL and read/write request and passing them to the VIOSOCK driver. This commit introduces routines for creating IOCTL requests and sending them to VIOSOCK. Also, a concept of WSK Completion Contexts is introduces. The purpose of these contexts is to transfer information between code sending IRPs and their completion routines. Also, these contexts can be used to implement one WSK interface call as a sequence of requests to the VIOSOCK driver.

Signed-off-by: Martin Drab <[email protected]>
2024-02-11 14:59:56 +02:00
Martin Drab c1d7158df3 WSK: Ability to create and close sockets
Signed-off-by: Martin Drab <[email protected]>
2024-02-11 14:59:56 +02:00
Martin Drab 44600cceae WSK: Address translation routines
Implements WskGetAddressInfo, WskFreeAddressInfo and WskGetNameInfo which can be used to translate AF_VSOCK addresses between their string and binary forms. Also, some necessary logic for IRP processing is being added as well. This is necessary because the WSK interface uses IRPs to signal the client driver that certain WSK operation was completed. Apart from that (and from providing operation results in their `IoStatus` field), IRPs are not used by the interface (they carry neither operation information, nor data associated with it).

It is worth to note that the whole concept of address translation is not that useful for AF_VSOCK since there are no such things as DNS servers and domain names.

ref: [WskGetAddressInfo](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wsk/nc-wsk-pfn_wsk_get_address_info)
ref: [WskFreeAddressInfo](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wsk/nc-wsk-pfn_wsk_free_address_info)
ref: [WskGetNameInfo](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wsk/nc-wsk-pfn_wsk_get_name_info)
Signed-off-by: Martin Drab <[email protected]>
2024-02-11 14:59:56 +02:00
Martin Drab 219b875197 WSK: Module initialization, Wsk(De)Register, Wsk(Capture|Release)ProviderNPI
Unlike the Windows WSK implementation, this library needs to be initialized through VioWskModuleInit before calling its WsRegister equivalent. This approach allows the client driver to provide the library with an optional device object that is then used to prevent IRP completion routines and workitems used by the library to execute after the device deletion. If the client application decides not to provide such a device object, the library can live with it but no unload protection is then enforced.

Also, the client driver must provide pointer to its DRIVER_OBJECT which is used during WskCaptureProviderNPI to connect to the VIOSOCK driver. Instead of having the VIOSOCK device name hard-coded, the library takes advantage of IoRegisterPlugPlayNotification to search for the GUID_DEVINTERFACE_VIOSOCK device interface (which is enabled by the VIOSOCK driver) dynamically.

Signed-off-by: Martin Drab <[email protected]>
2024-02-11 14:59:56 +02:00
Martin Drab ccbcbcad1a WSK: Add more convenient debug print macros
These macros will be used mostly when entering into or exiting from a function, sending routine name nad values of its arguments to a potential kernel debugger. These macros are NOPs on Release build, however, their usage can be invaluable when debugging driver crashes.

Signed-off-by: Martin Drab <[email protected]>
2024-02-11 14:59:56 +02:00
Martin Drab f8b3119432 WSK: Fixes related to the repository and MSVS requirements
- WSK project added to the main solution,
- removed Debug configurations (to be in sync with other projects)

Signed-off-by: Martin Drab <[email protected]>
2024-02-11 14:59:56 +02:00
Yan Vugenfirer 44162b75b2 [virtio] RHEL-23315: Remove legacy DMA code in the WDF library
Solves: https://issues.redhat.com/browse/RHEL-23315

There is unused code in the WDF library. Cleaning as part of the effort to
remove pre-Win10 code from the code base.

Signed-off-by: Yan Vugenfirer <[email protected]>
2024-02-08 12:34:03 +02:00
Martin Drab 091c35f384 [viosock]: Take care of recv requests stucks after socket shutdown
When an other end (peer) of the socket reports a shutdown, the recv request queue is not processed. This means that some recv calls may get stuck forever. This commit changes the behavior -- when a shutdown from its peer is received, the recv queue gets processed and all requests that would get stuck are completed with STATUS_SUCCESS (which usually ends in receiving zero bytes).

Signed-off-by: Martin Drab <[email protected]>
2024-01-30 15:22:33 +02:00
Martin Drab e1755944e3 viosock: Reference also the internal file objects
The Socket driver stores socket-related data in memory associated with file objects representing the sockets. It uses WdfObjectReference/WdfObjectDereference to track ownership and protect sockets being in use from deletion. However, these routines do not affect reference count of the underlying FILE_OBJECT structures (served by Object Manager) -- they work only with the reference count of the WDF object wrapped around the FILE_OBJECT structure. Thus, when the underlying FILE_OBJECT is deleted, WdfObjectReference does not protect the socket context from deallocation.

This commit fixes this issue by introducing VioSockReference and VioSockDereference which also work with reference count of the wrapped FILE_OBJECT structures. Also, VioSockClose is replaced with VioSockCleanup -- the latter one is invoked when the last handle for a file object (FILE_OBJECT, not WDFFILEOBJECT) gets closed (the former one is invoked when the last reference is gone -- which does not happen if VioSock(De)reference are used). For usermode, this makes no difference since user applications work only with handles, not pointer references to file objects.

Signed-off-by:¨Martin Drab <[email protected]>
2024-01-28 10:17:53 +02:00
Yuri Benditovich 0a6c5fc482 netkvm: remove spaces at the beginning of the line
Signed-off-by: Yuri Benditovich <[email protected]>
2024-01-22 14:18:30 +02:00
Yuri Benditovich 39a198bc91 netkvm: update netkvm-wmi.cmd script
Signed-off-by: Yuri Benditovich <[email protected]>
2024-01-22 14:18:30 +02:00
Yuri Benditovich c21e0accd4 netkvm: report correct TX queue size via WMI
Signed-off-by: Yuri Benditovich <[email protected]>
2024-01-22 14:18:30 +02:00
Yuri Benditovich f25ede16eb netkvm: add metrics for allocated shared memory for RX
Signed-off-by: Yuri Benditovich <[email protected]>
2024-01-22 14:18:30 +02:00
Yuri Benditovich 641cc937e0 netkvm: add metrics for copied Tx packets
Signed-off-by: Yuri Benditovich <[email protected]>
2024-01-22 14:18:30 +02:00
Yuri Benditovich 634e6b4670 netkvm: rework vendor specific WMI properties
Split tx,rx and rss statistics
Add property for [initial] configuration data
Make reset of statistics selective and explicit
Add metrics for:
- minimal number of rx buffers
- indications with 'resource' flag
- amount of allocated shared memory

Signed-off-by: Yuri Benditovich <[email protected]>
2024-01-22 14:18:30 +02:00
Yuri Benditovich 6ca618ae03 netkvm: hide vendor-specific OIDs from 'supported' list
They are not mandatory in the list of supported OIDs,
OID_GEN_SUPPORTED_GUIDS is enough.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-01-22 14:18:30 +02:00
junjiehua 00d2037945 [netkvm] add a workaround for rx packet loss
Implemented a workaround for rx packet loss encountered with TCP_NODELAY. By default,
this feature is turned off to minimize the impact on CPU performance and network bandwidth.

To activate the feature, go to the network card properties and set the MinRxBufferPercent
to a value above 0. A good starting point is to set MinRxBufferPercent to 25% and then monitor
for any packet loss. If packet loss continues, incrementally adjust the value to 50%, then 75%,
and if necessary, up to the maximum of 100%.

In extreme cases, it may be required to not only adjust the  MinRxBufferPercent but also to increase
the number of queues and the size of each queue (queue_size).

It is important to note that this feature is only applicable to rx packet loss.

For more details, see [this thread](https://github.com/virtio-win/kvm-guest-drivers-windows/issues/1012).

Signed-off-by: junjiehua <[email protected]>
2024-01-18 11:21:17 +02:00
Yuri Benditovich d89185c6be netkvmco: (minor) remove unneded lines causing warning
Removal of redundant/unneded lines from the .vcxproj
They also caused by IDE warning on loading of any project
including netkvmco.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-01-17 15:01:17 +02:00
Yuri Benditovich c81ff1fa55 netkvm: (minor) define IsPowerOfTwo in common header
And remove the same definition from various files.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-01-17 15:01:17 +02:00
Yuri Benditovich 1ea1b12a5c netkvm: change limit of RX buffers per queue 256=>1024
https://issues.redhat.com/browse/RHEL-19430

The number of buffers is always limited by queue size,
so with the default QEMU setting (256) the driver will do
the same. If QEMU is configured in command-line to have
bigger queue (it allows up to 1024), the previous driver
required to change also driver property to really use
full size of QEMU RX queue. Now this will not be required
(up to 1024 buffers).

Signed-off-by: Yuri Benditovich <[email protected]>
2024-01-17 15:01:17 +02:00
Vadim Rozenfeld 74e209f6c8 [balloon] clean up pre-Win10 code (usermode part).
Signed-off-by: Vadim Rozenfeld <[email protected]>
2024-01-17 11:57:24 +11:00
Vadim Rozenfeld 91a68570e9 [balloon] clean up pre-Win10 code (kernel part).
Signed-off-by: Vadim Rozenfeld <[email protected]>
2024-01-17 11:57:24 +11:00
Vadim Rozenfeld e1693d54f1 [viostor] clean up pre-Win10 code
Signed-off-by: Vadim Rozenfeld <[email protected]>
2024-01-17 11:57:24 +11:00
zhangjianminng c408c18940 netkvm: add the feature of copy mapping
for the problem description
please visit #942

Signed-off-by:  Zhang JianMing <[email protected]>
2024-01-16 15:31:03 +02:00
zhangjianminng 6c2f08a4d9 netkvm: refactor BindToDescriptor return type to use NBMappingStatus enum
This commit updates the CNB::BindToDescriptor method signature, changing
the return type from a boolean to the newly introduced NBMappingStatus
enum. The updated method now returns one of the following statuses:

    NBMappingStatus::SUCCESS
    NBMappingStatus::NO_RESOURCE
    NBMappingStatus::FAILURE

This change allows for more detailed reporting of the binding operation
outcome, enabling the caller to distinguish between different failure
reasons beyond the previous binary success/failure indication. The
NBMappingStatus enum provides a clearer, more expressive way to handle
the results of the binding process.

Signed-off-by:  Zhang JianMing <[email protected]>
2024-01-16 15:31:03 +02:00
zhangjianminng 6d23a8260b netkvm: add CopyFromMdlChain function to CNB class
This commit introduces the CopyFromMdlChain function to the CNB class. The function is responsible for copying data from a Memory Descriptor List (MDL) chain to a specified destination buffer. A special focus has been given to ensuring the function handles the traversal of the MDL chain correctly, updating the Source MDL pointer and the Offset within the current MDL as it progresses through the chain.

Signed-off-by:  Zhang JianMing <[email protected]>
2024-01-16 15:31:03 +02:00
zhangjianminng a9d3c71d03 netkvm: define MAX_FRAGMENTS_IN_ONE_NB macro to cap SGTableCapacity
This commit introduces the MAX_FRAGMENTS_IN_ONE_NB macro, which
defines the maximum number of fragments in a single NET_BUFFER. It
is used to constrain the SGTableCapacity value, ensuring it does
not exceed the meaningful limit set by MAX_FRAGMENTS_IN_ONE_NB.

Signed-off-by:  Zhang JianMing <[email protected]>
2024-01-16 15:31:03 +02:00
zhangjianminng 19ee48c26f netkvm: add additional pages to TXManager for upcoming copy mechanism
This commit introduces extra pages within the TXManager module,
which are intended to support the copy mechanism that will be
implemented in subsequent updates. The addition of these pages lays
the groundwork for the new functionality and ensures that the
TXManager is prepared for the enhancements.

Signed-off-by:  Zhang JianMing <[email protected]>
2024-01-16 15:31:03 +02:00
Vadim Rozenfeld dffda9c996 [vioscsi] add support for tracing SRB processing time
https://issues.redhat.com/browse/RHEL-19188

v2 changed the Registry Key name to "TraceResponseTime" as
suggested by JonKohler

Signed-off-by: Vadim Rozenfeld <[email protected]>
2024-01-16 22:03:41 +11:00
Vadim Rozenfeld 956b7bea7a [vioscsi] clean up win8-related code
Signed-off-by: Vadim Rozenfeld <[email protected]>
2024-01-16 22:03:41 +11:00
Yuri Benditovich 359f42c102 netkvm: filter RX packets as early as possible
https://issues.redhat.com/browse/RHEL-20575

Currently the driver get RX descriptor from the rx virtQ,
analyses it (L2/L3), calculates hash and delivers to the
proper RSS queue. Later it extract the packet from the RSS
queue and checks whether it passes RX filters.
Now we move the filtering to the earliest stage - just after
basic analysis.
Note that in case of vhost there are no receive filters
configured by the host and typically the host does not work
in promiscuous mode, so it is redundant to calculate the hash
and trigger the RSS queue for packets that should be dropped.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-01-16 10:17:40 +02:00
Vadim Rozenfeld 649d5e051e [viogpudod] report resolution 1024x768 as a preferred one
related to https://issues.redhat.com/browse/RHEL-21032 and
https://issues.redhat.com/browse/RHEL-1292

Signed-off-by: Vadim Rozenfeld <[email protected]>
2024-01-16 09:05:15 +11:00