Skip to contentSkip to conversation

vmbus: Add DeviceTree support for message connection-id

PATCH Superseded Hardik Garg 3 participants 17 messages Jun 19, 2025 – Nov 6, 2025

Subsystems (3)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover vmbus: Add DeviceTree support for message connection-id

This patch series adds support for configuring the VMBus message connection-id through DeviceTree. The connection-id determines which hypervisor communication channel the guest should use to talk to the VMBus host.

Changes in v4:
- Split the patch into two separate patches:
* DeviceTree bindings documentation
* Implementation changes
- Fix warnings reported by checkpatch

Changes in v3:
- https://lore.kernel.org/all/[email protected]/

Changes in v2:
- https://lore.kernel.org/all/[email protected]/

Changes in v1:
- https://lore.kernel.org/all/[email protected]/

The series consists of two patches:
1. dt-bindings: microsoft: Add vmbus message-connection-id property
2. vmbus: retrieve connection-id from DeviceTree

Testing:
- Tested on Microsoft Hyper-V
- Verified with and without the DeviceTree property
- Confirmed proper fallback to default values
- Validated binding documentation with dt_binding_check

Hardik Garg (2):
dt-bindings: microsoft: Add vmbus message-connection-id property
vmbus: retrieve connection-id from DeviceTree

 Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml |  9 +++++++++
 drivers/hv/connection.c                                    |  6 ++++--
 drivers/hv/vmbus_drv.c                                    | 13 +++++++++++++
 3 files changed, 26 insertions(+), 2 deletions(-)
Signature · 1 line
2.40.4
#1 lore raw

PATCH v4 1/2 dt-bindings: microsoft: Add vmbus message-connection-id property

Document the microsoft,message-connection-id property for VMBus DeviceTree node. This property allows specifying the connection ID used for communication between host and guest.

---
v3: https://lore.kernel.org/all/[email protected]
v2: https://lore.kernel.org/all/[email protected]
v1: https://lore.kernel.org/all/[email protected]

---
 Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml | 9 +++++++++
 1 file changed, 9 insertions(+)
Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml +9 -0
index 0bea4f5287ce..615b48bd6a8b 100644
@@ -17,6 +17,14 @@ properties:
   compatible:
     const: microsoft,vmbus
 
+  microsoft,message-connection-id:
+    description: |
+      VMBus message connection ID to be used for communication between host and
+      guest. If not specified, defaults to VMBUS_MESSAGE_CONNECTION_ID_4 (4) for
+      protocol version VERSION_WIN10_V5 and above, or VMBUS_MESSAGE_CONNECTION_ID
+      (1) for older versions.
+    $ref: /schemas/types.yaml#/definitions/uint32
+
   ranges: true
 
   '#address-cells':
@@ -55,6 +63,7 @@ examples:
 
             vmbus@ff0000000 {
                 compatible = "microsoft,vmbus";
+                microsoft,message-connection-id = <4>;
                 #address-cells = <2>;
                 #size-cells = <1>;
                 ranges = <0x0f 0xf0000000 0x0f 0xf0000000 0x10000000>;
Signature · 1 line
2.40.4
#2 lore raw

Re: [PATCH v4 1/2] dt-bindings: microsoft: Add vmbus message-connection-id property

Quoted 2 lines · Hardik Garg

Document the microsoft,message-connection-id property for VMBus DeviceTree node. This property allows specifying the connection ID used for

What is a connection ID and why it cannot be inferred from existing system API?

Quoted 16 lines

communication between host and guest.

---
v3: https://lore.kernel.org/all/[email protected]
v2: https://lore.kernel.org/all/[email protected]
v1: https://lore.kernel.org/all/[email protected]

---
 Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml | 9 +++++++++
 1 file changed, 9 insertions(+)
Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml +0 -0
index 0bea4f5287ce..615b48bd6a8b 100644

Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml properties: · line 18

Quoted 2 lines
Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml +0 -0
@@ -17,6 +17,14 @@ properties:
   compatible:
     const: microsoft,vmbus

There's a reason why you have here generic property - this is generic and/or discoverable and/or whatever software interface. Adding now more properties, just because you made it generic, is not the way.

Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml properties: · line 21

Quoted 3 lines
Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml +2 -0
+  microsoft,message-connection-id:
+    description: |

Drop |

Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml properties: · line 25

Quoted 4 lines
Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml +4 -0
+      VMBus message connection ID to be used for communication between host and
+      guest. If not specified, defaults to VMBUS_MESSAGE_CONNECTION_ID_4 (4) for
+      protocol version VERSION_WIN10_V5 and above, or VMBUS_MESSAGE_CONNECTION_ID
+      (1) for older versions.

Missing constraints, defaults, if this stays, but frankly speaking it looks really not appropriate, considering lack of any explanation in the binding or in commit msg.

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH v4 1/2] dt-bindings: microsoft: Add vmbus message-connection-id property

