linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/18] Drivers: hv: vmbus: Restructure architecture specific code
@ 2016-12-30 21:35 kys
  2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
  0 siblings, 1 reply; 22+ messages in thread
From: kys @ 2016-12-30 21:35 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa
  Cc: K. Y. Srinivasan

From: K. Y. Srinivasan <kys@microsoft.com>

The current Hyper-V code under drivers/hv has bunch of X86 specific code.
Restructure the code and move al architecture specific code to the
appropriate files.

As I was working on this restructuring, Roman Kagan <rkagan@virtuozzo.com>
has submitted patches to restructure the Hyper-V header files to address
a different need - to share the definitions across all Hyper-V drivers
including QEMU based drivers. Roman and I will coordinate our work.

K. Y. Srinivasan (18):
  Drivers: hv: vmbus: Move the definition of
    hv_x64_msr_hypercall_contents
  Drivers: hv: vmbus: Move the definition of generate_guest_id()
  Drivers: hv vmbus: Move Hypercall page setup out of common code
  Drivers: hv: vmbus: Move Hypercall invocation code out of common code
  Drivers: hv: vmbus: Consolidate all Hyper-V specific clocksource code
  Drivers: hv: vmbus: Move the extracting of Hypervisor version
    information
  Drivers: hv: vmbus: Move the crash notification function
  Drivers: hv: vmbus: Move the check for hypercall page setup
  Drivers: hv: vmbus: Move the code to signal end of message
  Drivers: hv: vmbus: Restructure the clockevents code
  Drivers: hv: util: Use hv_get_current_tick() to get current tick
  Drivers: hv: vmbus: Get rid of an unsused variable
  Drivers: hv: vmbus: Define APIs to manipulate the message page
  Drivers: hv: vmbus: Define APIs to manipulate the event page
  Drivers: hv: vmbus: Define APIs to manipulate the synthetic interrupt
    controller
  Drivers: hv: vmbus: Define an API to retrieve virtual processor index
  Drivers: hv: vmbus: Define an APIs to manage interrupt state
  Drivers: hv: vmbus: Cleanup hyperv_vmbus.h

 arch/x86/Kbuild                    |    3 +
 arch/x86/hyperv/Makefile           |    1 +
 arch/x86/hyperv/hv_init.c          |  251 ++++++++++++++++++++++++++++++
 arch/x86/include/asm/mshyperv.h    |  147 ++++++++++++++++++
 arch/x86/include/uapi/asm/hyperv.h |    8 +
 arch/x86/kernel/cpu/mshyperv.c     |   50 ++++---
 drivers/hv/channel_mgmt.c          |    1 +
 drivers/hv/connection.c            |    7 +-
 drivers/hv/hv.c                    |  296 ++++--------------------------------
 drivers/hv/hv_util.c               |    3 +-
 drivers/hv/hyperv_vmbus.h          |  291 +-----------------------------------
 drivers/hv/vmbus_drv.c             |   25 ---
 12 files changed, 472 insertions(+), 611 deletions(-)
 create mode 100644 arch/x86/hyperv/Makefile
 create mode 100644 arch/x86/hyperv/hv_init.c

-- 
1.7.4.1

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents
  2016-12-30 21:35 [PATCH 00/18] Drivers: hv: vmbus: Restructure architecture specific code kys
@ 2016-12-30 21:35 ` kys
  2016-12-30 21:35   ` [PATCH 02/18] Drivers: hv: vmbus: Move the definition of generate_guest_id() kys
                     ` (17 more replies)
  0 siblings, 18 replies; 22+ messages in thread
From: kys @ 2016-12-30 21:35 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa
  Cc: K. Y. Srinivasan

From: K. Y. Srinivasan <kys@microsoft.com>

As part of the effort to separate out architecture specific code, move the
definition of hv_x64_msr_hypercall_contents to x86 specific header file.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 arch/x86/include/asm/mshyperv.h |   12 ++++++++++++
 drivers/hv/hyperv_vmbus.h       |   15 ---------------
 2 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index aaf59b7..188ddfd 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -13,6 +13,18 @@ struct ms_hyperv_info {
 
 extern struct ms_hyperv_info ms_hyperv;
 
+/*
+ * Declare the MSR used to setup pages used to communicate with the hypervisor.
+ */
+union hv_x64_msr_hypercall_contents {
+	u64 as_uint64;
+	struct {
+		u64 enable:1;
+		u64 reserved:11;
+		u64 guest_physical_address:52;
+	};
+};
+
 void hyperv_callback_vector(void);
 #ifdef CONFIG_TRACING
 #define trace_hyperv_callback_vector hyperv_callback_vector
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 83beea7..a1ff036 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -306,21 +306,6 @@ enum hv_guest_os_microsoft_ids {
 	};
 };
 
-/*
- * Declare the MSR used to setup pages used to communicate with the hypervisor.
- */
-#define HV_X64_MSR_HYPERCALL	0x40000001
-
-union hv_x64_msr_hypercall_contents {
-	u64 as_uint64;
-	struct {
-		u64 enable:1;
-		u64 reserved:11;
-		u64 guest_physical_address:52;
-	};
-};
-
-
 enum {
 	VMBUS_MESSAGE_CONNECTION_ID	= 1,
 	VMBUS_MESSAGE_PORT_ID		= 1,
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 02/18] Drivers: hv: vmbus: Move the definition of generate_guest_id()
  2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
@ 2016-12-30 21:35   ` kys
  2016-12-30 21:35   ` [PATCH 03/18] Drivers: hv vmbus: Move Hypercall page setup out of common code kys
                     ` (16 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: kys @ 2016-12-30 21:35 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa
  Cc: K. Y. Srinivasan

From: K. Y. Srinivasan <kys@microsoft.com>

As part of the effort to separate out architecture specific code, move the
definition of generate_guest_id() to x86 specific header file.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 arch/x86/include/asm/mshyperv.h |   43 +++++++++++++++++++++++++++++++++++++++
 drivers/hv/hyperv_vmbus.h       |   43 ---------------------------------------
 2 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 188ddfd..15a0c27 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -25,6 +25,49 @@ struct ms_hyperv_info {
 	};
 };
 
+/*
+ * The guest OS needs to register the guest ID with the hypervisor.
+ * The guest ID is a 64 bit entity and the structure of this ID is
+ * specified in the Hyper-V specification:
+ *
+ * msdn.microsoft.com/en-us/library/windows/hardware/ff542653%28v=vs.85%29.aspx
+ *
+ * While the current guideline does not specify how Linux guest ID(s)
+ * need to be generated, our plan is to publish the guidelines for
+ * Linux and other guest operating systems that currently are hosted
+ * on Hyper-V. The implementation here conforms to this yet
+ * unpublished guidelines.
+ *
+ *
+ * Bit(s)
+ * 63 - Indicates if the OS is Open Source or not; 1 is Open Source
+ * 62:56 - Os Type; Linux is 0x100
+ * 55:48 - Distro specific identification
+ * 47:16 - Linux kernel version number
+ * 15:0  - Distro specific identification
+ *
+ *
+ */
+
+#define HV_LINUX_VENDOR_ID              0x8800
+
+/*
+ * Generate the guest ID based on the guideline described above.
+ */
+
+static inline  __u64 generate_guest_id(__u64 d_info1, __u64 kernel_version,
+				       __u64 d_info2)
+{
+	__u64 guest_id = 0;
+
+	guest_id = (((__u64)HV_LINUX_VENDOR_ID) << 56);
+	guest_id |= (d_info1 << 48);
+	guest_id |= (kernel_version << 16);
+	guest_id |= d_info2;
+
+	return guest_id;
+}
+
 void hyperv_callback_vector(void);
 #ifdef CONFIG_TRACING
 #define trace_hyperv_callback_vector hyperv_callback_vector
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index a1ff036..da57626 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -320,49 +320,6 @@ enum {
 
 #define HV_PRESENT_BIT			0x80000000
 
-/*
- * The guest OS needs to register the guest ID with the hypervisor.
- * The guest ID is a 64 bit entity and the structure of this ID is
- * specified in the Hyper-V specification:
- *
- * http://msdn.microsoft.com/en-us/library/windows/hardware/ff542653%28v=vs.85%29.aspx
- *
- * While the current guideline does not specify how Linux guest ID(s)
- * need to be generated, our plan is to publish the guidelines for
- * Linux and other guest operating systems that currently are hosted
- * on Hyper-V. The implementation here conforms to this yet
- * unpublished guidelines.
- *
- *
- * Bit(s)
- * 63 - Indicates if the OS is Open Source or not; 1 is Open Source
- * 62:56 - Os Type; Linux is 0x100
- * 55:48 - Distro specific identification
- * 47:16 - Linux kernel version number
- * 15:0  - Distro specific identification
- *
- *
- */
-
-#define HV_LINUX_VENDOR_ID		0x8100
-
-/*
- * Generate the guest ID based on the guideline described above.
- */
-
-static inline  __u64 generate_guest_id(__u8 d_info1, __u32 kernel_version,
-					__u16 d_info2)
-{
-	__u64 guest_id = 0;
-
-	guest_id = (((__u64)HV_LINUX_VENDOR_ID) << 48);
-	guest_id |= (((__u64)(d_info1)) << 48);
-	guest_id |= (((__u64)(kernel_version)) << 16);
-	guest_id |= ((__u64)(d_info2));
-
-	return guest_id;
-}
-
 
 #define HV_CPU_POWER_MANAGEMENT		(1 << 0)
 #define HV_RECOMMENDATIONS_MAX		4
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 03/18] Drivers: hv vmbus: Move Hypercall page setup out of common code
  2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
  2016-12-30 21:35   ` [PATCH 02/18] Drivers: hv: vmbus: Move the definition of generate_guest_id() kys
@ 2016-12-30 21:35   ` kys
  2016-12-30 21:35   ` [PATCH 04/18] Drivers: hv: vmbus: Move Hypercall invocation code " kys
                     ` (15 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: kys @ 2016-12-30 21:35 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa
  Cc: K. Y. Srinivasan

From: K. Y. Srinivasan <kys@microsoft.com>

As part of the effort to separate out architecture specific code, move the
hypercall page setup to an architecture specific file.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 arch/x86/Kbuild                 |    3 ++
 arch/x86/hyperv/Makefile        |    1 +
 arch/x86/hyperv/hv_init.c       |   62 +++++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/mshyperv.h |    5 +++
 arch/x86/kernel/cpu/mshyperv.c  |    7 ++++
 drivers/hv/hv.c                 |   45 ++--------------------------
 6 files changed, 81 insertions(+), 42 deletions(-)
 create mode 100644 arch/x86/hyperv/Makefile
 create mode 100644 arch/x86/hyperv/hv_init.c

diff --git a/arch/x86/Kbuild b/arch/x86/Kbuild
index eb3abf8..586b786 100644
--- a/arch/x86/Kbuild
+++ b/arch/x86/Kbuild
@@ -7,6 +7,9 @@ obj-$(CONFIG_KVM) += kvm/
 # Xen paravirtualization support
 obj-$(CONFIG_XEN) += xen/
 
+# Hyper-V paravirtualization support
+obj-$(CONFIG_HYPERVISOR_GUEST) += hyperv/
+
 # lguest paravirtualization support
 obj-$(CONFIG_LGUEST_GUEST) += lguest/
 
diff --git a/arch/x86/hyperv/Makefile b/arch/x86/hyperv/Makefile
new file mode 100644
index 0000000..171ae09
--- /dev/null
+++ b/arch/x86/hyperv/Makefile
@@ -0,0 +1 @@
+obj-y		:= hv_init.o
diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
new file mode 100644
index 0000000..3206bfda
--- /dev/null
+++ b/arch/x86/hyperv/hv_init.c
@@ -0,0 +1,62 @@
+/*
+ * X86 specific Hyper-V initialization code.
+ *
+ * Copyright (C) 2016, Microsoft, Inc.
+ *
+ * Author : K. Y. Srinivasan <kys@microsoft.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ *
+ */
+
+#include <linux/types.h>
+#include <asm/hypervisor.h>
+#include <asm/hyperv.h>
+#include <asm/mshyperv.h>
+#include <linux/version.h>
+#include <linux/vmalloc.h>
+#include <linux/mm.h>
+
+void *hv_hypercall_pg;
+/*
+ * This function is to be invoked early in the boot sequence after the
+ * hypervisor has been detected.
+ *
+ * 1. Setup the hypercall page.
+ */
+void hyperv_init(void)
+{
+	u64 guest_id;
+	union hv_x64_msr_hypercall_contents hypercall_msr;
+
+	if (x86_hyper != &x86_hyper_ms_hyperv)
+		return;
+
+	/*
+	 * Setup the hypercall page and enable hypercalls.
+	 * 1. Register the guest ID
+	 * 2. Enable the hypercall and register the hypercall page
+	 */
+	guest_id = generate_guest_id(0, LINUX_VERSION_CODE, 0);
+	wrmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id);
+
+	hv_hypercall_pg  = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_EXEC);
+	if (hv_hypercall_pg == NULL) {
+		wrmsrl(HV_X64_MSR_GUEST_OS_ID, 0);
+		return;
+	}
+
+	rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
+	hypercall_msr.enable = 1;
+	hypercall_msr.guest_physical_address = vmalloc_to_pfn(hv_hypercall_pg);
+	wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
+}
+EXPORT_SYMBOL_GPL(hv_hypercall_pg);
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 15a0c27..e5f57e1 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -80,4 +80,9 @@ static inline  __u64 generate_guest_id(__u64 d_info1, __u64 kernel_version,
 void hv_remove_kexec_handler(void);
 void hv_setup_crash_handler(void (*handler)(struct pt_regs *regs));
 void hv_remove_crash_handler(void);
+
+#if IS_ENABLED(CONFIG_HYPERV)
+void hyperv_init(void);
+extern void *hv_hypercall_pg;
+#endif
 #endif
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 8f44c5a..8b376f8 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -204,6 +204,13 @@ static void __init ms_hyperv_init_platform(void)
 	 */
 	if (efi_enabled(EFI_BOOT))
 		x86_platform.get_nmi_reason = hv_get_nmi_reason;
+
+#if IS_ENABLED(CONFIG_HYPERV)
+	/*
+	 * Setup the hook to get control post apic initialization.
+	 */
+	x86_platform.apic_post_init = hyperv_init;
+#endif
 }
 
 const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 04a0fd8..a11e827 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -193,7 +193,6 @@ int hv_init(void)
 {
 	int max_leaf;
 	union hv_x64_msr_hypercall_contents hypercall_msr;
-	void *virtaddr = NULL;
 
 	memset(hv_context.synic_event_page, 0, sizeof(void *) * NR_CPUS);
 	memset(hv_context.synic_message_page, 0,
@@ -211,33 +210,15 @@ int hv_init(void)
 
 	max_leaf = query_hypervisor_info();
 
-	/*
-	 * Write our OS ID.
-	 */
-	hv_context.guestid = generate_guest_id(0, LINUX_VERSION_CODE, 0);
-	wrmsrl(HV_X64_MSR_GUEST_OS_ID, hv_context.guestid);
 
 	/* See if the hypercall page is already set */
-	rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
-
-	virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_EXEC);
-
-	if (!virtaddr)
-		goto cleanup;
-
-	hypercall_msr.enable = 1;
-
-	hypercall_msr.guest_physical_address = vmalloc_to_pfn(virtaddr);
-	wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
-
-	/* Confirm that hypercall page did get setup. */
 	hypercall_msr.as_uint64 = 0;
 	rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
 
 	if (!hypercall_msr.enable)
-		goto cleanup;
+		return -ENOTSUPP;
 
-	hv_context.hypercall_page = virtaddr;
+	hv_context.hypercall_page = hv_hypercall_pg;
 
 #ifdef CONFIG_X86_64
 	if (ms_hyperv.features & HV_X64_MSR_REFERENCE_TSC_AVAILABLE) {
@@ -261,15 +242,6 @@ int hv_init(void)
 	return 0;
 
 cleanup:
-	if (virtaddr) {
-		if (hypercall_msr.enable) {
-			hypercall_msr.as_uint64 = 0;
-			wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
-		}
-
-		vfree(virtaddr);
-	}
-
 	return -ENOTSUPP;
 }
 
@@ -280,20 +252,9 @@ int hv_init(void)
  */
 void hv_cleanup(bool crash)
 {
-	union hv_x64_msr_hypercall_contents hypercall_msr;
-
-	/* Reset our OS id */
-	wrmsrl(HV_X64_MSR_GUEST_OS_ID, 0);
-
-	if (hv_context.hypercall_page) {
-		hypercall_msr.as_uint64 = 0;
-		wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
-		if (!crash)
-			vfree(hv_context.hypercall_page);
-		hv_context.hypercall_page = NULL;
-	}
 
 #ifdef CONFIG_X86_64
+	union hv_x64_msr_hypercall_contents hypercall_msr;
 	/*
 	 * Cleanup the TSC page based CS.
 	 */
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 04/18] Drivers: hv: vmbus: Move Hypercall invocation code out of common code
  2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
  2016-12-30 21:35   ` [PATCH 02/18] Drivers: hv: vmbus: Move the definition of generate_guest_id() kys
  2016-12-30 21:35   ` [PATCH 03/18] Drivers: hv vmbus: Move Hypercall page setup out of common code kys
@ 2016-12-30 21:35   ` kys
  2016-12-30 21:35   ` [PATCH 05/18] Drivers: hv: vmbus: Consolidate all Hyper-V specific clocksource code kys
                     ` (14 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: kys @ 2016-12-30 21:35 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa
  Cc: K. Y. Srinivasan

From: K. Y. Srinivasan <kys@microsoft.com>

As part of the effort to separate out architecture specific code, move the
hypercall invocation code to an architecture specific file.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 arch/x86/hyperv/hv_init.c       |   54 +++++++++++++++++++++++++++++++++++---
 arch/x86/include/asm/mshyperv.h |    1 -
 drivers/hv/hv.c                 |   52 -------------------------------------
 drivers/hv/hyperv_vmbus.h       |    1 -
 4 files changed, 49 insertions(+), 59 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index 3206bfda..b5c8e04 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -25,7 +25,7 @@
 #include <linux/vmalloc.h>
 #include <linux/mm.h>
 
-void *hv_hypercall_pg;
+static void *hypercall_pg;
 /*
  * This function is to be invoked early in the boot sequence after the
  * hypervisor has been detected.
@@ -48,15 +48,59 @@ void hyperv_init(void)
 	guest_id = generate_guest_id(0, LINUX_VERSION_CODE, 0);
 	wrmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id);
 
-	hv_hypercall_pg  = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_EXEC);
-	if (hv_hypercall_pg == NULL) {
+	hypercall_pg  = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_EXEC);
+	if (hypercall_pg == NULL) {
 		wrmsrl(HV_X64_MSR_GUEST_OS_ID, 0);
 		return;
 	}
 
 	rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
 	hypercall_msr.enable = 1;
-	hypercall_msr.guest_physical_address = vmalloc_to_pfn(hv_hypercall_pg);
+	hypercall_msr.guest_physical_address = vmalloc_to_pfn(hypercall_pg);
 	wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
 }
-EXPORT_SYMBOL_GPL(hv_hypercall_pg);
+
+/*
+ * hv_do_hypercall- Invoke the specified hypercall
+ */
+u64 hv_do_hypercall(u64 control, void *input, void *output)
+{
+	u64 input_address = (input) ? virt_to_phys(input) : 0;
+	u64 output_address = (output) ? virt_to_phys(output) : 0;
+#ifdef CONFIG_X86_64
+	u64 hv_status = 0;
+
+	if (!hypercall_pg)
+		return (u64)ULLONG_MAX;
+
+	__asm__ __volatile__("mov %0, %%r8" : : "r" (output_address) : "r8");
+	__asm__ __volatile__("call *%3" : "=a" (hv_status) :
+			     "c" (control), "d" (input_address),
+			     "m" (hypercall_pg));
+
+	return hv_status;
+
+#else
+
+	u32 control_hi = control >> 32;
+	u32 control_lo = control & 0xFFFFFFFF;
+	u32 hv_status_hi = 1;
+	u32 hv_status_lo = 1;
+	u32 input_address_hi = input_address >> 32;
+	u32 input_address_lo = input_address & 0xFFFFFFFF;
+	u32 output_address_hi = output_address >> 32;
+	u32 output_address_lo = output_address & 0xFFFFFFFF;
+
+	if (!hypercall_pg)
+		return (u64)ULLONG_MAX;
+
+	__asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
+			      "=a"(hv_status_lo) : "d" (control_hi),
+			      "a" (control_lo), "b" (input_address_hi),
+			      "c" (input_address_lo), "D"(output_address_hi),
+			      "S"(output_address_lo), "m" (hypercall_pg));
+
+	return hv_status_lo | ((u64)hv_status_hi << 32);
+#endif /* !x86_64 */
+}
+EXPORT_SYMBOL_GPL(hv_do_hypercall);
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index e5f57e1..ed8e073 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -83,6 +83,5 @@ static inline  __u64 generate_guest_id(__u64 d_info1, __u64 kernel_version,
 
 #if IS_ENABLED(CONFIG_HYPERV)
 void hyperv_init(void);
-extern void *hv_hypercall_pg;
 #endif
 #endif
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index a11e827..11388d3 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -36,7 +36,6 @@
 /* The one and only */
 struct hv_context hv_context = {
 	.synic_initialized	= false,
-	.hypercall_page		= NULL,
 };
 
 #define HV_TIMER_FREQUENCY (10 * 1000 * 1000) /* 100ns period */
@@ -88,52 +87,6 @@ static int query_hypervisor_info(void)
 	return max_leaf;
 }
 
-/*
- * hv_do_hypercall- Invoke the specified hypercall
- */
-u64 hv_do_hypercall(u64 control, void *input, void *output)
-{
-	u64 input_address = (input) ? virt_to_phys(input) : 0;
-	u64 output_address = (output) ? virt_to_phys(output) : 0;
-	void *hypercall_page = hv_context.hypercall_page;
-#ifdef CONFIG_X86_64
-	u64 hv_status = 0;
-
-	if (!hypercall_page)
-		return (u64)ULLONG_MAX;
-
-	__asm__ __volatile__("mov %0, %%r8" : : "r" (output_address) : "r8");
-	__asm__ __volatile__("call *%3" : "=a" (hv_status) :
-			     "c" (control), "d" (input_address),
-			     "m" (hypercall_page));
-
-	return hv_status;
-
-#else
-
-	u32 control_hi = control >> 32;
-	u32 control_lo = control & 0xFFFFFFFF;
-	u32 hv_status_hi = 1;
-	u32 hv_status_lo = 1;
-	u32 input_address_hi = input_address >> 32;
-	u32 input_address_lo = input_address & 0xFFFFFFFF;
-	u32 output_address_hi = output_address >> 32;
-	u32 output_address_lo = output_address & 0xFFFFFFFF;
-
-	if (!hypercall_page)
-		return (u64)ULLONG_MAX;
-
-	__asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
-			      "=a"(hv_status_lo) : "d" (control_hi),
-			      "a" (control_lo), "b" (input_address_hi),
-			      "c" (input_address_lo), "D"(output_address_hi),
-			      "S"(output_address_lo), "m" (hypercall_page));
-
-	return hv_status_lo | ((u64)hv_status_hi << 32);
-#endif /* !x86_64 */
-}
-EXPORT_SYMBOL_GPL(hv_do_hypercall);
-
 #ifdef CONFIG_X86_64
 static cycle_t read_hv_clock_tsc(struct clocksource *arg)
 {
@@ -218,8 +171,6 @@ int hv_init(void)
 	if (!hypercall_msr.enable)
 		return -ENOTSUPP;
 
-	hv_context.hypercall_page = hv_hypercall_pg;
-
 #ifdef CONFIG_X86_64
 	if (ms_hyperv.features & HV_X64_MSR_REFERENCE_TSC_AVAILABLE) {
 		union hv_x64_msr_hypercall_contents tsc_msr;
@@ -466,9 +417,6 @@ int hv_synic_init(unsigned int cpu)
 	union hv_synic_scontrol sctrl;
 	u64 vp_index;
 
-	if (!hv_context.hypercall_page)
-		return -EFAULT;
-
 	/* Check the version */
 	rdmsrl(HV_X64_MSR_SVERSION, version);
 
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index da57626..0948526 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -371,7 +371,6 @@ struct hv_context {
 	*/
 	u64 guestid;
 
-	void *hypercall_page;
 	void *tsc_page;
 
 	bool synic_initialized;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 05/18] Drivers: hv: vmbus: Consolidate all Hyper-V specific clocksource code
  2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
                     ` (2 preceding siblings ...)
  2016-12-30 21:35   ` [PATCH 04/18] Drivers: hv: vmbus: Move Hypercall invocation code " kys
@ 2016-12-30 21:35   ` kys
  2016-12-30 21:36   ` [PATCH 06/18] Drivers: hv: vmbus: Move the extracting of Hypervisor version information kys
                     ` (13 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: kys @ 2016-12-30 21:35 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa
  Cc: K. Y. Srinivasan

From: K. Y. Srinivasan <kys@microsoft.com>

As part of the effort to separate out architecture specific code,
consolidate all Hyper-V specific clocksource code to an architecture
specific code.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 arch/x86/hyperv/hv_init.c       |  104 +++++++++++++++++++++++++++++++++++++++
 arch/x86/include/asm/mshyperv.h |   12 +++++
 arch/x86/kernel/cpu/mshyperv.c  |   23 ---------
 drivers/hv/hv.c                 |   95 -----------------------------------
 drivers/hv/hyperv_vmbus.h       |    8 ---
 5 files changed, 116 insertions(+), 126 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index b5c8e04..940a970 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -24,6 +24,79 @@
 #include <linux/version.h>
 #include <linux/vmalloc.h>
 #include <linux/mm.h>
+#include <linux/clockchips.h>
+
+
+#ifdef CONFIG_X86_64
+
+static struct ms_hyperv_tsc_page *tsc_pg;
+
+static cycle_t read_hv_clock_tsc(struct clocksource *arg)
+{
+	cycle_t current_tick;
+
+	if (tsc_pg->tsc_sequence != 0) {
+		/*
+		 * Use the tsc page to compute the value.
+		 */
+
+		while (1) {
+			cycle_t tmp;
+			u32 sequence = tsc_pg->tsc_sequence;
+			u64 cur_tsc;
+			u64 scale = tsc_pg->tsc_scale;
+			s64 offset = tsc_pg->tsc_offset;
+
+			rdtscll(cur_tsc);
+			/* current_tick = ((cur_tsc *scale) >> 64) + offset */
+			asm("mulq %3"
+				: "=d" (current_tick), "=a" (tmp)
+				: "a" (cur_tsc), "r" (scale));
+
+			current_tick += offset;
+			if (tsc_pg->tsc_sequence == sequence)
+				return current_tick;
+
+			if (tsc_pg->tsc_sequence != 0)
+				continue;
+			/*
+			 * Fallback using MSR method.
+			 */
+			break;
+		}
+	}
+	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
+	return current_tick;
+}
+
+static struct clocksource hyperv_cs_tsc = {
+		.name		= "hyperv_clocksource_tsc_page",
+		.rating		= 400,
+		.read		= read_hv_clock_tsc,
+		.mask		= CLOCKSOURCE_MASK(64),
+		.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+};
+#endif
+
+static cycle_t read_hv_clock_msr(struct clocksource *arg)
+{
+	cycle_t current_tick;
+	/*
+	 * Read the partition counter to get the current tick count. This count
+	 * is set to 0 when the partition is created and is incremented in
+	 * 100 nanosecond units.
+	 */
+	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
+	return current_tick;
+}
+
+static struct clocksource hyperv_cs_msr = {
+	.name		= "hyperv_clocksource_msr",
+	.rating		= 400,
+	.read		= read_hv_clock_msr,
+	.mask		= CLOCKSOURCE_MASK(64),
+	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+};
 
 static void *hypercall_pg;
 /*
@@ -31,6 +104,7 @@
  * hypervisor has been detected.
  *
  * 1. Setup the hypercall page.
+ * 2. Register Hyper-V specific clocksource.
  */
 void hyperv_init(void)
 {
@@ -58,6 +132,36 @@ void hyperv_init(void)
 	hypercall_msr.enable = 1;
 	hypercall_msr.guest_physical_address = vmalloc_to_pfn(hypercall_pg);
 	wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
+
+	/*
+	 * Register Hyper-V specific clocksource.
+	 */
+#ifdef CONFIG_X86_64
+	if (ms_hyperv.features & HV_X64_MSR_REFERENCE_TSC_AVAILABLE) {
+		union hv_x64_msr_hypercall_contents tsc_msr;
+
+		tsc_pg = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL);
+		if (!tsc_pg)
+			clocksource_register_hz(&hyperv_cs_msr, NSEC_PER_SEC/100);
+			return;
+
+		rdmsrl(HV_X64_MSR_REFERENCE_TSC, tsc_msr.as_uint64);
+
+		tsc_msr.enable = 1;
+		tsc_msr.guest_physical_address = vmalloc_to_pfn(tsc_pg);
+
+		wrmsrl(HV_X64_MSR_REFERENCE_TSC, tsc_msr.as_uint64);
+		clocksource_register_hz(&hyperv_cs_tsc, NSEC_PER_SEC/100);
+		return;
+	}
+#endif
+	/*
+	 * For 32 bit guests just use the MSR based mechanism for reading
+	 * the partition counter.
+	 */
+
+	if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE)
+		clocksource_register_hz(&hyperv_cs_msr, NSEC_PER_SEC/100);
 }
 
 /*
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index ed8e073..adfe8cc 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -26,6 +26,18 @@ struct ms_hyperv_info {
 };
 
 /*
+ * TSC page layout.
+ */
+
+struct ms_hyperv_tsc_page {
+	volatile u32 tsc_sequence;
+	u32 reserved1;
+	volatile u64 tsc_scale;
+	volatile s64 tsc_offset;
+	u64 reserved2[509];
+};
+
+/*
  * The guest OS needs to register the guest ID with the hypervisor.
  * The guest ID is a 64 bit entity and the structure of this ID is
  * specified in the Hyper-V specification:
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 8b376f8..6afb517 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -133,26 +133,6 @@ static uint32_t  __init ms_hyperv_platform(void)
 	return 0;
 }
 
-static cycle_t read_hv_clock(struct clocksource *arg)
-{
-	cycle_t current_tick;
-	/*
-	 * Read the partition counter to get the current tick count. This count
-	 * is set to 0 when the partition is created and is incremented in
-	 * 100 nanosecond units.
-	 */
-	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
-	return current_tick;
-}
-
-static struct clocksource hyperv_cs = {
-	.name		= "hyperv_clocksource",
-	.rating		= 400, /* use this when running on Hyperv*/
-	.read		= read_hv_clock,
-	.mask		= CLOCKSOURCE_MASK(64),
-	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
-};
-
 static unsigned char hv_get_nmi_reason(void)
 {
 	return 0;
@@ -185,9 +165,6 @@ static void __init ms_hyperv_init_platform(void)
 	}
 #endif
 
