[azure][PATCH 3/3] Revert "UBUNTU: SAUCE: x86/hyper-v: use hypercall for remote TLB flush"

Marcelo Henrique Cerri marcelo.cerri at canonical.com
Mon Oct 2 14:16:12 UTC 2017


BugLink: http://bugs.launchpad.net/bugs/1719045

This reverts commit 5e61aa7ca654028fe5a175b58fd0b64a13cf3604.

Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri at canonical.com>
---
 arch/x86/hyperv/Makefile           |   2 +-
 arch/x86/hyperv/hv_init.c          |   2 -
 arch/x86/hyperv/mmu.c              | 117 -------------------------------------
 arch/x86/include/asm/mshyperv.h    |   2 -
 arch/x86/include/uapi/asm/hyperv.h |   7 ---
 arch/x86/kernel/cpu/mshyperv.c     |   1 -
 6 files changed, 1 insertion(+), 130 deletions(-)
 delete mode 100644 arch/x86/hyperv/mmu.c

diff --git a/arch/x86/hyperv/Makefile b/arch/x86/hyperv/Makefile
index 367a8203cfcf..171ae09864d7 100644
--- a/arch/x86/hyperv/Makefile
+++ b/arch/x86/hyperv/Makefile
@@ -1 +1 @@
-obj-y		:= hv_init.o mmu.o
+obj-y		:= hv_init.o
diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index 749f0e231e45..31c8e191b19b 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -148,8 +148,6 @@ void hyperv_init(void)
 	hypercall_msr.guest_physical_address = vmalloc_to_pfn(hv_hypercall_pg);
 	wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
 
-	hyper_alloc_mmu();
-
 	/*
 	 * Register Hyper-V specific clocksource.
 	 */
diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c
deleted file mode 100644
index e3ab9b984b52..000000000000
--- a/arch/x86/hyperv/mmu.c
+++ /dev/null
@@ -1,117 +0,0 @@
-#include <linux/types.h>
-#include <linux/hyperv.h>
-#include <linux/slab.h>
-#include <linux/log2.h>
-#include <asm/mshyperv.h>
-#include <asm/tlbflush.h>
-#include <asm/msr.h>
-#include <asm/fpu/api.h>
-
-/* HvFlushVirtualAddressSpace, HvFlushVirtualAddressList hypercalls */
-struct hv_flush_pcpu {
-	__u64 address_space;
-	__u64 flags;
-	__u64 processor_mask;
-	__u64 gva_list[];
-};
-
-static struct hv_flush_pcpu __percpu *pcpu_flush;
-
-static void hyperv_flush_tlb_others(const struct cpumask *cpus,
-				    struct mm_struct *mm, unsigned long start,
-				    unsigned long end)
-{
-	struct hv_flush_pcpu *flush;
-	unsigned long cur, flags;
-	u64 status = -1ULL;
-	int cpu, vcpu, gva_n, max_gvas;
-
-	if (!pcpu_flush || !hv_hypercall_pg)
-		goto do_native;
-
-	if (cpumask_empty(cpus))
-		return;
-
-	local_irq_save(flags);
-
-	flush = this_cpu_ptr(pcpu_flush);
-
-	if (mm) {
-		flush->address_space = virt_to_phys(mm->pgd);
-		flush->flags = 0;
-	} else {
-		flush->address_space = 0;
-		flush->flags = HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES;
-	}
-
-	flush->processor_mask = 0;
-	if (cpumask_equal(cpus, cpu_present_mask)) {
-		flush->flags |= HV_FLUSH_ALL_PROCESSORS;
-	} else {
-		for_each_cpu(cpu, cpus) {
-			vcpu = hv_cpu_number_to_vp_number(cpu);
-			if (vcpu != -1 && vcpu < 64)
-				flush->processor_mask |= 1 << vcpu;
-			else
-				goto do_native;
-		}
-	}
-
-	/*
-	 * We can flush not more than max_gvas with one hypercall. Flush the
-	 * whole address space if we were asked to do more.
-	 */
-	max_gvas = (PAGE_SIZE - sizeof(*flush)) / 8;
-
-	if (end == TLB_FLUSH_ALL ||
-	    (end && ((end - start)/(PAGE_SIZE*PAGE_SIZE)) > max_gvas)) {
-		if (end == TLB_FLUSH_ALL)
-			flush->flags |= HV_FLUSH_NON_GLOBAL_MAPPINGS_ONLY;
-		status = hv_do_hypercall(HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE,
-					 flush, NULL);
-	} else {
-		cur = start;
-		gva_n = 0;
-		do {
-			flush->gva_list[gva_n] = cur & PAGE_MASK;
-			/*
-			 * Lower 12 bits encode the number of additional
-			 * pages to flush (in addition to the 'cur' page).
-			 */
-			if (end >= cur + PAGE_SIZE * PAGE_SIZE)
-				flush->gva_list[gva_n] |= ~PAGE_MASK;
-			else if (end > cur)
-				flush->gva_list[gva_n] |=
-					(end - cur - 1) >> PAGE_SHIFT;
-
-			cur += PAGE_SIZE * PAGE_SIZE;
-			++gva_n;
-
-		} while (cur < end);
-
-		status = hv_do_rep_hypercall(HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST,
-					     gva_n, 0, flush, NULL);
-
-	}
-
-	local_irq_restore(flags);
-
-	if (!(status & 0xffff))
-		return;
-do_native:
-	native_flush_tlb_others(cpus, mm, start, end);
-}
-
-void hyperv_setup_mmu_ops(void)
-{
-	if (ms_hyperv.hints & HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED) {
-		pr_info("Hyper-V: Using hypercall for remote TLB flush\n");
-		pv_mmu_ops.flush_tlb_others = hyperv_flush_tlb_others;
-	}
-}
-
-void hyper_alloc_mmu(void)
-{
-	if (ms_hyperv.hints & HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED)
-		pcpu_flush = __alloc_percpu(PAGE_SIZE, PAGE_SIZE);
-}
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 4ed62b6a4464..2420ac33392d 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -307,8 +307,6 @@ static inline int hv_cpu_number_to_vp_number(int cpu_number)
 }
 
 void hyperv_init(void);
