From nobody Sat Feb 7 16:23:13 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5D9B8846C; Wed, 4 Jun 2025 00:43:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997827; cv=none; b=AiR8xMEA5yY8irEph3QnfQdmBmebgOdkZrdLQurCfjweeDIZvX2sKXc9xyMGyBXoge3SzUhYKNESiZLmR3xLW/eWNTS9sfF2ysNGcjbfeU+xYQC2a16bQ8c3tBIJ9693JPDCuD6hnPlZgFGQrKaK5dm2dOAlVmBE3Xl+uNElTHM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997827; c=relaxed/simple; bh=dhZK/mbD/B/W3rp8HtrbqjPVQLXYz17gmLzX9jVAw0Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QVKMjxieZ6mDdjAfOYZxmzKZRJRXtQ760Eh2OcH0xFDCLhGgbLV/cahHxpgthWivlUCGAL03L1BfYbeEpoibH2/fk5DPITUIojVBeS/HqqzMEEDn7JFMTqQcT6F3voSutAlKpGLoidlDXEc370mqR98xxCth6Y5JU8m/omAEyPU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=ERvUQIfx; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="ERvUQIfx" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id B24F32115DDF; Tue, 3 Jun 2025 17:43:44 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B24F32115DDF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1748997824; bh=L0zwZxej62ckeG9kTheAzPG/t1KXKM3djWbh+qBjdxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ERvUQIfx+DNJMbA2TMQQNHq9H31u5J7ONl+QVFCfpJByurULEdhdYmBX9YODgO7S/ 5o05HVgqa1yY6FPTd+A9VYS76IV7ygbINnNJLS8AjrvUW6rieYQwnaRJi1v1GD3fGe ZxoQ1QB2jOvY6sN6gVyoE6dNxSVmwvm43WGbae3o= From: Roman Kisel To: alok.a.tiwari@oracle.com, arnd@arndb.de, bp@alien8.de, corbet@lwn.net, dave.hansen@linux.intel.com, decui@microsoft.com, haiyangz@microsoft.com, hpa@zytor.com, kys@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, tglx@linutronix.de, wei.liu@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, bperkins@microsoft.com, sunilmut@microsoft.com Subject: [PATCH hyperv-next v3 01/15] Documentation: hyperv: Confidential VMBus Date: Tue, 3 Jun 2025 17:43:27 -0700 Message-ID: <20250604004341.7194-2-romank@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250604004341.7194-1-romank@linux.microsoft.com> References: <20250604004341.7194-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Define what the confidential VMBus is and describe what advantages it offers on the capable hardware. Signed-off-by: Roman Kisel Reviewed-by: Alok Tiwari --- Documentation/virt/hyperv/coco.rst | 125 ++++++++++++++++++++++++++++- 1 file changed, 124 insertions(+), 1 deletion(-) diff --git a/Documentation/virt/hyperv/coco.rst b/Documentation/virt/hyperv= /coco.rst index c15d6fe34b4e..b4904b64219d 100644 --- a/Documentation/virt/hyperv/coco.rst +++ b/Documentation/virt/hyperv/coco.rst @@ -178,7 +178,7 @@ These Hyper-V and VMBus memory pages are marked as decr= ypted: =20 * VMBus monitor pages =20 -* Synthetic interrupt controller (synic) related pages (unless supplied by +* Synthetic interrupt controller (SynIC) related pages (unless supplied by the paravisor) =20 * Per-cpu hypercall input and output pages (unless running with a paraviso= r) @@ -258,3 +258,126 @@ normal page fault is generated instead of #VC or #VE,= and the page-fault- based handlers for load_unaligned_zeropad() fixup the reference. When the encrypted/decrypted transition is complete, the pages are marked as "prese= nt" again. See hv_vtom_clear_present() and hv_vtom_set_host_visibility(). + +Confidential VMBus +------------------ + +The confidential VMBus enables the confidential guest not to interact with= the +untrusted host partition and the untrusted hypervisor. Instead, the guest = relies +on the trusted paravisor to communicate with the devices processing sensit= ive +data. The hardware (SNP or TDX) encrypts the guest memory and the register= state +while measuring the paravisor image using the platform security processor = to +ensure trusted and confidential computing. + +Confidential VMBus provides a secure communication channel between the gue= st and +the paravisor, ensuring that sensitive data is protected from hypervisor-= level +access through memory encryption and register state isolation. + +The unencrypted data never leaves the VM so neither the host partition nor= the +hypervisor can access it at all. In addition to that, the guest only needs= to +establish a VMBus connection with the paravisor for the channels that proc= ess +sensitive data, and the paravisor abstracts the details of communicating w= ith +the specific devices away. + +Confidential VMBus is an extension of Confidential Computing (CoCo) VMs +(a.k.a. "Isolated" VMs in Hyper-V terminology). Without Confidential VMBus, +guest VMBus device drivers (the "VSC"s in VMBus terminology) communicate +with VMBus servers (the VSPs) running on the Hyper-V host. The +communication must be through memory that has been decrypted so the +host can access it. With Confidential VMBus, one or more of the VSPs reside +in the trusted paravisor layer in the guest VM. Since the paravisor layer = also +operates in encrypted memory, the memory used for communication with +such VSPs does not need to be decrypted and thereby exposed to the +Hyper-V host. The paravisor is responsible for communicating securely +with the Hyper-V host as necessary. In some cases (e.g. time synchonizatio= n, +key-value pairs exchange) the unencrypted data doesn't need to be communic= ated +with the host at all, and a conventional VMBus connection suffices. + +Here is the data flow for a conventional VMBus connection and the Confiden= tial +VMBus connection (C stands for the client or VSC, S for the server or VSP): + ++---- GUEST ----+ +----- DEVICE ----+ +----- HOST -----+ +| | | | | | +| | | | | | +| | | =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = | +| | | | | | +| | | | | | +| | | | | | ++----- C -------+ +-----------------+ +------- S ------+ + || || + || || ++------||------------------ VMBus --------------------------||------+ +| Interrupts, MMIO | ++-------------------------------------------------------------------+ + ++---- GUEST --------------- VTL0 ------+ +-- DEVICE --+ +| | | | +| +- PARAVISOR --------- VTL2 -----+ | | | +| | +-- VMBus Relay ------+ =3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D | +| | | Interrupts, MMIO | | | | | +| | +-------- S ----------+ | | +------------+ +| | || | | +| +---------+ || | | +| | Linux | || OpenHCL | | +| | kernel | || | | +| +---- C --+-----||---------------+ | +| || || | ++-------++------- C -------------------+ +------------+ + || | HOST | + || +---- S -----+ ++-------||----------------- VMBus ---------------------------||-----+ +| Interrupts, MMIO | ++-------------------------------------------------------------------+ + +An implementation of the VMBus relay that offers the Confidential VMBus ch= annels +is available in the OpenVMM project as a part of the OpenHCL paravisor. Pl= ease +refer to https://openvmm.dev/ and https://github.com/microsoft/openvmm for= more +information about the OpenHCL paravisor. + +A guest that is running with a paravisor must determine at runtime if +Confidential VMBus is supported by the current paravisor. It does so by fi= rst +trying to establish a Confidential VMBus connection with the paravisor usi= ng +standard mechanisms where the memory remains encrypted. If this succeeds, +then the guest can proceed to use Confidential VMBus. If it fails, then the +guest must fallback to establishing a non-Confidential VMBus connection wi= th +the Hyper-V host. + +Confidential VMBus is a characteristic of the VMBus connection as a whole, +and of each VMBus channel that is created. When a Confidential VMBus +connection is established, the paravisor provides the guest the message-pa= ssing +path that is used for VMBus device creation and deletion, and it provides a +per-CPU synthetic interrupt controller (SynIC) just like the SynIC that is +offered by the Hyper-V host. Each VMBus device that is offered to the guest +indicates the degree to which it participates in Confidential VMBus. The o= ffer +indicates if the device uses encrypted ring buffers, and if the device uses +encrypted memory for DMA that is done outside the ring buffer. These setti= ngs +may be different for different devices using the same Confidential VMBus +connection. + +Although these settings are separate, in practice it'll always be encrypted +ring buffer only or both encrypted ring buffer and external data. If a cha= nnel +is offered by the paravisor with confidential VMBus, the ring buffer can a= lways +be encrypted since it's strictly for communication between the VTL2 paravi= sor +and the VTL0 guest. However, other memory regions are often used for e.g. = DMA, +so they need to be accessible by the underlying hardware, and must be unen= crypted +(unless the device supports encrypted memory). Currently, there are no any= VSPs +in OpenHCL that support encrypted external memory, but we will use it in t= he +future. + +Because some devices on a Confidential VMBus may require decrypted ring bu= ffers +and DMA transfers, the guest must interact with two SynICs -- the one prov= ided +by the paravisor and the one provided by the Hyper-V host when Confidential +VMBus is not offered. Interrupts are always signaled by the paravisor SynI= C, but +the guest must check for messages and for channel interrupts on both SynIC= s. + +In the case of a confidential VM, regular SynIC access by the guest is +intercepted by the paravisor (this includes various MSRs such as the SIMP = and +SIEFP, as well as hypercalls like HvPostMessage and HvSignalEvent). If the= guest +actually wants to communicate with the hypervisor, it has to use special m= echanisms +(GHCB page on SNP, or tdcall on TDX). Messages will always be one or the o= ther: +with confidential VMBus, all messages use the paravisor SynIC, otherwise t= hey all +use the hypervisor SynIC. For interrupt signaling, though, some channels m= ay be +running on the host (non-confidential, using the VMBus relay) and use the = hypervisor +SynIC, and some on the paravisor and use its SynIC. The RelIDs are coordin= ated by +the OpenHCL VMBus server and are guaranteed to be unique regardless of whe= ther +the channel originated on the host or the paravisor. --=20 2.43.0 From nobody Sat Feb 7 16:23:13 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 963C6C2FA; Wed, 4 Jun 2025 00:43:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997828; cv=none; b=kzYFcGmvUYBPl/n5yR7r39WNmfYW/tbTSdUZ6DQagfE9JWXfpg6toZrcCz7iheWPytuEoleU0/6Xhopn1HjnBmsvvk73SlsvPiUvm0507DYCOcT+xJ/zb6Pfe0Aw5Fuk4XClWacW/qMk9hW3E3cJf8uhmmATr0OZee/N3fQTgFQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997828; c=relaxed/simple; bh=gEvWKJXU8L4y9QPtoH2C/fG0E6Bhvb8su7JcYIw6thg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AfJWgJEVbEXizC+1PJFILa8IlFgYDslpzch1ASNA4kDyZA2t3SUHAe4i8se7/NKsjc+yAs9h8LA74IA7UUN/TTgg4lM5cLjFTLJ0V2RILWICSh0bLLvrtYiEjV2Nw9AtI8m75ZRecKAd7if4f5AE8onVJz6CeR8eDVOhtE76mVQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=BoUXoCYI; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="BoUXoCYI" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id ECF11211659E; Tue, 3 Jun 2025 17:43:44 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com ECF11211659E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1748997825; bh=nrTw2GEotm/yZGp8DmdZq/kHAypxC1VVS8awu+QuSWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BoUXoCYI23RHKCJInGde4XWtTbhNi2+rgOKQLBG5PhSBLZu9H71SWtsLoOOoyNEIR ajp9sxAF0Cj++daKVfeeGZGHKdfIOZflfpT7EmU632kzgQJm8uIqOjziNt0IyA6oJ5 kbY7h+59C3xv9q4QW3gDgGkAjfwjY+vQD+BqYmys= From: Roman Kisel To: alok.a.tiwari@oracle.com, arnd@arndb.de, bp@alien8.de, corbet@lwn.net, dave.hansen@linux.intel.com, decui@microsoft.com, haiyangz@microsoft.com, hpa@zytor.com, kys@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, tglx@linutronix.de, wei.liu@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, bperkins@microsoft.com, sunilmut@microsoft.com Subject: [PATCH hyperv-next v3 02/15] drivers: hv: VMBus protocol version 6.0 Date: Tue, 3 Jun 2025 17:43:28 -0700 Message-ID: <20250604004341.7194-3-romank@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250604004341.7194-1-romank@linux.microsoft.com> References: <20250604004341.7194-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The confidential VMBus is supported starting from the protocol version 6.0 onwards. Update the relevant definitions, and provide a function that returns whether VMBus is confidential or not. No functional changes. Signed-off-by: Roman Kisel Reviewed-by: Alok Tiwari --- drivers/hv/vmbus_drv.c | 12 ++++++ include/asm-generic/mshyperv.h | 1 + include/linux/hyperv.h | 69 ++++++++++++++++++++++++---------- 3 files changed, 63 insertions(+), 19 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index c236081d0a87..678ad59deb2d 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -56,6 +56,18 @@ static long __percpu *vmbus_evt; int vmbus_irq; int vmbus_interrupt; =20 +/* + * If the Confidential VMBus is used, the data on the "wire" is not + * visible to either the host or the hypervisor. + */ +static bool is_confidential; + +bool vmbus_is_confidential(void) +{ + return is_confidential; +} +EXPORT_SYMBOL_GPL(vmbus_is_confidential); + /* * The panic notifier below is responsible solely for unloading the * vmbus connection, which is necessary in a panic event. diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h index a729b77983fa..9722934a8332 100644 --- a/include/asm-generic/mshyperv.h +++ b/include/asm-generic/mshyperv.h @@ -373,6 +373,7 @@ static inline int hv_call_create_vp(int node, u64 parti= tion_id, u32 vp_index, u3 return -EOPNOTSUPP; } #endif /* CONFIG_MSHV_ROOT */ +bool vmbus_is_confidential(void); =20 #if IS_ENABLED(CONFIG_HYPERV_VTL_MODE) u8 __init get_vtl(void); diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 23b3c3a2ed8c..f87f3f2f8e89 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -265,16 +265,18 @@ static inline u32 hv_get_avail_to_write_percent( * Linux kernel. */ =20 -#define VERSION_WS2008 ((0 << 16) | (13)) -#define VERSION_WIN7 ((1 << 16) | (1)) -#define VERSION_WIN8 ((2 << 16) | (4)) -#define VERSION_WIN8_1 ((3 << 16) | (0)) -#define VERSION_WIN10 ((4 << 16) | (0)) -#define VERSION_WIN10_V4_1 ((4 << 16) | (1)) -#define VERSION_WIN10_V5 ((5 << 16) | (0)) -#define VERSION_WIN10_V5_1 ((5 << 16) | (1)) -#define VERSION_WIN10_V5_2 ((5 << 16) | (2)) -#define VERSION_WIN10_V5_3 ((5 << 16) | (3)) +#define VMBUS_MAKE_VERSION(MAJ, MIN) ((((u32)MAJ) << 16) | (MIN)) +#define VERSION_WS2008 VMBUS_MAKE_VERSION(0, 13) +#define VERSION_WIN7 VMBUS_MAKE_VERSION(1, 1) +#define VERSION_WIN8 VMBUS_MAKE_VERSION(2, 4) +#define VERSION_WIN8_1 VMBUS_MAKE_VERSION(3, 0) +#define VERSION_WIN10 VMBUS_MAKE_VERSION(4, 0) +#define VERSION_WIN10_V4_1 VMBUS_MAKE_VERSION(4, 1) +#define VERSION_WIN10_V5 VMBUS_MAKE_VERSION(5, 0) +#define VERSION_WIN10_V5_1 VMBUS_MAKE_VERSION(5, 1) +#define VERSION_WIN10_V5_2 VMBUS_MAKE_VERSION(5, 2) +#define VERSION_WIN10_V5_3 VMBUS_MAKE_VERSION(5, 3) +#define VERSION_WIN10_V6_0 VMBUS_MAKE_VERSION(6, 0) =20 /* Make maximum size of pipe payload of 16K */ #define MAX_PIPE_DATA_PAYLOAD (sizeof(u8) * 16384) @@ -335,14 +337,22 @@ struct vmbus_channel_offer { } __packed; =20 /* Server Flags */ -#define VMBUS_CHANNEL_ENUMERATE_DEVICE_INTERFACE 1 -#define VMBUS_CHANNEL_SERVER_SUPPORTS_TRANSFER_PAGES 2 -#define VMBUS_CHANNEL_SERVER_SUPPORTS_GPADLS 4 -#define VMBUS_CHANNEL_NAMED_PIPE_MODE 0x10 -#define VMBUS_CHANNEL_LOOPBACK_OFFER 0x100 -#define VMBUS_CHANNEL_PARENT_OFFER 0x200 -#define VMBUS_CHANNEL_REQUEST_MONITORED_NOTIFICATION 0x400 -#define VMBUS_CHANNEL_TLNPI_PROVIDER_OFFER 0x2000 +#define VMBUS_CHANNEL_ENUMERATE_DEVICE_INTERFACE 0x0001 +/* + * This flag indicates that the channel is offered by the paravisor, and m= ust + * use encrypted memory for the channel ring buffer. + */ +#define VMBUS_CHANNEL_CONFIDENTIAL_RING_BUFFER 0x0002 +/* + * This flag indicates that the channel is offered by the paravisor, and m= ust + * use encrypted memory for GPA direct packets and additional GPADLs. + */ +#define VMBUS_CHANNEL_CONFIDENTIAL_EXTERNAL_MEMORY 0x0004 +#define VMBUS_CHANNEL_NAMED_PIPE_MODE 0x0010 +#define VMBUS_CHANNEL_LOOPBACK_OFFER 0x0100 +#define VMBUS_CHANNEL_PARENT_OFFER 0x0200 +#define VMBUS_CHANNEL_REQUEST_MONITORED_NOTIFICATION 0x0400 +#define VMBUS_CHANNEL_TLNPI_PROVIDER_OFFER 0x2000 =20 struct vmpacket_descriptor { u16 type; @@ -621,6 +631,12 @@ struct vmbus_channel_relid_released { u32 child_relid; } __packed; =20 +/* + * Used by the paravisor only, means that the encrypted ring buffers and + * the encrypted external memory are supported + */ +#define VMBUS_FEATURE_FLAG_CONFIDENTIAL_CHANNELS 0x10 + struct vmbus_channel_initiate_contact { struct vmbus_channel_message_header header; u32 vmbus_version_requested; @@ -630,7 +646,8 @@ struct vmbus_channel_initiate_contact { struct { u8 msg_sint; u8 msg_vtl; - u8 reserved[6]; + u8 reserved[2]; + u32 feature_flags; /* VMBus version 6.0 */ }; }; u64 monitor_page1; @@ -1008,6 +1025,10 @@ struct vmbus_channel { =20 /* boolean to control visibility of sysfs for ring buffer */ bool ring_sysfs_visible; + /* The ring buffer is encrypted */ + bool co_ring_buffer; + /* The external memory is encrypted */ + bool co_external_memory; }; =20 #define lock_requestor(channel, flags) \ @@ -1032,6 +1053,16 @@ u64 vmbus_request_addr_match(struct vmbus_channel *c= hannel, u64 trans_id, u64 rqst_addr); u64 vmbus_request_addr(struct vmbus_channel *channel, u64 trans_id); =20 +static inline bool is_co_ring_buffer(const struct vmbus_channel_offer_chan= nel *o) +{ + return !!(o->offer.chn_flags & VMBUS_CHANNEL_CONFIDENTIAL_RING_BUFFER); +} + +static inline bool is_co_external_memory(const struct vmbus_channel_offer_= channel *o) +{ + return !!(o->offer.chn_flags & VMBUS_CHANNEL_CONFIDENTIAL_EXTERNAL_MEMORY= ); +} + static inline bool is_hvsock_offer(const struct vmbus_channel_offer_channe= l *o) { return !!(o->offer.chn_flags & VMBUS_CHANNEL_TLNPI_PROVIDER_OFFER); --=20 2.43.0 From nobody Sat Feb 7 16:23:13 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A5176CA4E; Wed, 4 Jun 2025 00:43:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997827; cv=none; b=pQebBDwx7bnAjRSay/GYHxrbvvmWqJ3eEFD1mAs38LkyMm+dFANFIUXDpCI7Wsnu6YlnlYJPBbynpZ0kVp2+QPBiYkxR2tOEtkAWipPzAC766E6TkxN0259WqB7F5UBJb8vb9OUeicxirpeAiVI8MrC0kTiG2mBn+RpZPggqEhA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997827; c=relaxed/simple; bh=z06AfXBu3Wnaj3am6I5bQMHfFjjgGU6Io2/r8kFyd2o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fe4uCg1t9dkLcx+VZ9fayDX/QAjw/7z8hIvs6WEYx40OoFrpqMTKK2P/iVKLlAHTfRAMjWtw54SHpyCTvh8WsUEdLfElSjHIohJqK0NsdJ1bivIj4ppxl/T+NtScOkusxEb2ZevqNlYDlG6GFfaThLWzThZHj98ADcffi3J3xYU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=UsAkW9Ni; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="UsAkW9Ni" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id 342582116B25; Tue, 3 Jun 2025 17:43:45 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 342582116B25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1748997825; bh=8goRauVaYSFozRwRLcm6JZoNqih7m4xmGWRntzKXbqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UsAkW9NioV6LBEgDomuRjnAfurpjQs3G5mUAkWGn4umNEd0uSk8TY7RT0XgF8GqTZ HnaLsw4M7vtQLDRJZf9r7KNIqAJ1NVtoO2lB1Ls5qmZvJhuUjFcm8gzMtF9uWtIapp PINmxtR94CBCr9aqgU8GWv521lbQMGp2s2giu8uA= From: Roman Kisel To: alok.a.tiwari@oracle.com, arnd@arndb.de, bp@alien8.de, corbet@lwn.net, dave.hansen@linux.intel.com, decui@microsoft.com, haiyangz@microsoft.com, hpa@zytor.com, kys@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, tglx@linutronix.de, wei.liu@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, bperkins@microsoft.com, sunilmut@microsoft.com Subject: [PATCH hyperv-next v3 03/15] arch: hyperv: Get/set SynIC synth.registers via paravisor Date: Tue, 3 Jun 2025 17:43:29 -0700 Message-ID: <20250604004341.7194-4-romank@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250604004341.7194-1-romank@linux.microsoft.com> References: <20250604004341.7194-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The confidential VMBus is built on the guest talking to the paravisor only. Provide functions that allow manipulating the SynIC registers via paravisor. No functional changes. Signed-off-by: Roman Kisel Reviewed-by: Alok Tiwari --- arch/x86/kernel/cpu/mshyperv.c | 44 ++++++++++++++++++++++++++++++++++ drivers/hv/hv_common.c | 13 ++++++++++ include/asm-generic/mshyperv.h | 2 ++ 3 files changed, 59 insertions(+) diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index 3e2533954675..83a85d94bcb3 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -89,6 +89,50 @@ void hv_set_non_nested_msr(unsigned int reg, u64 value) } EXPORT_SYMBOL_GPL(hv_set_non_nested_msr); =20 +/* + * Attempt to get the SynIC register value from the paravisor. + * + * Not all paravisors support reading SynIC registers, so this function + * may fail. The register for the SynIC of the running CPU is accessed. + * + * Writes the SynIC register value into the memory pointed by val, + * and ~0ULL is on failure. + * + * Returns -ENODEV if the MSR is not a SynIC register, or another error + * code if getting the MSR fails (meaning the paravisor doesn't support + * relaying VMBus comminucations). + */ +int hv_para_get_synic_register(unsigned int reg, u64 *val) +{ + u64 reg_val =3D ~0ULL; + int err =3D -ENODEV; + + if (hv_is_synic_msr(reg)) + reg_val =3D native_read_msr_safe(reg, &err); + *val =3D reg_val; + + return err; +} + +/* + * Attempt to set the SynIC register value with the paravisor. + * + * Not all paravisors support reading SynIC registers, so this function + * may fail. The register for the SynIC of the running CPU is accessed. + * + * Sets the register to the value supplied. + * + * Returns: -ENODEV if the MSR is not a SynIC register, or another error + * code if writing to the MSR fails (meaning the paravisor doesn't support + * relaying VMBus comminucations). + */ +int hv_para_set_synic_register(unsigned int reg, u64 val) +{ + if (!hv_is_synic_msr(reg)) + return -ENODEV; + return wrmsrl_safe(reg, val); +} + u64 hv_get_msr(unsigned int reg) { if (hv_nested) diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c index 49898d10faff..a179ea482cb1 100644 --- a/drivers/hv/hv_common.c +++ b/drivers/hv/hv_common.c @@ -716,6 +716,19 @@ u64 __weak hv_tdx_hypercall(u64 control, u64 param1, u= 64 param2) } EXPORT_SYMBOL_GPL(hv_tdx_hypercall); =20 +int __weak hv_para_get_synic_register(unsigned int reg, u64 *val) +{ + *val =3D ~0ULL; + return -ENODEV; +} +EXPORT_SYMBOL_GPL(hv_para_get_synic_register); + +int __weak hv_para_set_synic_register(unsigned int reg, u64 val) +{ + return -ENODEV; +} +EXPORT_SYMBOL_GPL(hv_para_set_synic_register); + void hv_identify_partition_type(void) { /* Assume guest role */ diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h index 9722934a8332..f239b102fc53 100644 --- a/include/asm-generic/mshyperv.h +++ b/include/asm-generic/mshyperv.h @@ -333,6 +333,8 @@ bool hv_is_isolation_supported(void); bool hv_isolation_type_snp(void); u64 hv_ghcb_hypercall(u64 control, void *input, void *output, u32 input_si= ze); u64 hv_tdx_hypercall(u64 control, u64 param1, u64 param2); +int hv_para_get_synic_register(unsigned int reg, u64 *val); +int hv_para_set_synic_register(unsigned int reg, u64 val); void hyperv_cleanup(void); bool hv_query_ext_cap(u64 cap_query); void hv_setup_dma_ops(struct device *dev, bool coherent); --=20 2.43.0 From nobody Sat Feb 7 16:23:13 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 28328B665; Wed, 4 Jun 2025 00:43:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997827; cv=none; b=gd01X0S+zfiubkXhllpgz4HYO5xAh8BXu+Umc9AN0KfIXWnCYEi4AdcAUyxGc/kRPGHgkr8VQc7u9lcldatx9hLzPZG4rOX35MHXrmiLVf8VS4hlIWQwNb9StbaYAakreiuBT0pNJCxE0eIjZwXmVPK3TFBiEPZO0bPY5Ldwc5E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997827; c=relaxed/simple; bh=QY1MsUIE3B8H/obojmZnsFa1h4TAkdls1yVtcOG+Fjo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GHczObiFaNr5gW5YIaMhTrIjhdX6TJm/e37vQYB3JQh2f4tMAp2+BvF7kSSYMdv3Il5wxWQAcsSRDoWkMM9CqwqGtzLci59+1QaRf2nknNUow4yZ1cl+wdAgAxyjwoVIHnUodEZdWoYU0+ijsH4wQbFSQrDrBB8k6alIvpgEZ9I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=Vbl2GwRG; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="Vbl2GwRG" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id 6FF392116B50; Tue, 3 Jun 2025 17:43:45 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6FF392116B50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1748997825; bh=Edyue9zLDGHoqfApU478/BzTldR4EqRL+7s8Di7ovLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vbl2GwRGS3QQm42V3GjndlJkVgH36cJWNuWHb+T/iZswUm8ez2xQpsKiMbQAzUyQz uAsruhCS5q2NzZsq+qAp2TeX0XjfEN48PWXPMqK/ct+wRDt+SU7HWCVw+Ft/R6S+qn 0M8Tp+DKNjg6oqbeVB6vZNx3u4xrkajnB2m0joHA= From: Roman Kisel To: alok.a.tiwari@oracle.com, arnd@arndb.de, bp@alien8.de, corbet@lwn.net, dave.hansen@linux.intel.com, decui@microsoft.com, haiyangz@microsoft.com, hpa@zytor.com, kys@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, tglx@linutronix.de, wei.liu@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, bperkins@microsoft.com, sunilmut@microsoft.com Subject: [PATCH hyperv-next v3 04/15] arch/x86: mshyperv: Trap on access for some synthetic MSRs Date: Tue, 3 Jun 2025 17:43:30 -0700 Message-ID: <20250604004341.7194-5-romank@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250604004341.7194-1-romank@linux.microsoft.com> References: <20250604004341.7194-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To set up and run the confidential VMBus, the guest needs the paravisor to intercept access to some synthetic MSRs. In the non-confidential case, the guest continues using the vendor-specific guest-host communication protocol. Update the hv_set_non_nested_msr() function to trap access to some synthetic MSRs. Signed-off-by: Roman Kisel Reviewed-by: Alok Tiwari --- arch/x86/kernel/cpu/mshyperv.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index 83a85d94bcb3..db6f3e3db012 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -77,14 +78,28 @@ EXPORT_SYMBOL_GPL(hv_get_non_nested_msr); =20 void hv_set_non_nested_msr(unsigned int reg, u64 value) { + if (reg =3D=3D HV_X64_MSR_EOM && vmbus_is_confidential()) { + /* Reach out to the paravisor. */ + native_wrmsrl(reg, value); + return; + } + if (hv_is_synic_msr(reg) && ms_hyperv.paravisor_present) { + /* The hypervisor will get the intercept. */ hv_ivm_msr_write(reg, value); =20 - /* Write proxy bit via wrmsl instruction */ - if (hv_is_sint_msr(reg)) - wrmsrl(reg, value | 1 << 20); + if (hv_is_sint_msr(reg)) { + /* + * Write proxy bit in the case of non-confidential VMBus. + * Using wrmsl instruction so the following goes to the paravisor. + */ + u32 proxy =3D vmbus_is_confidential() ? 0 : 1; + + value |=3D (proxy << 20); + native_wrmsrl(reg, value); + } } else { - wrmsrl(reg, value); + native_wrmsrl(reg, value); } } EXPORT_SYMBOL_GPL(hv_set_non_nested_msr); --=20 2.43.0 From nobody Sat Feb 7 16:23:13 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 29C8A1BC4E; Wed, 4 Jun 2025 00:43:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997829; cv=none; b=bHBkOCwOOkTri32O93CD1uwWGF8lLS21QGZvbfoJHrHDR2t0g/egDxIcXynzywgEOPQsX+xL+j9uMK0CuFkAtrbzJnQGhb5YT9j4jAMiLHrxuJrgJS4JN+uc5eJ4Ry4WUj8rQFDEraxi2OVNXP6V3mep0SWeRSUUnyZU6kzi1/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997829; c=relaxed/simple; bh=4McgACtIqZE2r4rD+v0juzY5YfpUZCPCnLlTiET8S/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o7iYtnSuOB7p4E9+pLKPjykCAtTFuWUmVtePmjECq10ZyM4XW/i31DME7Mhg5HWoTbtkDZKfCNjv9CddI99vCyex5aKwuBWLjL2PFiZ149UspxhbLA/MD+UZUAjcnFz6p5smNOpBxeBilunxilv9A2/vLiTMNySPqvcSoGufzKs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=EJj1o6ED; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="EJj1o6ED" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id ABF032116B51; Tue, 3 Jun 2025 17:43:45 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com ABF032116B51 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1748997825; bh=drIlPMFwLyWS+EVnSe4OjcY0cTbW/iU4Qldza0fm1aY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EJj1o6EDCywkzgHChhuZMySOl+Gu+4yOl6giCQXIdQhkOmgevHM9pgf6AHAYzenBR gUgUM8P9LWTgBZFQh1HYzCFL02nIQdRMfrFA8JX2KngPvuwOJmIeWBCF/uCRdLamY8 SEilbpFnYbazV9V2p7JFyWowkAdV0muj2FN/8zEQ= From: Roman Kisel To: alok.a.tiwari@oracle.com, arnd@arndb.de, bp@alien8.de, corbet@lwn.net, dave.hansen@linux.intel.com, decui@microsoft.com, haiyangz@microsoft.com, hpa@zytor.com, kys@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, tglx@linutronix.de, wei.liu@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, bperkins@microsoft.com, sunilmut@microsoft.com Subject: [PATCH hyperv-next v3 05/15] Drivers: hv: Rename fields for SynIC message and event pages Date: Tue, 3 Jun 2025 17:43:31 -0700 Message-ID: <20250604004341.7194-6-romank@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250604004341.7194-1-romank@linux.microsoft.com> References: <20250604004341.7194-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Support for the confidential VMBus requires using SynIC message and event pages shared with the host and separate ones accessible only to the paravisor. Rename the host-accessible SynIC message and event pages to be able to add the paravisor ones. No functional changes. The field name is also changed in mshv_root.* for consistency. Signed-off-by: Roman Kisel --- drivers/hv/channel_mgmt.c | 6 ++-- drivers/hv/hv.c | 66 +++++++++++++++++++-------------------- drivers/hv/hyperv_vmbus.h | 4 +-- drivers/hv/mshv_root.h | 2 +- drivers/hv/mshv_synic.c | 6 ++-- drivers/hv/vmbus_drv.c | 6 ++-- 6 files changed, 45 insertions(+), 45 deletions(-) diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index 6e084c207414..6f87220e2ca3 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -843,14 +843,14 @@ static void vmbus_wait_for_unload(void) =3D per_cpu_ptr(hv_context.cpu_context, cpu); =20 /* - * In a CoCo VM the synic_message_page is not allocated + * In a CoCo VM the hyp_synic_message_page is not allocated * in hv_synic_alloc(). Instead it is set/cleared in * hv_synic_enable_regs() and hv_synic_disable_regs() * such that it is set only when the CPU is online. If * not all present CPUs are online, the message page * might be NULL, so skip such CPUs. */ - page_addr =3D hv_cpu->synic_message_page; + page_addr =3D hv_cpu->hyp_synic_message_page; if (!page_addr) continue; =20 @@ -891,7 +891,7 @@ static void vmbus_wait_for_unload(void) struct hv_per_cpu_context *hv_cpu =3D per_cpu_ptr(hv_context.cpu_context, cpu); =20 - page_addr =3D hv_cpu->synic_message_page; + page_addr =3D hv_cpu->hyp_synic_message_page; if (!page_addr) continue; =20 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index 308c8f279df8..964b9102477d 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c @@ -145,20 +145,20 @@ int hv_synic_alloc(void) * Skip these pages allocation here. */ if (!ms_hyperv.paravisor_present && !hv_root_partition()) { - hv_cpu->synic_message_page =3D + hv_cpu->hyp_synic_message_page =3D (void *)get_zeroed_page(GFP_ATOMIC); - if (!hv_cpu->synic_message_page) { + if (!hv_cpu->hyp_synic_message_page) { pr_err("Unable to allocate SYNIC message page\n"); goto err; } =20 - hv_cpu->synic_event_page =3D + hv_cpu->hyp_synic_event_page =3D (void *)get_zeroed_page(GFP_ATOMIC); - if (!hv_cpu->synic_event_page) { + if (!hv_cpu->hyp_synic_event_page) { pr_err("Unable to allocate SYNIC event page\n"); =20 - free_page((unsigned long)hv_cpu->synic_message_page); - hv_cpu->synic_message_page =3D NULL; + free_page((unsigned long)hv_cpu->hyp_synic_message_page); + hv_cpu->hyp_synic_message_page =3D NULL; goto err; } } @@ -166,30 +166,30 @@ int hv_synic_alloc(void) if (!ms_hyperv.paravisor_present && (hv_isolation_type_snp() || hv_isolation_type_tdx())) { ret =3D set_memory_decrypted((unsigned long) - hv_cpu->synic_message_page, 1); + hv_cpu->hyp_synic_message_page, 1); if (ret) { pr_err("Failed to decrypt SYNIC msg page: %d\n", ret); - hv_cpu->synic_message_page =3D NULL; + hv_cpu->hyp_synic_message_page =3D NULL; =20 /* * Free the event page here so that hv_synic_free() * won't later try to re-encrypt it. */ - free_page((unsigned long)hv_cpu->synic_event_page); - hv_cpu->synic_event_page =3D NULL; + free_page((unsigned long)hv_cpu->hyp_synic_event_page); + hv_cpu->hyp_synic_event_page =3D NULL; goto err; } =20 ret =3D set_memory_decrypted((unsigned long) - hv_cpu->synic_event_page, 1); + hv_cpu->hyp_synic_event_page, 1); if (ret) { pr_err("Failed to decrypt SYNIC event page: %d\n", ret); - hv_cpu->synic_event_page =3D NULL; + hv_cpu->hyp_synic_event_page =3D NULL; goto err; } =20 - memset(hv_cpu->synic_message_page, 0, PAGE_SIZE); - memset(hv_cpu->synic_event_page, 0, PAGE_SIZE); + memset(hv_cpu->hyp_synic_message_page, 0, PAGE_SIZE); + memset(hv_cpu->hyp_synic_event_page, 0, PAGE_SIZE); } } =20 @@ -225,28 +225,28 @@ void hv_synic_free(void) =20 if (!ms_hyperv.paravisor_present && (hv_isolation_type_snp() || hv_isolation_type_tdx())) { - if (hv_cpu->synic_message_page) { + if (hv_cpu->hyp_synic_message_page) { ret =3D set_memory_encrypted((unsigned long) - hv_cpu->synic_message_page, 1); + hv_cpu->hyp_synic_message_page, 1); if (ret) { pr_err("Failed to encrypt SYNIC msg page: %d\n", ret); - hv_cpu->synic_message_page =3D NULL; + hv_cpu->hyp_synic_message_page =3D NULL; } } =20 - if (hv_cpu->synic_event_page) { + if (hv_cpu->hyp_synic_event_page) { ret =3D set_memory_encrypted((unsigned long) - hv_cpu->synic_event_page, 1); + hv_cpu->hyp_synic_event_page, 1); if (ret) { pr_err("Failed to encrypt SYNIC event page: %d\n", ret); - hv_cpu->synic_event_page =3D NULL; + hv_cpu->hyp_synic_event_page =3D NULL; } } } =20 free_page((unsigned long)hv_cpu->post_msg_page); - free_page((unsigned long)hv_cpu->synic_event_page); - free_page((unsigned long)hv_cpu->synic_message_page); + free_page((unsigned long)hv_cpu->hyp_synic_event_page); + free_page((unsigned long)hv_cpu->hyp_synic_message_page); } =20 kfree(hv_context.hv_numa_map); @@ -276,12 +276,12 @@ void hv_synic_enable_regs(unsigned int cpu) /* Mask out vTOM bit. ioremap_cache() maps decrypted */ u64 base =3D (simp.base_simp_gpa << HV_HYP_PAGE_SHIFT) & ~ms_hyperv.shared_gpa_boundary; - hv_cpu->synic_message_page =3D + hv_cpu->hyp_synic_message_page =3D (void *)ioremap_cache(base, HV_HYP_PAGE_SIZE); - if (!hv_cpu->synic_message_page) + if (!hv_cpu->hyp_synic_message_page) pr_err("Fail to map synic message page.\n"); } else { - simp.base_simp_gpa =3D virt_to_phys(hv_cpu->synic_message_page) + simp.base_simp_gpa =3D virt_to_phys(hv_cpu->hyp_synic_message_page) >> HV_HYP_PAGE_SHIFT; } =20 @@ -295,12 +295,12 @@ void hv_synic_enable_regs(unsigned int cpu) /* Mask out vTOM bit. ioremap_cache() maps decrypted */ u64 base =3D (siefp.base_siefp_gpa << HV_HYP_PAGE_SHIFT) & ~ms_hyperv.shared_gpa_boundary; - hv_cpu->synic_event_page =3D + hv_cpu->hyp_synic_event_page =3D (void *)ioremap_cache(base, HV_HYP_PAGE_SIZE); - if (!hv_cpu->synic_event_page) + if (!hv_cpu->hyp_synic_event_page) pr_err("Fail to map synic event page.\n"); } else { - siefp.base_siefp_gpa =3D virt_to_phys(hv_cpu->synic_event_page) + siefp.base_siefp_gpa =3D virt_to_phys(hv_cpu->hyp_synic_event_page) >> HV_HYP_PAGE_SHIFT; } =20 @@ -358,8 +358,8 @@ void hv_synic_disable_regs(unsigned int cpu) */ simp.simp_enabled =3D 0; if (ms_hyperv.paravisor_present || hv_root_partition()) { - iounmap(hv_cpu->synic_message_page); - hv_cpu->synic_message_page =3D NULL; + iounmap(hv_cpu->hyp_synic_message_page); + hv_cpu->hyp_synic_message_page =3D NULL; } else { simp.base_simp_gpa =3D 0; } @@ -370,8 +370,8 @@ void hv_synic_disable_regs(unsigned int cpu) siefp.siefp_enabled =3D 0; =20 if (ms_hyperv.paravisor_present || hv_root_partition()) { - iounmap(hv_cpu->synic_event_page); - hv_cpu->synic_event_page =3D NULL; + iounmap(hv_cpu->hyp_synic_event_page); + hv_cpu->hyp_synic_event_page =3D NULL; } else { siefp.base_siefp_gpa =3D 0; } @@ -401,7 +401,7 @@ static bool hv_synic_event_pending(void) { struct hv_per_cpu_context *hv_cpu =3D this_cpu_ptr(hv_context.cpu_context= ); union hv_synic_event_flags *event =3D - (union hv_synic_event_flags *)hv_cpu->synic_event_page + VMBUS_MESSAGE_S= INT; + (union hv_synic_event_flags *)hv_cpu->hyp_synic_event_page + VMBUS_MESSA= GE_SINT; unsigned long *recv_int_page =3D event->flags; /* assumes VMBus version >= =3D VERSION_WIN8 */ bool pending; u32 relid; diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h index 0b450e53161e..fc3cdb26ff1a 100644 --- a/drivers/hv/hyperv_vmbus.h +++ b/drivers/hv/hyperv_vmbus.h @@ -120,8 +120,8 @@ enum { * Per cpu state for channel handling */ struct hv_per_cpu_context { - void *synic_message_page; - void *synic_event_page; + void *hyp_synic_message_page; + void *hyp_synic_event_page; =20 /* * The page is only used in hv_post_message() for a TDX VM (with the diff --git a/drivers/hv/mshv_root.h b/drivers/hv/mshv_root.h index e3931b0f1269..db6b42db2fdc 100644 --- a/drivers/hv/mshv_root.h +++ b/drivers/hv/mshv_root.h @@ -169,7 +169,7 @@ struct mshv_girq_routing_table { }; =20 struct hv_synic_pages { - struct hv_message_page *synic_message_page; + struct hv_message_page *hyp_synic_message_page; struct hv_synic_event_flags_page *synic_event_flags_page; struct hv_synic_event_ring_page *synic_event_ring_page; }; diff --git a/drivers/hv/mshv_synic.c b/drivers/hv/mshv_synic.c index e6b6381b7c36..f8b0337cdc82 100644 --- a/drivers/hv/mshv_synic.c +++ b/drivers/hv/mshv_synic.c @@ -394,7 +394,7 @@ mshv_intercept_isr(struct hv_message *msg) void mshv_isr(void) { struct hv_synic_pages *spages =3D this_cpu_ptr(mshv_root.synic_pages); - struct hv_message_page **msg_page =3D &spages->synic_message_page; + struct hv_message_page **msg_page =3D &spages->hyp_synic_message_page; struct hv_message *msg; bool handled; =20 @@ -456,7 +456,7 @@ int mshv_synic_init(unsigned int cpu) #endif union hv_synic_scontrol sctrl; struct hv_synic_pages *spages =3D this_cpu_ptr(mshv_root.synic_pages); - struct hv_message_page **msg_page =3D &spages->synic_message_page; + struct hv_message_page **msg_page =3D &spages->hyp_synic_message_page; struct hv_synic_event_flags_page **event_flags_page =3D &spages->synic_event_flags_page; struct hv_synic_event_ring_page **event_ring_page =3D @@ -550,7 +550,7 @@ int mshv_synic_cleanup(unsigned int cpu) union hv_synic_sirbp sirbp; union hv_synic_scontrol sctrl; struct hv_synic_pages *spages =3D this_cpu_ptr(mshv_root.synic_pages); - struct hv_message_page **msg_page =3D &spages->synic_message_page; + struct hv_message_page **msg_page =3D &spages->hyp_synic_message_page; struct hv_synic_event_flags_page **event_flags_page =3D &spages->synic_event_flags_page; struct hv_synic_event_ring_page **event_ring_page =3D diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 678ad59deb2d..695b1ba7113c 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -1060,7 +1060,7 @@ static void vmbus_onmessage_work(struct work_struct *= work) void vmbus_on_msg_dpc(unsigned long data) { struct hv_per_cpu_context *hv_cpu =3D (void *)data; - void *page_addr =3D hv_cpu->synic_message_page; + void *page_addr =3D hv_cpu->hyp_synic_message_page; struct hv_message msg_copy, *msg =3D (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT; struct vmbus_channel_message_header *hdr; @@ -1244,7 +1244,7 @@ static void vmbus_chan_sched(struct hv_per_cpu_contex= t *hv_cpu) * The event page can be directly checked to get the id of * the channel that has the interrupt pending. */ - void *page_addr =3D hv_cpu->synic_event_page; + void *page_addr =3D hv_cpu->hyp_synic_event_page; union hv_synic_event_flags *event =3D (union hv_synic_event_flags *)page_addr + VMBUS_MESSAGE_SINT; @@ -1327,7 +1327,7 @@ static void vmbus_isr(void) =20 vmbus_chan_sched(hv_cpu); =20 - page_addr =3D hv_cpu->synic_message_page; + page_addr =3D hv_cpu->hyp_synic_message_page; msg =3D (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT; =20 /* Check if there are actual msgs to be processed */ --=20 2.43.0 From nobody Sat Feb 7 16:23:13 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 287381B95B; Wed, 4 Jun 2025 00:43:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997829; cv=none; b=TjrBPGqWr2jEpylkjSjMtwP6oxBhEpKlQFwONHwqjAand/GMDSUekXFltFTvi3bNkXi7PE4Td5/eZjpfc65EyrymyahOKbqKR7E7Q2oMkLeztXCMxSvrFb+8hlRQ0sh1qUP4uVcdCe6c4UjRlGnNF3F3VUJvTLOfEX78p/THSPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997829; c=relaxed/simple; bh=hHWOqvudJhEz9KMRw0qJ/liQV11ZuKY+N4bCQ80Y0PI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WC9zvTh5kXAkSbCMOaUJswxJARAM/PttxHrkcOEbFtAye3jF4PC1B3TGoKnluWi1gvcpT9ivUCtGfKAXftrSqi6RYDGWfNugKujGpY2E48HI9urAiFsvVIm5Q0zr22nOUH/0Wzg3tfX4kejWuj5Fxwe/zfHDH/EzTM7A1JW0Ads= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=WVeZ1sk7; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="WVeZ1sk7" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id E81CB2117443; Tue, 3 Jun 2025 17:43:45 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E81CB2117443 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1748997826; bh=iRPOC/OOwq5b6JgofRXXJ+Zawfs997ge+A7efcrcalA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WVeZ1sk7VD/6zJXtXRkrTJRxK5kAevCvpDI3mymX7s5aBosmXPseHR051UWJbcLrN 41M0Idc/g9z+5/gXU6WOkmPJW5MhZ+rMgWGes0j1UI6WeUDvxkiznLlHUoj1bEhiEi xObA6lOwkKHe6xj1srgXArRjRU/+prlKdNf6CbUE= From: Roman Kisel To: alok.a.tiwari@oracle.com, arnd@arndb.de, bp@alien8.de, corbet@lwn.net, dave.hansen@linux.intel.com, decui@microsoft.com, haiyangz@microsoft.com, hpa@zytor.com, kys@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, tglx@linutronix.de, wei.liu@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, bperkins@microsoft.com, sunilmut@microsoft.com Subject: [PATCH hyperv-next v3 06/15] Drivers: hv: Allocate the paravisor SynIC pages when required Date: Tue, 3 Jun 2025 17:43:32 -0700 Message-ID: <20250604004341.7194-7-romank@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250604004341.7194-1-romank@linux.microsoft.com> References: <20250604004341.7194-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The paravisor needs the SynIC pages to communicate with the guest via the confidential VMBus. Refactor and extaned the exisitng code to account for that. Signed-off-by: Roman Kisel --- drivers/hv/hv.c | 184 +++++++++++++++++++------------------- drivers/hv/hyperv_vmbus.h | 17 ++++ 2 files changed, 111 insertions(+), 90 deletions(-) diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index 964b9102477d..e25c91eb6af5 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c @@ -94,10 +94,70 @@ int hv_post_message(union hv_connection_id connection_i= d, return hv_result(status); } =20 +static int hv_alloc_page(unsigned int cpu, void **page, bool decrypt, + const char *note) +{ + int ret =3D 0; + + /* + * After the page changes its encryption status, its contents might + * appear scrambled on some hardware. Thus `get_zeroed_page` would + * zero the page out in vain, we do that ourselves exactly once. + * + * By default, the page is allocated encrypted provided the system + * supports that. + */ + *page =3D (void *)__get_free_page(GFP_KERNEL); + if (!*page) + return -ENOMEM; + + if (decrypt) + ret =3D set_memory_decrypted((unsigned long)*page, 1); + if (ret) + goto failed; + + memset(*page, 0, PAGE_SIZE); + return 0; + +failed: + + pr_err("allocation failed for %s page, error %d when allocating the page,= decrypted %d\n", + note, ret, decrypt); + free_page((unsigned long)*page); + *page =3D NULL; + return ret; +} + +static int hv_free_page(void **page, bool encrypt, const char *note) +{ + int ret =3D 0; + + if (!*page) + return 0; + + if (encrypt) + ret =3D set_memory_encrypted((unsigned long)*page, 1); + + /* + * In the case of the action failure, the page is leaked. + * Something is wrong, prefer to lose the page and stay afloat. + */ + if (ret) { + pr_err("deallocation failed for %s page, error %d, encrypt %d\n", + note, ret, encrypt); + } else + free_page((unsigned long)*page); + + *page =3D NULL; + + return ret; +} + int hv_synic_alloc(void) { int cpu, ret =3D -ENOMEM; struct hv_per_cpu_context *hv_cpu; + const bool decrypt =3D !vmbus_is_confidential(); =20 /* * First, zero all per-cpu memory areas so hv_synic_free() can @@ -123,73 +183,37 @@ int hv_synic_alloc(void) vmbus_on_msg_dpc, (unsigned long)hv_cpu); =20 if (ms_hyperv.paravisor_present && hv_isolation_type_tdx()) { - hv_cpu->post_msg_page =3D (void *)get_zeroed_page(GFP_ATOMIC); - if (!hv_cpu->post_msg_page) { - pr_err("Unable to allocate post msg page\n"); - goto err; - } - - ret =3D set_memory_decrypted((unsigned long)hv_cpu->post_msg_page, 1); - if (ret) { - pr_err("Failed to decrypt post msg page: %d\n", ret); - /* Just leak the page, as it's unsafe to free the page. */ - hv_cpu->post_msg_page =3D NULL; + ret =3D hv_alloc_page(cpu, &hv_cpu->post_msg_page, + decrypt, "post msg"); + if (ret) goto err; - } - - memset(hv_cpu->post_msg_page, 0, PAGE_SIZE); } =20 /* - * Synic message and event pages are allocated by paravisor. - * Skip these pages allocation here. + * If these SynIC pages are not allocated, SIEF and SIM pages + * are configured using what the root partition or the paravisor + * provides upon reading the SIEFP and SIMP registers. */ if (!ms_hyperv.paravisor_present && !hv_root_partition()) { - hv_cpu->hyp_synic_message_page =3D - (void *)get_zeroed_page(GFP_ATOMIC); - if (!hv_cpu->hyp_synic_message_page) { - pr_err("Unable to allocate SYNIC message page\n"); + ret =3D hv_alloc_page(cpu, &hv_cpu->hyp_synic_message_page, + decrypt, "hypervisor SynIC msg"); + if (ret) goto err; - } - - hv_cpu->hyp_synic_event_page =3D - (void *)get_zeroed_page(GFP_ATOMIC); - if (!hv_cpu->hyp_synic_event_page) { - pr_err("Unable to allocate SYNIC event page\n"); - - free_page((unsigned long)hv_cpu->hyp_synic_message_page); - hv_cpu->hyp_synic_message_page =3D NULL; + ret =3D hv_alloc_page(cpu, &hv_cpu->hyp_synic_event_page, + decrypt, "hypervisor SynIC event"); + if (ret) goto err; } - } =20 - if (!ms_hyperv.paravisor_present && - (hv_isolation_type_snp() || hv_isolation_type_tdx())) { - ret =3D set_memory_decrypted((unsigned long) - hv_cpu->hyp_synic_message_page, 1); - if (ret) { - pr_err("Failed to decrypt SYNIC msg page: %d\n", ret); - hv_cpu->hyp_synic_message_page =3D NULL; - - /* - * Free the event page here so that hv_synic_free() - * won't later try to re-encrypt it. - */ - free_page((unsigned long)hv_cpu->hyp_synic_event_page); - hv_cpu->hyp_synic_event_page =3D NULL; + if (vmbus_is_confidential()) { + ret =3D hv_alloc_page(cpu, &hv_cpu->para_synic_message_page, + decrypt, "paravisor SynIC msg"); + if (ret) goto err; - } - - ret =3D set_memory_decrypted((unsigned long) - hv_cpu->hyp_synic_event_page, 1); - if (ret) { - pr_err("Failed to decrypt SYNIC event page: %d\n", ret); - hv_cpu->hyp_synic_event_page =3D NULL; + ret =3D hv_alloc_page(cpu, &hv_cpu->para_synic_event_page, + decrypt, "paravisor SynIC event"); + if (ret) goto err; - } - - memset(hv_cpu->hyp_synic_message_page, 0, PAGE_SIZE); - memset(hv_cpu->hyp_synic_event_page, 0, PAGE_SIZE); } } =20 @@ -205,48 +229,28 @@ int hv_synic_alloc(void) =20 void hv_synic_free(void) { - int cpu, ret; + int cpu; + const bool encrypt =3D !vmbus_is_confidential(); =20 for_each_present_cpu(cpu) { struct hv_per_cpu_context *hv_cpu =3D per_cpu_ptr(hv_context.cpu_context, cpu); =20 - /* It's better to leak the page if the encryption fails. */ - if (ms_hyperv.paravisor_present && hv_isolation_type_tdx()) { - if (hv_cpu->post_msg_page) { - ret =3D set_memory_encrypted((unsigned long) - hv_cpu->post_msg_page, 1); - if (ret) { - pr_err("Failed to encrypt post msg page: %d\n", ret); - hv_cpu->post_msg_page =3D NULL; - } - } + if (ms_hyperv.paravisor_present && hv_isolation_type_tdx()) + hv_free_page(&hv_cpu->post_msg_page, + encrypt, "post msg"); + if (!ms_hyperv.paravisor_present && !hv_root_partition()) { + hv_free_page(&hv_cpu->hyp_synic_event_page, + encrypt, "hypervisor SynIC event"); + hv_free_page(&hv_cpu->hyp_synic_message_page, + encrypt, "hypervisor SynIC msg"); } - - if (!ms_hyperv.paravisor_present && - (hv_isolation_type_snp() || hv_isolation_type_tdx())) { - if (hv_cpu->hyp_synic_message_page) { - ret =3D set_memory_encrypted((unsigned long) - hv_cpu->hyp_synic_message_page, 1); - if (ret) { - pr_err("Failed to encrypt SYNIC msg page: %d\n", ret); - hv_cpu->hyp_synic_message_page =3D NULL; - } - } - - if (hv_cpu->hyp_synic_event_page) { - ret =3D set_memory_encrypted((unsigned long) - hv_cpu->hyp_synic_event_page, 1); - if (ret) { - pr_err("Failed to encrypt SYNIC event page: %d\n", ret); - hv_cpu->hyp_synic_event_page =3D NULL; - } - } + if (vmbus_is_confidential()) { + hv_free_page(&hv_cpu->para_synic_event_page, + encrypt, "paravisor SynIC event"); + hv_free_page(&hv_cpu->para_synic_message_page, + encrypt, "paravisor SynIC msg"); } - - free_page((unsigned long)hv_cpu->post_msg_page); - free_page((unsigned long)hv_cpu->hyp_synic_event_page); - free_page((unsigned long)hv_cpu->hyp_synic_message_page); } =20 kfree(hv_context.hv_numa_map); diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h index fc3cdb26ff1a..9619edcf9f88 100644 --- a/drivers/hv/hyperv_vmbus.h +++ b/drivers/hv/hyperv_vmbus.h @@ -120,8 +120,25 @@ enum { * Per cpu state for channel handling */ struct hv_per_cpu_context { + /* + * SynIC pages for communicating with the host. + * + * These pages are accessible to the host partition and the hypervisor, + * so they can only be used for exchanging data when the host partition + * and the hypervisor are trusted. + */ void *hyp_synic_message_page; void *hyp_synic_event_page; + /* + * SynIC pages for communicating with the paravisor. + * + * These pages can be accessed only from within the guest partition. + * Neither the host partition nor the hypervisor can access these pages, + * so they can be used for exchanging data when the host partition and + * the hypervisor are not trusted, such as in a confidential VM. + */ + void *para_synic_message_page; + void *para_synic_event_page; =20 /* * The page is only used in hv_post_message() for a TDX VM (with the --=20 2.43.0 From nobody Sat Feb 7 16:23:13 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 55D871E519; Wed, 4 Jun 2025 00:43:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997829; cv=none; b=Ppd8witQf0dPZTUTuFNDdDIf4IkzqILN0WJt/Nf41EzzKoOpzDG6O4fhOdTMWK6YhDd8rk0qadQuonNcDP3rtYTcEBZo6kR/h+wRdm6uXaZO8e2nsyi85zWH3WApz/MfI5h5toWH9JcZtXBdM5ug8VqD9JSyk0uTXaaTFppy6sA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997829; c=relaxed/simple; bh=Z2a9TzfIsBx6WMfuQqjTzSaUgD3Resw90i86KAVIP6o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nTML19VUOEjSkeitv45Yv7ivzrb76Cr9Wnst0eiBCddJbSCZrN8ap8k6BY0edSHMPEIZV0/V/6v5SYdZ4OZxmLvd7VJMgnvjvZvvli38HCymdjBwxbppwTV+Osl7C1y+F568hUhPCuuTBuNZY8qobgslgVLT40MVlbzcdxDlNsU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=O7fBzkqF; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="O7fBzkqF" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id 30C2E2117441; Tue, 3 Jun 2025 17:43:46 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 30C2E2117441 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1748997826; bh=njYzXPLBXWszHfRNWp7EuYdZXKPASUgohOyGSK4pdFg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O7fBzkqF6w2hGSpwMWVGZPljeDJ5BKyANglSzBkU2Nyd6MU/YG/51DnwPoI8vx72P dWqWRqMUXwYRyKpwIP93KKCgqcHzBuVi2Yrkq0y+FZUEO7+0rrBTQF/1CVsSXBeZjE Whn0O+aI0aOm76mtNNH1BgZ9NtQ3H/6n3B/pkvyQ= From: Roman Kisel To: alok.a.tiwari@oracle.com, arnd@arndb.de, bp@alien8.de, corbet@lwn.net, dave.hansen@linux.intel.com, decui@microsoft.com, haiyangz@microsoft.com, hpa@zytor.com, kys@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, tglx@linutronix.de, wei.liu@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, bperkins@microsoft.com, sunilmut@microsoft.com Subject: [PATCH hyperv-next v3 07/15] Drivers: hv: Post messages via the confidential VMBus if available Date: Tue, 3 Jun 2025 17:43:33 -0700 Message-ID: <20250604004341.7194-8-romank@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250604004341.7194-1-romank@linux.microsoft.com> References: <20250604004341.7194-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When the confidential VMBus is available, the guest should post messages via the paravisor. Update hv_post_message() to request posting messages from the paravisor rather than through GHCB or TD calls. Signed-off-by: Roman Kisel --- drivers/hv/hv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index e25c91eb6af5..1f7cf1244509 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c @@ -74,7 +74,7 @@ int hv_post_message(union hv_connection_id connection_id, aligned_msg->payload_size =3D payload_size; memcpy((void *)aligned_msg->payload, payload, payload_size); =20 - if (ms_hyperv.paravisor_present) { + if (ms_hyperv.paravisor_present && !vmbus_is_confidential()) { if (hv_isolation_type_tdx()) status =3D hv_tdx_hypercall(HVCALL_POST_MESSAGE, virt_to_phys(aligned_msg), 0); --=20 2.43.0 From nobody Sat Feb 7 16:23:13 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 55DB41E52D; Wed, 4 Jun 2025 00:43:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997828; cv=none; b=DERX+w8V6ViKkKUzAJsdrKISz3qDqnJwi7uRWfQZQzQG09tGPTJ3AgEBu2gD35E+YJ7GsWhvBs5h9MnKHwSzE0zvgNNpznphbh/8I49/znw2IYLKdK8xgWAT1tf1v5iPeugC8LzHCM+YKy8euGs82xlTyMtZbnq7xS3J6jlHzOM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997828; c=relaxed/simple; bh=I99ATGrgD7XawikCaVwkKDyfblPK065Jd+ZqTiEtwDQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EjZTEPoaZ0LckWc+SjdT7ffqvrvshjaO1mveQaWp+lBBtAMRGVdNSLhu8n+k5d5NN9W7kDWpYKbtAzu0vU9UxEPiXMnl6b7fs0tm/fgwzOnnxinNeOLAV5cN+NgQLRP4SWsqq1HYqH5As2z9hCkWW3NTANJ9brPqe+fAiJMTuv4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=JQ0hHu5l; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="JQ0hHu5l" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id 6BA9B2117446; Tue, 3 Jun 2025 17:43:46 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6BA9B2117446 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1748997826; bh=ZShplV4bAYCDbYEU2Ei1HtNkAps8t8DA995FmRQAChw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JQ0hHu5lana2ZWgWM5ePpoMdQotzLuBlV7k6nfsaH2IHCgFIUIFLZdocLG077GfPu oV1l6OWXIIU4sdjx76AQWlnZvysfC6IxBXtcbJOBJtLsJQbCqKR9inuIZXUvL5/aLf jM2lxkusnxehzasnAaw0A3LIS6bt+2V1MLP9ijF8= From: Roman Kisel To: alok.a.tiwari@oracle.com, arnd@arndb.de, bp@alien8.de, corbet@lwn.net, dave.hansen@linux.intel.com, decui@microsoft.com, haiyangz@microsoft.com, hpa@zytor.com, kys@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, tglx@linutronix.de, wei.liu@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, bperkins@microsoft.com, sunilmut@microsoft.com Subject: [PATCH hyperv-next v3 08/15] Drivers: hv: remove stale comment Date: Tue, 3 Jun 2025 17:43:34 -0700 Message-ID: <20250604004341.7194-9-romank@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250604004341.7194-1-romank@linux.microsoft.com> References: <20250604004341.7194-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The comment about the x2v shim is ancient and long since incorrect. Remove the incorrect comment. Signed-off-by: Roman Kisel --- drivers/hv/hv.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index 1f7cf1244509..6a4857def82d 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c @@ -257,11 +257,7 @@ void hv_synic_free(void) } =20 /* - * hv_synic_init - Initialize the Synthetic Interrupt Controller. - * - * If it is already initialized by another entity (ie x2v shim), we need to - * retrieve the initialized message and event pages. Otherwise, we create= and - * initialize the message and event pages. + * hv_synic_enable_regs - Initialize the Synthetic Interrupt Controller. */ void hv_synic_enable_regs(unsigned int cpu) { --=20 2.43.0 From nobody Sat Feb 7 16:23:13 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 83523286A1; Wed, 4 Jun 2025 00:43:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997829; cv=none; b=iz2rLq/imBH12zvqwWi0vwD2UXaYY9aHkfTNyWcBcDqTJZ3pfgGQoGbdrP/sHL643HTMU7zN1kBaJzXcuMpJPJh9gKCf5Kw/sZyI0niupSv93nyslibSzHUgXwvOg50mVwrrik8DWd72eFN9iprLxKUXmSWIZNwbGhcb9/5lwN0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997829; c=relaxed/simple; bh=HBQr7m9q3N3TQWANmfZROgY/3eYF1L7aiZwfZ2AV4Wg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jHmVY9Izn4DnXidXxty+OnLBu/KbIsKgnojCoxISDfqY76k8jGo8slfdKOAxW1s5qUe6ekkBg5w9yQ5N0XjlpiopPG1nkajNHWIV6GGZC1dAm0mvH9kvp8YaO58H8yHMsyUfg2URkxlVMVkpX7BWYmT5/qFOZvttWEdOHau6P0Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=QiqoC+yL; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="QiqoC+yL" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id A79C72117447; Tue, 3 Jun 2025 17:43:46 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A79C72117447 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1748997826; bh=ftxOWRCisP0EsHUqwVLwCROgXQzvFotG1fMQh4+Adsk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QiqoC+yLZZklcLTqWGKPbc+HQfrSPMO6MJLDmCJ+rA9rGVd0yRfD2wuE8EWTAjVxP 3dsh4vkv8nqroPXThXm59Ly7J2RihhGRtuGm4eYgrljlss6p18y1VcOX9Q322VCc/k mc/S1w7tyBEOMFlTo87sKUY6SNUWMWs03D9TnpzE= From: Roman Kisel To: alok.a.tiwari@oracle.com, arnd@arndb.de, bp@alien8.de, corbet@lwn.net, dave.hansen@linux.intel.com, decui@microsoft.com, haiyangz@microsoft.com, hpa@zytor.com, kys@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, tglx@linutronix.de, wei.liu@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, bperkins@microsoft.com, sunilmut@microsoft.com Subject: [PATCH hyperv-next v3 09/15] Drivers: hv: Use memunmap() to check if the address is in IO map Date: Tue, 3 Jun 2025 17:43:35 -0700 Message-ID: <20250604004341.7194-10-romank@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250604004341.7194-1-romank@linux.microsoft.com> References: <20250604004341.7194-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It might happen that some hyp SynIC pages aren't IO mapped. Use memunmap() that checks for that and only then calls iounmap() Signed-off-by: Roman Kisel --- drivers/hv/hv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index 6a4857def82d..9a66656d89e0 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c @@ -358,7 +358,7 @@ void hv_synic_disable_regs(unsigned int cpu) */ simp.simp_enabled =3D 0; if (ms_hyperv.paravisor_present || hv_root_partition()) { - iounmap(hv_cpu->hyp_synic_message_page); + memunmap(hv_cpu->hyp_synic_message_page); hv_cpu->hyp_synic_message_page =3D NULL; } else { simp.base_simp_gpa =3D 0; @@ -370,7 +370,7 @@ void hv_synic_disable_regs(unsigned int cpu) siefp.siefp_enabled =3D 0; =20 if (ms_hyperv.paravisor_present || hv_root_partition()) { - iounmap(hv_cpu->hyp_synic_event_page); + memunmap(hv_cpu->hyp_synic_event_page); hv_cpu->hyp_synic_event_page =3D NULL; } else { siefp.base_siefp_gpa =3D 0; --=20 2.43.0 From nobody Sat Feb 7 16:23:13 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8355928DD0; Wed, 4 Jun 2025 00:43:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997829; cv=none; b=X8qsTj78FM+bb9CH8/jeBloqzRuHcvKH9A909U/FaH2RcMiOC4dtwYxt4oS7/ltzozcfSQK1H9bI6KmzavWylwW3g8YokzTkJAHElrkqDrC2g/y3WF+WjNYUk4N16d6u/goku1eibd7an7gU35f9tQV7EUL3cqx64UCLs4uPGro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997829; c=relaxed/simple; bh=S6NNXMAeozlLImSbXgnHi/ltsm81aFZBRSwp8YUJV7I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y0AezI/cUDeIRiAkUuGTDiFpZ2yuXXNL1Vezw2U/ZfSTM1XWPyyyb1ndlpNjZx3RA91b/poR0ar6XLEH/+RKYEJb0UuvFqkfCXCojbgXZpIEofzEbbTSUgj+NNJzlzFxAq2ZO9IaR5QgYrrbx1npAWhGbhKjzDPjV3GgeujweGQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=rE1XTNUM; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="rE1XTNUM" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id E36B92117442; Tue, 3 Jun 2025 17:43:46 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E36B92117442 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1748997827; bh=6ORUl5m6HwLA9mAuHKQ4DHWFTROfZExIZhOKRTufXW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rE1XTNUMEslshbdMhozLtOclQfcMMQq5tjCzLhXN1g5A9LOgcDhs/3FK1GyrHEZKJ yh/1sO9050A9ALRcjme9lykPY1Y2EVkgXCPibB4PresIDnyFaUnLAKnKz6kl9UVwI5 n22hAEfypll5m+FZ43s1D8oK50OxmsfSvxltbT4E= From: Roman Kisel To: alok.a.tiwari@oracle.com, arnd@arndb.de, bp@alien8.de, corbet@lwn.net, dave.hansen@linux.intel.com, decui@microsoft.com, haiyangz@microsoft.com, hpa@zytor.com, kys@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, tglx@linutronix.de, wei.liu@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, bperkins@microsoft.com, sunilmut@microsoft.com Subject: [PATCH hyperv-next v3 10/15] Drivers: hv: Rename the SynIC enable and disable routines Date: Tue, 3 Jun 2025 17:43:36 -0700 Message-ID: <20250604004341.7194-11-romank@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250604004341.7194-1-romank@linux.microsoft.com> References: <20250604004341.7194-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The confidential VMBus requires support for the both hypervisor facing SynIC and the paravisor one. Rename the functions that enable and disable SynIC with the hypervisor. Signed-off-by: Roman Kisel --- drivers/hv/channel_mgmt.c | 2 +- drivers/hv/hv.c | 11 ++++++----- drivers/hv/hyperv_vmbus.h | 4 ++-- drivers/hv/vmbus_drv.c | 6 +++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index 6f87220e2ca3..ca2fe10c110a 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -845,7 +845,7 @@ static void vmbus_wait_for_unload(void) /* * In a CoCo VM the hyp_synic_message_page is not allocated * in hv_synic_alloc(). Instead it is set/cleared in - * hv_synic_enable_regs() and hv_synic_disable_regs() + * hv_hyp_synic_enable_regs() and hv_hyp_synic_disable_regs() * such that it is set only when the CPU is online. If * not all present CPUs are online, the message page * might be NULL, so skip such CPUs. diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index 9a66656d89e0..2b561825089a 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c @@ -257,9 +257,10 @@ void hv_synic_free(void) } =20 /* - * hv_synic_enable_regs - Initialize the Synthetic Interrupt Controller. + * hv_hyp_synic_enable_regs - Initialize the Synthetic Interrupt Controller + * with the hypervisor. */ -void hv_synic_enable_regs(unsigned int cpu) +void hv_hyp_synic_enable_regs(unsigned int cpu) { struct hv_per_cpu_context *hv_cpu =3D per_cpu_ptr(hv_context.cpu_context, cpu); @@ -325,14 +326,14 @@ void hv_synic_enable_regs(unsigned int cpu) =20 int hv_synic_init(unsigned int cpu) { - hv_synic_enable_regs(cpu); + hv_hyp_synic_enable_regs(cpu); =20 hv_stimer_legacy_init(cpu, VMBUS_MESSAGE_SINT); =20 return 0; } =20 -void hv_synic_disable_regs(unsigned int cpu) +void hv_hyp_synic_disable_regs(unsigned int cpu) { struct hv_per_cpu_context *hv_cpu =3D per_cpu_ptr(hv_context.cpu_context, cpu); @@ -515,7 +516,7 @@ int hv_synic_cleanup(unsigned int cpu) always_cleanup: hv_stimer_legacy_cleanup(cpu); =20 - hv_synic_disable_regs(cpu); + hv_hyp_synic_disable_regs(cpu); =20 return ret; } diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h index 9619edcf9f88..c1df611d1eb2 100644 --- a/drivers/hv/hyperv_vmbus.h +++ b/drivers/hv/hyperv_vmbus.h @@ -188,10 +188,10 @@ extern int hv_synic_alloc(void); =20 extern void hv_synic_free(void); =20 -extern void hv_synic_enable_regs(unsigned int cpu); +extern void hv_hyp_synic_enable_regs(unsigned int cpu); extern int hv_synic_init(unsigned int cpu); =20 -extern void hv_synic_disable_regs(unsigned int cpu); +extern void hv_hyp_synic_disable_regs(unsigned int cpu); extern int hv_synic_cleanup(unsigned int cpu); =20 /* Interface */ diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 695b1ba7113c..f7e82a4fe133 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -2809,7 +2809,7 @@ static void hv_crash_handler(struct pt_regs *regs) */ cpu =3D smp_processor_id(); hv_stimer_cleanup(cpu); - hv_synic_disable_regs(cpu); + hv_hyp_synic_disable_regs(cpu); }; =20 static int hv_synic_suspend(void) @@ -2834,14 +2834,14 @@ static int hv_synic_suspend(void) * interrupts-disabled context. */ =20 - hv_synic_disable_regs(0); + hv_hyp_synic_disable_regs(0); =20 return 0; } =20 static void hv_synic_resume(void) { - hv_synic_enable_regs(0); + hv_hyp_synic_enable_regs(0); =20 /* * Note: we don't need to call hv_stimer_init(0), because the timer --=20 2.43.0 From nobody Sat Feb 7 16:23:13 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD03335971; Wed, 4 Jun 2025 00:43:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997830; cv=none; b=s+XaPgHYkI6mIPZKq5WQzanrYFa3o6ocTkvyj1ol3FQ2JwoGfiXqxC3DMAbloj8Kh98GIA3QG9ZL6lkw1kX48Bgd+bfOWQ7XyANJRq36BdDc4ZbGjvTSi/l9GX4rVvvp9B9fFuOI1QapJgR1fQOU5ONRP1U9fUg84odHmOV2LhE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997830; c=relaxed/simple; bh=PM4eGyI5r13CjUV33HbF5W2RIgXYjtVpEONLefd7S8E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aKZ+nLrJmq8ZlNdPYqH+thUZg2bhO+o1gc8Ghgt5uSNtUedN7zbow2+q9xekSeFeEWGgV3Pm2urTdjcbQtz7fKAuIKCMPwKAi/FUhojrF3TRJNeuGT2x3yEjtOFceg+prBW9TdIaX11trR8WaiFuVpuE5ZSorVq0v7xrIaqYgs8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=jEl6ehIt; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="jEl6ehIt" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id 2995A2117444; Tue, 3 Jun 2025 17:43:47 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2995A2117444 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1748997827; bh=y+ahWosz0MramHAxl570frT28U36/vEXSThjr+v2c/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jEl6ehIt4vXMNVViOEReFy9zFD1dju9+ZS0XbQhYW1jcqxa2EuUofZh5KcbPeiJxJ Qf2QKhvMxfs6FoLAejBtqilRyNZGJLsYSx6qVUPn6qIFFTyU7aw5Vy6pBRVWCv0UlK zCYkubhlL5Xw2XeAfd2gfwrKJ/DAfAzEjLcfYOXE= From: Roman Kisel To: alok.a.tiwari@oracle.com, arnd@arndb.de, bp@alien8.de, corbet@lwn.net, dave.hansen@linux.intel.com, decui@microsoft.com, haiyangz@microsoft.com, hpa@zytor.com, kys@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, tglx@linutronix.de, wei.liu@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, bperkins@microsoft.com, sunilmut@microsoft.com Subject: [PATCH hyperv-next v3 11/15] Drivers: hv: Functions for setting up and tearing down the paravisor SynIC Date: Tue, 3 Jun 2025 17:43:37 -0700 Message-ID: <20250604004341.7194-12-romank@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250604004341.7194-1-romank@linux.microsoft.com> References: <20250604004341.7194-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The confidential VMBus runs with the paravisor SynIC and requires configuring it with the paravisor. Add the functions for configuring the paravisor SynIC Signed-off-by: Roman Kisel --- drivers/hv/hv.c | 180 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 169 insertions(+), 11 deletions(-) diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index 2b561825089a..c9649ab3439e 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c @@ -203,7 +203,7 @@ int hv_synic_alloc(void) decrypt, "hypervisor SynIC event"); if (ret) goto err; - } + } =20 if (vmbus_is_confidential()) { ret =3D hv_alloc_page(cpu, &hv_cpu->para_synic_message_page, @@ -267,7 +267,6 @@ void hv_hyp_synic_enable_regs(unsigned int cpu) union hv_synic_simp simp; union hv_synic_siefp siefp; union hv_synic_sint shared_sint; - union hv_synic_scontrol sctrl; =20 /* Setup the Synic's message page */ simp.as_uint64 =3D hv_get_msr(HV_MSR_SIMP); @@ -288,7 +287,7 @@ void hv_hyp_synic_enable_regs(unsigned int cpu) =20 hv_set_msr(HV_MSR_SIMP, simp.as_uint64); =20 - /* Setup the Synic's event page */ + /* Setup the Synic's event page with the hypervisor. */ siefp.as_uint64 =3D hv_get_msr(HV_MSR_SIEFP); siefp.siefp_enabled =3D 1; =20 @@ -316,6 +315,11 @@ void hv_hyp_synic_enable_regs(unsigned int cpu) shared_sint.masked =3D false; shared_sint.auto_eoi =3D hv_recommend_using_aeoi(); hv_set_msr(HV_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64); +} + +static void hv_hyp_synic_enable_interrupts(void) +{ + union hv_synic_scontrol sctrl; =20 /* Enable the global synic bit */ sctrl.as_uint64 =3D hv_get_msr(HV_MSR_SCONTROL); @@ -324,13 +328,90 @@ void hv_hyp_synic_enable_regs(unsigned int cpu) hv_set_msr(HV_MSR_SCONTROL, sctrl.as_uint64); } =20 +/* + * The paravisor might not support proxying SynIC, and this + * function may fail. + */ +static int hv_para_synic_enable_regs(unsigned int cpu) +{ + int err; + union hv_synic_simp simp; + union hv_synic_siefp siefp; + struct hv_per_cpu_context *hv_cpu + =3D per_cpu_ptr(hv_context.cpu_context, cpu); + + /* Setup the Synic's message page with the paravisor. */ + err =3D hv_para_get_synic_register(HV_MSR_SIMP, &simp.as_uint64); + if (err) + return err; + simp.simp_enabled =3D 1; + simp.base_simp_gpa =3D virt_to_phys(hv_cpu->para_synic_message_page) + >> HV_HYP_PAGE_SHIFT; + err =3D hv_para_set_synic_register(HV_MSR_SIMP, simp.as_uint64); + if (err) + return err; + + /* Setup the Synic's event page with the paravisor. */ + err =3D hv_para_get_synic_register(HV_MSR_SIEFP, &siefp.as_uint64); + if (err) + return err; + siefp.siefp_enabled =3D 1; + siefp.base_siefp_gpa =3D virt_to_phys(hv_cpu->para_synic_event_page) + >> HV_HYP_PAGE_SHIFT; + return hv_para_set_synic_register(HV_MSR_SIEFP, siefp.as_uint64); +} + +static int hv_para_synic_enable_interrupts(void) +{ + union hv_synic_scontrol sctrl; + int err; + + /* Enable the global synic bit */ + err =3D hv_para_get_synic_register(HV_MSR_SCONTROL, &sctrl.as_uint64); + if (err) + return err; + sctrl.enable =3D 1; + + return hv_para_set_synic_register(HV_MSR_SCONTROL, sctrl.as_uint64); +} + int hv_synic_init(unsigned int cpu) { + int err; + + /* + * The paravisor may not support the confidential VMBus, + * check on that first. + */ + if (vmbus_is_confidential()) { + err =3D hv_para_synic_enable_regs(cpu); + if (err) + goto fail; + } + hv_hyp_synic_enable_regs(cpu); + if (vmbus_is_confidential()) { + err =3D hv_para_synic_enable_interrupts(); + if (err) + goto fail; + } else + hv_hyp_synic_enable_interrupts(); =20 hv_stimer_legacy_init(cpu, VMBUS_MESSAGE_SINT); =20 return 0; + +fail: + /* + * The failure may only come from enabling the paravisor SynIC. + * That in turn means that the confidential VMBus cannot be used + * which is not an error: the setup will be re-tried with the + * non-confidential VMBus. + * + * We also don't bother attempting to reset the paravisor registers + * as something isn't working there anyway. + */ + return err; } =20 void hv_hyp_synic_disable_regs(unsigned int cpu) @@ -340,7 +421,6 @@ void hv_hyp_synic_disable_regs(unsigned int cpu) union hv_synic_sint shared_sint; union hv_synic_simp simp; union hv_synic_siefp siefp; - union hv_synic_scontrol sctrl; =20 shared_sint.as_uint64 =3D hv_get_msr(HV_MSR_SINT0 + VMBUS_MESSAGE_SINT); =20 @@ -378,14 +458,71 @@ void hv_hyp_synic_disable_regs(unsigned int cpu) } =20 hv_set_msr(HV_MSR_SIEFP, siefp.as_uint64); +} + +static void hv_hyp_synic_disable_interrupts(void) +{ + union hv_synic_scontrol sctrl; =20 /* Disable the global synic bit */ sctrl.as_uint64 =3D hv_get_msr(HV_MSR_SCONTROL); sctrl.enable =3D 0; hv_set_msr(HV_MSR_SCONTROL, sctrl.as_uint64); +} =20 - if (vmbus_irq !=3D -1) - disable_percpu_irq(vmbus_irq); +static void hv_para_synic_disable_regs(unsigned int cpu) +{ + /* + * When a get/set register error is encountered, the function + * returns as the paravisor may not support these registers. + */ + int err; + union hv_synic_simp simp; + union hv_synic_siefp siefp; + + struct hv_per_cpu_context *hv_cpu + =3D per_cpu_ptr(hv_context.cpu_context, cpu); + + /* Disable SynIC's message page in the paravisor. */ + err =3D hv_para_get_synic_register(HV_MSR_SIMP, &simp.as_uint64); + if (err) + return; + simp.simp_enabled =3D 0; + + if (hv_cpu->para_synic_message_page) { + free_page((u64)(hv_cpu->para_synic_message_page)); + hv_cpu->para_synic_message_page =3D NULL; + } + + err =3D hv_para_set_synic_register(HV_MSR_SIMP, simp.as_uint64); + if (err) + return; + + /* Disable SynIC's event page in the paravisor. */ + err =3D hv_para_get_synic_register(HV_MSR_SIEFP, &siefp.as_uint64); + if (err) + return; + siefp.siefp_enabled =3D 0; + + if (hv_cpu->para_synic_event_page) { + free_page((u64)(hv_cpu->para_synic_event_page)); + hv_cpu->para_synic_event_page =3D NULL; + } + + hv_para_set_synic_register(HV_MSR_SIEFP, siefp.as_uint64); +} + +static void hv_para_synic_disable_interrupts(void) +{ + union hv_synic_scontrol sctrl; + int err; + + /* Disable the global synic bit */ + err =3D hv_para_get_synic_register(HV_MSR_SCONTROL, &sctrl.as_uint64); + if (err) + return; + sctrl.enable =3D 0; + hv_para_set_synic_register(HV_MSR_SCONTROL, sctrl.as_uint64); } =20 #define HV_MAX_TRIES 3 @@ -398,16 +535,18 @@ void hv_hyp_synic_disable_regs(unsigned int cpu) * that the normal interrupt handling mechanism will find and process the = channel interrupt * "very soon", and in the process clear the bit. */ -static bool hv_synic_event_pending(void) +static bool __hv_synic_event_pending(union hv_synic_event_flags *event, in= t sint) { - struct hv_per_cpu_context *hv_cpu =3D this_cpu_ptr(hv_context.cpu_context= ); - union hv_synic_event_flags *event =3D - (union hv_synic_event_flags *)hv_cpu->hyp_synic_event_page + VMBUS_MESSA= GE_SINT; - unsigned long *recv_int_page =3D event->flags; /* assumes VMBus version >= =3D VERSION_WIN8 */ + unsigned long *recv_int_page; bool pending; u32 relid; int tries =3D 0; =20 + if (!event) + return false; + + event +=3D sint; + recv_int_page =3D event->flags; /* assumes VMBus version >=3D VERSION_WIN= 8 */ retry: pending =3D false; for_each_set_bit(relid, recv_int_page, HV_EVENT_FLAGS_COUNT) { @@ -424,6 +563,17 @@ static bool hv_synic_event_pending(void) return pending; } =20 +static bool hv_synic_event_pending(void) +{ + struct hv_per_cpu_context *hv_cpu =3D this_cpu_ptr(hv_context.cpu_context= ); + union hv_synic_event_flags *hyp_synic_event_page =3D hv_cpu->hyp_synic_ev= ent_page; + union hv_synic_event_flags *para_synic_event_page =3D hv_cpu->para_synic_= event_page; + + return + __hv_synic_event_pending(hyp_synic_event_page, VMBUS_MESSAGE_SINT) || + __hv_synic_event_pending(para_synic_event_page, VMBUS_MESSAGE_SINT); +} + static int hv_pick_new_cpu(struct vmbus_channel *channel) { int ret =3D -EBUSY; @@ -517,6 +667,14 @@ int hv_synic_cleanup(unsigned int cpu) hv_stimer_legacy_cleanup(cpu); =20 hv_hyp_synic_disable_regs(cpu); + if (vmbus_is_confidential()) { + hv_para_synic_disable_regs(cpu); + hv_para_synic_disable_interrupts(); + } else { + hv_hyp_synic_disable_interrupts(); + } + if (vmbus_irq !=3D -1) + disable_percpu_irq(vmbus_irq); =20 return ret; } --=20 2.43.0 From nobody Sat Feb 7 16:23:13 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C40E03595E; Wed, 4 Jun 2025 00:43:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997829; cv=none; b=EssO8pNxZnylOZJAWqAmYgBiGjY3zYzkChZSueJvUmvBicsb6ZlueQv17BFwOaGhfr/DFWaJZEcq2eq5xMGGCDCzszpN/MVPYT0/McDtbOTZ5NaOhZu86/BE+L7/mxE8JllgZrVn1BjIymmeGSN6ZYqNSgncccOpJj3PEarVMr8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997829; c=relaxed/simple; bh=icRtk77BzzKKOoll5KWJ9DqBS6Nr3J49vHfAt0yO4hQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p+0auvEFtBIp5pS3+5TZ1JbIcfxh2YJecTex7YXlLGngD16HCOJ/hQahxMy1LdyqrQAseWDM0PDy88Jdj8fyyYr2WPyQoWSUh/e/UrCi0+yv/QXeS1MUG75SREaKCgTVBAfGxv54wVSzr3A/b4kE/4Pk3NF3G85g2107z9IKZ2k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=hfJuS4OM; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="hfJuS4OM" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id 653B42117448; Tue, 3 Jun 2025 17:43:47 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 653B42117448 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1748997827; bh=LAms2U6ddYyXTCzFfIbLw3Ykqrp3qhPKBffWKvGeuMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hfJuS4OMPYK8UsTI1JH3rCYLxlsPredTImbcfqjD3o+D08CPrmRq8p89nRJ5QcJk5 l9eYP3gRSWXrd+2/Wl7CIckJCpaBOEFpFI9SHsMle0cqRCTZVtROalnWhbs3gGFFzv ytuL39SY3+5+DavPxCg4+bfPVGrO6kJczygFsgnQ= From: Roman Kisel To: alok.a.tiwari@oracle.com, arnd@arndb.de, bp@alien8.de, corbet@lwn.net, dave.hansen@linux.intel.com, decui@microsoft.com, haiyangz@microsoft.com, hpa@zytor.com, kys@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, tglx@linutronix.de, wei.liu@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, bperkins@microsoft.com, sunilmut@microsoft.com Subject: [PATCH hyperv-next v3 12/15] Drivers: hv: Allocate encrypted buffers when requested Date: Tue, 3 Jun 2025 17:43:38 -0700 Message-ID: <20250604004341.7194-13-romank@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250604004341.7194-1-romank@linux.microsoft.com> References: <20250604004341.7194-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Confidential VMBus is built around using buffers not shared with the host. Support allocating encrypted buffers when requested. Signed-off-by: Roman Kisel --- drivers/hv/channel.c | 43 +++++++++++++++++++++++---------------- drivers/hv/hyperv_vmbus.h | 3 ++- drivers/hv/ring_buffer.c | 5 +++-- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c index fb8cd8469328..3e2891c4b800 100644 --- a/drivers/hv/channel.c +++ b/drivers/hv/channel.c @@ -443,20 +443,23 @@ static int __vmbus_establish_gpadl(struct vmbus_chann= el *channel, return ret; } =20 - /* - * Set the "decrypted" flag to true for the set_memory_decrypted() - * success case. In the failure case, the encryption state of the - * memory is unknown. Leave "decrypted" as true to ensure the - * memory will be leaked instead of going back on the free list. - */ - gpadl->decrypted =3D true; - ret =3D set_memory_decrypted((unsigned long)kbuffer, - PFN_UP(size)); - if (ret) { - dev_warn(&channel->device_obj->device, - "Failed to set host visibility for new GPADL %d.\n", - ret); - return ret; + gpadl->decrypted =3D !((channel->co_external_memory && type =3D=3D HV_GPA= DL_BUFFER) || + (channel->co_ring_buffer && type =3D=3D HV_GPADL_RING)); + if (gpadl->decrypted) { + /* + * Set the "decrypted" flag to true for the set_memory_decrypted() + * success case. In the failure case, the encryption state of the + * memory is unknown. Leave "decrypted" as true to ensure the + * memory will be leaked instead of going back on the free list. + */ + ret =3D set_memory_decrypted((unsigned long)kbuffer, + PFN_UP(size)); + if (ret) { + dev_warn(&channel->device_obj->device, + "Failed to set host visibility for new GPADL %d.\n", + ret); + return ret; + } } =20 init_completion(&msginfo->waitevent); @@ -676,12 +679,13 @@ static int __vmbus_open(struct vmbus_channel *newchan= nel, goto error_clean_ring; =20 err =3D hv_ringbuffer_init(&newchannel->outbound, - page, send_pages, 0); + page, send_pages, 0, newchannel->co_ring_buffer); if (err) goto error_free_gpadl; =20 err =3D hv_ringbuffer_init(&newchannel->inbound, &page[send_pages], - recv_pages, newchannel->max_pkt_size); + recv_pages, newchannel->max_pkt_size, + newchannel->co_ring_buffer); if (err) goto error_free_gpadl; =20 @@ -862,8 +866,11 @@ int vmbus_teardown_gpadl(struct vmbus_channel *channel= , struct vmbus_gpadl *gpad =20 kfree(info); =20 - ret =3D set_memory_encrypted((unsigned long)gpadl->buffer, - PFN_UP(gpadl->size)); + if (gpadl->decrypted) + ret =3D set_memory_encrypted((unsigned long)gpadl->buffer, + PFN_UP(gpadl->size)); + else + ret =3D 0; if (ret) pr_warn("Fail to set mem host visibility in GPADL teardown %d.\n", ret); =20 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h index c1df611d1eb2..0f02e163b0a0 100644 --- a/drivers/hv/hyperv_vmbus.h +++ b/drivers/hv/hyperv_vmbus.h @@ -199,7 +199,8 @@ extern int hv_synic_cleanup(unsigned int cpu); void hv_ringbuffer_pre_init(struct vmbus_channel *channel); =20 int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info, - struct page *pages, u32 pagecnt, u32 max_pkt_size); + struct page *pages, u32 pagecnt, u32 max_pkt_size, + bool confidential); =20 void hv_ringbuffer_cleanup(struct hv_ring_buffer_info *ring_info); =20 diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index 3c9b02471760..05c2cd42fc75 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -183,7 +183,8 @@ void hv_ringbuffer_pre_init(struct vmbus_channel *chann= el) =20 /* Initialize the ring buffer. */ int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info, - struct page *pages, u32 page_cnt, u32 max_pkt_size) + struct page *pages, u32 page_cnt, u32 max_pkt_size, + bool confidential) { struct page **pages_wraparound; int i; @@ -207,7 +208,7 @@ int hv_ringbuffer_init(struct hv_ring_buffer_info *ring= _info, =20 ring_info->ring_buffer =3D (struct hv_ring_buffer *) vmap(pages_wraparound, page_cnt * 2 - 1, VM_MAP, - pgprot_decrypted(PAGE_KERNEL)); + confidential ? PAGE_KERNEL : pgprot_decrypted(PAGE_KERNEL)); =20 kfree(pages_wraparound); if (!ring_info->ring_buffer) --=20 2.43.0 From nobody Sat Feb 7 16:23:13 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5610B4AEE0; Wed, 4 Jun 2025 00:43:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997830; cv=none; b=AzuMVBu7r0doRSntLXw/rAk+9YaOZXltT2chwuSh+gFN37uwJFY0KNOX4KoTzZ69fn6fZgsNeXJcUPxi/Lu580uVHdB6qijHL4SFAyPaORf/Ypae9lughzMuXFkjDtGqNS9VeiWvRGN79nAisisl1lX4+DAxZGwdaOVHaSK0LOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997830; c=relaxed/simple; bh=afyzY3pm5CQTRuBJaTL/7fnXbhgafdMaXJITAblpCbo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LOff4A/QBwccINZfmnBeFjTOVCQH7oTR3FdEAgVGOtWLCy2GihGDevK1H3XyLUkXZHu75VCD7e7tr502gSmk6mIxW4s2TzrbdZIFxLKEAU05+y6Wi0A+L+nV3WDf2oYZCDVSyB0Tecd7QErEI0cnhxiCl1ZFujlvf13Vr+XtmMk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=YCvebn2+; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="YCvebn2+" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id A31802117449; Tue, 3 Jun 2025 17:43:47 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A31802117449 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1748997827; bh=tG251cKgdNqMSYQOyf9na8PTYaITUoZaTg9nS4Q7t4U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YCvebn2+o2bF1eUZEODy7ZVCLjjj4zIw+FwIVwNP2JRyhKOwLAGGuufjDfWJ/VTGi fXyhSrNnEDFPu1yAWkswaJcD3hImJMK8mGh5f2/gIprNQkkDwzLil67hEzaIsqtI4b mxdIDmBTOnqgdm3r0BcW7JrTrgNYxgI3khpF6oBI= From: Roman Kisel To: alok.a.tiwari@oracle.com, arnd@arndb.de, bp@alien8.de, corbet@lwn.net, dave.hansen@linux.intel.com, decui@microsoft.com, haiyangz@microsoft.com, hpa@zytor.com, kys@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, tglx@linutronix.de, wei.liu@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, bperkins@microsoft.com, sunilmut@microsoft.com Subject: [PATCH hyperv-next v3 13/15] Drivers: hv: Support confidential VMBus channels Date: Tue, 3 Jun 2025 17:43:39 -0700 Message-ID: <20250604004341.7194-14-romank@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250604004341.7194-1-romank@linux.microsoft.com> References: <20250604004341.7194-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To run a confidential VMBus channels, one has to initialize the co_ring_buffers and co_external_memory fields of the channel structure. Advertise support upon negoatiating the version and compute values for those fields and initialize them. Signed-off-by: Roman Kisel --- drivers/hv/channel_mgmt.c | 19 +++++++++++++++++++ drivers/hv/connection.c | 3 +++ 2 files changed, 22 insertions(+) diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index ca2fe10c110a..33bc29e826bd 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -1021,6 +1021,7 @@ static void vmbus_onoffer(struct vmbus_channel_messag= e_header *hdr) struct vmbus_channel_offer_channel *offer; struct vmbus_channel *oldchannel, *newchannel; size_t offer_sz; + bool co_ring_buffer, co_external_memory; =20 offer =3D (struct vmbus_channel_offer_channel *)hdr; =20 @@ -1033,6 +1034,22 @@ static void vmbus_onoffer(struct vmbus_channel_messa= ge_header *hdr) return; } =20 + co_ring_buffer =3D is_co_ring_buffer(offer); + if (co_ring_buffer) { + if (vmbus_proto_version < VERSION_WIN10_V6_0 || !vmbus_is_confidential()= ) { + atomic_dec(&vmbus_connection.offer_in_progress); + return; + } + } + + co_external_memory =3D is_co_external_memory(offer); + if (is_co_external_memory(offer)) { + if (vmbus_proto_version < VERSION_WIN10_V6_0 || !vmbus_is_confidential()= ) { + atomic_dec(&vmbus_connection.offer_in_progress); + return; + } + } + oldchannel =3D find_primary_channel_by_offer(offer); =20 if (oldchannel !=3D NULL) { @@ -1111,6 +1128,8 @@ static void vmbus_onoffer(struct vmbus_channel_messag= e_header *hdr) pr_err("Unable to allocate channel object\n"); return; } + newchannel->co_ring_buffer =3D co_ring_buffer; + newchannel->co_external_memory =3D co_external_memory; =20 vmbus_setup_channel_state(newchannel, offer); =20 diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c index be490c598785..eeb472019d69 100644 --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c @@ -105,6 +105,9 @@ int vmbus_negotiate_version(struct vmbus_channel_msginf= o *msginfo, u32 version) vmbus_connection.msg_conn_id =3D VMBUS_MESSAGE_CONNECTION_ID; } =20 + if (vmbus_is_confidential() && version >=3D VERSION_WIN10_V6_0) + msg->feature_flags =3D VMBUS_FEATURE_FLAG_CONFIDENTIAL_CHANNELS; + /* * shared_gpa_boundary is zero in non-SNP VMs, so it's safe to always * bitwise OR it --=20 2.43.0 From nobody Sat Feb 7 16:23:13 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7934D4D599; Wed, 4 Jun 2025 00:43:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997830; cv=none; b=TWQs+ZKbIWi7YXyfsJpsu8u7aJslymIeZDgxBmHpMiXyDTVHvfsAC4SNshSkwApRUx0hPx7moDkWQNkhRiJJqNO+b9lkYeFQ4xd+CGnbG/TWmKu5Jk1Xavlptg7XYWU/Py03RB6rwHqbwnatCkyFHfuMiug2+6LjNUsO228ABf4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997830; c=relaxed/simple; bh=ZnAPNrGK35dWIknC1WFEbFSVhJEYFVuM7Dw2GuY9DWU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XxdSpi264/ADBXEa6pbAsvcwnKilwHXslVUYTtgsyR+Rspup24/qbNbuZs3x6kXVgKndDsq3v1OaXDQkOddp7i0DwgtzHd7eglElEimzCAEf3xrVibCz07c/6UkCkDOXQJBvUz5OmaaurJO/xME+C/v0S2ngxcMB7AtAHHBVDK0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=pHgo33vJ; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="pHgo33vJ" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id DD74D211744F; Tue, 3 Jun 2025 17:43:47 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com DD74D211744F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1748997828; bh=G4bFX/AkEXixqQTmxNm11dgAqyCUyPe6SpQCUFK0Rb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pHgo33vJjcgxZVVIYCl47eqX8NQTORBvhhZ1iokSfkx9r6yttX3BEdR7CFWkYIjOI yf/wUJoWyFvYtl93bslUGYJM6belX0eU4OYwq8QagVDme0Ujrb/PPTP80pbNd0eLZN ElTPFw+WTPEto9YEvpJUthaK7WM7nB88R/AdHXno= From: Roman Kisel To: alok.a.tiwari@oracle.com, arnd@arndb.de, bp@alien8.de, corbet@lwn.net, dave.hansen@linux.intel.com, decui@microsoft.com, haiyangz@microsoft.com, hpa@zytor.com, kys@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, tglx@linutronix.de, wei.liu@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, bperkins@microsoft.com, sunilmut@microsoft.com Subject: [PATCH hyperv-next v3 14/15] Drivers: hv: Support establishing the confidential VMBus connection Date: Tue, 3 Jun 2025 17:43:40 -0700 Message-ID: <20250604004341.7194-15-romank@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250604004341.7194-1-romank@linux.microsoft.com> References: <20250604004341.7194-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To establish the confidential VMBus connection the CoCo VM guest first attempts to connect to the VMBus server run by the paravisor. If that fails, the guest falls back to the non-confidential VMBus. Implement that in the VMBus driver initialization. Signed-off-by: Roman Kisel --- drivers/hv/vmbus_drv.c | 169 +++++++++++++++++++++++++++-------------- 1 file changed, 110 insertions(+), 59 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index f7e82a4fe133..88701c3ad999 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -1057,12 +1057,9 @@ static void vmbus_onmessage_work(struct work_struct = *work) kfree(ctx); } =20 -void vmbus_on_msg_dpc(unsigned long data) +static void __vmbus_on_msg_dpc(void *message_page_addr) { - struct hv_per_cpu_context *hv_cpu =3D (void *)data; - void *page_addr =3D hv_cpu->hyp_synic_message_page; - struct hv_message msg_copy, *msg =3D (struct hv_message *)page_addr + - VMBUS_MESSAGE_SINT; + struct hv_message msg_copy, *msg; struct vmbus_channel_message_header *hdr; enum vmbus_channel_message_type msgtype; const struct vmbus_channel_message_table_entry *entry; @@ -1070,6 +1067,10 @@ void vmbus_on_msg_dpc(unsigned long data) __u8 payload_size; u32 message_type; =20 + if (!message_page_addr) + return; + msg =3D (struct hv_message *)message_page_addr + VMBUS_MESSAGE_SINT; + /* * 'enum vmbus_channel_message_type' is supposed to always be 'u32' as * it is being used in 'struct vmbus_channel_message_header' definition @@ -1195,6 +1196,14 @@ void vmbus_on_msg_dpc(unsigned long data) vmbus_signal_eom(msg, message_type); } =20 +void vmbus_on_msg_dpc(unsigned long data) +{ + struct hv_per_cpu_context *hv_cpu =3D (void *)data; + + __vmbus_on_msg_dpc(hv_cpu->hyp_synic_message_page); + __vmbus_on_msg_dpc(hv_cpu->para_synic_message_page); +} + #ifdef CONFIG_PM_SLEEP /* * Fake RESCIND_CHANNEL messages to clean up hv_sock channels by force for @@ -1233,21 +1242,19 @@ static void vmbus_force_channel_rescinded(struct vm= bus_channel *channel) #endif /* CONFIG_PM_SLEEP */ =20 /* - * Schedule all channels with events pending + * Schedule all channels with events pending. + * The event page can be directly checked to get the id of + * the channel that has the interrupt pending. */ -static void vmbus_chan_sched(struct hv_per_cpu_context *hv_cpu) +static void vmbus_chan_sched(struct hv_per_cpu_context *hv_cpu, void *even= t_page_addr) { unsigned long *recv_int_page; u32 maxbits, relid; + union hv_synic_event_flags *event; =20 - /* - * The event page can be directly checked to get the id of - * the channel that has the interrupt pending. - */ - void *page_addr =3D hv_cpu->hyp_synic_event_page; - union hv_synic_event_flags *event - =3D (union hv_synic_event_flags *)page_addr + - VMBUS_MESSAGE_SINT; + if (!event_page_addr) + return; + event =3D (union hv_synic_event_flags *)event_page_addr + VMBUS_MESSAGE_S= INT; =20 maxbits =3D HV_EVENT_FLAGS_COUNT; recv_int_page =3D event->flags; @@ -1318,26 +1325,40 @@ static void vmbus_chan_sched(struct hv_per_cpu_cont= ext *hv_cpu) } } =20 -static void vmbus_isr(void) +static void vmbus_message_sched(struct hv_per_cpu_context *hv_cpu, void *m= essage_page_addr) { - struct hv_per_cpu_context *hv_cpu - =3D this_cpu_ptr(hv_context.cpu_context); - void *page_addr; struct hv_message *msg; =20 - vmbus_chan_sched(hv_cpu); - - page_addr =3D hv_cpu->hyp_synic_message_page; - msg =3D (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT; + if (!message_page_addr) + return; + msg =3D (struct hv_message *)message_page_addr + VMBUS_MESSAGE_SINT; =20 /* Check if there are actual msgs to be processed */ if (msg->header.message_type !=3D HVMSG_NONE) { if (msg->header.message_type =3D=3D HVMSG_TIMER_EXPIRED) { hv_stimer0_isr(); vmbus_signal_eom(msg, HVMSG_TIMER_EXPIRED); - } else + } else { tasklet_schedule(&hv_cpu->msg_dpc); + } } +} + +static void vmbus_isr(void) +{ + struct hv_per_cpu_context *hv_cpu + =3D this_cpu_ptr(hv_context.cpu_context); + + /* + * Suggested-by: Michael Kelley + * One possible optimization would be to keep track of the largest relID = that's in use, + * and only scan up to that relID. + */ + vmbus_chan_sched(hv_cpu, hv_cpu->hyp_synic_event_page); + vmbus_chan_sched(hv_cpu, hv_cpu->para_synic_event_page); + + vmbus_message_sched(hv_cpu, hv_cpu->hyp_synic_message_page); + vmbus_message_sched(hv_cpu, hv_cpu->para_synic_message_page); =20 add_interrupt_randomness(vmbus_interrupt); } @@ -1355,6 +1376,60 @@ static void vmbus_percpu_work(struct work_struct *wo= rk) hv_synic_init(cpu); } =20 +static int vmbus_alloc_synic_and_connect(void) +{ + int ret, cpu; + struct work_struct __percpu *works; + int hyperv_cpuhp_online; + + ret =3D hv_synic_alloc(); + if (ret < 0) + goto err_alloc; + + + works =3D alloc_percpu(struct work_struct); + if (!works) { + ret =3D -ENOMEM; + goto err_alloc; + } + + /* + * Initialize the per-cpu interrupt state and stimer state. + * Then connect to the host. + */ + cpus_read_lock(); + for_each_online_cpu(cpu) { + struct work_struct *work =3D per_cpu_ptr(works, cpu); + + INIT_WORK(work, vmbus_percpu_work); + schedule_work_on(cpu, work); + } + + for_each_online_cpu(cpu) + flush_work(per_cpu_ptr(works, cpu)); + + /* Register the callbacks for possible CPU online/offline'ing */ + ret =3D cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ONLINE_DYN, "hyperv= /vmbus:online", + hv_synic_init, hv_synic_cleanup); + cpus_read_unlock(); + free_percpu(works); + if (ret < 0) + goto err_alloc; + hyperv_cpuhp_online =3D ret; + + ret =3D vmbus_connect(); + if (ret) + goto err_connect; + return 0; + +err_connect: + cpuhp_remove_state(hyperv_cpuhp_online); + return -ENODEV; +err_alloc: + hv_synic_free(); + return -ENOMEM; +} + /* * vmbus_bus_init -Main vmbus driver initialization routine. * @@ -1365,8 +1440,7 @@ static void vmbus_percpu_work(struct work_struct *wor= k) */ static int vmbus_bus_init(void) { - int ret, cpu; - struct work_struct __percpu *works; + int ret; =20 ret =3D hv_init(); if (ret !=3D 0) { @@ -1401,41 +1475,21 @@ static int vmbus_bus_init(void) } } =20 - ret =3D hv_synic_alloc(); - if (ret) - goto err_alloc; - - works =3D alloc_percpu(struct work_struct); - if (!works) { - ret =3D -ENOMEM; - goto err_alloc; - } - /* - * Initialize the per-cpu interrupt state and stimer state. - * Then connect to the host. + * Attempt to establish the confidential VMBus connection first if this V= M is + * a hardware confidential VM, and the paravisor is present. */ - cpus_read_lock(); - for_each_online_cpu(cpu) { - struct work_struct *work =3D per_cpu_ptr(works, cpu); + ret =3D -ENODEV; + if (ms_hyperv.paravisor_present && (hv_isolation_type_tdx() || hv_isolati= on_type_snp())) { + is_confidential =3D true; + ret =3D vmbus_alloc_synic_and_connect(); + is_confidential =3D !ret; =20 - INIT_WORK(work, vmbus_percpu_work); - schedule_work_on(cpu, work); + pr_info("VMBus is confidential: %d\n", is_confidential); } =20 - for_each_online_cpu(cpu) - flush_work(per_cpu_ptr(works, cpu)); - - /* Register the callbacks for possible CPU online/offline'ing */ - ret =3D cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ONLINE_DYN, "hyperv= /vmbus:online", - hv_synic_init, hv_synic_cleanup); - cpus_read_unlock(); - free_percpu(works); - if (ret < 0) - goto err_alloc; - hyperv_cpuhp_online =3D ret; - - ret =3D vmbus_connect(); + if (!is_confidential) + ret =3D vmbus_alloc_synic_and_connect(); if (ret) goto err_connect; =20 @@ -1451,9 +1505,6 @@ static int vmbus_bus_init(void) return 0; =20 err_connect: - cpuhp_remove_state(hyperv_cpuhp_online); -err_alloc: - hv_synic_free(); if (vmbus_irq =3D=3D -1) { hv_remove_vmbus_handler(); } else { --=20 2.43.0 From nobody Sat Feb 7 16:23:13 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0C5E372625; Wed, 4 Jun 2025 00:43:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997830; cv=none; b=uSkfoD+nQwv23ClFtap9pZxnsL9KHFa78u/G4R+B2rIwTcwvUrj6O712ImyQQfN8rQu40xFENOBXQBDlcw+FZWR5Ad0zr9Fv1slDDuqNk6YuT/Xkdh0n51vCbqaY2rWSJFOQ99SGcx0maXNrO+iYfDumFCzXn7WEIx/O8bxMyXA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748997830; c=relaxed/simple; bh=qu5wrCRGckFddgOVao5M+PQvlTFUez7DHz4TBUqUopY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f0Y02VfBfbkcJsTl+qodOGNVqRkShXQxh3P0BAFhItp8CVGUbiQkMpEKOghPYsxDtEA8OmSH5Ymyxia90HOJklg2pfLn4HZRD7vNcpXEnuymnv6tG0t3bsQPdM9UU/QW87OaRyuFuq/hSa+wBxzwGvr/+6R8qCHyAUzIv6cZNBM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=fT62NYCK; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="fT62NYCK" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id 23742211744D; Tue, 3 Jun 2025 17:43:48 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 23742211744D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1748997828; bh=5NILQvH5aX9tvrOJMwj2GLYW/SEBrWgpZjSjwN/upug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fT62NYCKaOi1r3nQQ2phA+78GAYqZzdidu63lQ0n8P896grkB7UwaF/o7dzybHx3z eZq+bZOBaCVvc5CZR3QS1I+GDau9/vsQmZOrVhpq1HeuNn/dIyEWkp+MvrgMCWVIw0 X+2tz1uJ/Funk9IeIp3ArJ1XvPh2fYXJsX+6UPFk= From: Roman Kisel To: alok.a.tiwari@oracle.com, arnd@arndb.de, bp@alien8.de, corbet@lwn.net, dave.hansen@linux.intel.com, decui@microsoft.com, haiyangz@microsoft.com, hpa@zytor.com, kys@microsoft.com, mingo@redhat.com, mhklinux@outlook.com, tglx@linutronix.de, wei.liu@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, bperkins@microsoft.com, sunilmut@microsoft.com Subject: [PATCH hyperv-next v3 15/15] Drivers: hv: Set the default VMBus version to 6.0 Date: Tue, 3 Jun 2025 17:43:41 -0700 Message-ID: <20250604004341.7194-16-romank@linux.microsoft.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250604004341.7194-1-romank@linux.microsoft.com> References: <20250604004341.7194-1-romank@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The confidential VMBus is supported by the protocol version 6.0 onwards. Attempt to establish the VMBus 6.0 connection thus enabling the confidential VMBus features when available. Signed-off-by: Roman Kisel --- drivers/hv/connection.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c index eeb472019d69..7cd43463f969 100644 --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c @@ -51,6 +51,7 @@ EXPORT_SYMBOL_GPL(vmbus_proto_version); * Linux guests and are not listed. */ static __u32 vmbus_versions[] =3D { + VERSION_WIN10_V6_0, VERSION_WIN10_V5_3, VERSION_WIN10_V5_2, VERSION_WIN10_V5_1, @@ -65,7 +66,7 @@ static __u32 vmbus_versions[] =3D { * Maximal VMBus protocol version guests can negotiate. Useful to cap the * VMBus version for testing and debugging purpose. */ -static uint max_version =3D VERSION_WIN10_V5_3; +static uint max_version =3D VERSION_WIN10_V6_0; =20 module_param(max_version, uint, S_IRUGO); MODULE_PARM_DESC(max_version, --=20 2.43.0