linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/2] Add VMBus message connection ID support via DeviceTree
@ 2025-12-23 23:05 Hardik Garg
  2025-12-23 23:07 ` [PATCH v5 1/2] dt-bindings: microsoft: Add vmbus message-connection-id property Hardik Garg
  2025-12-23 23:09 ` [PATCH v5 2/2] Drivers: hv: vmbus: retrieve connection-id from DeviceTree Hardik Garg
  0 siblings, 2 replies; 3+ messages in thread
From: Hardik Garg @ 2025-12-23 23:05 UTC (permalink / raw)
  To: kys, haiyangz, wei.liu, decui, krzk+dt, robh, conor+dt, mhklinux
  Cc: devicetree, linux-hyperv, linux-kernel, ssengar, longli,
	Naman Jain, hargar

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

Changes in v5:
- Updated subject line and commit description to clarify what
  connection ID is and why DeviceTree support is required
- Addressed reviewer feedback about zero handling and binding
  constraints
- Revised binding description to clarify version-based selection
  instead of using "defaults" language
- Fixed checkpatch warnings (indentation and alignment)

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

Changes in v3:
- Added documentation for the new property in DeviceTree bindings
-
https://lore.kernel.org/all/6a92ca86-ad6b-4d49-af6e-1ed7651b8ab8@linux.microsoft.com/

Changes in v2:
- Rebased on hyperv-next branch as requested by maintainers
- Added details about the property name format in the commit message
-
https://lore.kernel.org/all/096edaf7-cc90-42b6-aff4-c5f088574e1e@linux.microsoft.com/

Changes in v1:
- Initial submission
-
https://lore.kernel.org/all/6acee4bf-cb04-43b9-9476-e8d811d26dfd@linux.microsoft.com/

Testing:
- Tested on Microsoft Hyper-V
- Verified with and without the DeviceTree property
- Confirmed proper fallback to version-based connection ID selection
- Validated binding documentation with dt_binding_check

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

 .../devicetree/bindings/bus/microsoft,vmbus.yaml    | 12 ++++++++++++
 drivers/hv/connection.c                             |  7 +++++--
 drivers/hv/vmbus_drv.c                              |  8 ++++++++
 3 files changed, 25 insertions(+), 2 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v5 1/2] dt-bindings: microsoft: Add vmbus message-connection-id property
  2025-12-23 23:05 [PATCH v5 0/2] Add VMBus message connection ID support via DeviceTree Hardik Garg
@ 2025-12-23 23:07 ` Hardik Garg
  2025-12-23 23:09 ` [PATCH v5 2/2] Drivers: hv: vmbus: retrieve connection-id from DeviceTree Hardik Garg
  1 sibling, 0 replies; 3+ messages in thread
From: Hardik Garg @ 2025-12-23 23:07 UTC (permalink / raw)
  To: kys, haiyangz, wei.liu, decui, krzk+dt, robh, conor+dt, mhklinux
  Cc: devicetree, linux-hyperv, linux-kernel, ssengar, longli,
	Naman Jain, hargar

Document the microsoft,message-connection-id property for VMBus
DeviceTree node. The connection-id 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 guests 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.

Each guest has a private hypervisor mailbox and cannot access any other
guests 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.

Signed-off-by: Hardik Garg <hargar@linux.microsoft.com>
---
v4:
https://lore.kernel.org/all/1750374395-14615-2-git-send-email-hargar@linux.microsoft.com
v3:
https://lore.kernel.org/all/6a92ca86-ad6b-4d49-af6e-1ed7651b8ab8@linux.microsoft.com
v2:
https://lore.kernel.org/all/096edaf7-cc90-42b6-aff4-c5f088574e1e@linux.microsoft.com
v1:
https://lore.kernel.org/all/6acee4bf-cb04-43b9-9476-e8d811d26dfd@linux.microsoft.com
---
 .../devicetree/bindings/bus/microsoft,vmbus.yaml     | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml
b/Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml
index 0bea4f5287ce..4745c2b89ac5 100644
--- a/Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml
+++ b/Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml
@@ -17,6 +17,17 @@ properties:
   compatible:
     const: microsoft,vmbus
 
+  microsoft,message-connection-id:
+    description:
+      connection-id 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. When this
+      property is not present, the driver selects the connection ID
+      based on the protocol version (4 for VERSION_WIN10_V5 and
+      newer, or 1 for older versions).
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 1
+
   ranges: true
 
   '#address-cells':
@@ -55,6 +66,7 @@ examples:
 
             vmbus@ff0000000 {
                 compatible = "microsoft,vmbus";
+                microsoft,message-connection-id = <4>;
                 #address-cells = <2>;
                 #size-cells = <1>;
                 ranges = <0x0f 0xf0000000 0x0f 0xf0000000 0x10000000>;
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v5 2/2] Drivers: hv: vmbus: retrieve connection-id from DeviceTree
  2025-12-23 23:05 [PATCH v5 0/2] Add VMBus message connection ID support via DeviceTree Hardik Garg
  2025-12-23 23:07 ` [PATCH v5 1/2] dt-bindings: microsoft: Add vmbus message-connection-id property Hardik Garg
@ 2025-12-23 23:09 ` Hardik Garg
  1 sibling, 0 replies; 3+ messages in thread
From: Hardik Garg @ 2025-12-23 23:09 UTC (permalink / raw)
  To: kys, haiyangz, wei.liu, decui, krzk+dt, robh, conor+dt, mhklinux
  Cc: devicetree, linux-hyperv, linux-kernel, ssengar, longli,
	Naman Jain, hargar

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. When this property is not present,
the driver selects the connection ID based on the protocol version
(4 for VERSION_WIN10_V5 and newer, or 1 for older versions).

Signed-off-by: Hardik Garg <hargar@linux.microsoft.com>
---
v4:
https://lore.kernel.org/all/1750374395-14615-3-git-send-email-hargar@linux.microsoft.com
v3:
https://lore.kernel.org/all/6a92ca86-ad6b-4d49-af6e-1ed7651b8ab8@linux.microsoft.com
v2:
https://lore.kernel.org/all/096edaf7-cc90-42b6-aff4-c5f088574e1e@linux.microsoft.com
v1:
https://lore.kernel.org/all/6acee4bf-cb04-43b9-9476-e8d811d26dfd@linux.microsoft.com
---
 drivers/hv/connection.c |  7 +++++--
 drivers/hv/vmbus_drv.c  |  8 ++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 5d9cb5bf2d62..660cad3886f5 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -100,12 +100,15 @@ 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;
+
     if (vmbus_is_confidential() && version >= VERSION_WIN10_V6_0)
         msg->feature_flags = VMBUS_FEATURE_FLAG_CONFIDENTIAL_CHANNELS;
 
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 47fcab38398a..f8c0594ab85f 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -2600,10 +2600,18 @@ 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 */
+    if (!of_property_read_u32(np, "microsoft,message-connection-id",
+                  &conn_id)) {
+        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;
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-12-23 23:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-23 23:05 [PATCH v5 0/2] Add VMBus message connection ID support via DeviceTree Hardik Garg
2025-12-23 23:07 ` [PATCH v5 1/2] dt-bindings: microsoft: Add vmbus message-connection-id property Hardik Garg
2025-12-23 23:09 ` [PATCH v5 2/2] Drivers: hv: vmbus: retrieve connection-id from DeviceTree Hardik Garg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).