Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlaf Hering <ohering@suse.de>2017-10-20 12:20:33 +0200
committerOlaf Hering <ohering@suse.de>2017-10-20 12:23:30 +0200
commit32343838ca7273e407d3f45bc6205d43509bcb85 (patch)
tree91a883048fa4b281258120b78e3accdc1ae5c693
parent7b1b28a479daf8a6e0e43d1a55d2015f5e10b570 (diff)
x86/hyperv: Don't use percpu areas for pcpu_flush/pcpu_flush_ex
structures (fate#323887).
-rw-r--r--patches.suse/msft-hv-1472-x86-hyperv-Don-t-use-percpu-areas-for-pcpu_flush-pcp.patch115
-rw-r--r--series.conf1
2 files changed, 116 insertions, 0 deletions
diff --git a/patches.suse/msft-hv-1472-x86-hyperv-Don-t-use-percpu-areas-for-pcpu_flush-pcp.patch b/patches.suse/msft-hv-1472-x86-hyperv-Don-t-use-percpu-areas-for-pcpu_flush-pcp.patch
new file mode 100644
index 0000000000..2f7a9c1a18
--- /dev/null
+++ b/patches.suse/msft-hv-1472-x86-hyperv-Don-t-use-percpu-areas-for-pcpu_flush-pcp.patch
@@ -0,0 +1,115 @@
+From: Vitaly Kuznetsov <vkuznets@redhat.com>
+Date: Thu, 5 Oct 2017 13:39:24 +0200
+Patch-mainline: v4.14-rc5
+Subject: x86/hyperv: Don't use percpu areas for pcpu_flush/pcpu_flush_ex structures
+Git-commit: 60d73a7c96601434dfdb56d5b9167ff3b850d8d7
+References: fate#323887
+
+hv_do_hypercall() does virt_to_phys() translation and with some configs
+(CONFIG_SLAB) this doesn't work for percpu areas, we pass wrong memory to
+hypervisor and get #GP. We could use working slow_virt_to_phys() instead
+but doing so kills the performance.
+
+Move pcpu_flush/pcpu_flush_ex structures out of percpu areas and
+allocate memory on first call. The additional level of indirection gives
+us a small performance penalty, in future we may consider introducing
+hypercall functions which avoid virt_to_phys() conversion and cache
+physical addresses of pcpu_flush/pcpu_flush_ex structures somewhere.
+
+Reported-by: Simon Xiao <sixiao@microsoft.com>
+Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
+Cc: Dexuan Cui <decui@microsoft.com>
+Cc: Haiyang Zhang <haiyangz@microsoft.com>
+Cc: Jork Loeser <Jork.Loeser@microsoft.com>
+Cc: K. Y. Srinivasan <kys@microsoft.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Stephen Hemminger <sthemmin@microsoft.com>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: devel@linuxdriverproject.org
+Link: http://lkml.kernel.org/r/20171005113924.28021-1-vkuznets@redhat.com
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Acked-by: Olaf Hering <ohering@suse.de>
+---
+ arch/x86/hyperv/mmu.c | 34 ++++++++++++++++++++++++++++------
+ 1 file changed, 28 insertions(+), 6 deletions(-)
+
+diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c
+--- a/arch/x86/hyperv/mmu.c
++++ b/arch/x86/hyperv/mmu.c
+@@ -36,9 +36,9 @@ struct hv_flush_pcpu_ex {
+ /* Each gva in gva_list encodes up to 4096 pages to flush */
+ #define HV_TLB_FLUSH_UNIT (4096 * PAGE_SIZE)
+
+-static struct hv_flush_pcpu __percpu *pcpu_flush;
++static struct hv_flush_pcpu __percpu **pcpu_flush;
+
+-static struct hv_flush_pcpu_ex __percpu *pcpu_flush_ex;
++static struct hv_flush_pcpu_ex __percpu **pcpu_flush_ex;
+
+ /*
+ * Fills in gva_list starting from offset. Returns the number of items added.
+@@ -109,6 +109,7 @@ static void hyperv_flush_tlb_others(const struct cpumask *cpus,
+ struct mm_struct *mm, unsigned long start, unsigned long end)
+ {
+ int cpu, vcpu, gva_n, max_gvas;
++ struct hv_flush_pcpu **flush_pcpu;
+ struct hv_flush_pcpu *flush;
+ u64 status = U64_MAX;
+ unsigned long flags;
+@@ -123,7 +124,17 @@ static void hyperv_flush_tlb_others(const struct cpumask *cpus,
+
+ local_irq_save(flags);
+
+- flush = this_cpu_ptr(pcpu_flush);
++ flush_pcpu = this_cpu_ptr(pcpu_flush);
++
++ if (unlikely(!*flush_pcpu))
++ *flush_pcpu = page_address(alloc_page(GFP_ATOMIC));
++
++ flush = *flush_pcpu;
++
++ if (unlikely(!flush)) {
++ local_irq_restore(flags);
++ goto do_native;
++ }
+
+ if (mm) {
+ flush->address_space = virt_to_phys(mm->pgd);
+@@ -180,6 +191,7 @@ static void hyperv_flush_tlb_others_ex(const struct cpumask *cpus,
+ struct mm_struct *mm, unsigned long start, unsigned long end)
+ {
+ int nr_bank = 0, max_gvas, gva_n;
++ struct hv_flush_pcpu_ex **flush_pcpu;
+ struct hv_flush_pcpu_ex *flush;
+ u64 status = U64_MAX;
+ unsigned long flags;
+@@ -194,7 +206,17 @@ static void hyperv_flush_tlb_others_ex(const struct cpumask *cpus,
+
+ local_irq_save(flags);
+
+- flush = this_cpu_ptr(pcpu_flush_ex);
++ flush_pcpu = this_cpu_ptr(pcpu_flush_ex);
++
++ if (unlikely(!*flush_pcpu))
++ *flush_pcpu = page_address(alloc_page(GFP_ATOMIC));
++
++ flush = *flush_pcpu;
++
++ if (unlikely(!flush)) {
++ local_irq_restore(flags);
++ goto do_native;
++ }
+
+ if (mm) {
+ flush->address_space = virt_to_phys(mm->pgd);
+@@ -273,7 +295,7 @@ void hyper_alloc_mmu(void)
+ return;
+
+ if (!(ms_hyperv.hints & HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED))
+- pcpu_flush = __alloc_percpu(PAGE_SIZE, PAGE_SIZE);
++ pcpu_flush = alloc_percpu(struct hv_flush_pcpu *);
+ else
+- pcpu_flush_ex = __alloc_percpu(PAGE_SIZE, PAGE_SIZE);
++ pcpu_flush_ex = alloc_percpu(struct hv_flush_pcpu_ex *);
+ }
diff --git a/series.conf b/series.conf
index 12aa5a1576..a6c1c5f324 100644
--- a/series.conf
+++ b/series.conf
@@ -1718,6 +1718,7 @@
patches.suse/msft-hv-1468-Drivers-hv-fcopy-restore-correct-transfer-length.patch
patches.suse/msft-hv-1470-Drivers-hv-vmbus-Fix-bugs-in-rescind-handling.patch
patches.suse/msft-hv-1471-x86-hyperv-Clear-vCPU-banks-between-calls-to-avoid-f.patch
+ patches.suse/msft-hv-1472-x86-hyperv-Don-t-use-percpu-areas-for-pcpu_flush-pcp.patch
patches.suse/suse-hv-guest-os-id.patch
patches.suse/suse-hv-kvp_on_msg.dbg.patch