Thank you for your review, Krzysztof. I apologize for the delay in my response.

Quoted 2 lines
Quoted 2 lines

What is a connection ID and why it cannot be inferred from existing system API?

The connection-id determines which hypervisor communication channel the guest should use to talk to the VMBus host. Reading from DeviceTree allows platforms to specify their preferred communication channel, making it more flexible (I will add this detail in the commit message). Presently, this value is hardcoded and there is no existing API to read it.

Quoted 3 lines
Quoted 3 lines

There's a reason why you have here generic property - this is generic and/or discoverable and/or whatever software interface. Adding now more properties, just because you made it generic, is not the way.

Presently the value is hardcoded and we want to provide a functionality to the user to specify their prefered communication channel. This is a virtualized hardware property for us.

Quoted 1 line
Quoted 1 line

Drop |

I will remove "|".

Quoted 3 lines
Quoted 3 lines

Missing constraints, defaults, if this stays, but frankly speaking it looks really not appropriate, considering lack of any explanation in the binding or in commit msg.

I will add constraints, and defaults.

Please let me know if there are any other issues that I should fix with the next version of the patch and thank you again for the review.

Regards,
Hardik

#4 lore raw

Re: [PATCH v4 1/2] dt-bindings: microsoft: Add vmbus message-connection-id property

Quoted 2 lines · Hardik Garg

Thank you for your review, Krzysztof. I apologize for the delay in my response.

You got review after 8 hours.

You respond after 3 weeks.

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

What is a connection ID and why it cannot be inferred from existing system API?

The connection-id determines which hypervisor communication channel the guest should use to talk to the VMBus host. Reading from DeviceTree allows platforms to specify their preferred communication channel, making it more flexible (I will add this detail in the commit message). Presently, this

We don't add properties to make things flexible.

Quoted 9 lines

value is hardcoded and there is no existing API to read it.

Quoted 3 lines
Quoted 3 lines

There's a reason why you have here generic property - this is generic and/or discoverable and/or whatever software interface. Adding now more properties, just because you made it generic, is not the way.

Presently the value is hardcoded and we want to provide a functionality to the user to specify their prefered communication channel. This is a virtualized hardware property for us.

That's not really acceptable reason. With such approach I would add 100 properties to make various things "flexible".

Best regards,
Krzysztof

#5 lore raw

Re: [PATCH v4 1/2] dt-bindings: microsoft: Add vmbus message-connection-id property

Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines

What is a connection ID and why it cannot be inferred from existing system API?

The connection-id determines which hypervisor communication channel the guest should use to talk to the VMBus host. Reading from DeviceTree allows platforms to specify their preferred communication channel, making it more flexible (I will add this detail in the commit message). Presently, this

We don't add properties to make things flexible.

You're right. I should have explained better. The connection ID is a hardware configuration detail that defines which specific VMBus channel is used for host-guest communication. This value is configured by the host and passed to the guest through the host's device tree. Different hypervisor versions and configurations may require different channels, and this needs to be specified by the platform.

Quoted 10 lines
Quoted 10 lines
Quoted 3 lines
Quoted 3 lines

There's a reason why you have here generic property - this is generic and/or discoverable and/or whatever software interface. Adding now more properties, just because you made it generic, is not the way.