-void hyperv_setup_mmu_ops(void);
-void hyper_alloc_mmu(void);
 void hyperv_report_panic(struct pt_regs *regs);
 bool hv_is_hypercall_page_setup(void);
 void hyperv_cleanup(void);
diff --git a/arch/x86/include/uapi/asm/hyperv.h b/arch/x86/include/uapi/asm/hyperv.h
index ecb0470e520b..3d5df582709a 100644
--- a/arch/x86/include/uapi/asm/hyperv.h
+++ b/arch/x86/include/uapi/asm/hyperv.h
@@ -242,8 +242,6 @@
 		(~((1ull << HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT) - 1))
 
 /* Declare the various hypercall operations. */
-#define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE	0x0002
-#define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST	0x0003
 #define HVCALL_NOTIFY_LONG_SPIN_WAIT		0x0008
 #define HVCALL_POST_MESSAGE			0x005c
 #define HVCALL_SIGNAL_EVENT			0x005d
@@ -261,11 +259,6 @@
 #define HV_PROCESSOR_POWER_STATE_C2		2
 #define HV_PROCESSOR_POWER_STATE_C3		3
 
-#define HV_FLUSH_ALL_PROCESSORS			0x00000001
-#define HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES	0x00000002
-#define HV_FLUSH_NON_GLOBAL_MAPPINGS_ONLY	0x00000004
-#define HV_FLUSH_USE_EXTENDED_RANGE_FORMAT	0x00000008
-
 /* Hypercall interface */
 union hv_hypercall_input {
 	u64 as_uint64;
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 42664f944cbc..b3bf024fc4e0 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -255,7 +255,6 @@ static void __init ms_hyperv_init_platform(void)
 	 * Setup the hook to get control post apic initialization.
 	 */
 	x86_platform.apic_post_init = hyperv_init;
-	hyperv_setup_mmu_ops();
 #endif
 }
 
-- 
2.7.4





More information about the kernel-team mailing list