[PATCH v1 06/13] KVM: PPC: Add @offset to kvmppc_spapr_tce_table
Alexey Kardashevskiy
aik at ozlabs.ru
Tue Jul 15 19:25:26 EST 2014
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 at 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
More information about the Linuxppc-dev
mailing list