Presently the value is hardcoded and we want to provide a functionality to the user to specify their prefered communication channel. This is a virtualized hardware property for us.

That's not really acceptable reason. With such approach I would add 100 properties to make various things "flexible".

I understand your concern. Let me clarify: this isn't about making things flexible for flexibility's sake. The connection ID is a fundamental hardware configuration parameter that is set by the host and must be matched in the guest. The host configures this value in its device tree and shares it with the guest. Without the correct channel ID, the VMBus communication fails. Different hypervisor configurations require different channels, and this cannot be automatically discovered.

Would you prefer if we handled this configuration through a different mechanism? I'm open to suggestions.

Thanks,
Hardik

#6 lore raw

Re: [PATCH v4 1/2] dt-bindings: microsoft: Add vmbus message-connection-id property

Quoted 8 lines · Hardik Garg
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

What is a connection ID and why it cannot be inferred from existing system API?

The connection-id determines which hypervisor communication channel the guest should use to talk to the VMBus host. Reading from DeviceTree allows platforms to specify their preferred communication channel, making it more flexible (I will add this detail in the commit message). Presently, this

Quoted 8 lines
Quoted 1 line
Quoted 1 line

We don't add properties to make things flexible.

You're right. I should have explained better. The connection ID is a hardware configuration detail that defines which specific VMBus channel is used for host-guest communication. This value is configured by the host and passed to the guest through the host's device tree. Different hypervisor versions and configurations may require different channels, and this needs to be specified by the platform.

Host is supposed to have multiple guests, so this feels like you are going to prepare for each guest different DTS with different connection ID. This feels like poor design. DTS is supposed to be relatively static configuration, not runtime choice vmguestid+1.

The guest cannot access other configuration channels, can it? If it can, it would mean it can eavesdrop on other guests? So obviously it cannot. Therefore from guest point of view this is completely redundant. Guest cannot use any other value, thus guest should not configure it. The guest has only one channel and uses only this one which gets to right place to the host.

Best regards,
Krzysztof

#7 lore raw

Re: [PATCH v4 1/2] dt-bindings: microsoft: Add vmbus message-connection-id property

Quoted 11 lines

Host is supposed to have multiple guests, so this feels like you are going to prepare for each guest different DTS with different connection ID. This feels like poor design. DTS is supposed to be relatively static configuration, not runtime choice vmguestid+1.

The guest cannot access other configuration channels, can it? If it can, it would mean it can eavesdrop on other guests? So obviously it cannot. Therefore from guest point of view this is completely redundant. Guest cannot use any other value, thus guest should not configure it. The guest has only one channel and uses only this one which gets to right place to the host.

Thank you for your feedback. Let me explain the connection ID in more detail:

1. Message Port Architecture:
- The connection ID specifies which Hyper-V hypervisor message port (mailbox slot) to use for communication between the host and guest
- The hypervisor has multiple message ports, but historically VMBus only used one
- With the introduction of VTL2 (Virtual Trust Level 2), the control plane can now be hosted in VTL2, requiring different message ports for communication

2. Control Plane Communication:
- The VMBus control plane on the host needs to communicate with the VMBus driver in the guest
- When the control plane is hosted in VTL2, it requires a different message port than the standard communication path
- The connection ID tells the guest whether to use the standard or alternate message port for this control plane communication

3. Message Processing:
- Each message is tagged with an ID
- If the guest uses an incorrect ID, the host won't recognize the message and will drop it
- This is not about choosing between multiple available channels - it's about using the correct mailbox slot for communication

4. Security and Isolation:
- Each guest has its private hypervisor mailbox
- Multiple guests using the same connection ID cannot interfere with each other
- The connection ID is more like a "root ID" that helps enumerate devices on the bus, not a channel selector between guests

5. Dynamic Nature:
- The connection ID is specified when the guest starts running
- The host can change it during VM lifecycle events (reset/reboot)
- This is why the VMBus driver needs to know the connection ID every time the kernel starts
- The ID might be different from what it was during the last guest run

Thanks,
Hardik

#8 lore raw

