All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: linuxppc-dev@lists.ozlabs.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
	Paul Mackerras <paulus@samba.org>,
	David Gibson <david@gibson.dropbear.id.au>,
	kvm-ppc@vger.kernel.org, kvm@vger.kernel.org
Subject: [PATCH kernel 3/4] KVM: PPC: Add @offset to kvmppc_spapr_tce_table
Date: Thu, 21 Jan 2016 19:15:25 +1100	[thread overview]
Message-ID: <1453364126-22527-4-git-send-email-aik@ozlabs.ru> (raw)
In-Reply-To: <1453364126-22527-1-git-send-email-aik@ozlabs.ru>

This enables userspace view of TCE tables to start from non-zero offset
on a bus. This will be used for huge DMA windows.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 arch/powerpc/include/asm/kvm_host.h | 1 +
 arch/powerpc/kvm/book3s_64_vio_hv.c | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index a4ed9f5..8769f91 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -185,6 +185,7 @@ struct kvmppc_spapr_tce_table {
 	u64 liobn;
 	struct rcu_head rcu;
 	u32 page_shift;
+	u64 offset;		/* in pages */
 	u64 size;		/* in pages */
 	struct page *pages[0];
 };
diff --git a/arch/powerpc/kvm/book3s_64_vio_hv.c b/arch/powerpc/kvm/book3s_64_vio_hv.c
index 01ef9f9..0e66459 100644
--- a/arch/powerpc/kvm/book3s_64_vio_hv.c
+++ b/arch/powerpc/kvm/book3s_64_vio_hv.c
@@ -75,7 +75,8 @@ long kvmppc_ioba_validate(struct kvmppc_spapr_tce_table *stt,
 	unsigned long mask = ~((1ULL << stt->page_shift) - 1);
 	unsigned long idx = ioba >> stt->page_shift;
 
-	if ((ioba & ~mask) || (idx + npages > stt->size))
+	if ((ioba & ~mask) || (idx < stt->offset) ||
+			(idx - stt->offset + npages > stt->size))
 		return H_PARAMETER;
 
 	return H_SUCCESS;
@@ -147,6 +148,7 @@ void kvmppc_tce_put(struct kvmppc_spapr_tce_table *stt,
 	struct page *page;
 	u64 *tbl;
 
+	idx -= stt->offset;
 	page = stt->pages[idx / TCES_PER_PAGE];
 	tbl = kvmppc_page_address(page);
 
@@ -324,7 +326,7 @@ long kvmppc_h_get_tce(struct kvm_vcpu *vcpu, unsigned long liobn,
 	if (ret != H_SUCCESS)
 		return ret;
 
-	idx = ioba >> stt->page_shift;
+	idx = (ioba >> stt->page_shift) - stt->offset;
 	page = stt->pages[idx / TCES_PER_PAGE];
 	tbl = (u64 *)page_address(page);
 
-- 
2.5.0.rc3


WARNING: multiple messages have this Message-ID (diff)
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: linuxppc-dev@lists.ozlabs.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
	Paul Mackerras <paulus@samba.org>,
	David Gibson <david@gibson.dropbear.id.au>,
	kvm-ppc@vger.kernel.org, kvm@vger.kernel.org
Subject: [PATCH kernel 3/4] KVM: PPC: Add @offset to kvmppc_spapr_tce_table
Date: Thu, 21 Jan 2016 08:15:25 +0000	[thread overview]
Message-ID: <1453364126-22527-4-git-send-email-aik@ozlabs.ru> (raw)
In-Reply-To: <1453364126-22527-1-git-send-email-aik@ozlabs.ru>

This enables userspace view of TCE tables to start from non-zero offset
on a bus. This will be used for huge DMA windows.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 arch/powerpc/include/asm/kvm_host.h | 1 +
 arch/powerpc/kvm/book3s_64_vio_hv.c | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index a4ed9f5..8769f91 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -185,6 +185,7 @@ struct kvmppc_spapr_tce_table {
 	u64 liobn;
 	struct rcu_head rcu;
 	u32 page_shift;
+	u64 offset;		/* in pages */
 	u64 size;		/* in pages */
 	struct page *pages[0];
 };
diff --git a/arch/powerpc/kvm/book3s_64_vio_hv.c b/arch/powerpc/kvm/book3s_64_vio_hv.c
index 01ef9f9..0e66459 100644
--- a/arch/powerpc/kvm/book3s_64_vio_hv.c
+++ b/arch/powerpc/kvm/book3s_64_vio_hv.c
@@ -75,7 +75,8 @@ long kvmppc_ioba_validate(struct kvmppc_spapr_tce_table *stt,
 	unsigned long mask = ~((1ULL << stt->page_shift) - 1);
 	unsigned long idx = ioba >> stt->page_shift;
 
-	if ((ioba & ~mask) || (idx + npages > stt->size))
+	if ((ioba & ~mask) || (idx < stt->offset) ||
+			(idx - stt->offset + npages > stt->size))
 		return H_PARAMETER;
 
 	return H_SUCCESS;
@@ -147,6 +148,7 @@ void kvmppc_tce_put(struct kvmppc_spapr_tce_table *stt,
 	struct page *page;
 	u64 *tbl;
 
+	idx -= stt->offset;
 	page = stt->pages[idx / TCES_PER_PAGE];
 	tbl = kvmppc_page_address(page);
 
@@ -324,7 +326,7 @@ long kvmppc_h_get_tce(struct kvm_vcpu *vcpu, unsigned long liobn,
 	if (ret != H_SUCCESS)
 		return ret;
 
-	idx = ioba >> stt->page_shift;
+	idx = (ioba >> stt->page_shift) - stt->offset;
 	page = stt->pages[idx / TCES_PER_PAGE];
 	tbl = (u64 *)page_address(page);
 
-- 
2.5.0.rc3


  parent reply	other threads:[~2016-01-21  8:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-21  8:15 [PATCH kernel 0/4] KVM: PPC: Add in-kernel acceleration for 64bit DMA Alexey Kardashevskiy
2016-01-21  8:15 ` Alexey Kardashevskiy
2016-01-21  8:15 ` [PATCH kernel 1/4] KVM: PPC: Reserve KVM_CAP_SPAPR_TCE_64 capability number Alexey Kardashevskiy
2016-01-21  8:15   ` Alexey Kardashevskiy
2016-01-25  5:23   ` David Gibson
2016-01-25  5:23     ` David Gibson
2016-01-25  5:23     ` David Gibson
2016-01-21  8:15 ` [PATCH kernel 2/4] KVM: PPC: Add @page_shift to kvmppc_spapr_tce_table Alexey Kardashevskiy
2016-01-21  8:15   ` Alexey Kardashevskiy
2016-01-25  5:30   ` David Gibson
2016-01-25  5:30     ` David Gibson
2016-01-21  8:15 ` Alexey Kardashevskiy [this message]
2016-01-21  8:15   ` [PATCH kernel 3/4] KVM: PPC: Add @offset " Alexey Kardashevskiy
2016-01-25  5:33   ` David Gibson
2016-01-25  5:33     ` David Gibson
2016-01-27  3:31     ` Alexey Kardashevskiy
2016-01-27  3:31       ` Alexey Kardashevskiy
2016-01-21  8:15 ` [PATCH kernel 4/4] KVM: PPC: Add support for 64bit TCE windows Alexey Kardashevskiy
2016-01-21  8:15   ` Alexey Kardashevskiy
2016-01-25  5:37   ` David Gibson
2016-01-25  5:37     ` David Gibson
2016-01-27  3:29     ` Alexey Kardashevskiy
2016-01-27  3:29       ` Alexey Kardashevskiy
2016-01-27 23:53       ` David Gibson
2016-01-27 23:53         ` David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453364126-22527-4-git-send-email-aik@ozlabs.ru \
    --to=aik@ozlabs.ru \
    --cc=david@gibson.dropbear.id.au \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.