Skip to content

Commit bf35d29

Browse files
romank-msftliuw
authored andcommitted
Drivers: hv: Support confidential VMBus channels
To make use of Confidential VMBus channels, initialize the co_ring_buffers and co_external_memory fields of the channel structure. Advertise support upon negotiating the version and compute values for those fields and initialize them. Signed-off-by: Roman Kisel <romank@linux.microsoft.com> Reviewed-by: Michael Kelley <mhklinux@outlook.com> Signed-off-by: Wei Liu <wei.liu@kernel.org>
1 parent 5101645 commit bf35d29

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

drivers/hv/channel_mgmt.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,7 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
10221022
struct vmbus_channel_offer_channel *offer;
10231023
struct vmbus_channel *oldchannel, *newchannel;
10241024
size_t offer_sz;
1025+
bool co_ring_buffer, co_external_memory;
10251026

10261027
offer = (struct vmbus_channel_offer_channel *)hdr;
10271028

@@ -1034,6 +1035,22 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
10341035
return;
10351036
}
10361037

1038+
co_ring_buffer = is_co_ring_buffer(offer);
1039+
co_external_memory = is_co_external_memory(offer);
1040+
if (!co_ring_buffer && co_external_memory) {
1041+
pr_err("Invalid offer relid=%d: the ring buffer isn't encrypted\n",
1042+
offer->child_relid);
1043+
return;
1044+
}
1045+
if (co_ring_buffer || co_external_memory) {
1046+
if (vmbus_proto_version < VERSION_WIN10_V6_0 || !vmbus_is_confidential()) {
1047+
pr_err("Invalid offer relid=%d: no support for confidential VMBus\n",
1048+
offer->child_relid);
1049+
atomic_dec(&vmbus_connection.offer_in_progress);
1050+
return;
1051+
}
1052+
}
1053+
10371054
oldchannel = find_primary_channel_by_offer(offer);
10381055

10391056
if (oldchannel != NULL) {
@@ -1112,6 +1129,8 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
11121129
pr_err("Unable to allocate channel object\n");
11131130
return;
11141131
}
1132+
newchannel->co_ring_buffer = co_ring_buffer;
1133+
newchannel->co_external_memory = co_external_memory;
11151134

11161135
vmbus_setup_channel_state(newchannel, offer);
11171136

drivers/hv/connection.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, u32 version)
105105
vmbus_connection.msg_conn_id = VMBUS_MESSAGE_CONNECTION_ID;
106106
}
107107

108+
if (vmbus_is_confidential() && version >= VERSION_WIN10_V6_0)
109+
msg->feature_flags = VMBUS_FEATURE_FLAG_CONFIDENTIAL_CHANNELS;
110+
108111
/*
109112
* shared_gpa_boundary is zero in non-SNP VMs, so it's safe to always
110113
* bitwise OR it

0 commit comments

Comments
 (0)