Re: [PATCH v4 1/2] dt-bindings: microsoft: Add vmbus message-connection-id property

Quoted 24 lines · Hardik Garg
Quoted 11 lines

Host is supposed to have multiple guests, so this feels like you are going to prepare for each guest different DTS with different connection ID. This feels like poor design. DTS is supposed to be relatively static configuration, not runtime choice vmguestid+1.

The guest cannot access other configuration channels, can it? If it can, it would mean it can eavesdrop on other guests? So obviously it cannot. Therefore from guest point of view this is completely redundant. Guest cannot use any other value, thus guest should not configure it. The guest has only one channel and uses only this one which gets to right place to the host.

Thank you for your feedback. Let me explain the connection ID in more detail:

1. Message Port Architecture:
- The connection ID specifies which Hyper-V hypervisor message port (mailbox slot) to use for communication between the host and guest
- The hypervisor has multiple message ports, but historically VMBus only used one
- With the introduction of VTL2 (Virtual Trust Level 2), the control plane can now be hosted in VTL2, requiring different message ports for communication

2. Control Plane Communication:
- The VMBus control plane on the host needs to communicate with the VMBus driver in the guest
- When the control plane is hosted in VTL2, it requires a different message port than the standard communication path
- The connection ID tells the guest whether to use the standard or alternate message port for this control plane communication

Quoted 5 lines

3. Message Processing:
- Each message is tagged with an ID
- If the guest uses an incorrect ID, the host won't recognize the message and will drop it
- This is not about choosing between multiple available channels - it's about using the correct mailbox slot for communication

Don't paste me specs in response to questions, but answer specific questions.

Quoted 3 lines

4. Security and Isolation:
- Each guest has its private hypervisor mailbox
- Multiple guests using the same connection ID cannot interfere with each other

Then all guests can use the same value, 0, making this property redundant.

Quoted 5 lines

- The connection ID is more like a "root ID" that helps enumerate devices on the bus, not a channel selector between guests

5. Dynamic Nature:
- The connection ID is specified when the guest starts running
- The host can change it during VM lifecycle events (reset/reboot)

So not suitable for DT. DT is a static data. You cannot just keep changing existing DT to match whatever you want runtime.

Quoted 2 lines

- This is why the VMBus driver needs to know the connection ID every time the kernel starts
- The ID might be different from what it was during the last guest run

Best regards,
Krzysztof

#9 lore raw

Re: [PATCH v4 1/2] dt-bindings: microsoft: Add vmbus message-connection-id property

Quoted 1 line

Then all guests can use the same value, 0, making this property redundant.

No, they cannot use the same value. The protocol requires different connection IDs for different communication paths. For example, a guest communicating with a VTL0 control plane uses a different connection ID than one communicating with a VTL2 control plane. The host specifies this value based on the guest's configuration, and there is no other discovery method available to determine the correct connection ID.

Quoted 1 line

So not suitable for DT. DT is a static data. You cannot just keep changing existing DT to match whatever you want runtime.

From the guest's perspective, this data is completely static - it doesn't change over the lifetime of the guest. The guest always looks it up in DT. The hypervisor merely populates this value in the guest's DT. Once set, it remains fixed for that guest instance, so this data is not dynamic, it's completely fixed for the guest.

Thanks,
Hardik

#10 lore raw

Re: [PATCH v4 1/2] dt-bindings: microsoft: Add vmbus message-connection-id property

Quoted 6 lines · Hardik Garg
Quoted 1 line

Then all guests can use the same value, 0, making this property redundant.

No, they cannot use the same value. The protocol requires different connection IDs for different communication paths. For example, a guest communicating with a VTL0 control plane uses a different connection ID than one communicating with a VTL2 control plane. The host specifies this value based on the guest's configuration, and there is no other discovery method available to determine the correct connection ID.

You completely removed entire thread and discussion making it difficult to connect to one of 100 or more discussions I am doing.

Plus wrap your emails according to netiquette rules.

The guest should not care about the value. Otherwise what if guests decides to ignore your DT property and start using other value? Sniffing other guests traffic? Causing conflicts or denial of service?

If different values are important for the host, then all guests should use whatever 0 which will map to different values on host by other means of your protocol.

Best regards,
Krzysztof

#11 lore raw

Re: [PATCH v4 1/2] dt-bindings: microsoft: Add vmbus message-connection-id property

Quoted 11 lines · Krzysztof Kozlowski
Quoted 6 lines · Hardik Garg
Quoted 1 line

Then all guests can use the same value, 0, making this property redundant.

No, they cannot use the same value. The protocol requires different connection IDs for different communication paths. For example, a guest communicating with a VTL0 control plane uses a different connection ID than one communicating with a VTL2 control plane. The host specifies this value based on the guest's configuration, and there is no other discovery method available to determine the correct connection ID.

You completely removed entire thread and discussion making it difficult to connect to one of 100 or more discussions I am doing.

Apologies for the very late reply — I realize it’s been a few months since your last feedback. I wanted to take time to revisit the design and explore possible alternatives to avoid introducing the connection-id property in the Device Tree. After evaluating the available mechanisms, unfortunately there isn’t a viable alternative for passing this information from the host to the guest in the current Hyper-V architecture.

To address your earlier comments in detail:

The connection-id is not an arbitrary or per-guest runtime configuration parameter — it is a hardware-level identifier that specifies which Hyper-V message port (or mailbox slot) the guest should use to communicate with the VMBus control plane. Historically, VMBus always used a single, fixed connection ID. However, with the introduction of Virtual Trust Level 2 (VTL2) support, the control plane can now reside in a different trust level, requiring the guest to communicate through a different message port. This connection-id is determined by the hypervisor based on the status of VMBus relay. From the guest’s perspective, it is completely static for the lifetime of that VM instance — it never changes at runtime. Once the kernel boots, it must read this value to establish communication with the correct VMBus control plane. There is currently no system API, or discoverable interface that allows the guest to determine this value dynamically.

Quoted 5 lines

The guest should not care about the value. Otherwise what if guests decides to ignore your DT property and start using other value? Sniffing other guests traffic? Causing conflicts or denial of service?

Regarding security and isolation:

Each guest has a private hypervisor mailbox and cannot access any other guest’s communication path. Using an incorrect connection ID does not allow eavesdropping or cause interference — it only results in failed VMBus initialization because the host drops messages sent to an unexpected port. Thus, exposing the correct connection ID to the guest is safe and necessary for correct initialization.

Quoted 4 lines

If different values are important for the host, then all guests should use whatever 0 which will map to different values on host by other means of your protocol.

Using a fixed value such as 0 for all guests would not work, because the Hyper-V host differentiates between multiple control-plane contexts (for example, VTL0 vs VTL2) using distinct connection IDs. The guest must use the value assigned by the host, as there is no implicit mapping or negotiation protocol to determine it otherwise.

In summary:
The connection-id is a static hardware configuration detail provided by the host before boot, not a runtime variable. It is required for correct message routing between the guest’s VMBus driver and the appropriate control plane. There is no existing API or firmware interface that can expose this information. Each guest has a dedicated, isolated mailbox, so security is preserved. If you still feel that Device Tree is not the right mechanism, I’m open to discussing alternative approaches that could convey this information from the host to the guest early during boot — though based on the current architecture, I have not found a suitable one yet.

Thank you again for your time, patience, and for your detailed feedback. I’ll make sure my next submission keeps full context and follows proper wrapping and quoting conventions.

Thanks,
Hardik

#12 lore raw

Re: [PATCH v4 1/2] dt-bindings: microsoft: Add vmbus message-connection-id property

Quoted 13 lines · Hardik Garg

Each guest has a private hypervisor mailbox and cannot access any other guest’s communication path. Using an incorrect connection ID does not allow eavesdropping or cause interference — it only results in failed VMBus initialization because the host drops messages sent to an unexpected port. Thus, exposing the correct connection ID to the guest is safe and necessary for correct initialization.

Quoted 4 lines

If different values are important for the host, then all guests should use whatever 0 which will map to different values on host by other means of your protocol.

