Thread (31 messages) 31 messages, 4 authors, 2021-09-30

Re: [PATCH V5 09/12] x86/Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

From: Tianyu Lan <hidden>
Date: 2021-09-16 10:57:40
Also in: linux-hyperv, linux-iommu, linux-scsi, lkml, netdev, xen-devel

On 9/15/2021 11:42 PM, Michael Kelley wrote:
quoted
@@ -196,13 +199,34 @@ static void swiotlb_init_io_tlb_mem(struct io_tlb_mem *mem, phys_addr_t start,
  		mem->slots[i].orig_addr = INVALID_PHYS_ADDR;
  		mem->slots[i].alloc_size = 0;
  	}
+
+	if (set_memory_decrypted((unsigned long)vaddr, bytes >> PAGE_SHIFT))
+		return -EFAULT;
+
+	/*
+	 * Map memory in the unencrypted physical address space when requested
+	 * (e.g. for Hyper-V AMD SEV-SNP Isolation VMs).
+	 */
+	if (swiotlb_unencrypted_base) {
+		phys_addr_t paddr = __pa(vaddr) + swiotlb_unencrypted_base;
Nit:  Use "start" instead of "__pa(vaddr)" since "start" is already the needed
physical address.

Yes, "start" should be used here.
quoted
@@ -304,7 +332,7 @@ int
  swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)
  {
  	struct io_tlb_mem *mem = &io_tlb_default_mem;
-	unsigned long bytes = nslabs << IO_TLB_SHIFT;
+	int ret;

  	if (swiotlb_force == SWIOTLB_NO_FORCE)
  		return 0;
@@ -318,8 +346,9 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)
  	if (!mem->slots)
  		return -ENOMEM;

-	set_memory_decrypted((unsigned long)tlb, bytes >> PAGE_SHIFT);
-	swiotlb_init_io_tlb_mem(mem, virt_to_phys(tlb), nslabs, true);
+	ret = swiotlb_init_io_tlb_mem(mem, virt_to_phys(tlb), nslabs, true);
+	if (ret)
Before returning the error, free the pages obtained from the earlier call
to __get_free_pages()?
Yes, will fix.

Thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help