Commit Graph
1136 Commits
Author SHA1 Message Date
benyamin-codez 7a0eef69d3 [NetKVM] Refactored legacy DVL creation
1. Refactors the CustomBuildStep Command to manage DVL file creation.
   We now create DVL files in the Project (driver) folder with version
   numbers in the file name for DVL files created with legacy EWDKs,
   and with the "latest" label for current EWDKs. These files are
   then copied to the relevant .\Install folders and renamed for
   extant WHCP submission operations. Makes use of the new batch file
   build\makeLegacyDVLs.bat script (from PR #1210), which now creates
   all legacy DVL files. Logging is also enabled to provide feedback
   when read at the tail of root\buildAll.bat. Please see PR #1212 for
   details on those changes.

2. Enables Win10_SDV for local (NetKVM) buildAll.bat script.

Signed-off-by: benyamin-codez <[email protected]>
2025-01-08 13:12:08 +01:00
benyamin-codez 04f589ff88 [build] Scrub the cleaners
a) Standardised cleaner routines
b) Introduced -quiet and -debug parameters when run from repo root
c) Moved from FOR loop to a shift loop to more reliably support a
   wider variety of directory formats and characters
d) Created NetKVM/clean_inx.cmd to delete *.inx files in NetKVM
e) Updated NetKVM/clean_dvl_log.cmd to use standardised routines
f) Moved all other custom clean operations to build/clean.bat
g) Added missing cleaner to viocrypt
h) Added missing entries for viomem and viocrypt to list of
   directories to clean

Signed-off-by: benyamin-codez <[email protected]>
2025-01-05 15:47:01 +01:00
Yuri Benditovich 82909adcb1 netkvm: remove unused member 'DriverHandle'
Signed-off-by: Yuri Benditovich <[email protected]>
2024-12-11 11:57:39 +01:00
Yuri Benditovich ec023725fc netkvm: fail init if failed to open NIC configuration
Under driver verifier with low resources simulation the
attempt to access NIC configuration may fail, important
fields of the context are not initialized correctly
causing driver verifier BSOD on attempt to allocate
zero bytes from memory. Fail initialization if the NIC
configuration is not accessible.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-12-11 11:57:39 +01:00
Yuri Benditovich ab1c77eaad netkvm: ensure the adapter object is always deleted
https://issues.redhat.com/browse/RHEL-68725

Simplify failure flow, remove redundant things from it and
ensure the pContext is always deleted. It's destructor does
complete cleanup, including interrupt deregistration. This
fixes BSOD under driver verifier with low resource simulation
NDIS_BUGCHECK_INIT_FAILED_WITHOUT_INTERRUPT_DEREGISTER.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-12-11 11:57:39 +01:00
Yuri Benditovich 1efdadfac2 netkvm: move RegisterFlow calls to constructor
Signed-off-by: Yuri Benditovich <[email protected]>
2024-12-11 11:57:39 +01:00
Yuri Benditovich ae37512cd4 netkvm: pass miniport context to constructor
Read-write lock is created with MiniportContext=NULL because
this happens in the constructor when this field in adapter
context is not populated yet. Pass miniport context as parameter
to the constructor of adapter object and propagate it to the
RSSParameters member.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-12-11 11:57:39 +01:00
Yuri Benditovich 236eea2418 netkvm: fix format of printouts in case of error
Signed-off-by: Yuri Benditovich <[email protected]>
2024-12-11 11:57:39 +01:00
Yuri Benditovich 5f5540a3cd netkvm: fix BSOD if some queue fails to renew
https://issues.redhat.com/browse/RHEL-68725
https://github.com/virtio-win/kvm-guest-drivers-windows/issues/1197
In such case we do not have any other option than request to
unload the driver. This can happen in 2 flows: power up (during
fast startup) or reset, both with driver verifier that simulates
low resources.
In reset flow we need to request driver unload explicitly.
Power up flow works in SET_POWER, so it will do it automatically.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-12-11 11:57:39 +01:00
Yuri Benditovich 2a9f853bb1 netkvm: use per-queue max RX buffers instead of global
Global value of max RX buffers, shared among queues, is
bad idea. It is especially bad when memory allocation
during queue initialization may fail, for example in case
of driver running under driver verifier. Changing the
global field to per-queue field.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-12-11 11:57:39 +01:00
Yuri Benditovich b85629eb5e netkvm: deregister miniport in erroneous path
https://issues.redhat.com/browse/RHEL-68725