Quoted 5 lines

Using a fixed value such as 0 for all guests would not work, because the Hyper-V host differentiates between multiple control-plane contexts (for example, VTL0 vs VTL2) using distinct connection IDs. The guest must use the value assigned by the host, as there is no implicit mapping or negotiation protocol to determine it otherwise.

Sorry, I am not going back to three months old discussion.

Therefore I close this topic for me with: since the actual value does not matter for the host - it will discard all messages which are not intended to this guest - you can just use value 0 and your hypervisor will map to proper port.

Best regards,
Krzysztof

#13 lore raw

Re: [PATCH v4 1/2] dt-bindings: microsoft: Add vmbus message-connection-id property

Quoted 12 lines · Krzysztof Kozlowski
Quoted 11 lines · Hardik Garg

Each guest has a private hypervisor mailbox and cannot access any other guest’s communication path. Using an incorrect connection ID does not allow eavesdropping or cause interference — it only results in failed VMBus initialization because the host drops messages sent to an unexpected port. Thus, exposing the correct connection ID to the guest is safe and necessary for correct initialization.

Quoted 4 lines

If different values are important for the host, then all guests should use whatever 0 which will map to different values on host by other means of your protocol.

Quoted 6 lines
Quoted 5 lines

Using a fixed value such as 0 for all guests would not work, because the Hyper-V host differentiates between multiple control-plane contexts (for example, VTL0 vs VTL2) using distinct connection IDs. The guest must use the value assigned by the host, as there is no implicit mapping or negotiation protocol to determine it otherwise.

Sorry, I am not going back to three months old discussion.

I understand your point and I apologize again for the delay in getting back to you. It took me some time to explore alternative approaches and verify whether the connection ID could be handled differently, but I’m now done with that investigation. I’ll make sure to respond in a timely manner going forward.

Quoted 5 lines

Therefore I close this topic for me with: since the actual value does not matter for the host - it will discard all messages which are not intended to this guest - you can just use value 0 and your hypervisor will map to proper port.

The connection ID is managed entirely by the hypervisor and varies depending on the VM’s configuration (for example, whether the control plane is in VTL0 or VTL2). There is no existing mapping logic on the guest side that could translate a constant value like 0 into the correct port assignment. The host assigns distinct IDs for each configuration, and the guest must use that specific value to establish the VMBus control channel correctly.

Could you please confirm if I’m misunderstanding your suggestion about the mapping mechanism? Without receiving the correct ID from the hypervisor (via DT or another interface), the guest cannot infer the right port on its own.

Also, since this thread is quite old, would you prefer that I start a new thread when I resend the updated patch?

Thanks again for your feedback and patience.

Thanks,
Hardik

#14 lore raw

PATCH v4 2/2 vmbus: retrieve connection-id from DeviceTree

In reply to Hardik Garg

The connection-id determines which hypervisor communication channel the guest should use to talk to the VMBus host. This patch adds support to read this value from the DeviceTree where it exists as a property under the vmbus node with the compatible ID "microsoft,message-connection-id". The property name follows the format <vendor>,<field> where "vendor": "microsoft" and "field": "message-connection-id"

Reading from DeviceTree allows platforms to specify their preferred communication channel, making it more flexible. If the property is not found in the DeviceTree, use the default connection ID (VMBUS_MESSAGE_CONNECTION_ID or VMBUS_MESSAGE_CONNECTION_ID_4 based on protocol version).

---
v3: https://lore.kernel.org/all/[email protected]
v2: https://lore.kernel.org/all/[email protected]
v1: https://lore.kernel.org/all/[email protected]

---
 drivers/hv/connection.c |  6 ++++--
 drivers/hv/vmbus_drv.c  | 13 +++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)
drivers/hv/connection.c +4 -2
index be490c598785..15d2b652783d 100644
@@ -99,11 +99,13 @@ int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, u32 version)
 	if (version >= VERSION_WIN10_V5) {
 		msg->msg_sint = VMBUS_MESSAGE_SINT;
 		msg->msg_vtl = ms_hyperv.vtl;
-		vmbus_connection.msg_conn_id = VMBUS_MESSAGE_CONNECTION_ID_4;
 	} else {
 		msg->interrupt_page = virt_to_phys(vmbus_connection.int_page);
-		vmbus_connection.msg_conn_id = VMBUS_MESSAGE_CONNECTION_ID;
 	}
+	/* Set default connection ID if not provided via DeviceTree */
+	if (!vmbus_connection.msg_conn_id)
+		vmbus_connection.msg_conn_id = (version >= VERSION_WIN10_V5) ?
+			VMBUS_MESSAGE_CONNECTION_ID_4 : VMBUS_MESSAGE_CONNECTION_ID;
 
 	/*
 	 * shared_gpa_boundary is zero in non-SNP VMs, so it's safe to always
drivers/hv/vmbus_drv.c +13 -0
index c236081d0a87..b78d5499e4bc 100644
@@ -2541,10 +2541,23 @@ static int vmbus_device_add(struct platform_device *pdev)
 	struct of_range range;
 	struct of_range_parser parser;
 	struct device_node *np = pdev->dev.of_node;
+	unsigned int conn_id;
 	int ret;
 
 	vmbus_root_device = &pdev->dev;
 
+	/*
+	 * Read connection ID from DeviceTree. The property name follows the
+	 * format <vendor>,<field> where:
+	 * - vendor: "microsoft"
+	 * - field: "message-connection-id"
+	 */
+	ret = of_property_read_u32(np, "microsoft,message-connection-id", &conn_id);
+	if (!ret) {
+		pr_info("VMBus message connection ID: %u\n", conn_id);
+	    vmbus_connection.msg_conn_id = conn_id;
+	}
+
 	ret = of_range_parser_init(&parser, np);
 	if (ret)
 		return ret;
Signature · 1 line
2.40.4
#15 lore raw

RE: [PATCH v4 2/2] vmbus: retrieve connection-id from DeviceTree

From: Hardik Garg <[email protected]> Sent: Thursday, June 19, 2025 4:07 PM

Quoted 1 line

For the patch "Subject:" line, prefer prefix "Drivers: hv: vmbus:" to be consistent historical precedent. We haven't always been consistent with that precedent, but I try to call it out when I have the opportunity. :-) If you look at the commit log for drivers/hv, you'll see that prefix fairly often, though sometimes shortened to just "Drivers: hv:" when the change is more generically for Hyper-V and not specifically VMBus.

Quoted 4 lines

The connection-id determines which hypervisor communication channel the guest should use to talk to the VMBus host. This patch adds support to read this value from the DeviceTree where it exists as a property under the vmbus node with the compatible ID "microsoft,message-connection-id".

Avoid wording like "this patch" in commit messages. Commit messages should be in imperative mood. So something like:

The connection-id determines which hypervisor communication channel the guest should use to talk to the VMBus host. Add steps to read this value from the DeviceTree where it exists as a property under the vmbus node with the compatible ID "microsoft,message-connection-id".

Quoted 52 lines

The property name follows the format <vendor>,<field> where "vendor": "microsoft" and "field": "message-connection-id"

Reading from DeviceTree allows platforms to specify their preferred communication channel, making it more flexible. If the property is not found in the DeviceTree, use the default connection ID (VMBUS_MESSAGE_CONNECTION_ID or VMBUS_MESSAGE_CONNECTION_ID_4 based on protocol version).

---
v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/

---
 drivers/hv/connection.c |  6 ++++--
 drivers/hv/vmbus_drv.c  | 13 +++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)
drivers/hv/connection.c +4 -2
index be490c598785..15d2b652783d 100644
@@ -99,11 +99,13 @@ int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, u32 version)
 	if (version >= VERSION_WIN10_V5) {
 		msg->msg_sint = VMBUS_MESSAGE_SINT;
 		msg->msg_vtl = ms_hyperv.vtl;
-		vmbus_connection.msg_conn_id = VMBUS_MESSAGE_CONNECTION_ID_4;
 	} else {
 		msg->interrupt_page = virt_to_phys(vmbus_connection.int_page);
-		vmbus_connection.msg_conn_id = VMBUS_MESSAGE_CONNECTION_ID;
 	}
