Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1728328 > unrolled thread

[PATCH v6 04/11] swiotlb: Map the buffer if it was unmapped by XPFO

Started byTycho Andersen <tycho@docker.com>
First post2017-09-07 19:40 +0200
Last post2017-09-08 09:20 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v6 04/11] swiotlb: Map the buffer if it was unmapped by XPFO Tycho Andersen <tycho@docker.com> - 2017-09-07 19:40 +0200
    Re: [PATCH v6 04/11] swiotlb: Map the buffer if it was unmapped by  XPFO Christoph Hellwig <hch@infradead.org> - 2017-09-07 20:20 +0200
      Re: [PATCH v6 04/11] swiotlb: Map the buffer if it was unmapped by  XPFO Tycho Andersen <tycho@docker.com> - 2017-09-07 20:50 +0200
        Re: [PATCH v6 04/11] swiotlb: Map the buffer if it was unmapped by  XPFO Christoph Hellwig <hch@infradead.org> - 2017-09-08 09:20 +0200

#1728328 — [PATCH v6 04/11] swiotlb: Map the buffer if it was unmapped by XPFO

FromTycho Andersen <tycho@docker.com>
Date2017-09-07 19:40 +0200
Subject[PATCH v6 04/11] swiotlb: Map the buffer if it was unmapped by XPFO
Message-ID<un8Wu-3e6-31@gated-at.bofh.it>
From: Juerg Haefliger <juerg.haefliger@canonical.com>

v6: * guard against lookup_xpfo() returning NULL

CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
Signed-off-by: Tycho Andersen <tycho@docker.com>
---
 include/linux/xpfo.h |  4 ++++
 lib/swiotlb.c        |  3 ++-
 mm/xpfo.c            | 15 +++++++++++++++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/include/linux/xpfo.h b/include/linux/xpfo.h
index 442c58ee930e..04590d1dcefa 100644
--- a/include/linux/xpfo.h
+++ b/include/linux/xpfo.h
@@ -30,6 +30,8 @@ void xpfo_kunmap(void *kaddr, struct page *page);
 void xpfo_alloc_pages(struct page *page, int order, gfp_t gfp);
 void xpfo_free_pages(struct page *page, int order);
 
+bool xpfo_page_is_unmapped(struct page *page);
+
 #else /* !CONFIG_XPFO */
 
 static inline void xpfo_kmap(void *kaddr, struct page *page) { }
@@ -37,6 +39,8 @@ static inline void xpfo_kunmap(void *kaddr, struct page *page) { }
 static inline void xpfo_alloc_pages(struct page *page, int order, gfp_t gfp) { }
 static inline void xpfo_free_pages(struct page *page, int order) { }
 
+static inline bool xpfo_page_is_unmapped(struct page *page) { return false; }
+
 #endif /* CONFIG_XPFO */
 
 #endif /* _LINUX_XPFO_H */
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index a8d74a733a38..d4fee5ca2d9e 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -420,8 +420,9 @@ static void swiotlb_bounce(phys_addr_t orig_addr, phys_addr_t tlb_addr,
 {
 	unsigned long pfn = PFN_DOWN(orig_addr);
 	unsigned char *vaddr = phys_to_virt(tlb_addr);
+	struct page *page = pfn_to_page(pfn);
 
-	if (PageHighMem(pfn_to_page(pfn))) {
+	if (PageHighMem(page) || xpfo_page_is_unmapped(page)) {
 		/* The buffer does not have a mapping.  Map it in and copy */
 		unsigned int offset = orig_addr & ~PAGE_MASK;
 		char *buffer;
diff --git a/mm/xpfo.c b/mm/xpfo.c
index bff24afcaa2e..cdbcbac582d5 100644
--- a/mm/xpfo.c
+++ b/mm/xpfo.c
@@ -220,3 +220,18 @@ void xpfo_kunmap(void *kaddr, struct page *page)
 	spin_unlock(&xpfo->maplock);
 }
 EXPORT_SYMBOL(xpfo_kunmap);
+
+bool xpfo_page_is_unmapped(struct page *page)
+{
+	struct xpfo *xpfo;
+
+	if (!static_branch_unlikely(&xpfo_inited))
+		return false;
+
+	xpfo = lookup_xpfo(page);
+	if (unlikely(!xpfo) && !xpfo->inited)
+		return false;
+
+	return test_bit(XPFO_PAGE_UNMAPPED, &xpfo->flags);
+}
+EXPORT_SYMBOL(xpfo_page_is_unmapped);
-- 
2.11.0

[toc] | [next] | [standalone]


#1728359 — Re: [PATCH v6 04/11] swiotlb: Map the buffer if it was unmapped by XPFO

FromChristoph Hellwig <hch@infradead.org>
Date2017-09-07 20:20 +0200
SubjectRe: [PATCH v6 04/11] swiotlb: Map the buffer if it was unmapped by XPFO
Message-ID<un9zc-3GP-11@gated-at.bofh.it>
In reply to#1728328
> -	if (PageHighMem(pfn_to_page(pfn))) {
> +	if (PageHighMem(page) || xpfo_page_is_unmapped(page)) {

Please don't sprinkle xpfo details over various bits of code.

Just add a helper with a descriptive name, e.g.

page_is_unmapped()

that also includes the highmem case, as that will easily document
what this check is doing.

[toc] | [prev] | [next] | [standalone]


#1728369 — Re: [PATCH v6 04/11] swiotlb: Map the buffer if it was unmapped by XPFO

FromTycho Andersen <tycho@docker.com>
Date2017-09-07 20:50 +0200
SubjectRe: [PATCH v6 04/11] swiotlb: Map the buffer if it was unmapped by XPFO
Message-ID<una2e-3SJ-11@gated-at.bofh.it>
In reply to#1728359
On Thu, Sep 07, 2017 at 11:10:15AM -0700, Christoph Hellwig wrote:
> > -	if (PageHighMem(pfn_to_page(pfn))) {
> > +	if (PageHighMem(page) || xpfo_page_is_unmapped(page)) {
> 
> Please don't sprinkle xpfo details over various bits of code.
> 
> Just add a helper with a descriptive name, e.g.
> 
> page_is_unmapped()
> 
> that also includes the highmem case, as that will easily document
> what this check is doing.

Will do, thanks.

Patch 7 has a similar feel to this one, I can add a wrapper around
__clean_dcache_area_pou() if that makes sense?

Tycho

[toc] | [prev] | [next] | [standalone]


#1728651 — Re: [PATCH v6 04/11] swiotlb: Map the buffer if it was unmapped by XPFO

FromChristoph Hellwig <hch@infradead.org>
Date2017-09-08 09:20 +0200
SubjectRe: [PATCH v6 04/11] swiotlb: Map the buffer if it was unmapped by XPFO
Message-ID<unlK3-3Bf-29@gated-at.bofh.it>
In reply to#1728369
On Thu, Sep 07, 2017 at 12:44:14PM -0600, Tycho Andersen wrote:
> On Thu, Sep 07, 2017 at 11:10:15AM -0700, Christoph Hellwig wrote:
> > > -	if (PageHighMem(pfn_to_page(pfn))) {
> > > +	if (PageHighMem(page) || xpfo_page_is_unmapped(page)) {
> > 
> > Please don't sprinkle xpfo details over various bits of code.
> > 
> > Just add a helper with a descriptive name, e.g.
> > 
> > page_is_unmapped()
> > 
> > that also includes the highmem case, as that will easily document
> > what this check is doing.
> 
> Will do, thanks.
> 
> Patch 7 has a similar feel to this one, I can add a wrapper around
> __clean_dcache_area_pou() if that makes sense?

That one is in low-level ARM code so I'm not that worried.
But in general it seems like we should simply have one interface
to check if a page has a kernel mapping or not, nad map/unmap it
if not instead of distinguishing between highmem and xpfo.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web