The problem can be reproduced under driver verifier with
low resource simulation. If the miniport is registered
but the protocol fail to register we need to deregister
the miniport. Otherwise in future attempts to load the driver
the NDIS enters erroneous state and may issue BSOD. Example of
BSOD: BUGCODE_NDIS_DRIVER/NDIS_BUGCHECK_REFCOUNT_IMBALANCE.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-12-11 11:57:39 +01:00
Yuri Benditovich 48cdf5f8d0 netkvm: init-time decide about maximum RX buffer size
Currently the driver always assume the maximim packet size
is ~64K as it is compiled with RSC support. The initial
reason was that if the RSC is disabled by admin (registry
value of the driver), it can be turned on by command, i.e.
without disable-enable. However this depends also on host
features. If the host does not support the GUEST_TSOx,
RSC will be reported to the OS as not supported but the
buffers are still huge without any reason.
(In such case the powershell reports IPv4 and IPv6 operational
state as Off even if the RSC keywords are enabled).
The commit moves the decision to initialization time - if the
RSC is not supported, the buffers are sized accoring to MTU.
The memory consumption is lower 16 times.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-11-28 11:15:53 +02:00
Yuri Benditovich 886047541e netkvm: use optimized layout of shared memories for RX
https://issues.redhat.com/browse/RHEL-19814

Do not allocate redundant memory, use full 4K+ pages when
needed, tail of the data (usually small) allocate together
with header/indirect block and make this block smaller than
4K when possible. This reduces 10% of all the shared memory
allocated for RX buffers. For non-RSC configuration it is
possible to reduce much more (for future).

Signed-off-by: Yuri Benditovich <[email protected]>
2024-11-28 11:15:53 +02:00
Yuri Benditovich f5e5b234c6 netkvm: apply the layout when allocating RX buffers
Signed-off-by: Yuri Benditovich <[email protected]>
2024-11-28 11:15:53 +02:00
Yuri Benditovich ec9e1f51c0 netkvm: prepare layout of RX shared buffers
Split the decisions about size of shared buffers for RXQ and
allocation of shared memories. Create optimal layout of RX shared
buffers before creation of queues; allocate the memories according
the layout. Initially optimized layout is desabled and we create
the "legacy" layout, fully compatible with what was done before.
This commit contains only creation of the layout, it is not yet
applied when allocating RX buffer's memories.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-11-28 11:15:53 +02:00
Yuri Benditovich d93a234575 netkvm: declare DMAR compatibility in the INF file
https://issues.redhat.com/browse/RHEL-1215

Enable DMAR if driver verifier is enabled

Signed-off-by: Yuri Benditovich <[email protected]>
2024-11-25 11:00:38 +02:00
Konstantin Kostiuk e6546dc358 RHEL-65784: Fix files ending
clang-format always check one \n at the end of file.

Jira: https://issues.redhat.com/browse/RHEL-65784

Signed-off-by: Konstantin Kostiuk <[email protected]>
2024-11-20 15:48:35 +02:00
Konstantin Kostiuk 84b50b8ecb Move build/sign related tools into a separate folder
Signed-off-by: Konstantin Kostiuk <[email protected]>
2024-10-13 14:41:59 +02:00
Ai Qi 6d53a2d0a9 NetKVM: ack VIRTIO_F_ORDER_PLATFORM
According to commit 48aeb261, add VIRTIO_F_ORDER_PLATFORM to NetKVM.

Signed-off-by: Ai Qi <[email protected]>
2024-09-21 14:07:21 +02:00
Yuri Benditovich 918a814456 netkvm-prot: fix typo in printout
Signed-off-by: Yuri Benditovich <[email protected]>
2024-06-25 10:30:06 +03:00
Yuri Benditovich d1af78d045 netkvm: disable poll mode in standby(failover) mode
Fixes: https://issues.redhat.com/browse/RHEL-32200

Supporting poll mode flows is very complicated in
case the driver acts as protocol driver above VF
device, so the driver will ignore the poll mode setting
in case it works in standby mode. If the VF driver does
not use the poll mode everything will work the same way
as in Win10. If the VF driver uses poll mode it reports
incoming packets from its poll mode handler already and
the NetKVM just indicates the packets up.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-06-25 10:30:06 +03:00
Yuri Benditovich 0c536eb25d netkvm-prot: do not stop service if the netkvmp.exe is deleted
In case the INF file is driver-isolation compatible the file
copied to directory other than %13% might be deleted on network
driver uninstall. In such case we should keep the protocol
running until other event happens, like protocol driver uninstall
or network driver installation.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-06-25 10:30:06 +03:00
Yuri Benditovich fb5ccb351a netkvm-prot: development time signing of vioprot.inf
For signing of the protocol INF just need to enable signing
in the .user file

Signed-off-by: Yuri Benditovich <[email protected]>
2024-06-25 10:30:06 +03:00
Yuri Benditovich 657ad7efb5 netkvm: fix affinity of poll handlers
https://issues.redhat.com/browse/RHEL-33334
Fix wrong affinity assignment.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-05-07 10:24:24 +03:00
Yuri Benditovich 5fd4ffbe44 netkvm: issue poll request from poll handler when needed
One of problems in HCK tests is that we often come to
state when poll handler is not called when this would
be expected and nothing happens that can trigger the polllng.
Issue 'request from self' to resume polling when RX or TX
needs service.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-05-05 15:13:47 +03:00
Yuri Benditovich dffd27a745 netkvm: add details to poll mode logs
Main thing is always understand what is the source of the
notification/trigger, this may be, for example TX, RX, RSS

