Skip to contentSkip to conversation

swiotlb: Do not zero buffer in set_memory_decrypted()

PATCH In review Kirill A. Shutemov 3 participants 3 messages Jan 25, 2022 – Jan 26, 2022 DMA mapping helpers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 swiotlb: Do not zero buffer in set_memory_decrypted()

For larger TDX VM, memset() after set_memory_decrypted() in swiotlb_update_mem_attributes() takes substantial portion of boot time.

Zeroing doesn't serve any functional purpose. Malicious VMM can mess with decrypted/shared buffer at any point.

Remove the memset().

---
 kernel/dma/swiotlb.c | 2 --
 1 file changed, 2 deletions(-)
kernel/dma/swiotlb.c +0 -2
index f1e7ea160b43..9390b38d2897 100644
@@ -207,8 +207,6 @@ void __init swiotlb_update_mem_attributes(void)
 	mem->vaddr = swiotlb_mem_remap(mem, bytes);
 	if (!mem->vaddr)
 		mem->vaddr = vaddr;
-
-	memset(mem->vaddr, 0, bytes);
 }
 
 static void swiotlb_init_io_tlb_mem(struct io_tlb_mem *mem, phys_addr_t start,
Signature · 6 lines
2.34.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Acked-by Tom Lendacky on v1 1/1
#1 lore raw
Quoted 9 lines · Kirill A. Shutemov

For larger TDX VM, memset() after set_memory_decrypted() in swiotlb_update_mem_attributes() takes substantial portion of boot time.

Zeroing doesn't serve any functional purpose. Malicious VMM can mess with decrypted/shared buffer at any point.

Remove the memset().

Quoted 9 lines
---
  kernel/dma/swiotlb.c | 2 --
  1 file changed, 2 deletions(-)
kernel/dma/swiotlb.c +0 -0
index f1e7ea160b43..9390b38d2897 100644

kernel/dma/swiotlb.c void __init swiotlb_update_mem_attributes(void) · line 212

Quoted 8 lines
kernel/dma/swiotlb.c +0 -2
@@ -207,8 +207,6 @@ void __init swiotlb_update_mem_attributes(void)
  	mem->vaddr = swiotlb_mem_remap(mem, bytes);
  	if (!mem->vaddr)
  		mem->vaddr = vaddr;
-
-	memset(mem->vaddr, 0, bytes);
  }
 
  static void swiotlb_init_io_tlb_mem(struct io_tlb_mem *mem, phys_addr_t start,

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu