Commit 00a5c58d authored by Alexey Kardashevskiy's avatar Alexey Kardashevskiy Committed by Michael Ellerman

KVM: PPC: Make iommu_table::it_userspace big endian

We are going to reuse multilevel TCE code for the userspace copy of
the TCE table and since it is big endian, let's make the copy big endian
too.
Reviewed-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
Signed-off-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
Acked-by: default avatarPaul Mackerras <paulus@ozlabs.org>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 191c2287
...@@ -117,7 +117,7 @@ struct iommu_table { ...@@ -117,7 +117,7 @@ struct iommu_table {
unsigned long *it_map; /* A simple allocation bitmap for now */ unsigned long *it_map; /* A simple allocation bitmap for now */
unsigned long it_page_shift;/* table iommu page size */ unsigned long it_page_shift;/* table iommu page size */
struct list_head it_group_list;/* List of iommu_table_group_link */ struct list_head it_group_list;/* List of iommu_table_group_link */
unsigned long *it_userspace; /* userspace view of the table */ __be64 *it_userspace; /* userspace view of the table */
struct iommu_table_ops *it_ops; struct iommu_table_ops *it_ops;
struct kref it_kref; struct kref it_kref;
}; };
......
...@@ -378,19 +378,19 @@ static long kvmppc_tce_iommu_mapped_dec(struct kvm *kvm, ...@@ -378,19 +378,19 @@ static long kvmppc_tce_iommu_mapped_dec(struct kvm *kvm,
{ {
struct mm_iommu_table_group_mem_t *mem = NULL; struct mm_iommu_table_group_mem_t *mem = NULL;
const unsigned long pgsize = 1ULL << tbl->it_page_shift; const unsigned long pgsize = 1ULL << tbl->it_page_shift;
unsigned long *pua = IOMMU_TABLE_USERSPACE_ENTRY(tbl, entry); __be64 *pua = IOMMU_TABLE_USERSPACE_ENTRY(tbl, entry);
if (!pua) if (!pua)
/* it_userspace allocation might be delayed */ /* it_userspace allocation might be delayed */
return H_TOO_HARD; return H_TOO_HARD;
mem = mm_iommu_lookup(kvm->mm, *pua, pgsize); mem = mm_iommu_lookup(kvm->mm, be64_to_cpu(*pua), pgsize);
if (!mem) if (!mem)
return H_TOO_HARD; return H_TOO_HARD;
mm_iommu_mapped_dec(mem); mm_iommu_mapped_dec(mem);
*pua = 0; *pua = cpu_to_be64(0);
return H_SUCCESS; return H_SUCCESS;
} }
...@@ -437,7 +437,8 @@ long kvmppc_tce_iommu_do_map(struct kvm *kvm, struct iommu_table *tbl, ...@@ -437,7 +437,8 @@ long kvmppc_tce_iommu_do_map(struct kvm *kvm, struct iommu_table *tbl,
enum dma_data_direction dir) enum dma_data_direction dir)
{ {
long ret; long ret;
unsigned long hpa, *pua = IOMMU_TABLE_USERSPACE_ENTRY(tbl, entry); unsigned long hpa;
__be64 *pua = IOMMU_TABLE_USERSPACE_ENTRY(tbl, entry);
struct mm_iommu_table_group_mem_t *mem; struct mm_iommu_table_group_mem_t *mem;
if (!pua) if (!pua)
...@@ -464,7 +465,7 @@ long kvmppc_tce_iommu_do_map(struct kvm *kvm, struct iommu_table *tbl, ...@@ -464,7 +465,7 @@ long kvmppc_tce_iommu_do_map(struct kvm *kvm, struct iommu_table *tbl,
if (dir != DMA_NONE) if (dir != DMA_NONE)
kvmppc_tce_iommu_mapped_dec(kvm, tbl, entry); kvmppc_tce_iommu_mapped_dec(kvm, tbl, entry);
*pua = ua; *pua = cpu_to_be64(ua);
return 0; return 0;
} }
......
...@@ -200,7 +200,7 @@ static long kvmppc_rm_tce_iommu_mapped_dec(struct kvm *kvm, ...@@ -200,7 +200,7 @@ static long kvmppc_rm_tce_iommu_mapped_dec(struct kvm *kvm,
{ {
struct mm_iommu_table_group_mem_t *mem = NULL; struct mm_iommu_table_group_mem_t *mem = NULL;
const unsigned long pgsize = 1ULL << tbl->it_page_shift; const unsigned long pgsize = 1ULL << tbl->it_page_shift;
unsigned long *pua = IOMMU_TABLE_USERSPACE_ENTRY(tbl, entry); __be64 *pua = IOMMU_TABLE_USERSPACE_ENTRY(tbl, entry);
if (!pua) if (!pua)
/* it_userspace allocation might be delayed */ /* it_userspace allocation might be delayed */
...@@ -210,13 +210,13 @@ static long kvmppc_rm_tce_iommu_mapped_dec(struct kvm *kvm, ...@@ -210,13 +210,13 @@ static long kvmppc_rm_tce_iommu_mapped_dec(struct kvm *kvm,
if (WARN_ON_ONCE_RM(!pua)) if (WARN_ON_ONCE_RM(!pua))
return H_HARDWARE; return H_HARDWARE;
mem = mm_iommu_lookup_rm(kvm->mm, *pua, pgsize); mem = mm_iommu_lookup_rm(kvm->mm, be64_to_cpu(*pua), pgsize);
if (!mem) if (!mem)
return H_TOO_HARD; return H_TOO_HARD;
mm_iommu_mapped_dec(mem); mm_iommu_mapped_dec(mem);
*pua = 0; *pua = cpu_to_be64(0);
return H_SUCCESS; return H_SUCCESS;
} }
...@@ -268,7 +268,7 @@ static long kvmppc_rm_tce_iommu_do_map(struct kvm *kvm, struct iommu_table *tbl, ...@@ -268,7 +268,7 @@ static long kvmppc_rm_tce_iommu_do_map(struct kvm *kvm, struct iommu_table *tbl,
{ {
long ret; long ret;
unsigned long hpa = 0; unsigned long hpa = 0;
unsigned long *pua = IOMMU_TABLE_USERSPACE_ENTRY(tbl, entry); __be64 *pua = IOMMU_TABLE_USERSPACE_ENTRY(tbl, entry);
struct mm_iommu_table_group_mem_t *mem; struct mm_iommu_table_group_mem_t *mem;
if (!pua) if (!pua)
...@@ -302,7 +302,7 @@ static long kvmppc_rm_tce_iommu_do_map(struct kvm *kvm, struct iommu_table *tbl, ...@@ -302,7 +302,7 @@ static long kvmppc_rm_tce_iommu_do_map(struct kvm *kvm, struct iommu_table *tbl,
if (dir != DMA_NONE) if (dir != DMA_NONE)
kvmppc_rm_tce_iommu_mapped_dec(kvm, tbl, entry); kvmppc_rm_tce_iommu_mapped_dec(kvm, tbl, entry);
*pua = ua; *pua = cpu_to_be64(ua);
return 0; return 0;
} }
......
...@@ -230,7 +230,7 @@ static long tce_iommu_userspace_view_alloc(struct iommu_table *tbl, ...@@ -230,7 +230,7 @@ static long tce_iommu_userspace_view_alloc(struct iommu_table *tbl,
decrement_locked_vm(mm, cb >> PAGE_SHIFT); decrement_locked_vm(mm, cb >> PAGE_SHIFT);
return -ENOMEM; return -ENOMEM;
} }
tbl->it_userspace = uas; tbl->it_userspace = (__be64 *) uas;
return 0; return 0;
} }
...@@ -482,20 +482,20 @@ static void tce_iommu_unuse_page_v2(struct tce_container *container, ...@@ -482,20 +482,20 @@ static void tce_iommu_unuse_page_v2(struct tce_container *container,
struct mm_iommu_table_group_mem_t *mem = NULL; struct mm_iommu_table_group_mem_t *mem = NULL;
int ret; int ret;
unsigned long hpa = 0; unsigned long hpa = 0;
unsigned long *pua = IOMMU_TABLE_USERSPACE_ENTRY(tbl, entry); __be64 *pua = IOMMU_TABLE_USERSPACE_ENTRY(tbl, entry);
if (!pua) if (!pua)
return; return;
ret = tce_iommu_prereg_ua_to_hpa(container, *pua, IOMMU_PAGE_SIZE(tbl), ret = tce_iommu_prereg_ua_to_hpa(container, be64_to_cpu(*pua),
&hpa, &mem); IOMMU_PAGE_SIZE(tbl), &hpa, &mem);
if (ret) if (ret)
pr_debug("%s: tce %lx at #%lx was not cached, ret=%d\n", pr_debug("%s: tce %llx at #%lx was not cached, ret=%d\n",
__func__, *pua, entry, ret); __func__, be64_to_cpu(*pua), entry, ret);
if (mem) if (mem)
mm_iommu_mapped_dec(mem); mm_iommu_mapped_dec(mem);
*pua = 0; *pua = cpu_to_be64(0);
} }
static int tce_iommu_clear(struct tce_container *container, static int tce_iommu_clear(struct tce_container *container,
...@@ -607,8 +607,7 @@ static long tce_iommu_build_v2(struct tce_container *container, ...@@ -607,8 +607,7 @@ static long tce_iommu_build_v2(struct tce_container *container,
for (i = 0; i < pages; ++i) { for (i = 0; i < pages; ++i) {
struct mm_iommu_table_group_mem_t *mem = NULL; struct mm_iommu_table_group_mem_t *mem = NULL;
unsigned long *pua = IOMMU_TABLE_USERSPACE_ENTRY(tbl, __be64 *pua = IOMMU_TABLE_USERSPACE_ENTRY(tbl, entry + i);
entry + i);
ret = tce_iommu_prereg_ua_to_hpa(container, ret = tce_iommu_prereg_ua_to_hpa(container,
tce, IOMMU_PAGE_SIZE(tbl), &hpa, &mem); tce, IOMMU_PAGE_SIZE(tbl), &hpa, &mem);
...@@ -642,7 +641,7 @@ static long tce_iommu_build_v2(struct tce_container *container, ...@@ -642,7 +641,7 @@ static long tce_iommu_build_v2(struct tce_container *container,
if (dirtmp != DMA_NONE) if (dirtmp != DMA_NONE)
tce_iommu_unuse_page_v2(container, tbl, entry + i); tce_iommu_unuse_page_v2(container, tbl, entry + i);
*pua = tce; *pua = cpu_to_be64(tce);
tce += IOMMU_PAGE_SIZE(tbl); tce += IOMMU_PAGE_SIZE(tbl);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment