Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Suchanek <msuchanek@suse.de>2018-10-31 13:27:38 +0100
committerMichal Suchanek <msuchanek@suse.de>2018-10-31 23:28:43 +0100
commit4f4e9dabebff09edec8e12c2d5264a2ba9b392b4 (patch)
treef82f8ac8aa56fe04da9138c0b30dad1e8017dacf
parent2154c26f5ce8595b848418d88c6dfcdb28264396 (diff)
KVM: PPC: Book3S: Fix matching of hardware and emulated TCE
tables (bsc#1061840).
-rw-r--r--patches.arch/KVM-PPC-Book3S-Fix-matching-of-hardware-and-emulated.patch76
-rw-r--r--series.conf1
2 files changed, 77 insertions, 0 deletions
diff --git a/patches.arch/KVM-PPC-Book3S-Fix-matching-of-hardware-and-emulated.patch b/patches.arch/KVM-PPC-Book3S-Fix-matching-of-hardware-and-emulated.patch
new file mode 100644
index 0000000000..505f4047bc
--- /dev/null
+++ b/patches.arch/KVM-PPC-Book3S-Fix-matching-of-hardware-and-emulated.patch
@@ -0,0 +1,76 @@
+From 76346cd93a5eca33700f82685d56172dd65d4c0a Mon Sep 17 00:00:00 2001
+From: Alexey Kardashevskiy <aik@ozlabs.ru>
+Date: Wed, 20 Jun 2018 18:42:58 +1000
+Subject: [PATCH] KVM: PPC: Book3S: Fix matching of hardware and emulated TCE
+ tables
+
+References: bsc#1061840
+Patch-mainline: v4.19-rc1
+Git-commit: 76346cd93a5eca33700f82685d56172dd65d4c0a
+
+When attaching a hardware table to LIOBN in KVM, we match table parameters
+such as page size, table offset and table size. However the tables are
+created via very different paths - VFIO and KVM - and the VFIO path goes
+through the platform code which has minimum TCE page size requirement
+(which is 4K but since we allocate memory by pages and cannot avoid
+alignment anyway, we align to 64k pages for powernv_defconfig).
+
+So when we match the tables, one might be bigger that the other which
+means the hardware table cannot get attached to LIOBN and DMA mapping
+fails.
+
+This removes the table size alignment from the guest visible table.
+This does not affect the memory allocation which is still aligned -
+kvmppc_tce_pages() takes care of this.
+
+This relaxes the check we do when attaching tables to allow the hardware
+table be bigger than the guest visible table.
+
+Ideally we want the KVM table to cover the same space as the hardware
+table does but since the hardware table may use multiple levels, and
+all levels must use the same table size (IODA2 design), the area it can
+actually cover might get very different from the window size which
+the guest requested, even though the guest won't map it all.
+
+Fixes: ca1fc489cf "KVM: PPC: Book3S: Allow backing bigger guest IOMMU pages with smaller physical pages"
+Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
+Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
+Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
+Acked-by: Michal Suchanek <msuchanek@suse.de>
+---
+ arch/powerpc/kvm/book3s_64_vio.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
+index d066e37551ec..85396e93747f 100644
+--- a/arch/powerpc/kvm/book3s_64_vio.c
++++ b/arch/powerpc/kvm/book3s_64_vio.c
+@@ -180,7 +180,7 @@ extern long kvm_spapr_tce_attach_iommu_group(struct kvm *kvm, int tablefd,
+ if ((tbltmp->it_page_shift <= stt->page_shift) &&
+ (tbltmp->it_offset << tbltmp->it_page_shift ==
+ stt->offset << stt->page_shift) &&
+- (tbltmp->it_size << tbltmp->it_page_shift ==
++ (tbltmp->it_size << tbltmp->it_page_shift >=
+ stt->size << stt->page_shift)) {
+ /*
+ * Reference the table to avoid races with
+@@ -296,7 +296,7 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
+ {
+ struct kvmppc_spapr_tce_table *stt = NULL;
+ struct kvmppc_spapr_tce_table *siter;
+- unsigned long npages, size;
++ unsigned long npages, size = args->size;
+ int ret = -ENOMEM;
+ int i;
+
+@@ -304,7 +304,6 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
+ (args->offset + args->size > (ULLONG_MAX >> args->page_shift)))
+ return -EINVAL;
+
+- size = _ALIGN_UP(args->size, PAGE_SIZE >> 3);
+ npages = kvmppc_tce_pages(size);
+ ret = kvmppc_account_memlimit(kvmppc_stt_pages(npages), true);
+ if (ret)
+--
+2.13.7
+
diff --git a/series.conf b/series.conf
index 4e02f11a73..c1a086d38f 100644
--- a/series.conf
+++ b/series.conf
@@ -17778,6 +17778,7 @@
patches.drivers/dmaengine-mv_xor_v2-kill-the-tasklets-upon-exit
patches.drivers/dmaengine-pl330-fix-irq-race-with-terminate_all.patch
patches.drivers/Input-atmel_mxt_ts-only-use-first-T9-instance.patch
+ patches.arch/KVM-PPC-Book3S-Fix-matching-of-hardware-and-emulated.patch
patches.fixes/kvm-s390-add-etoken-support-for-guests.patch
patches.arch/kvm-nvmx-fix-fault-vector-for-vmx-operation-at-cpl-0
patches.arch/kvm-vmx-track-host_state-loaded-using-a-loaded_vmcs-pointer