lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 17 Nov 2008 11:52:28 +0000
From:	Ian Campbell <Ian.Campbell@...rix.com>
To:	FUJITA Tomonori <fujita.tomonori@....ntt.co.jp>
Cc:	jeremy@...p.org, mingo@...e.hu, linux-kernel@...r.kernel.org,
	xen-devel@...ts.xensource.com, x86@...nel.org
Subject: Re: [PATCH 04 of 38] swiotlb: move some definitions to header

On Mon, 2008-11-17 at 12:48 +0900, FUJITA Tomonori wrote:
> Why do we need to export IO_TLB_SEGSIZE and IO_TLB_SHIFT to everyone
> in include/linux?

A subsequent Xen patch needs to make use of them, although I can't see
it in the patchset Jeremy posted so here it is (not fully baked yet)

Subject: xen swiotlb: fixup swiotlb is chunks smaller than MAX_CONTIG_ORDER

From: Ian Campbell <ian.campbell@...rix.com>

Signed-off-by: Ian Campbell <ian.campbell@...rix.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@...rix.com>
---
 arch/x86/kernel/pci-swiotlb_64.c |    7 +------
 drivers/pci/xen-iommu.c          |   30 ++++++++++++++++++++----------
 2 files changed, 21 insertions(+), 16 deletions(-)

===================================================================
--- a/arch/x86/kernel/pci-swiotlb_64.c
+++ b/arch/x86/kernel/pci-swiotlb_64.c
@@ -28,12 +28,7 @@
 
 void *swiotlb_alloc(unsigned order, unsigned long nslabs)
 {
-	void *ret = (void *)__get_free_pages(GFP_DMA | __GFP_NOWARN, order);
-
-	if (ret && xen_pv_domain())
-		xen_swiotlb_fixup(ret, 1u << order, nslabs);
-
-	return ret;
+	BUG();
 }
 
 static dma_addr_t
===================================================================
--- a/drivers/pci/xen-iommu.c
+++ b/drivers/pci/xen-iommu.c
@@ -6,6 +6,7 @@
 #include <linux/version.h>
 #include <linux/scatterlist.h>
 #include <linux/bio.h>
+#include <linux/swiotlb.h>
 #include <linux/io.h>
 #include <linux/bug.h>
 
@@ -43,19 +44,27 @@
 	unsigned long	*bitmap;
 };
 
+static int max_dma_bits = 32;
+
 void xen_swiotlb_fixup(void *buf, size_t size, unsigned long nslabs)
 {
-	unsigned order = get_order(size);
+	int i, rc;
+	int dma_bits;
 
-	printk(KERN_DEBUG "xen_swiotlb_fixup: buf=%p size=%zu order=%u\n",
-		buf, size, order);
+	printk(KERN_DEBUG "xen_swiotlb_fixup: buf=%p size=%zu\n",
+		buf, size);
 
-	if (WARN_ON(size != (PAGE_SIZE << order)))
-		return;
-
-	if (xen_create_contiguous_region((unsigned long)buf,
-					 order, 0xffffffff))
-		printk(KERN_ERR "xen_create_contiguous_region failed\n");
+	dma_bits = get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT) + PAGE_SHIFT;
+	for (i = 0; i < nslabs; i += IO_TLB_SEGSIZE) {
+		do {
+			rc = xen_create_contiguous_region(
+				(unsigned long)buf + (i << IO_TLB_SHIFT),
+				get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT),
+				dma_bits);
+		} while (rc && dma_bits++ < max_dma_bits);
+		if (rc)
+			panic(KERN_ERR "xen_create_contiguous_region failed\n");
+	}
 }
 
 static inline int address_needs_mapping(struct device *hwdev,
@@ -117,7 +126,8 @@
 	if (check_pages_physically_contiguous(pfn, offset, size))
 		return 0;
 
-	printk("range_straddles_page_boundary: p=%Lx size=%d pfn=%lx\n",
+	printk(KERN_WARNING "range_straddles_page_boundary: "
+	       "p=%Lx size=%zd pfn=%lx\n",
 		p, size, pfn);
 	return 1;
 }


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