Add VMBus message connection ID support via DeviceTree
v5 cover Add VMBus message connection ID support via DeviceTree
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/[email protected]/
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/[email protected]/
Changes in v1:
- Initial submission
-
https://lore.kernel.org/all/[email protected]/
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
PATCH v5 1/2 dt-bindings: microsoft: Add vmbus message-connection-id property
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.
---
v4:
https://lore.kernel.org/all/[email protected]
v3:
https://lore.kernel.org/all/[email protected]
v2:
https://lore.kernel.org/all/[email protected]
v1:
https://lore.kernel.org/all/[email protected]
---
.../devicetree/bindings/bus/microsoft,vmbus.yaml | 12 ++++++++++++
1 file changed, 12 insertions(+)
(quoted diff) +0 -0
b/Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml index 0bea4f5287ce..4745c2b89ac5 100644
Documentation/devicetree/bindings/bus/microsoft,vmbus.yaml +0 -0
@@ -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
PATCH v5 2/2 Drivers: hv: vmbus: retrieve connection-id from DeviceTree
In reply to Hardik GargThe 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).
---
v4:
https://lore.kernel.org/all/[email protected]
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 | 7 +++++--
drivers/hv/vmbus_drv.c | 8 ++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
drivers/hv/connection.c +0 -0
@@ -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;
drivers/hv/vmbus_drv.c +0 -0
@@ -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
Just a gentle ping on this patch in case it got lost. I want to check if anyone had a chance to look at it, or if there is anything I should update or clarify.
I’ve also noticed a formatting issue in patch 2/2, which I will address when sending a v6 along with any feedback.
Thanks,
Hardik
Quoted 13 lines · Hardik Garg
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)