+	/* Set default connection ID if not provided via DeviceTree */
+	if (!vmbus_connection.msg_conn_id)
+		vmbus_connection.msg_conn_id = (version >= VERSION_WIN10_V5) ?
+			VMBUS_MESSAGE_CONNECTION_ID_4 : VMBUS_MESSAGE_CONNECTION_ID;
 
 	/*
 	 * shared_gpa_boundary is zero in non-SNP VMs, so it's safe to always
drivers/hv/vmbus_drv.c +1 -0
index c236081d0a87..b78d5499e4bc 100644
@@ -2541,10 +2541,23 @@ static int vmbus_device_add(struct platform_device *pdev)
 	struct of_range range;
 	struct of_range_parser parser;
 	struct device_node *np = pdev->dev.of_node;
+	unsigned int conn_id;
 	int ret;
 
 	vmbus_root_device = &pdev->dev;
 

drivers/hv/vmbus_drv.c static int vmbus_device_add(struct platform_device *pdev) · line 2558

Quoted 10 lines
drivers/hv/vmbus_drv.c +10 -0
+	/*
+	 * Read connection ID from DeviceTree. The property name follows the
+	 * format <vendor>,<field> where:
+	 * - vendor: "microsoft"
+	 * - field: "message-connection-id"
+	 */
+	ret = of_property_read_u32(np, "microsoft,message-connection-id", &conn_id);
+	if (!ret) {
+		pr_info("VMBus message connection ID: %u\n", conn_id);
+	    vmbus_connection.msg_conn_id = conn_id;

Indentation problem here. Should be a full tab, not 4 spaces.

Quoted 8 lines
drivers/hv/vmbus_drv.c +2 -1
+	}
+
 	ret = of_range_parser_init(&parser, np);
 	if (ret)
 		return ret;
--

2.40.4

#16 lore raw

Re: [PATCH v4 2/2] vmbus: retrieve connection-id from DeviceTree

In reply to Hardik Garg
Quoted 28 lines · Hardik Garg

The connection-id determines which hypervisor communication channel the guest should use to talk to the VMBus host. This patch adds support to read this value from the DeviceTree where it exists as a property under the vmbus node with the compatible ID "microsoft,message-connection-id". The property name follows the format <vendor>,<field> where "vendor": "microsoft" and "field": "message-connection-id"

Reading from DeviceTree allows platforms to specify their preferred communication channel, making it more flexible. If the property is not found in the DeviceTree, use the default connection ID (VMBUS_MESSAGE_CONNECTION_ID or VMBUS_MESSAGE_CONNECTION_ID_4 based on protocol version).

---
v3: https://lore.kernel.org/all/[email protected]
v2: https://lore.kernel.org/all/[email protected]
v1: https://lore.kernel.org/all/[email protected]

---
 drivers/hv/connection.c |  6 ++++--
 drivers/hv/vmbus_drv.c  | 13 +++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)
drivers/hv/connection.c +0 -0
index be490c598785..15d2b652783d 100644

drivers/hv/connection.c int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, u32 version) · line 106

Quoted 10 lines
drivers/hv/connection.c +2 -2
@@ -99,11 +99,13 @@ int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, u32 version)
 	if (version >= VERSION_WIN10_V5) {
 		msg->msg_sint = VMBUS_MESSAGE_SINT;
 		msg->msg_vtl = ms_hyperv.vtl;
-		vmbus_connection.msg_conn_id = VMBUS_MESSAGE_CONNECTION_ID_4;
 	} else {
 		msg->interrupt_page = virt_to_phys(vmbus_connection.int_page);
-		vmbus_connection.msg_conn_id = VMBUS_MESSAGE_CONNECTION_ID;
 	}
+	/* Set default connection ID if not provided via DeviceTree */
+	if (!vmbus_connection.msg_conn_id)

Your binding said connection ID 0 is a valid one, so this is wrong. Or binding is wrong.

Best regards,
Krzysztof