Skip to content

Commit 931cccc

Browse files
andrea-parriSasha Levin
authored andcommitted
Drivers: hv: vmbus: Add module parameter to cap the VMBus version
Currently, Linux guests negotiate the VMBus version with Hyper-V and use the highest available VMBus version they can connect to. This has some drawbacks: by using the highest available version, certain code paths are never executed and can not be tested when the guest runs on the newest host. Add the module parameter "max_version", to upper-bound the VMBus versions guests can negotiate. Suggested-by: Dexuan Cui <[email protected]> Signed-off-by: Andrea Parri <[email protected]> Reviewed-by: Wei Liu <[email protected]> Reviewed-by: Michael Kelley <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 2d4f49b commit 931cccc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/hv/connection.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/wait.h>
1515
#include <linux/delay.h>
1616
#include <linux/mm.h>
17+
#include <linux/module.h>
1718
#include <linux/slab.h>
1819
#include <linux/vmalloc.h>
1920
#include <linux/hyperv.h>
@@ -55,6 +56,16 @@ static __u32 vmbus_versions[] = {
5556
VERSION_WS2008
5657
};
5758

59+
/*
60+
* Maximal VMBus protocol version guests can negotiate. Useful to cap the
61+
* VMBus version for testing and debugging purpose.
62+
*/
63+
static uint max_version = VERSION_WIN10_V5_2;
64+
65+
module_param(max_version, uint, S_IRUGO);
66+
MODULE_PARM_DESC(max_version,
67+
"Maximal VMBus protocol version which can be negotiated");
68+
5869
int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, u32 version)
5970
{
6071
int ret = 0;
@@ -240,6 +251,8 @@ int vmbus_connect(void)
240251
goto cleanup;
241252

242253
version = vmbus_versions[i];
254+
if (version > max_version)
255+
continue;
243256

244257
ret = vmbus_negotiate_version(msginfo, version);
245258
if (ret == -ETIMEDOUT)

0 commit comments

Comments
 (0)