linuxppc-dev.lists.ozlabs.org archive mirror
 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>,
	Gavin Shan <gwshan@linux.vnet.ibm.com>
Subject: [PATCH v1 06/13] KVM: PPC: Add @offset to kvmppc_spapr_tce_table
Date: Tue, 15 Jul 2014 19:25:26 +1000	[thread overview]
Message-ID: <1405416333-12477-7-git-send-email-aik@ozlabs.ru> (raw)
In-Reply-To: <1405416333-12477-1-git-send-email-aik@ozlabs.ru>

This enables guest visible TCE tables to start from non-zero offset
on a bus. This will be used for VFIO support.

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

diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index d3a154c..ed96b09 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -181,6 +181,7 @@ struct kvmppc_spapr_tce_table {
 	struct kvm *kvm;
 	u64 liobn;
 	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 fadfacb..a3a6597 100644
--- a/arch/powerpc/kvm/book3s_64_vio_hv.c
+++ b/arch/powerpc/kvm/book3s_64_vio_hv.c
@@ -74,7 +74,8 @@ long kvmppc_ioba_validate(struct kvmppc_spapr_tce_table *stt,
 	unsigned long mask = (1 << IOMMU_PAGE_SHIFT_4K) - 1;
 	unsigned long idx = ioba >> IOMMU_PAGE_SHIFT_4K;
 
-	if ((ioba & mask) || (stt->size + npages <= idx))
+	if ((ioba & mask) || (idx < stt->offset) ||
+			(stt->offset + stt->size + npages <= idx))
 		return H_PARAMETER;
 
 	return H_SUCCESS;
@@ -146,6 +147,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);
 
@@ -351,6 +353,7 @@ long kvmppc_h_get_tce(struct kvm_vcpu *vcpu, unsigned long liobn,
 		return ret;
 
 	idx = ioba >> IOMMU_PAGE_SHIFT_4K;
+	idx -= stt->offset;
 	page = stt->pages[idx / TCES_PER_PAGE];
 	tbl = (u64 *)page_address(page);
 
-- 
2.0.0

  parent reply	other threads:[~2014-07-15  9:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-15  9:25 [PATCH v1 00/13] powerpc: kvm: Enable in-kernel acceleration for VFIO Alexey Kardashevskiy
2014-07-15  9:25 ` [PATCH v1 01/13] KVM: PPC: Account TCE pages in locked_vm Alexey Kardashevskiy
2014-07-15  9:29   ` Alexey Kardashevskiy
2014-07-15  9:25 ` [PATCH v1 02/13] KVM: PPC: Rework kvmppc_spapr_tce_table to support variable page size Alexey Kardashevskiy
2014-07-15  9:25 ` [PATCH v1 03/13] KVM: PPC: Enable IOMMU_API for KVM_BOOK3S_64 permanently Alexey Kardashevskiy
2014-07-15  9:25 ` [PATCH v1 04/13] KVM: PPC: Reserve KVM_CAP_SPAPR_TCE_VFIO capability number Alexey Kardashevskiy
2014-07-15  9:25 ` [PATCH v1 05/13] KVM: PPC: Reserve KVM_CAP_SPAPR_TCE_64 " Alexey Kardashevskiy
2014-07-15  9:25 ` Alexey Kardashevskiy [this message]
2014-07-15  9:25 ` [PATCH v1 07/13] KVM: PPC: Add support for 64bit TCE windows Alexey Kardashevskiy
2014-07-15  9:25 ` [PATCH v1 08/13] KVM: PPC: Add hugepage support for IOMMU in-kernel handling Alexey Kardashevskiy
2014-07-15  9:25 ` [PATCH v1 09/13] KVM: PPC: Add page_shift support for in-kernel H_PUT_TCE/etc handlers Alexey Kardashevskiy
2014-07-15  9:25 ` [PATCH v1 10/13] KVM: PPC: Fix kvmppc_gpa_to_hva_and_get() to return host physical address Alexey Kardashevskiy
2014-07-15  9:25 ` [PATCH v1 11/13] KVM: PPC: Associate IOMMU group with guest copy of TCE table Alexey Kardashevskiy
2014-07-15  9:25 ` [PATCH v1 12/13] KVM: PPC: vfio kvm device: support spapr tce Alexey Kardashevskiy
2014-07-15  9:25 ` [PATCH v1 13/13] KVM: PPC: Add support for IOMMU in-kernel handling Alexey Kardashevskiy

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=1405416333-12477-7-git-send-email-aik@ozlabs.ru \
    --to=aik@ozlabs.ru \
    --cc=gwshan@linux.vnet.ibm.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).