Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions MSFT-Merge/commit-log
Original file line number Diff line number Diff line change
Expand Up @@ -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 [-]
Expand All @@ -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]
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.
60 changes: 28 additions & 32 deletions drivers/hv/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,8 @@ 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)
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;
Expand All @@ -96,28 +87,25 @@ 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;
}

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
Expand Down Expand Up @@ -174,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
*/
Expand Down Expand Up @@ -467,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.
Expand Down
2 changes: 2 additions & 0 deletions drivers/hv/hyperv_vmbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading