From 1fad9da9461213a0ea5833c36f7cfaa4866041d1 Mon Sep 17 00:00:00 2001 From: Hardik Garg Date: Thu, 8 Oct 2026 16:44:42 +0000 Subject: [PATCH 1/3] Revert "Drivers: hv: Add connection id support" This reverts commit 995392d1b714a207970f1fd0688bf674ae66291e. --- drivers/hv/connection.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c index f10f18f884e9c..1fe3573ae52a4 100644 --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c @@ -71,16 +71,6 @@ module_param(max_version, uint, S_IRUGO); MODULE_PARM_DESC(max_version, "Maximal VMBus protocol version which can be negotiated"); -/* - * User requested connection id used to connect to the host. Useful for testing - * or when running a vmbus server on a non-standard connection id. - */ -static uint message_connection_id; - -module_param(message_connection_id, uint, 0444); -MODULE_PARM_DESC(message_connection_id, - "The VMBus message connection id used to communicate with the Host"); - int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, u32 version) { int ret = 0; @@ -115,9 +105,6 @@ int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, u32 version) vmbus_connection.msg_conn_id = VMBUS_MESSAGE_CONNECTION_ID; } - if (message_connection_id > 0) - vmbus_connection.msg_conn_id = message_connection_id; - /* * shared_gpa_boundary is zero in non-SNP VMs, so it's safe to always * bitwise OR it From 6b4692f829cfab002973c3793e6ccade4899662b Mon Sep 17 00:00:00 2001 From: Hardik Garg Date: Fri, 17 Jul 2026 00:18:37 +0000 Subject: [PATCH 2/3] Drivers: hv: vmbus: add VTL2 redirect connection ID [ Upstream commit 92d0593128023cf93ae61b7728dcc3062f8d514f ] VMBus sends CHANNELMSG_INITIATE_CONTACT through a Hyper-V message connection ID. Older protocol versions use VMBUS_MESSAGE_CONNECTION_ID, while protocol version 5.0 and newer normally use VMBUS_MESSAGE_CONNECTION_ID_4. For a VTL2 kernel using VMBus protocol 5.0 or newer, the host may expect INITIATE_CONTACT on either the redirect connection ID or VMBUS_MESSAGE_CONNECTION_ID_4. There is no capability indication that identifies which ID is active, so the driver must determine it at runtime. During VMBus negotiation, the redirect ID is tried first because it is used by VTL2 configurations with VMBus redirection enabled. If the redirect ID is unavailable, the host rejects it synchronously with HV_STATUS_INVALID_CONNECTION_ID, allowing fallback to the standard ID. Return a distinct error for an invalid Initiate Contact connection ID so this fallback does not mask other post-message failures or protocol-version rejections. Preserve the existing connection ID selection for older protocol versions or when running below VTL2. Signed-off-by: Hardik Garg Reviewed-by: Tianyu Lan Reviewed-by: Saurabh Sengar Reviewed-by: Naman Jain Reviewed-by: Michael Kelley Signed-off-by: Wei Liu Signed-off-by: Sasha Levin (cherry picked from commit ceb19f46e4758131f66db46d00cd88bb8542a198) --- drivers/hv/connection.c | 47 +++++++++++++++++++++++---------------- drivers/hv/hyperv_vmbus.h | 2 ++ 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c index 1fe3573ae52a4..9be2af772867d 100644 --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c @@ -71,7 +71,8 @@ module_param(max_version, uint, S_IRUGO); MODULE_PARM_DESC(max_version, "Maximal VMBus protocol version which can be negotiated"); -int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, u32 version) +static int vmbus_try_connection_id(struct vmbus_channel_msginfo *msginfo, + u32 version, u32 connection_id) { int ret = 0; struct vmbus_channel_initiate_contact *msg; @@ -86,20 +87,20 @@ int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, u32 version) msg->vmbus_version_requested = version; /* - * VMBus protocol 5.0 (VERSION_WIN10_V5) and higher require that we must - * use VMBUS_MESSAGE_CONNECTION_ID_4 for the Initiate Contact Message, - * and for subsequent messages, we must use the Message Connection ID - * field in the host-returned Version Response Message. And, with - * VERSION_WIN10_V5 and higher, we don't use msg->interrupt_page, but we - * tell the host explicitly that we still use VMBUS_MESSAGE_SINT(2) for - * compatibility. + * For VMBus protocol 5.0 (VERSION_WIN10_V5) and higher, use the + * caller-supplied connection_id for the Initiate Contact message so + * the caller can implement the required retry scheme. For subsequent + * messages, use the Message Connection ID field in the host-returned + * Version Response message. With VERSION_WIN10_V5 and higher, we don't + * use msg->interrupt_page, but tell the host explicitly that we still + * use VMBUS_MESSAGE_SINT(2) for compatibility. * * On old hosts, we should always use VMBUS_MESSAGE_CONNECTION_ID (1). */ 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; + vmbus_connection.msg_conn_id = connection_id; } else { msg->interrupt_page = virt_to_phys(vmbus_connection.int_page); vmbus_connection.msg_conn_id = VMBUS_MESSAGE_CONNECTION_ID; @@ -161,6 +162,22 @@ int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, u32 version) return ret; } +int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, u32 version) +{ + int ret; + + /* Try the redirect ID first for VTL2 with VMBus protocol 5.0+. */ + if (version >= VERSION_WIN10_V5 && ms_hyperv.vtl == 2) { + ret = vmbus_try_connection_id(msginfo, version, + VMBUS_MESSAGE_CONNECTION_ID_REDIRECT); + if (ret != -ENXIO) + return ret; + } + + return vmbus_try_connection_id(msginfo, version, + VMBUS_MESSAGE_CONNECTION_ID_4); +} + /* * vmbus_connect - Sends a connect request on the partition service connection */ @@ -454,18 +471,10 @@ int vmbus_post_msg(void *buffer, size_t buflen, bool can_sleep) switch (ret) { case HV_STATUS_INVALID_CONNECTION_ID: - /* - * See vmbus_negotiate_version(): VMBus protocol 5.0 - * and higher require that we must use - * VMBUS_MESSAGE_CONNECTION_ID_4 for the Initiate - * Contact message, but on old hosts that only - * support VMBus protocol 4.0 or lower, here we get - * HV_STATUS_INVALID_CONNECTION_ID and we should - * return an error immediately without retrying. - */ + /* Allow INITIATE_CONTACT to try another connection ID. */ hdr = buffer; if (hdr->msgtype == CHANNELMSG_INITIATE_CONTACT) - return -EINVAL; + return -ENXIO; /* * We could get this if we send messages too * frequently. diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h index 49a72a4f3f6a7..9c0b006b7f21a 100644 --- a/drivers/hv/hyperv_vmbus.h +++ b/drivers/hv/hyperv_vmbus.h @@ -109,6 +109,8 @@ struct hv_input_post_message { enum { VMBUS_MESSAGE_CONNECTION_ID = 1, VMBUS_MESSAGE_CONNECTION_ID_4 = 4, + /* VTL2 redirect connection ID for INITIATE_CONTACT. */ + VMBUS_MESSAGE_CONNECTION_ID_REDIRECT = 0x800074, VMBUS_MESSAGE_PORT_ID = 1, VMBUS_EVENT_CONNECTION_ID = 2, VMBUS_EVENT_PORT_ID = 2, From 9f7a9d9ace1df8dc1dcc7c14c96fc90bc5ad5b1c Mon Sep 17 00:00:00 2001 From: Hardik Garg Date: Thu, 8 Oct 2026 16:54:38 +0000 Subject: [PATCH 3/3] MSFT-Merge: retire superseded connection ID patch Signed-off-by: Hardik Garg --- MSFT-Merge/commit-log | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/MSFT-Merge/commit-log b/MSFT-Merge/commit-log index 9eb768e5932ab..5f623860a4e36 100644 --- a/MSFT-Merge/commit-log +++ b/MSFT-Merge/commit-log @@ -119,7 +119,6 @@ c630cc37901b 2026-08-14 x86/apic/savic: get GPA for SAVIC page using per_cpu_ Patch series in progress ------------------------ 6fd11a76911a 2024-04-17 PCI: Add a mutex to protect the global list pci_domain_busn_res_list (Status: Sent V1; Approx LOC: 25; Reference: https://lore.kernel.org/lkml/20240419015302.13871-1-decui@microsoft.com/; Testing: Tested on AH24) [Dexuan] -995392d1b714 2024-01-22 Drivers: hv: Add connection id support (Status: In review; Approx LOC: 8; Testing: Tested on AH27) [Hardik] 31a427ddeaf1 2025-02-11 vfio/pci: Continue to refactor vfio_pci_core_do_io_rw (Status: In review; Approx LOC: 30; Reference: https://lore.kernel.org/all/20240425165604.899447-4-gbayer@linux.ibm.com/) [Gerd Bayer (IBM)] 3dcb6050cf8b 2024-05-17 drivers/vmbus: Enhance Interrupt Management (Status: In review; Approx LOC: 850; Reference: [PATCH v2 00/15] Add arm64 support in MSHV_VTL - Naman Jain) [Naman] e3d9aa18101a 2024-05-17 drivers/hv: Enable MSHV_VTL_MODE for arm64 [-] @@ -131,4 +130,14 @@ f1bc8fdb27b1 2025-12-04 Fix x86 compilation errors [-] 1ada4de76a9f 2026-02-26 vtl: Fixes for compilation errors and warnings [-] cff21e6cb023 2025-04-22 hv: mshv: vtl: Allow aarch64 to use the Hyper-V VTL register page when available. (#53) [-] f701d02a32b1 2024-06-05 hyperv/arm64: Use PSCI to start processors. [-] -f6c55e5bec93 2023-02-16 x86/build: Only align ENTRY_TEXT to PMD_SIZE on x86 if PTI or SRSO is enabled. (Status: In review v4; Approx LOC: 10) [Hamza] \ No newline at end of file +f6c55e5bec93 2023-02-16 x86/build: Only align ENTRY_TEXT to PMD_SIZE on x86 if PTI or SRSO is enabled. (Status: In review v4; Approx LOC: 10) [Hamza] + + +Retired / superseded OOT commits +-------------------------------- +995392d1b714 2024-01-22 Drivers: hv: Add connection id support [Hardik] + Status: RETIRED - superseded by upstream + Revert: 1fad9da94612 + Replacement: ceb19f46e475 (6.18 stable); 92d059312802 (mainline) + Upgrade policy: Never replay the original or its revert. + Backport the replacement only if the target base lacks an equivalent fix. \ No newline at end of file