Confidential VMBus
Subsystems (10)
cover Confidential VMBus
Logically, there are two parts to this patch series:
1. The first part is to add the support for the confidential VMBus protocol, patches 1-4.
2. The second part is to avoid the bounce-buffering when the pages aren't shared with the host, patches 5-6.
Let us discuss the motivation and present the value proposition.
The guests running on Hyper-V can be confidential where the memory and the register content are encrypted, provided that the hardware supports that (currently AMD SEV-SNP and Intel TDX) and the guest is capable of using these features. The confidential guests cannot be introspected by the host nor the hypervisor without the guest sharing the memory contents upon doing which the memory is decrypted.
In the confidential guests, neither the host nor the hypervisor need to be trusted, and the guests processing sensitive data can take advantage of that.
Not trusting the host and the hypervisor (removing them from the Trusted Computing Base aka TCB) ncessitates that the method of communication between the host and the guest be changed. Below there is the breakdown of the options used in the both cases (in the diagrams below the server is marked as S, the client is marked as C):
1. Without the paravisoor the devices are connected to the host, and the host provides the device emulation or translation to the guest:
+---- GUEST ----+ +----- DEVICE ----+ +----- HOST -----+
| | | | | |
| | | | | |
| | | ========== |
| | | | | |
| | | | | |
| | | | | |
+----- C -------+ +-----------------+ +------- S ------+
|| ||
|| ||
+------||------------------ VMBus --------------------------||------+
| Interrupts, MMIO |
+-------------------------------------------------------------------+2. With the paravisor, the devices are connected to the paravisor, and the paravisor provides the device emulation or translation to the guest. The guest doesn't communicate with the host directly, and the guest communicates with the paravisor via the VMBus. The host is not trusted in this model, and the paravisor is trusted:
+---- GUEST ------+ +-- DEVICE --+
| | | |
| +- PARAVISOR -+ | | |
| | ==+==================================== |
| | OpenHCL | | | |
| | | C===================== | |
+-+---- C - S --+-+ || +------------+
|| || ||
|| || +-- VMBus Relay --||--+ +--- HOST ---+
|| ||======= Interrupts, MMIO | | |
|| +---------------------+ +---- S -----+
|| ||
+-------||----------------- VMBus --------------------------||------+
| Interrupts, MMIO |
+-------------------------------------------------------------------+Note that in the second case the guest doesn't need to share the memory with the host as it communicates only with the paravisor within their partition boundary. That is precisely the raison d'etre and the value proposition of this patch series: equip the confidential guest to use private (encrypted) memory and rely on the paravisor when this is available to be secure.
I'd like to thank the following people for their help with this patch series:
- Dexuan for help with the patches 4-6, validation and the fruitful discussions,
- Easwar for reviewing the refactoring of the page allocating and freeing in hv.c,
- John and Sven for the design,
- Mike for helping to avoid pitfalls when dealing with the GFP flags,
- Sven for blazing the trail and implementing the design in few codebases.
Roman Kisel (6):
Documentation: hyperv: Confidential VMBus
drivers: hyperv: VMBus protocol version 6.0
arch: hyperv: Get/set SynIC synth.registers via paravisor
arch: x86, drivers: hyperv: Enable confidential VMBus arch, drivers: Add device struct bitfield to not bounce-buffer
drivers: SCSI: Do not bounce-bufffer for the confidential VMBus
Documentation/virt/hyperv/vmbus.rst | 41 +++ arch/arm64/hyperv/mshyperv.c | 19 ++ arch/arm64/include/asm/mshyperv.h | 3 + arch/x86/include/asm/mshyperv.h | 3 + arch/x86/kernel/cpu/mshyperv.c | 51 ++- arch/x86/mm/mem_encrypt.c | 3 + drivers/hv/channel.c | 36 ++- drivers/hv/channel_mgmt.c | 29 +- drivers/hv/connection.c | 10 +- drivers/hv/hv.c | 485 ++++++++++++++++++++-------- drivers/hv/hyperv_vmbus.h | 9 +- drivers/hv/ring_buffer.c | 5 +- drivers/hv/vmbus_drv.c | 152 +++++---- drivers/scsi/storvsc_drv.c | 2 + include/asm-generic/mshyperv.h | 1 + include/linux/device.h | 8 + include/linux/dma-direct.h | 3 + include/linux/hyperv.h | 71 ++-- include/linux/swiotlb.h | 3 + 19 files changed, 696 insertions(+), 238 deletions(-)
base-commit: 628cc040b3a2980df6032766e8ef0688e981ab95
Signature · 1 line
2.43.0
PATCH 1/6 Documentation: hyperv: Confidential VMBus
Define what the confidential VMBus is and describe what advantages it offers on the capable hardware.
--- Documentation/virt/hyperv/vmbus.rst | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
Documentation/virt/hyperv/vmbus.rst +41 -0
@@ -324,3 +324,44 @@ rescinded, neither Hyper-V nor Linux retains any state about its previous existence. Such a device might be re-added later, in which case it is treated as an entirely new device. See vmbus_onoffer_rescind(). + +Confidential VMBus +------------------ + +The confidential VMBus provides the control and data planes where +the guest doesn't talk to either the hypervisor or the host. Instead, +it relies on the trusted paravisor. The hardware (SNP or TDX) encrypts +the guest memory and the register state also measuring the paravisor +image via using the platform security processor to ensure trsuted and +confidential computing. + +To support confidential communication with the paravisor, a VmBus client +will first attempt to use regular, non-isolated mechanisms for communication. +To do this, it must: + +* Configure the paravisor SIMP with an encrypted page. The paravisor SIMP is + configured by setting the relevant MSR directly, without using GHCB or tdcall. + +* Enable SINT 2 on both the paravisor and hypervisor, without setting the proxy + flag on the paravisor SINT. Enable interrupts on the paravisor SynIC. + +* Configure both the paravisor and hypervisor event flags page. + Both pages will need to be scanned when VmBus receives a channel interrupt. + +* Send messages to the paravisor by calling HvPostMessage directly, without using + GHCB or tdcall. + +* Set the EOM MSR directly in the paravisor, without using GHCB or tdcall. + +If sending the InitiateContact message using non-isolated HvPostMessage fails, +the client must fall back to using the hypervisor synic, by using the GHCB/tdcall +as appropriate. + +To fall back, the client will have to reconfigure the following: + +* Configure the hypervisor SIMP with a host-visible page. + Since the hypervisor SIMP is not used when in confidential mode, + this can be done up front, or only when needed, whichever makes sense for + the particular implementation. + +* Set the proxy flag on SINT 2 for the paravisor.
Signature · 1 line
2.43.0
PATCH 2/6 drivers: hyperv: VMBus protocol version 6.0
In reply to Roman KiselThe confidential VMBus is supported starting from the protocol version 6.0 onwards.
Update the relevant definitions, provide a function that returns whether VMBus is condifential or not.
--- drivers/hv/vmbus_drv.c | 12 ++++++ include/asm-generic/mshyperv.h | 1 + include/linux/hyperv.h | 71 +++++++++++++++++++++++++--------- 3 files changed, 65 insertions(+), 19 deletions(-)
drivers/hv/vmbus_drv.c +12 -0
@@ -55,6 +55,18 @@ static long __percpu *vmbus_evt;int vmbus_irq;int vmbus_interrupt; +/* +* 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.
include/asm-generic/mshyperv.h +1 -0
@@ -377,5 +377,6 @@ static inline int hv_call_create_vp(int node, u64 partition_id, u32 vp_index, u3return -EOPNOTSUPP ; }#endif /* CONFIG_MSHV_ROOT */ +bool vmbus_is_confidential (void );#endif
include/linux/hyperv.h +52 -19
107 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 3/6 arch: hyperv: Get/set SynIC synth.registers via paravisor
In reply to Roman KiselThe confidential VMBus is built on the guest talking to the paravisor only.
Provide functions that allow manipulating the SynIC registers via paravisor.
--- arch/arm64/hyperv/mshyperv.c | 19 +++++++++++++++++++ arch/arm64/include/asm/mshyperv.h | 3 +++ arch/x86/include/asm/mshyperv.h | 3 +++ arch/x86/kernel/cpu/mshyperv.c | 28 ++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+)
arch/arm64/hyperv/mshyperv.c +19 -0
@@ -91,3 +91,22 @@ bool hv_is_hyperv_initialized(void)return hyperv_initialized; }EXPORT_SYMBOL_GPL (hv_is_hyperv_initialized); + +/* +* Not supported yet. +*/ +u64 hv_pv_get_synic_register (unsigned int reg,int *err) +{ + *err = -ENODEV ; +return !0ULL ; +} +EXPORT_SYMBOL_GPL (hv_pv_get_synic_register); + +/* +* Not supported yet. +*/ +int hv_pv_set_synic_register (unsigned int reg,u64 val) +{ +return -ENODEV ; +} +EXPORT_SYMBOL_GPL (hv_pv_set_synic_register);
arch/arm64/include/asm/mshyperv.h +3 -0
@@ -53,6 +53,9 @@ static inline u64 hv_get_non_nested_msr(unsigned int reg)return hv_get_msr (reg); } +u64 hv_pv_get_synic_register (unsigned int reg,int *err); +int hv_pv_set_synic_register (unsigned int reg,u64 val); +/* SMCCC hypercall parameters */ #define HV_SMCCC_FUNC_NUMBER 1#define HV_FUNC_ID ARM_SMCCC_CALL_VAL( \
arch/x86/include/asm/mshyperv.h +3 -0
@@ -307,6 +307,9 @@ static __always_inline u64 hv_raw_get_msr(unsigned int reg) return __rdmsr(reg); } +u64 hv_pv_get_synic_register (unsigned int reg,int *err); +int hv_pv_set_synic_register (unsigned int reg,u64 val); +#else /* CONFIG_HYPERV */ static inline void hyperv_init (void ) {}static inline void hyperv_setup_mmu_ops (void ) {}
arch/x86/kernel/cpu/mshyperv.c +28 -0
@@ -89,6 +89,34 @@ void hv_set_non_nested_msr(unsigned int reg, u64 value) }EXPORT_SYMBOL_GPL (hv_set_non_nested_msr); +/* +* Not every paravisor supports getting SynIC registers, and +* this function may fail. The caller has to make sure that this function +* runs on the CPU of interest. +*/ +u64 hv_pv_get_synic_register (unsigned int reg,int *err) +{ +if (!hv_is_synic_msr (reg)) { + *err = -ENODEV ; +return !0ULL ; + } +return native_read_msr_safe (reg, err); +} +EXPORT_SYMBOL_GPL (hv_pv_get_synic_register); + +/* +* Not every paravisor supports setting SynIC registers, and +* this function may fail. The caller has to make sure that this function +* runs on the CPU of interest. +*/ +int hv_pv_set_synic_register (unsigned int reg,u64 val) +{ +if (!hv_is_synic_msr (reg)) +return -ENODEV ; +return wrmsrl_safe (reg, val); +} +EXPORT_SYMBOL_GPL (hv_pv_set_synic_register); +u64 hv_get_msr (unsigned int reg) {if (hv_nested)
Signature · 1 line
2.43.0
PATCH 4/6 arch: x86, drivers: hyperv: Enable confidential VMBus
In reply to Roman KiselConfidential VMBus employs the paravisor SynIC pages to implement the control plane of the protocol, and the data plane may use encrypted pages.
Implement scanning the additional pages in the control plane, and update the logic not to decrypt ring buffer and GPADLs (GPA descr. lists) unconditionally.
--- arch/x86/kernel/cpu/mshyperv.c | 23 +- drivers/hv/channel.c | 36 +-- drivers/hv/channel_mgmt.c | 29 +- drivers/hv/connection.c | 10 +- drivers/hv/hv.c | 485 ++++++++++++++++++++++++--------- drivers/hv/hyperv_vmbus.h | 9 +- drivers/hv/ring_buffer.c | 5 +- drivers/hv/vmbus_drv.c | 140 +++++----- 8 files changed, 518 insertions(+), 219 deletions(-)
arch/x86/kernel/cpu/mshyperv.c +19 -4
@@ -28,6 +28,7 @@#include <asm/apic.h> #include <asm/timer.h> #include <asm/reboot.h> +#include <asm/msr.h> #include <asm/nmi.h> #include <clocksource/hyperv_timer.h> #include <asm/numa.h>
@@ -77,14 +78,28 @@ EXPORT_SYMBOL_GPL(hv_get_non_nested_msr);void hv_set_non_nested_msr (unsigned int reg,u64 value) { +if (reg ==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); -/* 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 control plane. +* Using wrmsl instruction so the following goes to the paravisor. +*/ +u32 proxy =1 & !vmbus_is_confidential (); + + value |= (proxy <<20 ); +native_wrmsrl (reg, value); + } }else { -wrmsrl (reg, value); +native_wrmsrl (reg, value); } }EXPORT_SYMBOL_GPL (hv_set_non_nested_msr);
drivers/hv/channel.c +20 -16
@@ -443,20 +443,23 @@ static int __vmbus_establish_gpadl(struct vmbus_channel *channel,return ret; } -/* -* 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 = true; - ret =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; +if ((!channel->confidential_external_memory && type ==HV_GPADL_BUFFER ) || + (!channel->confidential_ring_buffer && type ==HV_GPADL_RING )) { +/* +* 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 = true; + ret =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; + } }init_completion (&msginfo->waitevent);
@@ -676,12 +679,13 @@ static int __vmbus_open(struct vmbus_channel *newchannel, goto error_clean_ring; err =hv_ringbuffer_init (&newchannel->outbound, - page, send_pages,0 ); + page, send_pages,0 , newchannel->confidential_ring_buffer);if (err) goto error_free_gpadl; err =hv_ringbuffer_init (&newchannel->inbound, &page[send_pages], - recv_pages, newchannel->max_pkt_size); + recv_pages, newchannel->max_pkt_size, + newchannel->confidential_ring_buffer);if (err) goto error_free_gpadl;
drivers/hv/channel_mgmt.c +26 -3
@@ -843,14 +843,14 @@ static void vmbus_wait_for_unload(void) = per_cpu_ptr(hv_context.cpu_context, cpu);/* -* In a CoCo VM the synic_message_page is not allocated +* In a CoCo VM the hv_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 = hv_cpu->synic_message_page; + page_addr = hv_cpu->hv_synic_message_page;if (!page_addr)continue ;
@@ -891,7 +891,7 @@ static void vmbus_wait_for_unload(void)struct hv_per_cpu_context *hv_cpu =per_cpu_ptr (hv_context.cpu_context, cpu); - page_addr = hv_cpu->synic_message_page; + page_addr = hv_cpu->hv_synic_message_page;if (!page_addr)continue ;
@@ -1021,6 +1021,7 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)struct vmbus_channel_offer_channel *offer;struct vmbus_channel *oldchannel, *newchannel;size_t offer_sz; +bool confidential_ring_buffer, confidential_external_memory; offer = (struct vmbus_channel_offer_channel *)hdr;
@@ -1033,6 +1034,18 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)return ; } + confidential_ring_buffer =is_confidential_ring_buffer (offer); +if (confidential_ring_buffer) { +if (vmbus_proto_version <VERSION_WIN_COPPER || !vmbus_is_confidential ()) +return ; + } + + confidential_external_memory =is_confidential_external_memory (offer); +if (is_confidential_external_memory (offer)) { +if (vmbus_proto_version <VERSION_WIN_COPPER || !vmbus_is_confidential ()) +return ; + } + oldchannel =find_primary_channel_by_offer (offer);if (oldchannel !=NULL ) {
@@ -1069,6 +1082,14 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)atomic_dec (&vmbus_connection.offer_in_progress); +if ((oldchannel->confidential_ring_buffer && !confidential_ring_buffer) || + (oldchannel->confidential_external_memory && + !confidential_external_memory)) { +pr_err_ratelimited ("Offer %d changes the confidential state\n" , + offer->child_relid); +return ; + } +WARN_ON (oldchannel->offermsg.child_relid !=INVALID_RELID );/* Fix up the relid. */ oldchannel->offermsg.child_relid = offer->child_relid;
@@ -1111,6 +1132,8 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)pr_err ("Unable to allocate channel object\n" );return ; } + newchannel->confidential_ring_buffer = confidential_ring_buffer; + newchannel->confidential_external_memory = confidential_external_memory;vmbus_setup_channel_state (newchannel, offer);
drivers/hv/connection.c +8 -2
@@ -51,7 +51,8 @@ EXPORT_SYMBOL_GPL(vmbus_proto_version);* Linux guests and are not listed. */ static __u32 vmbus_versions[] = { -VERSION_WIN10_V5_3 , +VERSION_WIN_COPPER , +VERSION_WIN_IRON ,VERSION_WIN10_V5_2 ,VERSION_WIN10_V5_1 ,VERSION_WIN10_V5 ,
@@ -65,7 +66,7 @@ static __u32 vmbus_versions[] = {* Maximal VMBus protocol version guests can negotiate. Useful to cap the * VMBus version for testing and debugging purpose. */ -static uint max_version =VERSION_WIN10_V5_3 ; +static uint max_version =VERSION_WIN_COPPER ;module_param (max_version, uint,S_IRUGO ); MODULE_PARM_DESC(max_version,
@@ -105,6 +106,11 @@ int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, u32 version) vmbus_connection.msg_conn_id =VMBUS_MESSAGE_CONNECTION_ID ; } +if (vmbus_is_confidential () && version >=VERSION_WIN_COPPER ) + msg->feature_flags =VMBUS_FEATURE_FLAG_CONFIDENTIAL_CHANNELS ; +else + msg->feature_flags =0 ; +/* * shared_gpa_boundary is zero in non-SNP VMs, so it's safe to always * bitwise OR it
drivers/hv/hv.c +358 -127
633 lines not on this page · raw message
drivers/hv/hyperv_vmbus.h +6 -3
@@ -120,8 +120,10 @@ enum {* Per cpu state for channel handling */ struct hv_per_cpu_context { -void *synic_message_page; -void *synic_event_page; +void *hv_synic_message_page; +void *hv_synic_event_page; +void *pv_synic_message_page; +void *pv_synic_event_page;/* * The page is only used in hv_post_message() for a TDX VM (with the
@@ -182,7 +184,8 @@ extern int hv_synic_cleanup(unsigned int cpu);void hv_ringbuffer_pre_init (struct vmbus_channel *channel);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);void hv_ringbuffer_cleanup (struct hv_ring_buffer_info *ring_info);
drivers/hv/ring_buffer.c +3 -2
@@ -183,7 +183,8 @@ void hv_ringbuffer_pre_init(struct vmbus_channel *channel)/* 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, ring_info->ring_buffer = (struct hv_ring_buffer *)vmap (pages_wraparound, page_cnt *2 -1 ,VM_MAP , -pgprot_decrypted (PAGE_KERNEL )); + confidential ?PAGE_KERNEL :pgprot_decrypted (PAGE_KERNEL ));kfree (pages_wraparound);if (!ring_info->ring_buffer)
drivers/hv/vmbus_drv.c +78 -62
218 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 5/6 arch, drivers: Add device struct bitfield to not bounce-buffer
In reply to Roman KiselBounce-buffering makes the system spend more time copying I/O data. When the I/O transaction take place between a confidential and a non-confidential endpoints, there is no other way around.
Introduce a device bitfield to indicate that the device doesn't need to perform bounce buffering. The capable device may employ it to save on copying data around.
--- arch/x86/mm/mem_encrypt.c | 3 +++ include/linux/device.h | 8 ++++++++ include/linux/dma-direct.h | 3 +++ include/linux/swiotlb.h | 3 +++ 4 files changed, 17 insertions(+)
arch/x86/mm/mem_encrypt.c +3 -0
@@ -19,6 +19,9 @@/* Override for DMA direct allocation check - ARCH_HAS_FORCE_DMA_UNENCRYPTED */ bool force_dma_unencrypted (struct device *dev) { +if (dev->use_priv_pages_for_io) +return false; +/* * For SEV, all DMA must be to unencrypted addresses. */
include/linux/device.h +8 -0
@@ -725,6 +725,8 @@ struct device_physical_location {* @dma_skip_sync: DMA sync operations can be skipped for coherent buffers. * @dma_iommu: Device is using default IOMMU implementation for DMA and * doesn't rely on dma_ops structure. +* @use_priv_pages_for_io: Device is using private pages for I/O, no need to +* bounce-buffer. * * At the lowest level, every device in a Linux system is represented by an * instance of struct device. The device structure contains the information
@@ -843,6 +845,7 @@ struct device {#ifdef CONFIG_IOMMU_DMA bool dma_iommu:1;#endif + bool use_priv_pages_for_io:1; };/**
@@ -1079,6 +1082,11 @@ static inline bool dev_removable_is_valid(struct device *dev)return dev->removable !=DEVICE_REMOVABLE_NOT_SUPPORTED ; } +static inline bool dev_priv_pages_for_io (struct device *dev) +{ +return dev->use_priv_pages_for_io; +} +/* * High level routines for use by the bus drivers */
include/linux/dma-direct.h +3 -0
@@ -94,6 +94,9 @@ static inline dma_addr_t phys_to_dma_unencrypted(struct device *dev,*/ static inline dma_addr_t phys_to_dma (struct device *dev,phys_addr_t paddr) { +if (dev_priv_pages_for_io (dev)) +return phys_to_dma_unencrypted (dev, paddr); +return __sme_set (phys_to_dma_unencrypted (dev, paddr)); }
include/linux/swiotlb.h +3 -0
@@ -173,6 +173,9 @@ static inline bool is_swiotlb_force_bounce(struct device *dev) {struct io_tlb_mem *mem = dev->dma_io_tlb_mem; +if (dev_priv_pages_for_io (dev)) +return false; +return mem && mem->force_bounce; }
Signature · 1 line
2.43.0
PATCH 6/6 drivers: SCSI: Do not bounce-bufffer for the confidential VMBus
In reply to Roman KiselThe device bit that indicates that the device is capable of I/O with private pages lets avoid excessive copying in the Hyper-V SCSI driver.
Set that bit equal to the confidential external memory one to not bounce buffer
--- drivers/scsi/storvsc_drv.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/storvsc_drv.c +2 -0
@@ -686,6 +686,8 @@ static void handle_sc_creation(struct vmbus_channel *new_sc)struct vmstorage_channel_properties props;int ret; + dev->use_priv_pages_for_io = new_sc->confidential_external_memory; + stor_device =get_out_stor_device (device);if (!stor_device)return ;
Signature · 1 line
2.43.0
Re: [PATCH hyperv-next 5/6] arch, drivers: Add device struct bitfield to not bounce-buffer
In reply to Roman KiselQuoted 8 lines · Roman Kisel
Bounce-buffering makes the system spend more time copying I/O data. When the I/O transaction take place between a confidential and a non-confidential endpoints, there is no other way around.
Introduce a device bitfield to indicate that the device doesn't need to perform bounce buffering. The capable device may employ it to save on copying data around.
I have no idea what this is supposed to mean, you need to explain it much better.
Re: [PATCH hyperv-next 6/6] drivers: SCSI: Do not bounce-bufffer for the confidential VMBus
In reply to Roman KiselQuoted 6 lines · Roman Kisel
The device bit that indicates that the device is capable of I/O with private pages lets avoid excessive copying in the Hyper-V SCSI driver.
Set that bit equal to the confidential external memory one to not bounce buffer
Drivers have absolutely no business telling this. The need for bounce buffering or not is a platform/IOMMU decision and not one specific to a certain device or driver.
Re: [PATCH hyperv-next 5/6] arch, drivers: Add device struct bitfield to not bounce-buffer
In reply to Christoph HellwigQuoted 6 lines · Christoph Hellwig
Quoted 5 lines · Roman Kisel
Bounce-buffering makes the system spend more time copying I/O data. When the I/O transaction take place between a confidential and a non-confidential endpoints, there is no other way around.
Quoted 6 lines
Quoted 3 lines
Introduce a device bitfield to indicate that the device doesn't need to perform bounce buffering. The capable device may employ it to save on copying data around.
I have no idea what this is supposed to mean, you need to explain it much better.
Thanks for reviewing! I'll fix the description.
Quoted 1 line
Signature · 2 lines
Thank you, Roman
Re: [PATCH hyperv-next 6/6] drivers: SCSI: Do not bounce-bufffer for the confidential VMBus
In reply to Christoph HellwigQuoted 11 lines · Christoph Hellwig
Quoted 6 lines · Roman Kisel
The device bit that indicates that the device is capable of I/O with private pages lets avoid excessive copying in the Hyper-V SCSI driver.
Set that bit equal to the confidential external memory one to not bounce buffer
Drivers have absolutely no business telling this. The need for bounce buffering or not is a platform/IOMMU decision and not one specific to a certain device or driver.
Seemed to work although I cannot claim nothing is going to be broken ever. It did appear from the code that one could have this per-device bit.
As I understand, you're saying this is architecturally broken. Do you think a broader set of changes would improve the implementation?
Quoted 1 line
Signature · 2 lines
Thank you, Roman
Robin Murphy
reviewerRe: [PATCH hyperv-next 5/6] arch, drivers: Add device struct bitfield to not bounce-buffer
In reply to Roman KiselQuoted 8 lines · Roman Kisel
Bounce-buffering makes the system spend more time copying I/O data. When the I/O transaction take place between a confidential and a non-confidential endpoints, there is no other way around.
Introduce a device bitfield to indicate that the device doesn't need to perform bounce buffering. The capable device may employ it to save on copying data around.
It's not so much about bounce buffering, it's more fundamentally about whether the device is trusted and able to access private memory at all or not. And performance is hardly the biggest concern either - if you do trust a device to operate on confidential data in private memory, then surely it is crucial to actively *prevent* that data ever getting into shared SWIOTLB pages where anyone else could also get at it. At worst that means CoCo VMs might need an *additional* non-shared SWIOTLB to support trusted devices with addressing limitations (and/or "swiotlb=force" debugging, potentially).
Also whatever we do for this really wants to tie in with the nascent TDISP stuff as well, since we definitely don't want to end up with more than one notion of whether a device is in a trusted/locked/private/etc. vs. unlocked/shared/etc. state with respect to DMA (or indeed anything else if we can avoid it).
Thanks,
Robin.
Quoted 83 lines
Signed-off-by Roman Kisel <[email protected]>--- arch/x86/mm/mem_encrypt.c | 3 +++ include/linux/device.h | 8 ++++++++ include/linux/dma-direct.h | 3 +++ include/linux/swiotlb.h | 3 +++ 4 files changed, 17 insertions(+)arch/x86/mm/mem_encrypt.c +3
-0@@ -19,6 +19,9 @@/* Override for DMA direct allocation check - ARCH_HAS_FORCE_DMA_UNENCRYPTED */ bool force_dma_unencrypted (struct device *dev) { +if (dev->use_priv_pages_for_io) +return false; +/* * For SEV, all DMA must be to unencrypted addresses. */ include/linux/device.h +8
-0@@ -725,6 +725,8 @@ struct device_physical_location {* @dma_skip_sync: DMA sync operations can be skipped for coherent buffers. * @dma_iommu: Device is using default IOMMU implementation for DMA and * doesn't rely on dma_ops structure. +* @use_priv_pages_for_io: Device is using private pages for I/O, no need to +* bounce-buffer. * * At the lowest level, every device in a Linux system is represented by an * instance of struct device. The device structure contains the information @@ -843,6 +845,7 @@ struct device {#ifdef CONFIG_IOMMU_DMA bool dma_iommu:1;#endif + bool use_priv_pages_for_io:1; };/** @@ -1079,6 +1082,11 @@ static inline bool dev_removable_is_valid(struct device *dev)return dev->removable !=DEVICE_REMOVABLE_NOT_SUPPORTED ; } +static inline bool dev_priv_pages_for_io (struct device *dev) +{ +return dev->use_priv_pages_for_io; +} +/* * High level routines for use by the bus drivers */ include/linux/dma-direct.h +3
-0@@ -94,6 +94,9 @@ static inline dma_addr_t phys_to_dma_unencrypted(struct device *dev,*/ static inline dma_addr_t phys_to_dma (struct device *dev,phys_addr_t paddr) { +if (dev_priv_pages_for_io (dev)) +return phys_to_dma_unencrypted (dev, paddr); +return __sme_set (phys_to_dma_unencrypted (dev, paddr)); }include/linux/swiotlb.h +3
-0@@ -173,6 +173,9 @@ static inline bool is_swiotlb_force_bounce(struct device *dev) {struct io_tlb_mem *mem = dev->dma_io_tlb_mem; +if (dev_priv_pages_for_io (dev)) +return false; +return mem && mem->force_bounce; }
Re: [PATCH hyperv-next 5/6] arch, drivers: Add device struct bitfield to not bounce-buffer
Quoted 11 lines · Robin Murphy
Quoted 8 lines · Roman Kisel
Bounce-buffering makes the system spend more time copying I/O data. When the I/O transaction take place between a confidential and a non-confidential endpoints, there is no other way around.
Introduce a device bitfield to indicate that the device doesn't need to perform bounce buffering. The capable device may employ it to save on copying data around.
It's not so much about bounce buffering, it's more fundamentally about whether the device is trusted and able to access private memory at all or not. And performance is hardly the biggest concern either - if you do trust a device to operate on confidential data in private memory, then surely it is crucial to actively *prevent* that data ever getting into shared SWIOTLB pages where anyone else could also get at it. At worst that means CoCo VMs might need an *additional* non-shared SWIOTLB to support trusted devices with addressing limitations (and/or "swiotlb=force" debugging, potentially).
Thanks, I should've highlighted that facet most certainly!
Quoted 2 lines
Also whatever we do for this really wants to tie in with the nascent TDISP stuff as well, since we definitely don't want to end up with more than one notion of whether a device is in a trusted/locked/private/etc. vs. unlocked/shared/etc. state with respect to DMA (or indeed anything else if we can avoid it).
Wouldn't TDISP be per-device as well? In which case, a flag would be needed just as being added in this patch.
Although, there must be a difference between a device with TDISP where the flag would be the indication of the feature, and this code where the driver may flip that back and forth...
Do you feel this is shoehorned in struct device? I couldn't find an appropriate private (== opaque pointer) part in the structure to store that bit (struct device_private wouldn't fit the bill) and looked like adding it to the struct itself would do no harm. However, my read of the room is that folks see that as dubious :)
What would be your opinion on where to store that flag to tie together its usage in the Hyper-V SCSI and not bounce-buffering?
Quoted 87 lines
Thanks,
Robin.Quoted 82 lines
Signed-off-by Roman Kisel <[email protected]>---
arch/x86/mm/mem_encrypt.c | 3 +++
include/linux/device.h | 8 ++++++++
include/linux/dma-direct.h| 3 +++
include/linux/swiotlb.h | 3 +++4 files changed, 17 insertions(+)arch/x86/mm/mem_encrypt.c +3
-0@@ -19,6 +19,9 @@ /* Override for DMA direct allocation check - ARCH_HAS_FORCE_DMA_UNENCRYPTED */ bool force_dma_unencrypted(struct device *dev) { + if (dev->use_priv_pages_for_io) + return false; + /** For SEV, all DMA must be to unencrypted addresses. */ include/linux/device.h +1
-0@@ -725,6 +725,8 @@ struct device_physical_location { * @dma_skip_sync: DMA sync operations can be skipped for coherent buffers. * @dma_iommu: Device is using default IOMMU implementation for DMA and * doesn't rely on dma_ops structure. + * @use_priv_pages_for_io: Device is using private pages for I/O, noneed to
+ * bounce-buffer.
*
* At the lowest level, every device in a Linux system is represented by an
* instance of struct device. The device structure contains the informationinclude/linux/device.h +6
-0@@ -843,6 +845,7 @@ struct device { #ifdef CONFIG_IOMMU_DMA bool dma_iommu:1; #endif + bool use_priv_pages_for_io:1; }; /**@@ -1079,6 +1082,11 @@ static inline bool dev_removable_is_valid(struct device *dev) return dev->removable != DEVICE_REMOVABLE_NOT_SUPPORTED; } +static inline bool dev_priv_pages_for_io (struct device *dev) +{ + return dev->use_priv_pages_for_io; +} + /** High level routines for use by the bus drivers */ include/linux/dma-direct.h +3
-0@@ -94,6 +94,9 @@ static inline dma_addr_tphys_to_dma_unencrypted(struct device *dev, */ static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) { + if (dev_priv_pages_for_io(dev)) + return phys_to_dma_unencrypted(dev, paddr); + return __sme_set(phys_to_dma_unencrypted(dev, paddr)); }include/linux/swiotlb.h +3
-0@@ -173,6 +173,9 @@ static inline bool is_swiotlb_force_bounce(struct device *dev) { struct io_tlb_mem *mem = dev->dma_io_tlb_mem; + if (dev_priv_pages_for_io(dev)) + return false; + return mem && mem->force_bounce; }
Signature · 2 lines
Thank you, Roman
Re: [PATCH hyperv-next 5/6] arch, drivers: Add device struct bitfield to not bounce-buffer
[ add linux-coco ]
Quoted 23 lines · Roman Kisel
Quoted 10 lines · Robin Murphy
Quoted 8 lines · Roman Kisel
Bounce-buffering makes the system spend more time copying I/O data. When the I/O transaction take place between a confidential and a non-confidential endpoints, there is no other way around.
Introduce a device bitfield to indicate that the device doesn't need to perform bounce buffering. The capable device may employ it to save on copying data around.
Quoted 9 lines
It's not so much about bounce buffering, it's more fundamentally about whether the device is trusted and able to access private memory at all or not. And performance is hardly the biggest concern either - if you do trust a device to operate on confidential data in private memory, then surely it is crucial to actively *prevent* that data ever getting into shared SWIOTLB pages where anyone else could also get at it. At worst that means CoCo VMs might need an *additional* non-shared SWIOTLB to support trusted devices with addressing limitations (and/or "swiotlb=force" debugging, potentially).
Quoted 1 line
Thanks, I should've highlighted that facet most certainly!
One would hope that no one is building a modern device with trusted I/O capability, *and* with a swiotlb addressing dependency. However, I agree that a non-shared swiotlb would be needed in such a scenario.
Otherwise the policy around "a device should not even be allowed to bounce buffer any private page" is a userspace responsibility to either not load the driver, not release secrets to this CVM, or otherwise make sure the device is only ever bounce buffering private memory that does not contain secrets.
Quoted 13 lines
Quoted 5 lines
Also whatever we do for this really wants to tie in with the nascent TDISP stuff as well, since we definitely don't want to end up with more than one notion of whether a device is in a trusted/locked/private/etc. vs. unlocked/shared/etc. state with respect to DMA (or indeed anything else if we can avoid it).
Wouldn't TDISP be per-device as well? In which case, a flag would be needed just as being added in this patch.
Although, there must be a difference between a device with TDISP where the flag would be the indication of the feature, and this code where the driver may flip that back and forth...
Quoted 8 lines
Do you feel this is shoehorned in
struct device? I couldn't find an appropriate private (== opaque pointer) part in the structure to store that bit (struct device_privatewouldn't fit the bill) and looked like adding it to the struct itself would do no harm. However, my read of the room is that folks see that as dubious :)What would be your opinion on where to store that flag to tie together its usage in the Hyper-V SCSI and not bounce-buffering?
The name and location of a flag bit is not the issue, it is the common expectation of how and when that flag is set.
tl;dr Linux likely needs a "private_accepted" flag for devices
Like Christoph said, a driver really has no business opting itself into different DMA addressing domains. For TDISP we are also being careful to make sure that flipping a device from shared to private is a suitably violent event. This is because the Linux DMA layer does not have a concept of allowing a device to have mappings from two different addressing domains simultaneously.
In the current TDISP proposal, a device starts in shared mode and only after validating all of the launch state of the CVM, device measurements, and a device interface report is it granted access to private memory. Without dumping a bunch of golden measurement data into the kernel that validation can really only be performed by userspace.
Enter this vmbus proposal that wants to emulate devices with a paravisor that is presumably within the TCB at launch, but the kernel can not really trust that until a "launch state of the CVM + paravisor" attestation event.
Like PCIe TDISP the capability of this device to access private memory is a property of the bus and the iommu. However, acceptance of the device into private operation is a willful policy action. It needs to validate not only the device provenance and state, but also the Linux DMA layer requirements of not holding shared or swiotlb mappings over the "entry into private mode operation" event.
All that said, I would advocate to require a userspace driven "device accept" event for all devices, not just TDISP, that want to enter private operation. Maybe later circle back to figure out if there is a lingering need for accepting devices via golden measurement, or other means, to skip the userpace round-trip dependency.
A "private_capable" flag might also make sense, but that is really a property of a bus that need not be carried necessarily in 'struct device'.
So for this confidential vmbus SCSI device to mesh with the mechanisms needed for TDISP I would expect it continues to launch in swiotlb mode by default. Export an attribute via hv_bus->dev_groups to indicate that the device is "private_capable" and then require userspace to twiddle a private_accepted flag with some safety for in-flight DMA.
RE: [PATCH hyperv-next 5/6] arch, drivers: Add device struct bitfield to not bounce-buffer
From: Dan Williams <[email protected]> Sent: Wednesday, April 9, 2025 4:30 PM
Quoted 84 lines
[ add linux-coco ]
Quoted 23 lines · Roman Kisel
Quoted 10 lines · Robin Murphy
Quoted 8 lines · Roman Kisel
Bounce-buffering makes the system spend more time copying I/O data. When the I/O transaction take place between a confidential and a non-confidential endpoints, there is no other way around.
Introduce a device bitfield to indicate that the device doesn't need to perform bounce buffering. The capable device may employ it to save on copying data around.
Quoted 9 lines
It's not so much about bounce buffering, it's more fundamentally about whether the device is trusted and able to access private memory at all or not. And performance is hardly the biggest concern either - if you do trust a device to operate on confidential data in private memory, then surely it is crucial to actively *prevent* that data ever getting into shared SWIOTLB pages where anyone else could also get at it. At worst that means CoCo VMs might need an *additional* non-shared SWIOTLB to support trusted devices with addressing limitations (and/or "swiotlb=force" debugging, potentially).
Quoted 1 line
Thanks, I should've highlighted that facet most certainly!
One would hope that no one is building a modern device with trusted I/O capability, *and* with a swiotlb addressing dependency. However, I agree that a non-shared swiotlb would be needed in such a scenario.
Otherwise the policy around "a device should not even be allowed to bounce buffer any private page" is a userspace responsibility to either not load the driver, not release secrets to this CVM, or otherwise make sure the device is only ever bounce buffering private memory that does not contain secrets.
Quoted 13 lines
Quoted 5 lines
Also whatever we do for this really wants to tie in with the nascent TDISP stuff as well, since we definitely don't want to end up with more than one notion of whether a device is in a trusted/locked/private/etc. vs. unlocked/shared/etc. state with respect to DMA (or indeed anything else if we can avoid it).
Wouldn't TDISP be per-device as well? In which case, a flag would be needed just as being added in this patch.
Although, there must be a difference between a device with TDISP where the flag would be the indication of the feature, and this code where the driver may flip that back and forth...
Quoted 8 lines
Do you feel this is shoehorned in
struct device? I couldn't find an appropriate private (== opaque pointer) part in the structure to store that bit (struct device_privatewouldn't fit the bill) and looked like adding it to the struct itself would do no harm. However, my read of the room is that folks see that as dubious :)What would be your opinion on where to store that flag to tie together its usage in the Hyper-V SCSI and not bounce-buffering?
The name and location of a flag bit is not the issue, it is the common expectation of how and when that flag is set.
tl;dr Linux likely needs a "
private_accepted" flag for devicesLike Christoph said, a driver really has no business opting itself into different DMA addressing domains. For TDISP we are also being careful to make sure that flipping a device from shared to private is a suitably violent event. This is because the Linux DMA layer does not have a concept of allowing a device to have mappings from two different addressing domains simultaneously.
In the current TDISP proposal, a device starts in shared mode and only after validating all of the launch state of the CVM, device measurements, and a device interface report is it granted access to private memory. Without dumping a bunch of golden measurement data into the kernel that validation can really only be performed by userspace.
Enter this vmbus proposal that wants to emulate devices with a paravisor that is presumably within the TCB at launch, but the kernel can not really trust that until a "launch state of the CVM + paravisor" attestation event.
Quoted 6 lines
Like PCIe TDISP the capability of this device to access private memory is a property of the bus and the iommu. However, acceptance of the device into private operation is a willful policy action. It needs to validate not only the device provenance and state, but also the Linux DMA layer requirements of not holding shared or swiotlb mappings over the "entry into private mode operation" event.
To flesh this out the swiotlb aspect a bit, once a TDISP device has gone private, how does it prevent the DMA layer from ever doing bounce buffering through the swiotlb? My understanding is that the DMA layer doesn't make any promises to not do bounce buffering. Given the vagaries of memory alignment, perhaps add in a virtual IOMMU, etc., it seems like a device driver can't necessarily predict what DMA operations might result in bounce buffering. Does TDISP anticipate needing a formal way to tell the DMA layer "don't bounce buffer"? (and return an error instead?) Or would there be a separate swiotlb memory pool that is private memory so that bounce buffer could be done when necessary and still maintain confidentiality?
Just wondering if there's any thinking on this topic ...
Thanks,
Michael
Re: [PATCH hyperv-next 5/6] arch, drivers: Add device struct bitfield to not bounce-buffer
In reply to Roman KiselQuoted 5 lines · Roman Kisel
Do you feel this is shoehorned in
struct device? I couldn't find an appropriate private (== opaque pointer) part in the structure to store that bit (struct device_privatewouldn't fit the bill) and looked like adding it to the struct itself would do no harm. However, my read of the room is that folks see that as dubious :)
We'll need per-device information. But it is much higher level than a need bounce buffer flag.
Re: [PATCH hyperv-next 5/6] arch, drivers: Add device struct bitfield to not bounce-buffer
In reply to Dan WilliamsQuoted 5 lines · Dan Williams
Quoted 1 line
Thanks, I should've highlighted that facet most certainly!
One would hope that no one is building a modern device with trusted I/O capability, *and* with a swiotlb addressing dependency. However, I agree that a non-shared swiotlb would be needed in such a scenario.
Hope is never a good idea when dealing with hardware :( PCIe already requires no addressing limitations, and programming interface specs like NVMe double down on that. But at least one big hyperscaler still managed to build such a device.
Also even if the periphal device is not addressing limited, the root port or interconnect might still be, we've seen quite a lot of that.
Re: [PATCH hyperv-next 5/6] arch, drivers: Add device struct bitfield to not bounce-buffer
In reply to Christoph HellwigQuoted 10 lines · Christoph Hellwig
Quoted 5 lines · Roman Kisel
Do you feel this is shoehorned in
struct device? I couldn't find an appropriate private (== opaque pointer) part in the structure to store that bit (struct device_privatewouldn't fit the bill) and looked like adding it to the struct itself would do no harm. However, my read of the room is that folks see that as dubious :)We'll need per-device information. But it is much higher level than a need bounce buffer flag.
I see, thanks for the explanation!
Signature · 2 lines
Thank you, Roman
Re: [PATCH hyperv-next 1/6] Documentation: hyperv: Confidential VMBus
In reply to Roman KiselDocumentation/virt/hyperv/vmbus.rst rescinded, neither Hyper-V nor Linux retains any state about · line 337
Quoted 13 lines · Roman Kisel
in which case it is treated as an entirely new device. See
vmbus_onoffer_rescind().Documentation/virt/hyperv/vmbus.rst +11
-0+ +Confidential VMBus +------------------ + +The confidential VMBus provides the control and data planes where +the guest doesn't talk to either the hypervisor or the host. Instead, +it relies on the trusted paravisor. The hardware (SNP or TDX) encrypts +the guest memory and the register state also measuring the paravisor +image via using the platform security processor to ensure trsuted and +confidential computing. +
typo trsuted -> trusted
Documentation/virt/hyperv/vmbus.rst rescinded, neither Hyper-V nor Linux retains any state about · line 340
Quoted 3 lines
Documentation/virt/hyperv/vmbus.rst +3
-0+To support confidential communication with the paravisor, a VmBus client +will first attempt to use regular, non-isolated mechanisms for communication. +To do this, it must:
Thanks,
Alok
Re: [PATCH hyperv-next 2/6] drivers: hyperv: VMBus protocol version 6.0
In reply to Roman KiselQuoted 6 lines · Roman Kisel
The confidential VMBus is supported starting from the protocol version 6.0 onwards.
Update the relevant definitions, provide a function that returns whether VMBus is condifential or not.
typo condifential -> confidential
drivers/hv/vmbus_drv.c
Quoted 11 lines
Signed-off-by Roman Kisel<[email protected]>--- drivers/hv/vmbus_drv.c | 12 ++++++ include/asm-generic/mshyperv.h | 1 + include/linux/hyperv.h | 71 +++++++++++++++++++++++++--------- 3 files changed, 65 insertions(+), 19 deletions(-)drivers/hv/vmbus_drv.c +0
-0
Thanks,
Alok
Re: [PATCH hyperv-next 1/6] Documentation: hyperv: Confidential VMBus
In reply to ALOK TIWARIQuoted 2 lines · ALOK TIWARI
[...]
Quoted 8 lines
typo trsuted -> trusted
Quoted 4 lines
(quoted diff) +2
-0+To support confidential communication with the paravisor, a VmBus client +will first attempt to use regular, non-isolated mechanisms forcommunication.
+To do this, it must:
Thanks for your help with this patch, and the other ones!! I'll make sure to use the spellchecker on the patches before sending another version out.
Quoted 3 lines
Thanks,
Alok
Signature · 2 lines
Thank you, Roman
Re: [PATCH hyperv-next 5/6] arch, drivers: Add device struct bitfield to not bounce-buffer
In reply to Christoph HellwigQuoted 7 lines · Christoph Hellwig
Quoted 5 lines · Dan Williams
Quoted 1 line
Thanks, I should've highlighted that facet most certainly!
One would hope that no one is building a modern device with trusted I/O capability, *and* with a swiotlb addressing dependency. However, I agree that a non-shared swiotlb would be needed in such a scenario.
Quoted 7 lines
Hope is never a good idea when dealing with hardware :( PCIe already requires no addressing limitations, and programming interface specs like NVMe double down on that. But at least one big hyperscaler still managed to build such a device.
Also even if the periphal device is not addressing limited, the root port or interconnect might still be, we've seen quite a lot of that.
Still it would be very obnoxious for someone to build a CC VM platform where CC DMA devices can't access all the guest physical memory in the CC address map :\
Keeping in mind that that the CC address map is being created by using the CPU MMU and the CPU IOMMU so it is entirely virtual and can be configured to match most problems the devices might have.
Too much memory would be the main issue..
IMHO I wouldn't implement secure SWIOTLB until someone does such a foolish thing, and I'd make them do the work as some kind of pennance :P
Jason
Re: [PATCH hyperv-next 5/6] arch, drivers: Add device struct bitfield to not bounce-buffer
In reply to Dan WilliamsQuoted 6 lines · Dan Williams
Like Christoph said, a driver really has no business opting itself into different DMA addressing domains. For TDISP we are also being careful to make sure that flipping a device from shared to private is a suitably violent event. This is because the Linux DMA layer does not have a concept of allowing a device to have mappings from two different addressing domains simultaneously.
And this is a very important point, several of the architectures have two completely independent iommu tables, and maybe even completely different IOMMU instances for trusted and non-trusted DMA traffic.
I expect configurations where trusted traffic is translated through the vIOMMU while non-trusted traffic is locked to an identity translation.
There are more issue here than just swiotlb :\
Quoted 3 lines
A "
private_capable" flag might also make sense, but that is really a property of a bus that need not be carried necessarily in 'struct device'.
However it works, it should be done before the driver is probed and remain stable for the duration of the driver attachment. From the iommu side the correct iommu domain, on the correct IOMMU instance to handle the expected traffic should be setup as the DMA API's iommu domain.
Jason
RE: [PATCH hyperv-next 5/6] arch, drivers: Add device struct bitfield to not bounce-buffer
In reply to Michael KelleyQuoted 1 line · Michael Kelley
From: Dan Williams <[email protected]> Sent: Wednesday, April 9, 2025 4:30 PM
[..]
Quoted 7 lines
Quoted 6 lines
Like PCIe TDISP the capability of this device to access private memory is a property of the bus and the iommu. However, acceptance of the device into private operation is a willful policy action. It needs to validate not only the device provenance and state, but also the Linux DMA layer requirements of not holding shared or swiotlb mappings over the "entry into private mode operation" event.
Quoted 11 lines
To flesh this out the swiotlb aspect a bit, once a TDISP device has gone private, how does it prevent the DMA layer from ever doing bounce buffering through the swiotlb? My understanding is that the DMA layer doesn't make any promises to not do bounce buffering. Given the vagaries of memory alignment, perhaps add in a virtual IOMMU, etc., it seems like a device driver can't necessarily predict what DMA operations might result in bounce buffering. Does TDISP anticipate needing a formal way to tell the DMA layer "don't bounce buffer"? (and return an error instead?) Or would there be a separate swiotlb memory pool that is private memory so that bounce buffer could be done when necessary and still maintain confidentiality?
I expect step 1 is just add some rude errors / safety for attempting to convert the mode of a device while it has any DMA mappings established, and explicit failures for attempts to fallback to swiotlb for 'private_accepted' devices.
The easiest way to enforce that a device does not cross the shared/private boundary while DMA mappings are live is to simply not allow that transition while a driver is bound (i.e. "dev->driver" is non-NULL).
Wei Liu
maintainerRe: [PATCH hyperv-next 1/6] Documentation: hyperv: Confidential VMBus
In reply to Roman KiselQuoted 18 lines · Roman Kisel
Define what the confidential VMBus is and describe what advantages it offers on the capable hardware.
Signed-off-by Roman Kisel <[email protected]>--- Documentation/virt/hyperv/vmbus.rst | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)Documentation/virt/hyperv/vmbus.rst +2
-0@@ -324,3 +324,44 @@ rescinded, neither Hyper-V nor Linux retains any state about its previous existence. Such a device might be re-added later, in which case it is treated as an entirely new device. See vmbus_onoffer_rescind(). + +Confidential VMBus
Documentation/virt/hyperv/vmbus.rst rescinded, neither Hyper-V nor Linux retains any state about · line 338
Quoted 10 lines
Documentation/virt/hyperv/vmbus.rst +10
-0+------------------ + +The confidential VMBus provides the control and data planes where +the guest doesn't talk to either the hypervisor or the host. Instead, +it relies on the trusted paravisor. The hardware (SNP or TDX) encrypts +the guest memory and the register state also measuring the paravisor +image via using the platform security processor to ensure trsuted and +confidential computing. + +To support confidential communication with the paravisor, a VmBus client
Please be consistent. In this document I see VMBus and VmBus. We should stick with only one form.
Wei.