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]
Message-Id: <20210203233709.19819-4-dongli.zhang@oracle.com>
Date:   Wed,  3 Feb 2021 15:37:06 -0800
From:   Dongli Zhang <dongli.zhang@...cle.com>
To:     dri-devel@...ts.freedesktop.org, intel-gfx@...ts.freedesktop.org,
        iommu@...ts.linux-foundation.org, linux-mips@...r.kernel.org,
        linux-mmc@...r.kernel.org, linux-pci@...r.kernel.org,
        linuxppc-dev@...ts.ozlabs.org, nouveau@...ts.freedesktop.org,
        x86@...nel.org, xen-devel@...ts.xenproject.org
Cc:     linux-kernel@...r.kernel.org, adrian.hunter@...el.com,
        akpm@...ux-foundation.org, benh@...nel.crashing.org,
        bskeggs@...hat.com, bhelgaas@...gle.com, bp@...en8.de,
        boris.ostrovsky@...cle.com, hch@....de, chris@...is-wilson.co.uk,
        daniel@...ll.ch, airlied@...ux.ie, hpa@...or.com, mingo@...nel.org,
        mingo@...hat.com, jani.nikula@...ux.intel.com,
        joonas.lahtinen@...ux.intel.com, jgross@...e.com,
        konrad.wilk@...cle.com, m.szyprowski@...sung.com,
        matthew.auld@...el.com, mpe@...erman.id.au, rppt@...nel.org,
        paulus@...ba.org, peterz@...radead.org, robin.murphy@....com,
        rodrigo.vivi@...el.com, sstabellini@...nel.org,
        bauerman@...ux.ibm.com, tsbogend@...ha.franken.de,
        tglx@...utronix.de, ulf.hansson@...aro.org, joe.jin@...cle.com,
        thomas.lendacky@....com
Subject: [PATCH RFC v1 3/6] swiotlb: introduce swiotlb_get_type() to calculate swiotlb buffer type

This patch introduces swiotlb_get_type() in order to calculate which
swiotlb buffer the given DMA address is belong to.

This is to prepare to enable 64-bit swiotlb.

Cc: Joe Jin <joe.jin@...cle.com>
Signed-off-by: Dongli Zhang <dongli.zhang@...cle.com>
---
 include/linux/swiotlb.h | 14 ++++++++++++++
 kernel/dma/swiotlb.c    |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 777046cd4d1b..3d5980d77810 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -3,6 +3,7 @@
 #define __LINUX_SWIOTLB_H
 
 #include <linux/dma-direction.h>
+#include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/limits.h>
@@ -23,6 +24,8 @@ enum swiotlb_t {
 	SWIOTLB_MAX,
 };
 
+extern int swiotlb_nr;
+
 /*
  * Maximum allowable number of contiguous slabs to map,
  * must be a power of 2.  What is the appropriate value ?
@@ -84,6 +87,17 @@ static inline bool is_swiotlb_buffer(phys_addr_t paddr)
 	       paddr < io_tlb_end[SWIOTLB_LO];
 }
 
+static inline int swiotlb_get_type(phys_addr_t paddr)
+{
+	int i;
+
+	for (i = 0; i < swiotlb_nr; i++)
+		if (paddr >= io_tlb_start[i] && paddr < io_tlb_end[i])
+			return i;
+
+	return -ENOENT;
+}
+
 void __init swiotlb_exit(void);
 unsigned int swiotlb_max_segment(void);
 size_t swiotlb_max_mapping_size(struct device *dev);
diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
index 1fbb65daa2dd..c91d3d2c3936 100644
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -109,6 +109,8 @@ static DEFINE_SPINLOCK(io_tlb_lock);
 
 static int late_alloc;
 
+int swiotlb_nr = 1;
+
 static int __init
 setup_io_tlb_npages(char *str)
 {
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