Signed-off-by: Yuri Benditovich <[email protected]>
2024-05-05 15:13:47 +03:00
Yuri Benditovich 5a11286adf netkvm: add detection/recovery for TX stuck packets
The packets might be stuck in send queue or in waiting list.
The recovery is simple - trigger TX processing of completed
and pending packets. Can be called from any external place,
for example from CheckForHang handler.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-05-05 15:13:47 +03:00
Yuri Benditovich 8b181d2c95 netkvm: possibility to test poll mode on 2022
This provides simple way to build the driver with minimal
modification and enable poll mode on any NDIS 6.85+,
for engineering testing purposes.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-05-05 15:13:47 +03:00
Yuri Benditovich 4068dea598 netkvm: more details in RX poll printout
Signed-off-by: Yuri Benditovich <[email protected]>
2024-05-05 15:13:47 +03:00
Yuri Benditovich e8a24b48b9 netkvm: temporary report 6.89 when OS has 6.89
This is temporary exception in NDIS revision negotiation
for driver built as 6.86, in order to satisfy HLK expectations
on Server 2025.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-05-05 15:13:47 +03:00
Yuri Benditovich 8b6f5ef6a0 netkvm: fix memory leak in TX overfragmenting flow
https://issues.redhat.com/browse/RHEL-24992
Memory leak of CNB::m_ExtraNBStorage happens if the
packet os overfragmented but we do not succeed to
allocate extra pages.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-11 10:37:33 +03:00
Yuri Benditovich dfdaec5aac netkvm: finally enable negotiation USO TX support
Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-07 10:40:33 +03:00
Yuri Benditovich 53d0f84014 netkvm: correct validation of segmentable UDP packet
Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-07 10:40:33 +03:00
Yuri Benditovich eed3ceba37 netkvm: fix content of USO capabilities report
NDIS 6.84 adds capabilities fields SubMssFinalSegmentSupported.
Set it to 'supported', allow UDP payload size that is not
multiple of MSS.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-07 10:40:33 +03:00
Yuri Benditovich 87632fc463 netkvm: define separate PARANDIS_MAX_USO_SIZE
There is no clear techical reason why the maximal size of
large UDP packet should be different from one of large TCP
packet. But currently (kernel mainstream, current kernel 6.9
and all earlier kernels) kernel defines UDP_MAX_SEGMENTS as 64.
Minimal MSS in Windows is 536, so we report maximal size of
UDP packet as 64 * 536, such a way we'll never get from OS
UDP packets that can't be transmitted.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-07 10:40:33 +03:00
Yuri Benditovich acb9ec17be netkvm: remove unused field
Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-07 10:40:33 +03:00
Yuri Benditovich 4d90f38ba7 netkvm: fix INF name reference in CAT file
For details see
https://github.com/virtio-win/kvm-guest-drivers-windows/issues/1081

Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-05 16:47:02 +03:00
Yuri Benditovich a785a25c31 netkvm-prot: update Readme.md
Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-05 16:47:02 +03:00
Yuri Benditovich 66246289fd netkvm-prot: update protocol service binary at runtime
https://issues.redhat.com/browse/RHEL-31482
Before this commit: netkvmp.exe is installed by protocol INF
to system32 directory, INF also creates netkvmp service for
this binary. The netkvmp.exe works with netkvm driver using
IOCTLs and continues doing it in case the netkvm driver is
updated, so these binaries at some point might get out of sync.
In order to update the netkvmp.exe the protocol INF must be
reinstalled.
After this commit: netkvmp.exe is installed by netkvm INF to
system directory. When the netkvmp.exe is called to install
the protocol it first copies itself to system32\netkvmps.exe,
then it installs protocol INF, which creates netkvmp service
with existing netkvmps.exe file. The service from time to time
checks that the service binary (netkvmps.exe) is identical to
netkvmp.exe. When it detects they are out of sync, it starts
'netkvmp.exe restartservice' and stops. The netkvmp.exe
copies itself to netkvmps.exe and starts the service. Such a
way, the protocol service is always in sync with netkvm driver.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-05 16:47:02 +03:00
Yuri Benditovich 21b640daf5 netkvm-prot: add logging on process running
Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-05 16:47:02 +03:00
Yuri Benditovich 097374a352 netkvm-prot: make BinaryPath() procedure static
Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-05 16:47:02 +03:00
Yuri Benditovich 1be84c81fe netkvm-prot: add system directory getter class
Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-05 16:47:02 +03:00
Yuri Benditovich 3ae4694b64 netkvm-prot: support delayed stop of the service
Make service stop synchronous or asynchronous depending on
the state of running thread. Normally the service will complete
the stop asynchronously when the thread stops running. Also
in case the service thread will decide to finish (in later case of
self-update) it should indicate the stopped state correctly.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-05 16:47:02 +03:00
Yuri Benditovich 30b722b528 netkvm-prot: convert NotifyObject to dummy driver project
- remove all the redundant files from the project
- change netkvmno.cpp to dummy driver file
- change project to be driver project (to sign INF)
- remove netkvmno.dll from INF file

Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-05 16:47:02 +03:00
Yuri Benditovich ef9503df36 netkvm: minor changes in printouts
Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-05 16:47:02 +03:00
Yuri Benditovich dfb56fb669 netkvm: minor comment fix
Signed-off-by: Yuri Benditovich <[email protected]>
2024-04-05 16:47:02 +03:00
Kostiantyn Kostiuk fcda1586e9 NetKVM: Use DIRID 12 for Win10 driver
As Windows Server 2016 has build lower than 16299, we should
have DIRID 12 for Win10 drivers.

Resolve: https://issues.redhat.com/browse/RHEL-1214

Signed-off-by: Kostiantyn Kostiuk <[email protected]>
2024-03-29 17:34:04 +11:00
Yuri Benditovich 7304a2404b netkvm: enable poll mode support for server 2025
https://issues.redhat.com/browse/RHEL-17932
Win11 driver supports poll mode when runs on server 2025
(runtime NDIS version 6.89)
On earlier versions Win11 driver contains *NdisPoll keyword
but this keyword does not make any behavioral change.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-03-28 09:54:50 +02:00
Yuri Benditovich 92a8ca54ec netkvm: compile Win11 driver with NDIS 6.86
NDIS 6.86 vs 6.85 does not include any new features and we
use 6.86 to separate build that support poll mode (Win11).
Although poll mode is supported by 6.85 we can't use Win10
driver with poll mode compiled in as the driver will fail
to load on OS where NDIS Poll Mode API is not exported.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-03-28 09:54:50 +02:00
Yuri Benditovich 4f1917af37 netkvm: add *NdisPoll configuration for Win11 INF
Currently this does not cause any functional change in the driver
without PARANDIS_SUPPORT_POLL define.

Signed-off-by: Yuri Benditovich <[email protected]>
2024-03-28 09:54:50 +02:00