-	if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE)
-		clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
-
 #ifdef CONFIG_X86_IO_APIC
 	no_timer_check = 1;
 #endif
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 11388d3..607d477 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -87,56 +87,6 @@ static int query_hypervisor_info(void)
 	return max_leaf;
 }
 
-#ifdef CONFIG_X86_64
-static cycle_t read_hv_clock_tsc(struct clocksource *arg)
-{
-	cycle_t current_tick;
-	struct ms_hyperv_tsc_page *tsc_pg = hv_context.tsc_page;
-
-	if (tsc_pg->tsc_sequence != 0) {
-		/*
-		 * Use the tsc page to compute the value.
-		 */
-
-		while (1) {
-			cycle_t tmp;
-			u32 sequence = tsc_pg->tsc_sequence;
-			u64 cur_tsc;
-			u64 scale = tsc_pg->tsc_scale;
-			s64 offset = tsc_pg->tsc_offset;
-
-			rdtscll(cur_tsc);
-			/* current_tick = ((cur_tsc *scale) >> 64) + offset */
-			asm("mulq %3"
-				: "=d" (current_tick), "=a" (tmp)
-				: "a" (cur_tsc), "r" (scale));
-
-			current_tick += offset;
-			if (tsc_pg->tsc_sequence == sequence)
-				return current_tick;
-
-			if (tsc_pg->tsc_sequence != 0)
-				continue;
-			/*
-			 * Fallback using MSR method.
-			 */
-			break;
-		}
-	}
-	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
-	return current_tick;
-}
-
-static struct clocksource hyperv_cs_tsc = {
-		.name           = "hyperv_clocksource_tsc_page",
-		.rating         = 425,
-		.read           = read_hv_clock_tsc,
-		.mask           = CLOCKSOURCE_MASK(64),
-		.flags          = CLOCK_SOURCE_IS_CONTINUOUS,
-};
-#endif
-
-
 /*
  * hv_init - Main initialization routine.
  *
@@ -171,29 +121,7 @@ int hv_init(void)
 	if (!hypercall_msr.enable)
 		return -ENOTSUPP;
 
-#ifdef CONFIG_X86_64
-	if (ms_hyperv.features & HV_X64_MSR_REFERENCE_TSC_AVAILABLE) {
-		union hv_x64_msr_hypercall_contents tsc_msr;
-		void *va_tsc;
-
-		va_tsc = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL);
-		if (!va_tsc)
-			goto cleanup;
-		hv_context.tsc_page = va_tsc;
-
-		rdmsrl(HV_X64_MSR_REFERENCE_TSC, tsc_msr.as_uint64);
-
-		tsc_msr.enable = 1;
-		tsc_msr.guest_physical_address = vmalloc_to_pfn(va_tsc);
-
-		wrmsrl(HV_X64_MSR_REFERENCE_TSC, tsc_msr.as_uint64);
-		clocksource_register_hz(&hyperv_cs_tsc, NSEC_PER_SEC/100);
-	}
-#endif
 	return 0;
-
-cleanup:
-	return -ENOTSUPP;
 }
 
 /*
@@ -204,29 +132,6 @@ int hv_init(void)
 void hv_cleanup(bool crash)
 {
 
-#ifdef CONFIG_X86_64
-	union hv_x64_msr_hypercall_contents hypercall_msr;
-	/*
-	 * Cleanup the TSC page based CS.
-	 */
-	if (ms_hyperv.features & HV_X64_MSR_REFERENCE_TSC_AVAILABLE) {
-		/*
-		 * Crash can happen in an interrupt context and unregistering
-		 * a clocksource is impossible and redundant in this case.
-		 */
-		if (!oops_in_progress) {
-			clocksource_change_rating(&hyperv_cs_tsc, 10);
-			clocksource_unregister(&hyperv_cs_tsc);
-		}
-
-		hypercall_msr.as_uint64 = 0;
-		wrmsrl(HV_X64_MSR_REFERENCE_TSC, hypercall_msr.as_uint64);
-		if (!crash) {
-			vfree(hv_context.tsc_page);
-			hv_context.tsc_page = NULL;
-		}
-	}
-#endif
 }
 
 /*
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 0948526..947455d 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -416,14 +416,6 @@ struct hv_context {
 
 extern struct hv_context hv_context;
 
-struct ms_hyperv_tsc_page {
-	volatile u32 tsc_sequence;
-	u32 reserved1;
-	volatile u64 tsc_scale;
-	volatile s64 tsc_offset;
-	u64 reserved2[509];
-};
-
 struct hv_ring_buffer_debug_info {
 	u32 current_interrupt_mask;
 	u32 current_read_index;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 06/18] Drivers: hv: vmbus: Move the extracting of Hypervisor version information
  2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
                     ` (3 preceding siblings ...)
  2016-12-30 21:35   ` [PATCH 05/18] Drivers: hv: vmbus: Consolidate all Hyper-V specific clocksource code kys
@ 2016-12-30 21:36   ` kys
  2016-12-30 21:36   ` [PATCH 07/18] Drivers: hv: vmbus: Move the crash notification function kys
                     ` (12 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: kys @ 2016-12-30 21:36 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa
  Cc: K. Y. Srinivasan

From: K. Y. Srinivasan <kys@microsoft.com>

As part of the effort to separate out architecture specific code,
extract hypervisor version information in an architecture specific
file.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 arch/x86/include/asm/mshyperv.h |   19 +++++++++++++++
 arch/x86/kernel/cpu/mshyperv.c  |   20 ++++++++++++++++
 drivers/hv/connection.c         |    7 +----
 drivers/hv/hv.c                 |   49 ---------------------------------------
 drivers/hv/hyperv_vmbus.h       |   27 ---------------------
 5 files changed, 41 insertions(+), 81 deletions(-)

diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index adfe8cc..54729e3 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -5,6 +5,25 @@
 #include <linux/interrupt.h>
 #include <asm/hyperv.h>
 
+/*
+ * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
+ * is set by CPUID(HVCPUID_VERSION_FEATURES).
+ */
+enum hv_cpuid_function {
+	HVCPUID_VERSION_FEATURES		= 0x00000001,
+	HVCPUID_VENDOR_MAXFUNCTION		= 0x40000000,
+	HVCPUID_INTERFACE			= 0x40000001,
+
+	/*
+	 * The remaining functions depend on the value of
+	 * HVCPUID_INTERFACE
+	 */
+	HVCPUID_VERSION				= 0x40000002,
+	HVCPUID_FEATURES			= 0x40000003,
+	HVCPUID_ENLIGHTENMENT_INFO		= 0x40000004,
+	HVCPUID_IMPLEMENTATION_LIMITS		= 0x40000005,
+};
+
 struct ms_hyperv_info {
 	u32 features;
 	u32 misc_features;
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 6afb517..2d5c89a9 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -140,6 +140,11 @@ static unsigned char hv_get_nmi_reason(void)
 
 static void __init ms_hyperv_init_platform(void)
 {
+	int hv_host_info_eax;
+	int hv_host_info_ebx;
+	int hv_host_info_ecx;
+	int hv_host_info_edx;
+
 	/*
 	 * Extract the features and hints
 	 */
@@ -150,6 +155,21 @@ static void __init ms_hyperv_init_platform(void)
 	pr_info("HyperV: features 0x%x, hints 0x%x\n",
 		ms_hyperv.features, ms_hyperv.hints);
 
+	/*
+	 * Extract host information.
+	 */
+	if (cpuid_eax(HVCPUID_VENDOR_MAXFUNCTION) >= HVCPUID_VERSION) {
+		hv_host_info_eax = cpuid_eax(HVCPUID_VERSION);
+		hv_host_info_ebx = cpuid_ebx(HVCPUID_VERSION);
+		hv_host_info_ecx = cpuid_ecx(HVCPUID_VERSION);
+		hv_host_info_edx = cpuid_edx(HVCPUID_VERSION);
+
+		pr_info("Hyper-V Host Build:%d-%d.%d-%d-%d.%d\n",
+			hv_host_info_eax, hv_host_info_ebx >> 16,
+			hv_host_info_ebx & 0xFFFF, hv_host_info_ecx,
+			hv_host_info_edx >> 24, hv_host_info_edx & 0xFFFFFF);
+	}
+
 #ifdef CONFIG_X86_LOCAL_APIC
 	if (ms_hyperv.features & HV_X64_MSR_APIC_FREQUENCY_AVAILABLE) {
 		/*
diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 9b72ebc..307a5a8 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -221,11 +221,8 @@ int vmbus_connect(void)
 		goto cleanup;
 
 	vmbus_proto_version = version;
-	pr_info("Hyper-V Host Build:%d-%d.%d-%d-%d.%d; Vmbus version:%d.%d\n",
-		    host_info_eax, host_info_ebx >> 16,
-		    host_info_ebx & 0xFFFF, host_info_ecx,
-		    host_info_edx >> 24, host_info_edx & 0xFFFFFF,
-		    version >> 16, version & 0xFFFF);
+	pr_info("Vmbus version:%d.%d\n",
+		version >> 16, version & 0xFFFF);
 
 	kfree(msginfo);
 	return 0;
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 607d477..55b85c3 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -43,58 +43,12 @@ struct hv_context hv_context = {
 #define HV_MIN_DELTA_TICKS 1
 
 /*
- * query_hypervisor_info - Get version info of the windows hypervisor
- */
-unsigned int host_info_eax;
-unsigned int host_info_ebx;
-unsigned int host_info_ecx;
-unsigned int host_info_edx;
-
-static int query_hypervisor_info(void)
-{
-	unsigned int eax;
-	unsigned int ebx;
-	unsigned int ecx;
-	unsigned int edx;
-	unsigned int max_leaf;
-	unsigned int op;
-
-	/*
-	* Its assumed that this is called after confirming that Viridian
-	* is present. Query id and revision.
-	*/
-	eax = 0;
-	ebx = 0;
-	ecx = 0;
-	edx = 0;
-	op = HVCPUID_VENDOR_MAXFUNCTION;
-	cpuid(op, &eax, &ebx, &ecx, &edx);
-
-	max_leaf = eax;
-
-	if (max_leaf >= HVCPUID_VERSION) {
-		eax = 0;
-		ebx = 0;
-		ecx = 0;
-		edx = 0;
-		op = HVCPUID_VERSION;
-		cpuid(op, &eax, &ebx, &ecx, &edx);
-		host_info_eax = eax;
-		host_info_ebx = ebx;
-		host_info_ecx = ecx;
-		host_info_edx = edx;
-	}
-	return max_leaf;
-}
-
-/*
  * hv_init - Main initialization routine.
  *
  * This routine must be called before any other routines in here are called
  */
 int hv_init(void)
 {
-	int max_leaf;
 	union hv_x64_msr_hypercall_contents hypercall_msr;
 
 	memset(hv_context.synic_event_page, 0, sizeof(void *) * NR_CPUS);
@@ -111,9 +65,6 @@ int hv_init(void)
 	memset(hv_context.clk_evt, 0,
 	       sizeof(void *) * NR_CPUS);
 
-	max_leaf = query_hypervisor_info();
-
-
 	/* See if the hypercall page is already set */
 	hypercall_msr.as_uint64 = 0;
 	rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 947455d..a7e35c8 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -40,25 +40,6 @@
  */
 #define HV_UTIL_NEGO_TIMEOUT 55
 
-/*
- * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
- * is set by CPUID(HVCPUID_VERSION_FEATURES).
- */
-enum hv_cpuid_function {
-	HVCPUID_VERSION_FEATURES		= 0x00000001,
-	HVCPUID_VENDOR_MAXFUNCTION		= 0x40000000,
-	HVCPUID_INTERFACE			= 0x40000001,
-
-	/*
-	 * The remaining functions depend on the value of
-	 * HVCPUID_INTERFACE
-	 */
-	HVCPUID_VERSION			= 0x40000002,
-	HVCPUID_FEATURES			= 0x40000003,
-	HVCPUID_ENLIGHTENMENT_INFO	= 0x40000004,
-	HVCPUID_IMPLEMENTATION_LIMITS		= 0x40000005,
-};
-
 #define  HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE   0x400
 
 #define HV_X64_MSR_CRASH_P0   0x40000100
@@ -444,14 +425,6 @@ extern int hv_post_message(union hv_connection_id connection_id,
 
 extern void hv_synic_clockevents_cleanup(void);
 
-/*
- * Host version information.
- */
-extern unsigned int host_info_eax;
-extern unsigned int host_info_ebx;
-extern unsigned int host_info_ecx;
-extern unsigned int host_info_edx;
-
 /* Interface */
 
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 07/18] Drivers: hv: vmbus: Move the crash notification function
  2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
                     ` (4 preceding siblings ...)
  2016-12-30 21:36   ` [PATCH 06/18] Drivers: hv: vmbus: Move the extracting of Hypervisor version information kys
@ 2016-12-30 21:36   ` kys
  2016-12-30 21:36   ` [PATCH 08/18] Drivers: hv: vmbus: Move the check for hypercall page setup kys
                     ` (11 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: kys @ 2016-12-30 21:36 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa
  Cc: K. Y. Srinivasan

From: K. Y. Srinivasan <kys@microsoft.com>

As part of the effort to separate out architecture specific code, move the
crash notification function.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 arch/x86/hyperv/hv_init.c          |   26 ++++++++++++++++++++++++++
 arch/x86/include/asm/mshyperv.h    |    1 +
 arch/x86/include/uapi/asm/hyperv.h |    8 ++++++++
 drivers/hv/hyperv_vmbus.h          |   10 ----------
 drivers/hv/vmbus_drv.c             |   25 -------------------------
 5 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index 940a970..299cafb 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -208,3 +208,29 @@ u64 hv_do_hypercall(u64 control, void *input, void *output)
 #endif /* !x86_64 */
 }
 EXPORT_SYMBOL_GPL(hv_do_hypercall);
+
+void hyperv_report_panic(struct pt_regs *regs)
+{
+	static bool panic_reported;
+
+	/*
+	 * We prefer to report panic on 'die' chain as we have proper
+	 * registers to report, but if we miss it (e.g. on BUG()) we need
+	 * to report it on 'panic'.
+	 */
+	if (panic_reported)
+		return;
+	panic_reported = true;
+
+	wrmsrl(HV_X64_MSR_CRASH_P0, regs->ip);
+	wrmsrl(HV_X64_MSR_CRASH_P1, regs->ax);
+	wrmsrl(HV_X64_MSR_CRASH_P2, regs->bx);
+	wrmsrl(HV_X64_MSR_CRASH_P3, regs->cx);
+	wrmsrl(HV_X64_MSR_CRASH_P4, regs->dx);
+
+	/*
+	 * Let Hyper-V know there is crash data available
+	 */
+	wrmsrl(HV_X64_MSR_CRASH_CTL, HV_CRASH_CTL_CRASH_NOTIFY);
+}
+EXPORT_SYMBOL_GPL(hyperv_report_panic);
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 54729e3..64e682d 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -114,5 +114,6 @@ static inline  __u64 generate_guest_id(__u64 d_info1, __u64 kernel_version,
 
 #if IS_ENABLED(CONFIG_HYPERV)
 void hyperv_init(void);
+void hyperv_report_panic(struct pt_regs *regs);
 #endif
 #endif
diff --git a/arch/x86/include/uapi/asm/hyperv.h b/arch/x86/include/uapi/asm/hyperv.h
index 9b1a918..3a20ccf 100644
--- a/arch/x86/include/uapi/asm/hyperv.h
+++ b/arch/x86/include/uapi/asm/hyperv.h
@@ -73,6 +73,9 @@
   */
 #define HV_X64_MSR_STAT_PAGES_AVAILABLE		(1 << 8)
 
+/* Crash MSR available */
+#define HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE (1 << 10)
+
 /*
  * Feature identification: EBX indicates which flags were specified at
  * partition creation. The format is the same as the partition creation
@@ -144,6 +147,11 @@
  */
 #define HV_X64_RELAXED_TIMING_RECOMMENDED	(1 << 5)
 
+/*
+ * Crash notification flag.
+ */
+#define HV_CRASH_CTL_CRASH_NOTIFY (1ULL << 63)
+
 /* MSR used to identify the guest OS. */
 #define HV_X64_MSR_GUEST_OS_ID			0x40000000
 
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index a7e35c8..59eb28c 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -40,16 +40,6 @@
  */
 #define HV_UTIL_NEGO_TIMEOUT 55
 
-#define  HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE   0x400
-
-#define HV_X64_MSR_CRASH_P0   0x40000100
-#define HV_X64_MSR_CRASH_P1   0x40000101
-#define HV_X64_MSR_CRASH_P2   0x40000102
-#define HV_X64_MSR_CRASH_P3   0x40000103
-#define HV_X64_MSR_CRASH_P4   0x40000104
-#define HV_X64_MSR_CRASH_CTL  0x40000105
-
-#define HV_CRASH_CTL_CRASH_NOTIFY (1ULL << 63)
 
 /* Define version of the synthetic interrupt controller. */
 #define HV_SYNIC_VERSION		(1)
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 565bdd1..8e81346 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -56,31 +56,6 @@ struct vmbus_dynid {
 
 static int hyperv_cpuhp_online;
 
-static void hyperv_report_panic(struct pt_regs *regs)
-{
-	static bool panic_reported;
-
-	/*
-	 * We prefer to report panic on 'die' chain as we have proper
-	 * registers to report, but if we miss it (e.g. on BUG()) we need
-	 * to report it on 'panic'.
-	 */
-	if (panic_reported)
-		return;
-	panic_reported = true;
-
-	wrmsrl(HV_X64_MSR_CRASH_P0, regs->ip);
-	wrmsrl(HV_X64_MSR_CRASH_P1, regs->ax);
-	wrmsrl(HV_X64_MSR_CRASH_P2, regs->bx);
-	wrmsrl(HV_X64_MSR_CRASH_P3, regs->cx);
-	wrmsrl(HV_X64_MSR_CRASH_P4, regs->dx);
-
-	/*
-	 * Let Hyper-V know there is crash data available
-	 */
-	wrmsrl(HV_X64_MSR_CRASH_CTL, HV_CRASH_CTL_CRASH_NOTIFY);
-}
-
 static int hyperv_panic_event(struct notifier_block *nb, unsigned long val,
 			      void *args)
 {
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 08/18] Drivers: hv: vmbus: Move the check for hypercall page setup
  2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
                     ` (5 preceding siblings ...)
  2016-12-30 21:36   ` [PATCH 07/18] Drivers: hv: vmbus: Move the crash notification function kys
@ 2016-12-30 21:36   ` kys
  2016-12-30 21:36   ` [PATCH 09/18] Drivers: hv: vmbus: Move the code to signal end of message kys
                     ` (10 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: kys @ 2016-12-30 21:36 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa
  Cc: K. Y. Srinivasan

From: K. Y. Srinivasan <kys@microsoft.com>

As part of the effort to separate out architecture specific code, move the
check for detecting if the hypercall page is setup.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 arch/x86/hyperv/hv_init.c       |   15 +++++++++++++++
 arch/x86/include/asm/mshyperv.h |    1 +
 drivers/hv/hv.c                 |    7 +------
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index 299cafb..8c14488 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -234,3 +234,18 @@ void hyperv_report_panic(struct pt_regs *regs)
 	wrmsrl(HV_X64_MSR_CRASH_CTL, HV_CRASH_CTL_CRASH_NOTIFY);
 }
 EXPORT_SYMBOL_GPL(hyperv_report_panic);
+
+bool hv_is_hypercall_page_setup(void)
+{
+	union hv_x64_msr_hypercall_contents hypercall_msr;
+
+	/* Check if the hypercall page is setup */
+	hypercall_msr.as_uint64 = 0;
+	rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
+
+	if (!hypercall_msr.enable)
+		return false;
+
+	return true;
+}
+EXPORT_SYMBOL_GPL(hv_is_hypercall_page_setup);
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 64e682d..c843ef6 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -115,5 +115,6 @@ static inline  __u64 generate_guest_id(__u64 d_info1, __u64 kernel_version,
 #if IS_ENABLED(CONFIG_HYPERV)
 void hyperv_init(void);
 void hyperv_report_panic(struct pt_regs *regs);
+bool hv_is_hypercall_page_setup(void);
 #endif
 #endif
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 55b85c3..9021398 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -49,7 +49,6 @@ struct hv_context hv_context = {
  */
 int hv_init(void)
 {
-	union hv_x64_msr_hypercall_contents hypercall_msr;
 
 	memset(hv_context.synic_event_page, 0, sizeof(void *) * NR_CPUS);
 	memset(hv_context.synic_message_page, 0,
@@ -65,11 +64,7 @@ int hv_init(void)
 	memset(hv_context.clk_evt, 0,
 	       sizeof(void *) * NR_CPUS);
 
-	/* See if the hypercall page is already set */
-	hypercall_msr.as_uint64 = 0;
-	rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
-
-	if (!hypercall_msr.enable)
+	if (!hv_is_hypercall_page_setup())
 		return -ENOTSUPP;
 
 	return 0;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 09/18] Drivers: hv: vmbus: Move the code to signal end of message
  2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
                     ` (6 preceding siblings ...)
  2016-12-30 21:36   ` [PATCH 08/18] Drivers: hv: vmbus: Move the check for hypercall page setup kys
@ 2016-12-30 21:36   ` kys
  2016-12-30 21:36   ` [PATCH 10/18] Drivers: hv: vmbus: Restructure the clockevents code kys
                     ` (9 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: kys @ 2016-12-30 21:36 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa
  Cc: K. Y. Srinivasan

From: K. Y. Srinivasan <kys@microsoft.com>

As part of the effort to separate out architecture specific code, move the
code for signaling end of message.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 arch/x86/include/asm/mshyperv.h |   37 +++++++++++++++++++++++++++++++++++++
 drivers/hv/channel_mgmt.c       |    1 +
 drivers/hv/hyperv_vmbus.h       |   35 -----------------------------------
 3 files changed, 38 insertions(+), 35 deletions(-)

diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index c843ef6..b57b470 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -99,6 +99,43 @@ static inline  __u64 generate_guest_id(__u64 d_info1, __u64 kernel_version,
 	return guest_id;
 }
 
+
+/* Free the message slot and signal end-of-message if required */
+static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type)
+{
+	/*
+	 * On crash we're reading some other CPU's message page and we need
+	 * to be careful: this other CPU may already had cleared the header
+	 * and the host may already had delivered some other message there.
+	 * In case we blindly write msg->header.message_type we're going
+	 * to lose it. We can still lose a message of the same type but
+	 * we count on the fact that there can only be one
+	 * CHANNELMSG_UNLOAD_RESPONSE and we don't care about other messages
+	 * on crash.
+	 */
+	if (cmpxchg(&msg->header.message_type, old_msg_type,
+		    HVMSG_NONE) != old_msg_type)
+		return;
+
+	/*
+	 * Make sure the write to MessageType (ie set to
+	 * HVMSG_NONE) happens before we read the
+	 * MessagePending and EOMing. Otherwise, the EOMing
+	 * will not deliver any more messages since there is
+	 * no empty slot
+	 */
+	mb();
+
+	if (msg->header.message_flags.msg_pending) {
+		/*
+		 * This will cause message queue rescan to
+		 * possibly deliver another msg from the
+		 * hypervisor
+		 */
+		wrmsrl(HV_X64_MSR_EOM, 0);
+	}
+}
+
 void hyperv_callback_vector(void);
 #ifdef CONFIG_TRACING
 #define trace_hyperv_callback_vector hyperv_callback_vector
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 0af7e39..49d77be 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -31,6 +31,7 @@
 #include <linux/completion.h>
 #include <linux/delay.h>
 #include <linux/hyperv.h>
+#include <asm/mshyperv.h>
 
 #include "hyperv_vmbus.h"
 
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 59eb28c..e9f5d2c 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -521,41 +521,6 @@ struct vmbus_channel_message_table_entry {
 extern struct vmbus_channel_message_table_entry
 	channel_message_table[CHANNELMSG_COUNT];
 
-/* Free the message slot and signal end-of-message if required */
-static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type)
-{
-	/*
-	 * On crash we're reading some other CPU's message page and we need
-	 * to be careful: this other CPU may already had cleared the header
-	 * and the host may already had delivered some other message there.
-	 * In case we blindly write msg->header.message_type we're going
-	 * to lose it. We can still lose a message of the same type but
-	 * we count on the fact that there can only be one
-	 * CHANNELMSG_UNLOAD_RESPONSE and we don't care about other messages
-	 * on crash.
-	 */
-	if (cmpxchg(&msg->header.message_type, old_msg_type,
-		    HVMSG_NONE) != old_msg_type)
-		return;
-
-	/*
-	 * Make sure the write to MessageType (ie set to
-	 * HVMSG_NONE) happens before we read the
-	 * MessagePending and EOMing. Otherwise, the EOMing
-	 * will not deliver any more messages since there is
-	 * no empty slot
-	 */
-	mb();
-
-	if (msg->header.message_flags.msg_pending) {
-		/*
-		 * This will cause message queue rescan to
-		 * possibly deliver another msg from the
-		 * hypervisor
-		 */
-		wrmsrl(HV_X64_MSR_EOM, 0);
-	}
-}
 
 /* General vmbus interface */
 
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 10/18] Drivers: hv: vmbus: Restructure the clockevents code
  2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
                     ` (7 preceding siblings ...)
  2016-12-30 21:36   ` [PATCH 09/18] Drivers: hv: vmbus: Move the code to signal end of message kys
@ 2016-12-30 21:36   ` kys
  2016-12-30 21:36   ` [PATCH 11/18] Drivers: hv: util: Use hv_get_current_tick() to get current tick kys
                     ` (8 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: kys @ 2016-12-30 21:36 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa
  Cc: K. Y. Srinivasan

From: K. Y. Srinivasan <kys@microsoft.com>

Move the relevant code that programs the hypervisor to an architecture
specific file.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 arch/x86/include/asm/mshyperv.h |    4 ++++
 drivers/hv/hv.c                 |   10 +++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index b57b470..a58c201 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -136,6 +136,10 @@ static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type)
 	}
 }
 
+#define hv_get_current_tick(tick) rdmsrl(HV_X64_MSR_TIME_REF_COUNT, tick)
+#define hv_init_timer(timer, tick) wrmsrl(timer, tick)
+#define hv_init_timer_config(config, val) wrmsrl(config, val)
+
 void hyperv_callback_vector(void);
 #ifdef CONFIG_TRACING
 #define trace_hyperv_callback_vector hyperv_callback_vector
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 9021398..0afffd8 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -118,16 +118,16 @@ static int hv_ce_set_next_event(unsigned long delta,
 
 	WARN_ON(!clockevent_state_oneshot(evt));
 
-	rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
+	hv_get_current_tick(current_tick);
 	current_tick += delta;
-	wrmsrl(HV_X64_MSR_STIMER0_COUNT, current_tick);
+	hv_init_timer(HV_X64_MSR_STIMER0_COUNT, current_tick);
 	return 0;
 }
 
 static int hv_ce_shutdown(struct clock_event_device *evt)
 {
-	wrmsrl(HV_X64_MSR_STIMER0_COUNT, 0);
-	wrmsrl(HV_X64_MSR_STIMER0_CONFIG, 0);
+	hv_init_timer(HV_X64_MSR_STIMER0_COUNT, 0);
+	hv_init_timer_config(HV_X64_MSR_STIMER0_CONFIG, 0);
 
 	return 0;
 }
@@ -139,7 +139,7 @@ static int hv_ce_set_oneshot(struct clock_event_device *evt)
 	timer_cfg.enable = 1;
 	timer_cfg.auto_enable = 1;
 	timer_cfg.sintx = VMBUS_MESSAGE_SINT;
-	wrmsrl(HV_X64_MSR_STIMER0_CONFIG, timer_cfg.as_uint64);
+	hv_init_timer_config(HV_X64_MSR_STIMER0_CONFIG, timer_cfg.as_uint64);
 
 	return 0;
 }
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 11/18] Drivers: hv: util: Use hv_get_current_tick() to get current tick
  2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
                     ` (8 preceding siblings ...)
  2016-12-30 21:36   ` [PATCH 10/18] Drivers: hv: vmbus: Restructure the clockevents code kys
@ 2016-12-30 21:36   ` kys
  2016-12-30 21:36   ` [PATCH 12/18] Drivers: hv: vmbus: Get rid of an unsused variable kys
                     ` (7 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: kys @ 2016-12-30 21:36 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa
  Cc: K. Y. Srinivasan

From: K. Y. Srinivasan <kys@microsoft.com>

As part of the effort to interact with Hyper-V in an instruction set
architecture independent way, use the new API to get the current
tick.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 drivers/hv/hv_util.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c
index e770774..7c90e33 100644
--- a/drivers/hv/hv_util.c
+++ b/drivers/hv/hv_util.c
@@ -27,6 +27,7 @@
 #include <linux/sysctl.h>
 #include <linux/reboot.h>
 #include <linux/hyperv.h>
+#include <asm/mshyperv.h>
 
 #include "hyperv_vmbus.h"
 
@@ -199,7 +200,7 @@ static void hv_set_host_time(struct work_struct *work)
 		 */
 		u64 current_tick;
 
-		rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
+		hv_get_current_tick(current_tick);
 		newtime += (current_tick - wrk->ref_time);
 	}
 	host_tns = (newtime - WLTIMEDELTA) * 100;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 12/18] Drivers: hv: vmbus: Get rid of an unsused variable
  2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
                     ` (9 preceding siblings ...)
  2016-12-30 21:36   ` [PATCH 11/18] Drivers: hv: util: Use hv_get_current_tick() to get current tick kys
@ 2016-12-30 21:36   ` kys
  2016-12-30 21:36   ` [PATCH 13/18] Drivers: hv: vmbus: Define APIs to manipulate the message page kys
                     ` (6 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: kys @ 2016-12-30 21:36 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa
  Cc: K. Y. Srinivasan

From: K. Y. Srinivasan <kys@microsoft.com>

The version variable while it is initialized is not used;
get rid of it.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 drivers/hv/hv.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 0afffd8..5a2a329 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -261,16 +261,12 @@ void hv_synic_free(void)
  */
 int hv_synic_init(unsigned int cpu)
 {
-	u64 version;
 	union hv_synic_simp simp;
 	union hv_synic_siefp siefp;
 	union hv_synic_sint shared_sint;
 	union hv_synic_scontrol sctrl;
 	u64 vp_index;
 
-	/* Check the version */
-	rdmsrl(HV_X64_MSR_SVERSION, version);
-
 	/* Setup the Synic's message page */
 	rdmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
 	simp.simp_enabled = 1;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 13/18] Drivers: hv: vmbus: Define APIs to manipulate the message page
  2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
                     ` (10 preceding siblings ...)
  2016-12-30 21:36   ` [PATCH 12/18] Drivers: hv: vmbus: Get rid of an unsused variable kys
@ 2016-12-30 21:36   ` kys
  2016-12-30 21:36   ` [PATCH 14/18] Drivers: hv: vmbus: Define APIs to manipulate the event page kys
                     ` (5 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: kys @ 2016-12-30 21:36 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa
  Cc: K. Y. Srinivasan

From: K. Y. Srinivasan <kys@microsoft.com>

As part of cleaning up architecture specific code, define APIs
to manipulate the message page.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 arch/x86/include/asm/mshyperv.h |    3 +++
 drivers/hv/hv.c                 |    8 ++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index a58c201..1e75141 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -140,6 +140,9 @@ static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type)
 #define hv_init_timer(timer, tick) wrmsrl(timer, tick)
 #define hv_init_timer_config(config, val) wrmsrl(config, val)
 
+#define hv_get_simp(val) rdmsrl(HV_X64_MSR_SIMP, val)
+#define hv_set_simp(val) wrmsrl(HV_X64_MSR_SIMP, val)
+
 void hyperv_callback_vector(void);
 #ifdef CONFIG_TRACING
 #define trace_hyperv_callback_vector hyperv_callback_vector
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 5a2a329..6088442d 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -268,12 +268,12 @@ int hv_synic_init(unsigned int cpu)
 	u64 vp_index;
 
 	/* Setup the Synic's message page */
-	rdmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
+	hv_get_simp(simp.as_uint64);
 	simp.simp_enabled = 1;
 	simp.base_simp_gpa = virt_to_phys(hv_context.synic_message_page[cpu])
 		>> PAGE_SHIFT;
 
-	wrmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
+	hv_set_simp(simp.as_uint64);
 
 	/* Setup the Synic's event page */
 	rdmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
@@ -392,11 +392,11 @@ int hv_synic_cleanup(unsigned int cpu)
 	/* Disable the interrupt */
 	wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
 
-	rdmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
+	hv_get_simp(simp.as_uint64);
 	simp.simp_enabled = 0;
 	simp.base_simp_gpa = 0;
 
-	wrmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
+	hv_set_simp(simp.as_uint64);
 
 	rdmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
 	siefp.siefp_enabled = 0;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 14/18] Drivers: hv: vmbus: Define APIs to manipulate the event page
  2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
                     ` (11 preceding siblings ...)
  2016-12-30 21:36   ` [PATCH 13/18] Drivers: hv: vmbus: Define APIs to manipulate the message page kys
@ 2016-12-30 21:36   ` kys
  2016-12-30 21:36   ` [PATCH 15/18] Drivers: hv: vmbus: Define APIs to manipulate the synthetic interrupt controller kys
                     ` (4 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: kys @ 2016-12-30 21:36 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa
  Cc: K. Y. Srinivasan

From: K. Y. Srinivasan <kys@microsoft.com>

As part of cleaning up architecture specific code, define APIs
to manipulate the event page.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 arch/x86/include/asm/mshyperv.h |    3 +++
 drivers/hv/hv.c                 |    8 ++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 1e75141..2ea7e16 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -143,6 +143,9 @@ static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type)
 #define hv_get_simp(val) rdmsrl(HV_X64_MSR_SIMP, val)
 #define hv_set_simp(val) wrmsrl(HV_X64_MSR_SIMP, val)
 
+#define hv_get_siefp(val) rdmsrl(HV_X64_MSR_SIEFP, val)
+#define hv_set_siefp(val) wrmsrl(HV_X64_MSR_SIEFP, val)
+
 void hyperv_callback_vector(void);
 #ifdef CONFIG_TRACING
 #define trace_hyperv_callback_vector hyperv_callback_vector
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 6088442d..0a1da5d 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -276,12 +276,12 @@ int hv_synic_init(unsigned int cpu)
 	hv_set_simp(simp.as_uint64);
 
 	/* Setup the Synic's event page */
-	rdmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
+	hv_get_siefp(siefp.as_uint64);
 	siefp.siefp_enabled = 1;
 	siefp.base_siefp_gpa = virt_to_phys(hv_context.synic_event_page[cpu])
 		>> PAGE_SHIFT;
 
-	wrmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
+	hv_set_siefp(siefp.as_uint64);
 
 	/* Setup the shared SINT. */
 	rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
@@ -398,11 +398,11 @@ int hv_synic_cleanup(unsigned int cpu)
 
 	hv_set_simp(simp.as_uint64);
 
-	rdmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
+	hv_get_siefp(siefp.as_uint64);
 	siefp.siefp_enabled = 0;
 	siefp.base_siefp_gpa = 0;
 
-	wrmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
+	hv_set_siefp(siefp.as_uint64);
 
 	/* Disable the global synic bit */
 	rdmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 15/18] Drivers: hv: vmbus: Define APIs to manipulate the synthetic interrupt controller
  2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
                     ` (12 preceding siblings ...)
  2016-12-30 21:36   ` [PATCH 14/18] Drivers: hv: vmbus: Define APIs to manipulate the event page kys
@ 2016-12-30 21:36   ` kys
  2016-12-30 21:36   ` [PATCH 16/18] Drivers: hv: vmbus: Define an API to retrieve virtual processor index kys
                     ` (3 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: kys @ 2016-12-30 21:36 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa
  Cc: K. Y. Srinivasan

From: K. Y. Srinivasan <kys@microsoft.com>

As part of cleaning up architecture specific code, define APIs
to manipulate the interrupt controller state.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 arch/x86/include/asm/mshyperv.h |    3 +++
 drivers/hv/hv.c                 |    8 ++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 2ea7e16..1ea19a5 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -146,6 +146,9 @@ static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type)
 #define hv_get_siefp(val) rdmsrl(HV_X64_MSR_SIEFP, val)
 #define hv_set_siefp(val) wrmsrl(HV_X64_MSR_SIEFP, val)
 
+#define hv_get_synic_state(val) rdmsrl(HV_X64_MSR_SCONTROL, val)
+#define hv_set_synic_state(val) wrmsrl(HV_X64_MSR_SCONTROL, val)
+
 void hyperv_callback_vector(void);
 #ifdef CONFIG_TRACING
 #define trace_hyperv_callback_vector hyperv_callback_vector
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 0a1da5d..3c9a819 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -294,10 +294,10 @@ int hv_synic_init(unsigned int cpu)
 	wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
 
 	/* Enable the global synic bit */
-	rdmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
+	hv_get_synic_state(sctrl.as_uint64);
 	sctrl.enable = 1;
 
-	wrmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
+	hv_set_synic_state(sctrl.as_uint64);
 
 	hv_context.synic_initialized = true;
 
@@ -405,9 +405,9 @@ int hv_synic_cleanup(unsigned int cpu)
 	hv_set_siefp(siefp.as_uint64);
 
 	/* Disable the global synic bit */
-	rdmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
+	hv_get_synic_state(sctrl.as_uint64);
 	sctrl.enable = 0;
-	wrmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
+	hv_set_synic_state(sctrl.as_uint64);
 
 	return 0;
 }
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 16/18] Drivers: hv: vmbus: Define an API to retrieve virtual processor index
  2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
                     ` (13 preceding siblings ...)
  2016-12-30 21:36   ` [PATCH 15/18] Drivers: hv: vmbus: Define APIs to manipulate the synthetic interrupt controller kys
@ 2016-12-30 21:36   ` kys
  2016-12-30 21:36   ` [PATCH 17/18] Drivers: hv: vmbus: Define an APIs to manage interrupt state kys
                     ` (2 subsequent siblings)
  17 siblings, 0 replies; 22+ messages in thread
From: kys @ 2016-12-30 21:36 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa
  Cc: K. Y. Srinivasan

From: K. Y. Srinivasan <kys@microsoft.com>

As part of cleaning up architecture specific code, define an API
to retrieve the virtual procesor index.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 arch/x86/include/asm/mshyperv.h |    2 ++
 drivers/hv/hv.c                 |    2 +-
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 1ea19a5..2d40bfc 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -149,6 +149,8 @@ static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type)
 #define hv_get_synic_state(val) rdmsrl(HV_X64_MSR_SCONTROL, val)
 #define hv_set_synic_state(val) wrmsrl(HV_X64_MSR_SCONTROL, val)
 
+#define hv_get_vp_index(index) rdmsrl(HV_X64_MSR_VP_INDEX, index)
+
 void hyperv_callback_vector(void);
 #ifdef CONFIG_TRACING
 #define trace_hyperv_callback_vector hyperv_callback_vector
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 3c9a819..9b2630b 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -306,7 +306,7 @@ int hv_synic_init(unsigned int cpu)
 	 * of cpuid and Linux' notion of cpuid.
 	 * This array will be indexed using Linux cpuid.
 	 */
-	rdmsrl(HV_X64_MSR_VP_INDEX, vp_index);
+	hv_get_vp_index(vp_index);
 	hv_context.vp_index[cpu] = (u32)vp_index;
 
 	/*
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 17/18] Drivers: hv: vmbus: Define an APIs to manage interrupt state
  2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
                     ` (14 preceding siblings ...)
  2016-12-30 21:36   ` [PATCH 16/18] Drivers: hv: vmbus: Define an API to retrieve virtual processor index kys
@ 2016-12-30 21:36   ` kys
  2016-12-30 21:36   ` [PATCH 18/18] Drivers: hv: vmbus: Cleanup hyperv_vmbus.h kys
  2017-01-10 17:27   ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents Greg KH
  17 siblings, 0 replies; 22+ messages in thread
From: kys @ 2016-12-30 21:36 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa
  Cc: K. Y. Srinivasan

From: K. Y. Srinivasan <kys@microsoft.com>

As part of cleaning up architecture specific code, define APIs
to manage interrupt state.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 arch/x86/include/asm/mshyperv.h |    3 +++
 drivers/hv/hv.c                 |   12 ++++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 2d40bfc..42505d1 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -151,6 +151,9 @@ static inline void vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type)
 
 #define hv_get_vp_index(index) rdmsrl(HV_X64_MSR_VP_INDEX, index)
 
+#define hv_get_synint_state(int_num, val) rdmsrl(int_num, val)
+#define hv_set_synint_state(int_num, val) wrmsrl(int_num, val)
+
 void hyperv_callback_vector(void);
 #ifdef CONFIG_TRACING
 #define trace_hyperv_callback_vector hyperv_callback_vector
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 9b2630b..df55257 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -284,14 +284,16 @@ int hv_synic_init(unsigned int cpu)
 	hv_set_siefp(siefp.as_uint64);
 
 	/* Setup the shared SINT. */
-	rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
+	hv_get_synint_state(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT,
+			    shared_sint.as_uint64);
 
 	shared_sint.as_uint64 = 0;
 	shared_sint.vector = HYPERVISOR_CALLBACK_VECTOR;
 	shared_sint.masked = false;
 	shared_sint.auto_eoi = true;
 
-	wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
+	hv_set_synint_state(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT,
+			    shared_sint.as_uint64);
 
 	/* Enable the global synic bit */
 	hv_get_synic_state(sctrl.as_uint64);
@@ -384,13 +386,15 @@ int hv_synic_cleanup(unsigned int cpu)
 		hv_ce_shutdown(hv_context.clk_evt[cpu]);
 	}
 
-	rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
+	hv_get_synint_state(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT,
+			    shared_sint.as_uint64);
 
 	shared_sint.masked = 1;
 
 	/* Need to correctly cleanup in the case of SMP!!! */
 	/* Disable the interrupt */
-	wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
+	hv_set_synint_state(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT,
+			    shared_sint.as_uint64);
 
 	hv_get_simp(simp.as_uint64);
 	simp.simp_enabled = 0;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 18/18] Drivers: hv: vmbus: Cleanup hyperv_vmbus.h
  2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
                     ` (15 preceding siblings ...)
  2016-12-30 21:36   ` [PATCH 17/18] Drivers: hv: vmbus: Define an APIs to manage interrupt state kys
@ 2016-12-30 21:36   ` kys
  2017-01-10 17:27   ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents Greg KH
  17 siblings, 0 replies; 22+ messages in thread
From: kys @ 2016-12-30 21:36 UTC (permalink / raw)
  To: gregkh, linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa
  Cc: K. Y. Srinivasan

From: K. Y. Srinivasan <kys@microsoft.com>

Get rid of all unused definitions.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 drivers/hv/hyperv_vmbus.h |  152 +--------------------------------------------
 1 files changed, 2 insertions(+), 150 deletions(-)

diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index e9f5d2c..2463ef9 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -41,66 +41,11 @@
 #define HV_UTIL_NEGO_TIMEOUT 55
 
 
-/* Define version of the synthetic interrupt controller. */
-#define HV_SYNIC_VERSION		(1)
 
-#define HV_ANY_VP			(0xFFFFFFFF)
 
-/* Define synthetic interrupt controller flag constants. */
-#define HV_EVENT_FLAGS_COUNT		(256 * 8)
 #define HV_EVENT_FLAGS_BYTE_COUNT	(256)
 #define HV_EVENT_FLAGS_DWORD_COUNT	(256 / sizeof(u32))
 
-/* Define invalid partition identifier. */
-#define HV_PARTITION_ID_INVALID		((u64)0x0)
-
-/* Define port type. */
-enum hv_port_type {
-	HVPORT_MSG	= 1,
-	HVPORT_EVENT		= 2,
-	HVPORT_MONITOR	= 3
-};
-
-/* Define port information structure. */
-struct hv_port_info {
-	enum hv_port_type port_type;
-	u32 padding;
-	union {
-		struct {
-			u32 target_sint;
-			u32 target_vp;
-			u64 rsvdz;
-		} message_port_info;
-		struct {
-			u32 target_sint;
-			u32 target_vp;
-			u16 base_flag_number;
-			u16 flag_count;
-			u32 rsvdz;
-		} event_port_info;
-		struct {
-			u64 monitor_address;
-			u64 rsvdz;
-		} monitor_port_info;
-	};
-};
-
-struct hv_connection_info {
-	enum hv_port_type port_type;
-	u32 padding;
-	union {
-		struct {
-			u64 rsvdz;
-		} message_connection_info;
-		struct {
-			u64 rsvdz;
-		} event_connection_info;
-		struct {
-			u64 monitor_address;
-		} monitor_connection_info;
-	};
-};
-
 /*
  * Timer configuration register.
  */
@@ -117,8 +62,6 @@ struct hv_connection_info {
 	};
 };
 
-/* Define the number of message buffers associated with each port. */
-#define HV_PORT_MESSAGE_BUFFER_COUNT	(16)
 
 /* Define the synthetic interrupt controller event flags format. */
 union hv_synic_event_flags {
@@ -126,11 +69,6 @@ struct hv_connection_info {
 	u32 flags32[HV_EVENT_FLAGS_DWORD_COUNT];
 };
 
-/* Define the synthetic interrupt flags page layout. */
-struct hv_synic_event_flags_page {
-	union hv_synic_event_flags sintevent_flags[HV_SYNIC_SINT_COUNT];
-};
-
 /* Define SynIC control register. */
 union hv_synic_scontrol {
 	u64 as_uint64;
@@ -232,6 +170,8 @@ struct hv_monitor_page {
 	u8 rsvdz4[1984];
 };
 
+#define HV_HYPERCALL_PARAM_ALIGN	sizeof(u64)
+
 /* Definition of the hv_post_message hypercall input structure. */
 struct hv_input_post_message {
 	union hv_connection_id connectionid;
@@ -241,41 +181,6 @@ struct hv_input_post_message {
 	u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
 };
 
-/*
- * Versioning definitions used for guests reporting themselves to the
- * hypervisor, and visa versa.
- */
-
-/* Version info reported by guest OS's */
-enum hv_guest_os_vendor {
-	HVGUESTOS_VENDOR_MICROSOFT	= 0x0001
-};
-
-enum hv_guest_os_microsoft_ids {
-	HVGUESTOS_MICROSOFT_UNDEFINED	= 0x00,
-	HVGUESTOS_MICROSOFT_MSDOS		= 0x01,
-	HVGUESTOS_MICROSOFT_WINDOWS3X	= 0x02,
-	HVGUESTOS_MICROSOFT_WINDOWS9X	= 0x03,
-	HVGUESTOS_MICROSOFT_WINDOWSNT	= 0x04,
-	HVGUESTOS_MICROSOFT_WINDOWSCE	= 0x05
-};
-
-/*
- * Declare the MSR used to identify the guest OS.
- */
-#define HV_X64_MSR_GUEST_OS_ID	0x40000000
-
-union hv_x64_msr_guest_os_id_contents {
-	u64 as_uint64;
-	struct {
-		u64 build_number:16;
-		u64 service_version:8; /* Service Pack, etc. */
-		u64 minor_version:8;
-		u64 major_version:8;
-		u64 os_id:8; /* enum hv_guest_os_microsoft_ids (if Vendor=MS) */
-		u64 vendor_id:16; /* enum hv_guest_os_vendor */
-	};
-};
 
 enum {
 	VMBUS_MESSAGE_CONNECTION_ID	= 1,
@@ -287,55 +192,6 @@ enum {
 	VMBUS_MESSAGE_SINT		= 2,
 };
 
-/* #defines */
-
-#define HV_PRESENT_BIT			0x80000000
-
-
-#define HV_CPU_POWER_MANAGEMENT		(1 << 0)
-#define HV_RECOMMENDATIONS_MAX		4
-
-#define HV_X64_MAX			5
-#define HV_CAPS_MAX			8
-
-
-#define HV_HYPERCALL_PARAM_ALIGN	sizeof(u64)
-
-
-/* Service definitions */
-
-#define HV_SERVICE_PARENT_PORT				(0)
-#define HV_SERVICE_PARENT_CONNECTION			(0)
-
-#define HV_SERVICE_CONNECT_RESPONSE_SUCCESS		(0)
-#define HV_SERVICE_CONNECT_RESPONSE_INVALID_PARAMETER	(1)
-#define HV_SERVICE_CONNECT_RESPONSE_UNKNOWN_SERVICE	(2)
-#define HV_SERVICE_CONNECT_RESPONSE_CONNECTION_REJECTED	(3)
-
-#define HV_SERVICE_CONNECT_REQUEST_MESSAGE_ID		(1)
-#define HV_SERVICE_CONNECT_RESPONSE_MESSAGE_ID		(2)
-#define HV_SERVICE_DISCONNECT_REQUEST_MESSAGE_ID	(3)
-#define HV_SERVICE_DISCONNECT_RESPONSE_MESSAGE_ID	(4)
-#define HV_SERVICE_MAX_MESSAGE_ID				(4)
-
-#define HV_SERVICE_PROTOCOL_VERSION (0x0010)
-#define HV_CONNECT_PAYLOAD_BYTE_COUNT 64
-
-/* #define VMBUS_REVISION_NUMBER	6 */
-
-/* Our local vmbus's port and connection id. Anything >0 is fine */
-/* #define VMBUS_PORT_ID		11 */
-
-/* 628180B8-308D-4c5e-B7DB-1BEB62E62EF4 */
-static const uuid_le VMBUS_SERVICE_ID = {
-	.b = {
-		0xb8, 0x80, 0x81, 0x62, 0x8d, 0x30, 0x5e, 0x4c,
-		0xb7, 0xdb, 0x1b, 0xeb, 0x62, 0xe6, 0x2e, 0xf4
-	},
-};
-
-
-
 struct hv_context {
 	/* We only support running on top of Hyper-V
 	* So at this point this really can only contain the Hyper-V ID
@@ -531,10 +387,6 @@ struct hv_device *vmbus_device_create(const uuid_le *type,
 int vmbus_device_register(struct hv_device *child_device_obj);
 void vmbus_device_unregister(struct hv_device *device_obj);
 
-/* static void */
-/* VmbusChildDeviceDestroy( */
-/* struct hv_device *); */
-
 struct vmbus_channel *relid2channel(u32 relid);
 
 void vmbus_free_channels(void);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents
  2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
                     ` (16 preceding siblings ...)
  2016-12-30 21:36   ` [PATCH 18/18] Drivers: hv: vmbus: Cleanup hyperv_vmbus.h kys
@ 2017-01-10 17:27   ` Greg KH
  2017-01-12  2:32     ` KY Srinivasan
  17 siblings, 1 reply; 22+ messages in thread
From: Greg KH @ 2017-01-10 17:27 UTC (permalink / raw)
  To: kys
  Cc: linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa

On Fri, Dec 30, 2016 at 01:35:55PM -0800, kys@exchange.microsoft.com wrote:
> From: K. Y. Srinivasan <kys@microsoft.com>
> 
> As part of the effort to separate out architecture specific code, move the
> definition of hv_x64_msr_hypercall_contents to x86 specific header file.
> 
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> ---
>  arch/x86/include/asm/mshyperv.h |   12 ++++++++++++
>  drivers/hv/hyperv_vmbus.h       |   15 ---------------
>  2 files changed, 12 insertions(+), 15 deletions(-)

This series doesn't apply against my tree.  Can you please refresh it
and resend?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents
  2017-01-10 17:27   ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents Greg KH
@ 2017-01-12  2:32     ` KY Srinivasan
  2017-01-12 18:29       ` Stephen Hemminger
  0 siblings, 1 reply; 22+ messages in thread
From: KY Srinivasan @ 2017-01-12  2:32 UTC (permalink / raw)
  To: Greg KH
  Cc: linux-kernel, devel, olaf, apw, vkuznets, jasowang,
	leann.ogasawara, rkagan, x86, tglx, hpa



> -----Original Message-----
> From: Greg KH [mailto:gregkh@linuxfoundation.org]
> Sent: Tuesday, January 10, 2017 9:27 AM
> To: KY Srinivasan <kys@microsoft.com>
> Cc: linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> olaf@aepfle.de; apw@canonical.com; vkuznets@redhat.com;
> jasowang@redhat.com; leann.ogasawara@canonical.com;
> rkagan@virtuozzo.com; x86@kernel.org; tglx@linutronix.de; hpa@zytor.com
> Subject: Re: [PATCH 01/18] Drivers: hv: vmbus: Move the definition of
> hv_x64_msr_hypercall_contents
> 
> On Fri, Dec 30, 2016 at 01:35:55PM -0800, kys@exchange.microsoft.com
> wrote:
> > From: K. Y. Srinivasan <kys@microsoft.com>
> >
> > As part of the effort to separate out architecture specific code, move the
> > definition of hv_x64_msr_hypercall_contents to x86 specific header file.
> >
> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > ---
> >  arch/x86/include/asm/mshyperv.h |   12 ++++++++++++
> >  drivers/hv/hyperv_vmbus.h       |   15 ---------------
> >  2 files changed, 12 insertions(+), 15 deletions(-)
> 
> This series doesn't apply against my tree.  Can you please refresh it
> and resend?

Will do.

K. Y
> 
> thanks,
> 
> greg k-h

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents
  2017-01-12  2:32     ` KY Srinivasan
@ 2017-01-12 18:29       ` Stephen Hemminger
  0 siblings, 0 replies; 22+ messages in thread
From: Stephen Hemminger @ 2017-01-12 18:29 UTC (permalink / raw)
  To: KY Srinivasan
  Cc: Greg KH, olaf, jasowang, x86, linux-kernel, tglx, rkagan, hpa,
	apw, devel, leann.ogasawara

On Thu, 12 Jan 2017 02:32:24 +0000
KY Srinivasan <kys@microsoft.com> wrote:

> > -----Original Message-----
> > From: Greg KH [mailto:gregkh@linuxfoundation.org]
> > Sent: Tuesday, January 10, 2017 9:27 AM
> > To: KY Srinivasan <kys@microsoft.com>
> > Cc: linux-kernel@vger.kernel.org; devel@linuxdriverproject.org;
> > olaf@aepfle.de; apw@canonical.com; vkuznets@redhat.com;
> > jasowang@redhat.com; leann.ogasawara@canonical.com;
> > rkagan@virtuozzo.com; x86@kernel.org; tglx@linutronix.de; hpa@zytor.com
> > Subject: Re: [PATCH 01/18] Drivers: hv: vmbus: Move the definition of
> > hv_x64_msr_hypercall_contents
> > 
> > On Fri, Dec 30, 2016 at 01:35:55PM -0800, kys@exchange.microsoft.com
> > wrote:  
> > > From: K. Y. Srinivasan <kys@microsoft.com>
> > >
> > > As part of the effort to separate out architecture specific code, move the
> > > definition of hv_x64_msr_hypercall_contents to x86 specific header file.
> > >
> > > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> > > ---
> > >  arch/x86/include/asm/mshyperv.h |   12 ++++++++++++
> > >  drivers/hv/hyperv_vmbus.h       |   15 ---------------
> > >  2 files changed, 12 insertions(+), 15 deletions(-)  
> > 
> > This series doesn't apply against my tree.  Can you please refresh it
> > and resend?  
> 
> Will do.
> 
> K. Y

Send me the patches, I have a vmbus-next tree ready for pull request.

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2017-01-12 18:30 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-30 21:35 [PATCH 00/18] Drivers: hv: vmbus: Restructure architecture specific code kys
2016-12-30 21:35 ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents kys
2016-12-30 21:35   ` [PATCH 02/18] Drivers: hv: vmbus: Move the definition of generate_guest_id() kys
2016-12-30 21:35   ` [PATCH 03/18] Drivers: hv vmbus: Move Hypercall page setup out of common code kys
2016-12-30 21:35   ` [PATCH 04/18] Drivers: hv: vmbus: Move Hypercall invocation code " kys
2016-12-30 21:35   ` [PATCH 05/18] Drivers: hv: vmbus: Consolidate all Hyper-V specific clocksource code kys
2016-12-30 21:36   ` [PATCH 06/18] Drivers: hv: vmbus: Move the extracting of Hypervisor version information kys
2016-12-30 21:36   ` [PATCH 07/18] Drivers: hv: vmbus: Move the crash notification function kys
2016-12-30 21:36   ` [PATCH 08/18] Drivers: hv: vmbus: Move the check for hypercall page setup kys
2016-12-30 21:36   ` [PATCH 09/18] Drivers: hv: vmbus: Move the code to signal end of message kys
2016-12-30 21:36   ` [PATCH 10/18] Drivers: hv: vmbus: Restructure the clockevents code kys
2016-12-30 21:36   ` [PATCH 11/18] Drivers: hv: util: Use hv_get_current_tick() to get current tick kys
2016-12-30 21:36   ` [PATCH 12/18] Drivers: hv: vmbus: Get rid of an unsused variable kys
2016-12-30 21:36   ` [PATCH 13/18] Drivers: hv: vmbus: Define APIs to manipulate the message page kys
2016-12-30 21:36   ` [PATCH 14/18] Drivers: hv: vmbus: Define APIs to manipulate the event page kys
2016-12-30 21:36   ` [PATCH 15/18] Drivers: hv: vmbus: Define APIs to manipulate the synthetic interrupt controller kys
2016-12-30 21:36   ` [PATCH 16/18] Drivers: hv: vmbus: Define an API to retrieve virtual processor index kys
2016-12-30 21:36   ` [PATCH 17/18] Drivers: hv: vmbus: Define an APIs to manage interrupt state kys
2016-12-30 21:36   ` [PATCH 18/18] Drivers: hv: vmbus: Cleanup hyperv_vmbus.h kys
2017-01-10 17:27   ` [PATCH 01/18] Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents Greg KH
2017-01-12  2:32     ` KY Srinivasan
2017-01-12 18:29       ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).