All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xen-devel] [PATCH v5 0/8] Port Xen to Hyper-V
@ 2019-11-30 11:57 Wei Liu
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 1/8] x86: introduce CONFIG_GUEST and move code Wei Liu
                   ` (7 more replies)
  0 siblings, 8 replies; 19+ messages in thread
From: Wei Liu @ 2019-11-30 11:57 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Paul Durrant, Andrew Cooper, Michael Kelley,
	Jan Beulich, Roger Pau Monné

Please see individual patches for changes

Cc: Jan Beulich <jbeulich@suse.com>                                                                                                                                                            
Cc: Andrew Cooper <andrew.cooper3@citrix.com>                                                                                                                                                  
Cc: Wei Liu <wl@xen.org>                                                                                                                                                                       
Cc: Roger Pau Monné <roger.pau@citrix.com>                                                                                                                                                     
Cc: Paul Durrant <paul@xen.org>      

Wei Liu (8):
  x86: introduce CONFIG_GUEST and move code
  x86: add missing headers in hypercall.h
  x86: drop hypervisor_cpuid_base
  x86: introduce hypervisor framework
  x86: rename hypervisor_{alloc,free}_unused_page
  x86: switch xen guest implementation to use hypervisor framework
  x86: be more verbose when running on a hypervisor
  x86: introduce CONFIG_HYPERV and detection code

 xen/arch/x86/Kconfig                          | 15 +++-
 xen/arch/x86/Makefile                         |  2 +-
 xen/arch/x86/guest/Makefile                   |  6 +-
 xen/arch/x86/guest/hyperv/Makefile            |  1 +
 xen/arch/x86/guest/hyperv/hyperv.c            | 54 +++++++++++++
 xen/arch/x86/guest/hypervisor.c               | 78 +++++++++++++++++++
 xen/arch/x86/guest/xen/Makefile               |  4 +
 xen/arch/x86/guest/{ => xen}/hypercall_page.S |  0
 xen/arch/x86/guest/{ => xen}/pvh-boot.c       |  2 +-
 xen/arch/x86/guest/{ => xen}/xen.c            | 60 +++++++-------
 xen/arch/x86/pv/shim.c                        |  6 +-
 xen/arch/x86/setup.c                          |  7 +-
 xen/include/asm-x86/guest.h                   |  2 +
 xen/include/asm-x86/guest/hypercall.h         |  4 +
 xen/include/asm-x86/guest/hyperv.h            | 43 ++++++++++
 xen/include/asm-x86/guest/hypervisor.h        | 62 +++++++++++++++
 xen/include/asm-x86/guest/xen.h               | 23 ++----
 17 files changed, 312 insertions(+), 57 deletions(-)
 create mode 100644 xen/arch/x86/guest/hyperv/Makefile
 create mode 100644 xen/arch/x86/guest/hyperv/hyperv.c
 create mode 100644 xen/arch/x86/guest/hypervisor.c
 create mode 100644 xen/arch/x86/guest/xen/Makefile
 rename xen/arch/x86/guest/{ => xen}/hypercall_page.S (100%)
 rename xen/arch/x86/guest/{ => xen}/pvh-boot.c (99%)
 rename xen/arch/x86/guest/{ => xen}/xen.c (94%)
 create mode 100644 xen/include/asm-x86/guest/hyperv.h
 create mode 100644 xen/include/asm-x86/guest/hypervisor.h

-- 
2.20.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Xen-devel] [PATCH v5 1/8] x86: introduce CONFIG_GUEST and move code
  2019-11-30 11:57 [Xen-devel] [PATCH v5 0/8] Port Xen to Hyper-V Wei Liu
@ 2019-11-30 11:57 ` Wei Liu
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 2/8] x86: add missing headers in hypercall.h Wei Liu
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 19+ messages in thread
From: Wei Liu @ 2019-11-30 11:57 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
	Roger Pau Monné

Xen is able to run as a guest on Xen. We plan to make it able to run
on Hyper-V as well.

Introduce CONFIG_GUEST which is set to true if either running on Xen
or Hyper-V is desired. Restructure code hierarchy for new code to
come.

No functional change intended.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/Kconfig                          | 7 +++++--
 xen/arch/x86/Makefile                         | 2 +-
 xen/arch/x86/guest/Makefile                   | 5 +----
 xen/arch/x86/guest/xen/Makefile               | 4 ++++
 xen/arch/x86/guest/{ => xen}/hypercall_page.S | 0
 xen/arch/x86/guest/{ => xen}/pvh-boot.c       | 0
 xen/arch/x86/guest/{ => xen}/xen.c            | 0
 7 files changed, 11 insertions(+), 7 deletions(-)
 create mode 100644 xen/arch/x86/guest/xen/Makefile
 rename xen/arch/x86/guest/{ => xen}/hypercall_page.S (100%)
 rename xen/arch/x86/guest/{ => xen}/pvh-boot.c (100%)
 rename xen/arch/x86/guest/{ => xen}/xen.c (100%)

diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig
index 28b3b4692a..18c8f6fd26 100644
--- a/xen/arch/x86/Kconfig
+++ b/xen/arch/x86/Kconfig
@@ -161,9 +161,12 @@ config XEN_ALIGN_2M
 
 endchoice
 
+config GUEST
+	bool
+
 config XEN_GUEST
-	def_bool n
-	prompt "Xen Guest"
+	bool "Xen Guest"
+	select GUEST
 	---help---
 	  Support for Xen detecting when it is running under Xen.
 
diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index a0b2f4ab15..7da5a2631e 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -1,7 +1,7 @@
 subdir-y += acpi
 subdir-y += cpu
 subdir-y += genapic
-subdir-$(CONFIG_XEN_GUEST) += guest
+subdir-$(CONFIG_GUEST) += guest
 subdir-$(CONFIG_HVM) += hvm
 subdir-y += mm
 subdir-$(CONFIG_XENOPROF) += oprofile
diff --git a/xen/arch/x86/guest/Makefile b/xen/arch/x86/guest/Makefile
index 26fb4b1007..6806f04947 100644
--- a/xen/arch/x86/guest/Makefile
+++ b/xen/arch/x86/guest/Makefile
@@ -1,4 +1 @@
-obj-y += hypercall_page.o
-obj-y += xen.o
-
-obj-bin-$(CONFIG_PVH_GUEST) += pvh-boot.init.o
+subdir-$(CONFIG_XEN_GUEST) += xen
diff --git a/xen/arch/x86/guest/xen/Makefile b/xen/arch/x86/guest/xen/Makefile
new file mode 100644
index 0000000000..26fb4b1007
--- /dev/null
+++ b/xen/arch/x86/guest/xen/Makefile
@@ -0,0 +1,4 @@
+obj-y += hypercall_page.o
+obj-y += xen.o
+
+obj-bin-$(CONFIG_PVH_GUEST) += pvh-boot.init.o
diff --git a/xen/arch/x86/guest/hypercall_page.S b/xen/arch/x86/guest/xen/hypercall_page.S
similarity index 100%
rename from xen/arch/x86/guest/hypercall_page.S
rename to xen/arch/x86/guest/xen/hypercall_page.S
diff --git a/xen/arch/x86/guest/pvh-boot.c b/xen/arch/x86/guest/xen/pvh-boot.c
similarity index 100%
rename from xen/arch/x86/guest/pvh-boot.c
rename to xen/arch/x86/guest/xen/pvh-boot.c
diff --git a/xen/arch/x86/guest/xen.c b/xen/arch/x86/guest/xen/xen.c
similarity index 100%
rename from xen/arch/x86/guest/xen.c
rename to xen/arch/x86/guest/xen/xen.c
-- 
2.20.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Xen-devel] [PATCH v5 2/8] x86: add missing headers in hypercall.h
  2019-11-30 11:57 [Xen-devel] [PATCH v5 0/8] Port Xen to Hyper-V Wei Liu
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 1/8] x86: introduce CONFIG_GUEST and move code Wei Liu
@ 2019-11-30 11:57 ` Wei Liu
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 3/8] x86: drop hypervisor_cpuid_base Wei Liu
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 19+ messages in thread
From: Wei Liu @ 2019-11-30 11:57 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
	Roger Pau Monné

Include asm_defns.h because ASM_CALL_CONSTRAINT is defined there.

Include xen/lib.h because we need ASSERT_UNREACHABLE.

No functional change.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/include/asm-x86/guest/hypercall.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/xen/include/asm-x86/guest/hypercall.h b/xen/include/asm-x86/guest/hypercall.h
index d548816b30..d0d2f5022d 100644
--- a/xen/include/asm-x86/guest/hypercall.h
+++ b/xen/include/asm-x86/guest/hypercall.h
@@ -23,6 +23,8 @@
 
 #include <xen/types.h>
 
+#include <asm/asm_defns.h>
+
 #include <public/xen.h>
 #include <public/sched.h>
 #include <public/hvm/hvm_op.h>
@@ -180,6 +182,8 @@ static inline long xen_hypercall_set_evtchn_upcall_vector(
 
 #else /* CONFIG_XEN_GUEST */
 
+#include <xen/lib.h>
+
 #include <public/sched.h>
 
 static inline void xen_hypercall_console_write(
-- 
2.20.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Xen-devel] [PATCH v5 3/8] x86: drop hypervisor_cpuid_base
  2019-11-30 11:57 [Xen-devel] [PATCH v5 0/8] Port Xen to Hyper-V Wei Liu
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 1/8] x86: introduce CONFIG_GUEST and move code Wei Liu
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 2/8] x86: add missing headers in hypercall.h Wei Liu
@ 2019-11-30 11:57 ` Wei Liu
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 4/8] x86: introduce hypervisor framework Wei Liu
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 19+ messages in thread
From: Wei Liu @ 2019-11-30 11:57 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
	Roger Pau Monné

The only user is Xen specific code in PV shim. We can therefore export
the variable directly.

Move __read_mostly to its standard place while at it.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/guest/xen/xen.c    | 7 +------
 xen/arch/x86/pv/shim.c          | 2 +-
 xen/include/asm-x86/guest/xen.h | 2 +-
 3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c
index a329e7c886..1e37086518 100644
--- a/xen/arch/x86/guest/xen/xen.c
+++ b/xen/arch/x86/guest/xen/xen.c
@@ -37,7 +37,7 @@
 
 bool __read_mostly xen_guest;
 
-static __read_mostly uint32_t xen_cpuid_base;
+uint32_t __read_mostly xen_cpuid_base;
 extern char hypercall_page[];
 static struct rangeset *mem;
 
@@ -297,11 +297,6 @@ int hypervisor_free_unused_page(mfn_t mfn)
     return rangeset_remove_range(mem, mfn_x(mfn), mfn_x(mfn));
 }
 
-uint32_t hypervisor_cpuid_base(void)
-{
-    return xen_cpuid_base;
-}
-
 static void ap_resume(void *unused)
 {
     map_vcpuinfo();
diff --git a/xen/arch/x86/pv/shim.c b/xen/arch/x86/pv/shim.c
index 35bf3945ac..351da970ef 100644
--- a/xen/arch/x86/pv/shim.c
+++ b/xen/arch/x86/pv/shim.c
@@ -995,7 +995,7 @@ domid_t get_initial_domain_id(void)
     if ( !pv_shim )
         return 0;
 
-    cpuid(hypervisor_cpuid_base() + 4, &eax, &ebx, &ecx, &edx);
+    cpuid(xen_cpuid_base + 4, &eax, &ebx, &ecx, &edx);
 
     return (eax & XEN_HVM_CPUID_DOMID_PRESENT) ? ecx : 1;
 }
diff --git a/xen/include/asm-x86/guest/xen.h b/xen/include/asm-x86/guest/xen.h
index 7e04e4a7ab..b015ed1883 100644
--- a/xen/include/asm-x86/guest/xen.h
+++ b/xen/include/asm-x86/guest/xen.h
@@ -30,13 +30,13 @@
 
 extern bool xen_guest;
 extern bool pv_console;
+extern uint32_t xen_cpuid_base;
 
 void probe_hypervisor(void);
 void hypervisor_setup(void);
 void hypervisor_ap_setup(void);
 int hypervisor_alloc_unused_page(mfn_t *mfn);
 int hypervisor_free_unused_page(mfn_t mfn);
-uint32_t hypervisor_cpuid_base(void);
 void hypervisor_resume(void);
 
 DECLARE_PER_CPU(unsigned int, vcpu_id);
-- 
2.20.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Xen-devel] [PATCH v5 4/8] x86: introduce hypervisor framework
  2019-11-30 11:57 [Xen-devel] [PATCH v5 0/8] Port Xen to Hyper-V Wei Liu
                   ` (2 preceding siblings ...)
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 3/8] x86: drop hypervisor_cpuid_base Wei Liu
@ 2019-11-30 11:57 ` Wei Liu
  2019-12-03 14:49   ` Jan Beulich
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 5/8] x86: rename hypervisor_{alloc, free}_unused_page Wei Liu
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Wei Liu @ 2019-11-30 11:57 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
	Roger Pau Monné

We will soon implement Hyper-V support for Xen. Add a framework for
that.

This requires moving some of the hypervisor_* functions from xen.h to
hypervisor.h.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
---
Changes in v5:
1. Make hypervisor_probe return const char *.

Changes in v4:
1. Add ASSERT_UNREACHABLE to stubs.
2. Move __read_mostly.
3. Return hops directly.
4. Drop Paul's review tag.
---
 xen/arch/x86/guest/Makefile            |  2 +
 xen/arch/x86/guest/hypervisor.c        | 45 +++++++++++++++++++
 xen/include/asm-x86/guest.h            |  1 +
 xen/include/asm-x86/guest/hypervisor.h | 62 ++++++++++++++++++++++++++
 xen/include/asm-x86/guest/xen.h        | 12 -----
 5 files changed, 110 insertions(+), 12 deletions(-)
 create mode 100644 xen/arch/x86/guest/hypervisor.c
 create mode 100644 xen/include/asm-x86/guest/hypervisor.h

diff --git a/xen/arch/x86/guest/Makefile b/xen/arch/x86/guest/Makefile
index 6806f04947..f63d64bbee 100644
--- a/xen/arch/x86/guest/Makefile
+++ b/xen/arch/x86/guest/Makefile
@@ -1 +1,3 @@
+obj-y += hypervisor.o
+
 subdir-$(CONFIG_XEN_GUEST) += xen
diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c
new file mode 100644
index 0000000000..c35c610d01
--- /dev/null
+++ b/xen/arch/x86/guest/hypervisor.c
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * arch/x86/guest/hypervisor.c
+ *
+ * Support for detecting and running under a hypervisor.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (c) 2019 Microsoft.
+ */
+#include <xen/init.h>
+#include <xen/types.h>
+
+#include <asm/cache.h>
+#include <asm/guest/hypervisor.h>
+
+static const struct hypervisor_ops __read_mostly *ops;
+
+const char *__init hypervisor_probe(void)
+{
+    if ( ops )
+        return ops->name;
+
+    return NULL;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/include/asm-x86/guest.h b/xen/include/asm-x86/guest.h
index a38c6b5b3f..8e167165ae 100644
--- a/xen/include/asm-x86/guest.h
+++ b/xen/include/asm-x86/guest.h
@@ -20,6 +20,7 @@
 #define __X86_GUEST_H__
 
 #include <asm/guest/hypercall.h>
+#include <asm/guest/hypervisor.h>
 #include <asm/guest/pvh-boot.h>
 #include <asm/guest/xen.h>
 #include <asm/pv/shim.h>
diff --git a/xen/include/asm-x86/guest/hypervisor.h b/xen/include/asm-x86/guest/hypervisor.h
new file mode 100644
index 0000000000..392f4b90ae
--- /dev/null
+++ b/xen/include/asm-x86/guest/hypervisor.h
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * asm-x86/guest/hypervisor.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions 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.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (c) 2019 Microsoft.
+ */
+
+#ifndef __X86_HYPERVISOR_H__
+#define __X86_HYPERVISOR_H__
+
+struct hypervisor_ops {
+    /* Name of the hypervisor */
+    const char *name;
+    /* Main setup routine */
+    void (*setup)(void);
+    /* AP setup */
+    void (*ap_setup)(void);
+    /* Resume from suspension */
+    void (*resume)(void);
+};
+
+#ifdef CONFIG_GUEST
+
+const char *hypervisor_probe(void);
+void hypervisor_setup(void);
+void hypervisor_ap_setup(void);
+void hypervisor_resume(void);
+
+#else
+
+#include <xen/lib.h>
+#include <xen/types.h>
+
+static inline const char *hypervisor_probe(void) { return NULL; }
+static inline void hypervisor_setup(void) { ASSERT_UNREACHABLE(); }
+static inline void hypervisor_ap_setup(void) { ASSERT_UNREACHABLE(); }
+static inline void hypervisor_resume(void) { ASSERT_UNREACHABLE(); }
+
+#endif  /* CONFIG_GUEST */
+
+#endif /* __X86_HYPERVISOR_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/include/asm-x86/guest/xen.h b/xen/include/asm-x86/guest/xen.h
index b015ed1883..3145f75361 100644
--- a/xen/include/asm-x86/guest/xen.h
+++ b/xen/include/asm-x86/guest/xen.h
@@ -33,11 +33,8 @@ extern bool pv_console;
 extern uint32_t xen_cpuid_base;
 
 void probe_hypervisor(void);
-void hypervisor_setup(void);
-void hypervisor_ap_setup(void);
 int hypervisor_alloc_unused_page(mfn_t *mfn);
 int hypervisor_free_unused_page(mfn_t mfn);
-void hypervisor_resume(void);
 
 DECLARE_PER_CPU(unsigned int, vcpu_id);
 DECLARE_PER_CPU(struct vcpu_info *, vcpu_info);
@@ -49,15 +46,6 @@ DECLARE_PER_CPU(struct vcpu_info *, vcpu_info);
 
 static inline void probe_hypervisor(void) {}
 
-static inline void hypervisor_setup(void)
-{
-    ASSERT_UNREACHABLE();
-}
-static inline void hypervisor_ap_setup(void)
-{
-    ASSERT_UNREACHABLE();
-}
-
 #endif /* CONFIG_XEN_GUEST */
 #endif /* __X86_GUEST_XEN_H__ */
 
-- 
2.20.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Xen-devel] [PATCH v5 5/8] x86: rename hypervisor_{alloc, free}_unused_page
  2019-11-30 11:57 [Xen-devel] [PATCH v5 0/8] Port Xen to Hyper-V Wei Liu
                   ` (3 preceding siblings ...)
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 4/8] x86: introduce hypervisor framework Wei Liu
@ 2019-11-30 11:57 ` Wei Liu
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 6/8] x86: switch xen guest implementation to use hypervisor framework Wei Liu
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 19+ messages in thread
From: Wei Liu @ 2019-11-30 11:57 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Jan Beulich, Roger Pau Monné

They are used in Xen code only.

No functional change.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
Reviewed-by: Paul Durrant <pdurrant@amazon.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/guest/xen/xen.c    | 6 +++---
 xen/arch/x86/pv/shim.c          | 4 ++--
 xen/include/asm-x86/guest/xen.h | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c
index 1e37086518..0f5b5267c5 100644
--- a/xen/arch/x86/guest/xen/xen.c
+++ b/xen/arch/x86/guest/xen/xen.c
@@ -93,7 +93,7 @@ static void map_shared_info(void)
     unsigned int i;
     unsigned long rc;
 
-    if ( hypervisor_alloc_unused_page(&mfn) )
+    if ( xg_alloc_unused_page(&mfn) )
         panic("unable to reserve shared info memory page\n");
 
     xatp.gpfn = mfn_x(mfn);
@@ -280,7 +280,7 @@ void hypervisor_ap_setup(void)
     init_evtchn();
 }
 
-int hypervisor_alloc_unused_page(mfn_t *mfn)
+int xg_alloc_unused_page(mfn_t *mfn)
 {
     unsigned long m;
     int rc;
@@ -292,7 +292,7 @@ int hypervisor_alloc_unused_page(mfn_t *mfn)
     return rc;
 }
 
-int hypervisor_free_unused_page(mfn_t mfn)
+int xg_free_unused_page(mfn_t mfn)
 {
     return rangeset_remove_range(mem, mfn_x(mfn), mfn_x(mfn));
 }
diff --git a/xen/arch/x86/pv/shim.c b/xen/arch/x86/pv/shim.c
index 351da970ef..7a898fdbe5 100644
--- a/xen/arch/x86/pv/shim.c
+++ b/xen/arch/x86/pv/shim.c
@@ -742,7 +742,7 @@ static long pv_shim_grant_table_op(unsigned int cmd,
                 };
                 mfn_t mfn;
 
-                rc = hypervisor_alloc_unused_page(&mfn);
+                rc = xg_alloc_unused_page(&mfn);
                 if ( rc )
                 {
                     gprintk(XENLOG_ERR,
@@ -754,7 +754,7 @@ static long pv_shim_grant_table_op(unsigned int cmd,
                 rc = xen_hypercall_memory_op(XENMEM_add_to_physmap, &xatp);
                 if ( rc )
                 {
-                    hypervisor_free_unused_page(mfn);
+                    xg_free_unused_page(mfn);
                     break;
                 }
 
diff --git a/xen/include/asm-x86/guest/xen.h b/xen/include/asm-x86/guest/xen.h
index 3145f75361..01dc3ee6f6 100644
--- a/xen/include/asm-x86/guest/xen.h
+++ b/xen/include/asm-x86/guest/xen.h
@@ -33,8 +33,8 @@ extern bool pv_console;
 extern uint32_t xen_cpuid_base;
 
 void probe_hypervisor(void);
-int hypervisor_alloc_unused_page(mfn_t *mfn);
-int hypervisor_free_unused_page(mfn_t mfn);
+int xg_alloc_unused_page(mfn_t *mfn);
+int xg_free_unused_page(mfn_t mfn);
 
 DECLARE_PER_CPU(unsigned int, vcpu_id);
 DECLARE_PER_CPU(struct vcpu_info *, vcpu_info);
-- 
2.20.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Xen-devel] [PATCH v5 6/8] x86: switch xen guest implementation to use hypervisor framework
  2019-11-30 11:57 [Xen-devel] [PATCH v5 0/8] Port Xen to Hyper-V Wei Liu
                   ` (4 preceding siblings ...)
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 5/8] x86: rename hypervisor_{alloc, free}_unused_page Wei Liu
@ 2019-11-30 11:57 ` Wei Liu
  2019-12-03 14:52   ` Jan Beulich
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 7/8] x86: be more verbose when running on a hypervisor Wei Liu
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 8/8] x86: introduce CONFIG_HYPERV and detection code Wei Liu
  7 siblings, 1 reply; 19+ messages in thread
From: Wei Liu @ 2019-11-30 11:57 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
	Roger Pau Monné

Signed-off-by: Wei Liu <liuwe@microsoft.com>
---
Changes in v5:
1. xen_probe -> xg_probe
2. Drop xen_ prefix for private functions
---
 xen/arch/x86/guest/hypervisor.c   | 27 +++++++++++++++++-
 xen/arch/x86/guest/xen/pvh-boot.c |  2 +-
 xen/arch/x86/guest/xen/xen.c      | 47 ++++++++++++++++++-------------
 xen/arch/x86/setup.c              |  2 +-
 xen/include/asm-x86/guest/xen.h   |  5 ++--
 5 files changed, 59 insertions(+), 24 deletions(-)

diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c
index c35c610d01..6cd86d0c02 100644
--- a/xen/arch/x86/guest/hypervisor.c
+++ b/xen/arch/x86/guest/hypervisor.c
@@ -22,18 +22,43 @@
 #include <xen/types.h>
 
 #include <asm/cache.h>
-#include <asm/guest/hypervisor.h>
+#include <asm/guest.h>
 
 static const struct hypervisor_ops __read_mostly *ops;
 
 const char *__init hypervisor_probe(void)
 {
+    if ( !cpu_has_hypervisor )
+        return NULL;
+
+    if ( ops )
+        return ops->name;
+
+    ops = xg_probe();
     if ( ops )
         return ops->name;
 
     return NULL;
 }
 
+void __init hypervisor_setup(void)
+{
+    if ( ops && ops->setup )
+        ops->setup();
+}
+
+void hypervisor_ap_setup(void)
+{
+    if ( ops && ops->ap_setup )
+        ops->ap_setup();
+}
+
+void hypervisor_resume(void)
+{
+    if ( ops && ops->resume )
+        ops->resume();
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/x86/guest/xen/pvh-boot.c b/xen/arch/x86/guest/xen/pvh-boot.c
index ca8e156f7d..498625eae0 100644
--- a/xen/arch/x86/guest/xen/pvh-boot.c
+++ b/xen/arch/x86/guest/xen/pvh-boot.c
@@ -103,7 +103,7 @@ void __init pvh_init(multiboot_info_t **mbi, module_t **mod)
 {
     convert_pvh_info(mbi, mod);
 
-    probe_hypervisor();
+    hypervisor_probe();
     ASSERT(xen_guest);
 
     get_memory_map();
diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c
index 0f5b5267c5..10daa043e4 100644
--- a/xen/arch/x86/guest/xen/xen.c
+++ b/xen/arch/x86/guest/xen/xen.c
@@ -67,22 +67,6 @@ static void __init find_xen_leaves(void)
     }
 }
 
-void __init probe_hypervisor(void)
-{
-    if ( xen_guest || !cpu_has_hypervisor )
-        return;
-
-    find_xen_leaves();
-
-    if ( !xen_cpuid_base )
-        return;
-
-    /* Fill the hypercall page. */
-    wrmsrl(cpuid_ebx(xen_cpuid_base + 2), __pa(hypercall_page));
-
-    xen_guest = true;
-}
-
 static void map_shared_info(void)
 {
     mfn_t mfn;
@@ -245,7 +229,7 @@ static void init_evtchn(void)
     }
 }
 
-void __init hypervisor_setup(void)
+static void __init setup(void)
 {
     init_memmap();
 
@@ -273,7 +257,7 @@ void __init hypervisor_setup(void)
     init_evtchn();
 }
 
-void hypervisor_ap_setup(void)
+static void ap_setup(void)
 {
     set_vcpu_id();
     map_vcpuinfo();
@@ -303,7 +287,7 @@ static void ap_resume(void *unused)
     init_evtchn();
 }
 
-void hypervisor_resume(void)
+static void resume(void)
 {
     /* Reset shared info page. */
     map_shared_info();
@@ -326,6 +310,31 @@ void hypervisor_resume(void)
         pv_console_init();
 }
 
+static const struct hypervisor_ops xg_ops = {
+    .name = "Xen",
+    .setup = setup,
+    .ap_setup = ap_setup,
+    .resume = resume,
+};
+
+const struct hypervisor_ops *__init xg_probe(void)
+{
+    if ( xen_guest )
+        return &xg_ops;
+
+    find_xen_leaves();
+
+    if ( !xen_cpuid_base )
+        return NULL;
+
+    /* Fill the hypercall page. */
+    wrmsrl(cpuid_ebx(xen_cpuid_base + 2), __pa(hypercall_page));
+
+    xen_guest = true;
+
+    return &xg_ops;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 7d27f36053..a6b354c29f 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -763,7 +763,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
      * allocing any xenheap structures wanted in lower memory. */
     kexec_early_calculations();
 
-    probe_hypervisor();
+    hypervisor_probe();
 
     parse_video_info();
 
diff --git a/xen/include/asm-x86/guest/xen.h b/xen/include/asm-x86/guest/xen.h
index 01dc3ee6f6..2042a9a0c2 100644
--- a/xen/include/asm-x86/guest/xen.h
+++ b/xen/include/asm-x86/guest/xen.h
@@ -23,6 +23,7 @@
 
 #include <asm/e820.h>
 #include <asm/fixmap.h>
+#include <asm/guest/hypervisor.h>
 
 #define XEN_shared_info ((struct shared_info *)fix_to_virt(FIX_XEN_SHARED_INFO))
 
@@ -32,7 +33,7 @@ extern bool xen_guest;
 extern bool pv_console;
 extern uint32_t xen_cpuid_base;
 
-void probe_hypervisor(void);
+const struct hypervisor_ops *xg_probe(void);
 int xg_alloc_unused_page(mfn_t *mfn);
 int xg_free_unused_page(mfn_t mfn);
 
@@ -44,7 +45,7 @@ DECLARE_PER_CPU(struct vcpu_info *, vcpu_info);
 #define xen_guest 0
 #define pv_console 0
 
-static inline void probe_hypervisor(void) {}
+static inline const struct hypervisor_ops *xg_probe(void) { return NULL; }
 
 #endif /* CONFIG_XEN_GUEST */
 #endif /* __X86_GUEST_XEN_H__ */
-- 
2.20.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Xen-devel] [PATCH v5 7/8] x86: be more verbose when running on a hypervisor
  2019-11-30 11:57 [Xen-devel] [PATCH v5 0/8] Port Xen to Hyper-V Wei Liu
                   ` (5 preceding siblings ...)
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 6/8] x86: switch xen guest implementation to use hypervisor framework Wei Liu
@ 2019-11-30 11:57 ` Wei Liu
  2019-12-03 14:54   ` Jan Beulich
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 8/8] x86: introduce CONFIG_HYPERV and detection code Wei Liu
  7 siblings, 1 reply; 19+ messages in thread
From: Wei Liu @ 2019-11-30 11:57 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
	Roger Pau Monné

Also replace reference to xen_guest.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
---
Changes in v5:
1. Cache and use hypervisor name instead
---
 xen/arch/x86/setup.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index a6b354c29f..fc049eaac8 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -700,6 +700,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
         .max_grant_frames = -1,
         .max_maptrack_frames = -1,
     };
+    const char *hypervisor_name;
 
     /* Critical region without IDT or TSS.  Any fault is deadly! */
 
@@ -763,7 +764,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
      * allocing any xenheap structures wanted in lower memory. */
     kexec_early_calculations();
 
-    hypervisor_probe();
+    hypervisor_name = hypervisor_probe();
 
     parse_video_info();
 
@@ -788,6 +789,8 @@ void __init noreturn __start_xen(unsigned long mbi_p)
     printk("Command line: %s\n", cmdline);
 
     printk("Xen image load base address: %#lx\n", xen_phys_start);
+    if ( hypervisor_name )
+        printk("Running on %s\n", hypervisor_name);
 
 #ifdef CONFIG_VIDEO
     printk("Video information:\n");
@@ -1569,7 +1572,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
             max_cpus = nr_cpu_ids;
     }
 
-    if ( xen_guest )
+    if ( hypervisor_name )
         hypervisor_setup();
 
     /* Low mappings were only needed for some BIOS table parsing. */
-- 
2.20.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Xen-devel] [PATCH v5 8/8] x86: introduce CONFIG_HYPERV and detection code
  2019-11-30 11:57 [Xen-devel] [PATCH v5 0/8] Port Xen to Hyper-V Wei Liu
                   ` (6 preceding siblings ...)
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 7/8] x86: be more verbose when running on a hypervisor Wei Liu
@ 2019-11-30 11:57 ` Wei Liu
  2019-12-03 16:54   ` Wei Liu
  7 siblings, 1 reply; 19+ messages in thread
From: Wei Liu @ 2019-11-30 11:57 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Jan Beulich, Roger Pau Monné

We use the same code structure as we did for Xen.

As starters, detect Hyper-V in probe routine. More complex
functionalities will be added later.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
Reviewed-by: Paul Durrant <pdurrant@amazon.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/Kconfig               |  8 +++++
 xen/arch/x86/guest/Makefile        |  1 +
 xen/arch/x86/guest/hyperv/Makefile |  1 +
 xen/arch/x86/guest/hyperv/hyperv.c | 54 ++++++++++++++++++++++++++++++
 xen/arch/x86/guest/hypervisor.c    |  8 +++++
 xen/include/asm-x86/guest.h        |  1 +
 xen/include/asm-x86/guest/hyperv.h | 43 ++++++++++++++++++++++++
 7 files changed, 116 insertions(+)
 create mode 100644 xen/arch/x86/guest/hyperv/Makefile
 create mode 100644 xen/arch/x86/guest/hyperv/hyperv.c
 create mode 100644 xen/include/asm-x86/guest/hyperv.h

diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig
index 18c8f6fd26..0a02b6ee3f 100644
--- a/xen/arch/x86/Kconfig
+++ b/xen/arch/x86/Kconfig
@@ -164,6 +164,14 @@ endchoice
 config GUEST
 	bool
 
+config HYPERV_GUEST
+	bool "Hyper-V Guest"
+	select GUEST
+	---help---
+	  Support for Xen detecting when it is running under Hyper-V.
+
+	  If unsure, say N.
+
 config XEN_GUEST
 	bool "Xen Guest"
 	select GUEST
diff --git a/xen/arch/x86/guest/Makefile b/xen/arch/x86/guest/Makefile
index f63d64bbee..f164196772 100644
--- a/xen/arch/x86/guest/Makefile
+++ b/xen/arch/x86/guest/Makefile
@@ -1,3 +1,4 @@
 obj-y += hypervisor.o
 
+subdir-$(CONFIG_HYPERV_GUEST) += hyperv
 subdir-$(CONFIG_XEN_GUEST) += xen
diff --git a/xen/arch/x86/guest/hyperv/Makefile b/xen/arch/x86/guest/hyperv/Makefile
new file mode 100644
index 0000000000..68170109a9
--- /dev/null
+++ b/xen/arch/x86/guest/hyperv/Makefile
@@ -0,0 +1 @@
+obj-y += hyperv.o
diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c
new file mode 100644
index 0000000000..916e08ff89
--- /dev/null
+++ b/xen/arch/x86/guest/hyperv/hyperv.c
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * arch/x86/guest/hyperv/hyperv.c
+ *
+ * Support for detecting and running under Hyper-V.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (c) 2019 Microsoft.
+ */
+#include <xen/init.h>
+
+#include <asm/guest.h>
+
+static const struct hypervisor_ops hyperv_ops = {
+    .name = "Hyper-V",
+};
+
+const struct hypervisor_ops * __init hyperv_probe(void)
+{
+    uint32_t eax, ebx, ecx, edx;
+
+    cpuid(0x40000000, &eax, &ebx, &ecx, &edx);
+    if ( !((ebx == 0x7263694d) &&  /* "Micr" */
+           (ecx == 0x666f736f) &&  /* "osof" */
+           (edx == 0x76482074)) )  /* "t Hv" */
+        return NULL;
+
+    cpuid(0x40000001, &eax, &ebx, &ecx, &edx);
+    if ( eax != 0x31237648 )    /* Hv#1 */
+        return NULL;
+
+    return &hyperv_ops;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c
index 6cd86d0c02..65c25115e0 100644
--- a/xen/arch/x86/guest/hypervisor.c
+++ b/xen/arch/x86/guest/hypervisor.c
@@ -38,6 +38,14 @@ const char *__init hypervisor_probe(void)
     if ( ops )
         return ops->name;
 
+    /*
+     * Detection of Hyper-V must come after Xen to avoid false positive due
+     * to viridian support
+     */
+    ops = hyperv_probe();
+    if ( ops )
+        return ops->name;
+
     return NULL;
 }
 
diff --git a/xen/include/asm-x86/guest.h b/xen/include/asm-x86/guest.h
index 8e167165ae..94448606d4 100644
--- a/xen/include/asm-x86/guest.h
+++ b/xen/include/asm-x86/guest.h
@@ -20,6 +20,7 @@
 #define __X86_GUEST_H__
 
 #include <asm/guest/hypercall.h>
+#include <asm/guest/hyperv.h>
 #include <asm/guest/hypervisor.h>
 #include <asm/guest/pvh-boot.h>
 #include <asm/guest/xen.h>
diff --git a/xen/include/asm-x86/guest/hyperv.h b/xen/include/asm-x86/guest/hyperv.h
new file mode 100644
index 0000000000..3f88b94c77
--- /dev/null
+++ b/xen/include/asm-x86/guest/hyperv.h
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * asm-x86/guest/hyperv.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions 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.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (c) 2019 Microsoft.
+ */
+
+#ifndef __X86_GUEST_HYPERV_H__
+#define __X86_GUEST_HYPERV_H__
+
+#ifdef CONFIG_HYPERV_GUEST
+
+#include <asm/guest/hypervisor.h>
+
+const struct hypervisor_ops *hyperv_probe(void);
+
+#else
+
+static inline const struct hypervisor_ops *hyperv_probe(void) { return NULL; }
+
+#endif /* CONFIG_HYPERV_GUEST */
+#endif /* __X86_GUEST_HYPERV_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
2.20.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH v5 4/8] x86: introduce hypervisor framework
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 4/8] x86: introduce hypervisor framework Wei Liu
@ 2019-12-03 14:49   ` Jan Beulich
  2019-12-03 16:29     ` Wei Liu
  0 siblings, 1 reply; 19+ messages in thread
From: Jan Beulich @ 2019-12-03 14:49 UTC (permalink / raw)
  To: Wei Liu
  Cc: Xen Development List, Roger Pau Monné,
	Wei Liu, Michael Kelley, Andrew Cooper

On 30.11.2019 12:57, Wei Liu wrote:
> We will soon implement Hyper-V support for Xen. Add a framework for
> that.
> 
> This requires moving some of the hypervisor_* functions from xen.h to
> hypervisor.h.
> 
> Signed-off-by: Wei Liu <liuwe@microsoft.com>

Acked-by: Jan Beulich <jbeulich@suse.com>
with one more adjustment (sorry for noticing only now):

> --- /dev/null
> +++ b/xen/arch/x86/guest/hypervisor.c
> @@ -0,0 +1,45 @@
> +/******************************************************************************
> + * arch/x86/guest/hypervisor.c
> + *
> + * Support for detecting and running under a hypervisor.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * 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.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; If not, see <http://www.gnu.org/licenses/>.
> + *
> + * Copyright (c) 2019 Microsoft.
> + */
> +#include <xen/init.h>
> +#include <xen/types.h>
> +
> +#include <asm/cache.h>
> +#include <asm/guest/hypervisor.h>
> +
> +static const struct hypervisor_ops __read_mostly *ops;

The __read_mostly is misplaced - it's an attribute of the variable,
not its type, and hence belongs after the * . It just so happens
that the compiler is (still) relatively relaxed in what it accepts,
but I think at least the gcc manual has a warning towards future
more strict behavior.

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH v5 6/8] x86: switch xen guest implementation to use hypervisor framework
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 6/8] x86: switch xen guest implementation to use hypervisor framework Wei Liu
@ 2019-12-03 14:52   ` Jan Beulich
  2019-12-03 16:29     ` Wei Liu
  0 siblings, 1 reply; 19+ messages in thread
From: Jan Beulich @ 2019-12-03 14:52 UTC (permalink / raw)
  To: Wei Liu
  Cc: Xen Development List, Roger Pau Monné,
	Wei Liu, Michael Kelley, Andrew Cooper

On 30.11.2019 12:57, Wei Liu wrote:
> Signed-off-by: Wei Liu <liuwe@microsoft.com>

Acked-by: Jan Beulich <jbeulich@suse.com>
again with one more remark:

> @@ -326,6 +310,31 @@ void hypervisor_resume(void)
>          pv_console_init();
>  }
>  
> +static const struct hypervisor_ops xg_ops = {

Along with other static variable not having an xg_ prefix,
this one could lose its one, too. But I'm not going to make
this a requirement.

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH v5 7/8] x86: be more verbose when running on a hypervisor
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 7/8] x86: be more verbose when running on a hypervisor Wei Liu
@ 2019-12-03 14:54   ` Jan Beulich
  2019-12-03 16:37     ` Wei Liu
  0 siblings, 1 reply; 19+ messages in thread
From: Jan Beulich @ 2019-12-03 14:54 UTC (permalink / raw)
  To: Wei Liu
  Cc: Xen Development List, Andrew Cooper, Wei Liu,
	Roger Pau Monné,
	Michael Kelley

On 30.11.2019 12:57, Wei Liu wrote:
> Also replace reference to xen_guest.
> 
> Signed-off-by: Wei Liu <liuwe@microsoft.com>

Acked-by: Jan Beulich <jbeulich@suse.com>

However, ...

> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -700,6 +700,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
>          .max_grant_frames = -1,
>          .max_maptrack_frames = -1,
>      };
> +    const char *hypervisor_name;
>  
>      /* Critical region without IDT or TSS.  Any fault is deadly! */
>  
> @@ -763,7 +764,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
>       * allocing any xenheap structures wanted in lower memory. */
>      kexec_early_calculations();
>  
> -    hypervisor_probe();
> +    hypervisor_name = hypervisor_probe();

... you no longer calling this function multiple time, why does
patch 4 still put in a respective guard?

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH v5 4/8] x86: introduce hypervisor framework
  2019-12-03 14:49   ` Jan Beulich
@ 2019-12-03 16:29     ` Wei Liu
  0 siblings, 0 replies; 19+ messages in thread
From: Wei Liu @ 2019-12-03 16:29 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley,
	Xen Development List, Roger Pau Monné

On Tue, Dec 03, 2019 at 03:49:33PM +0100, Jan Beulich wrote:
> On 30.11.2019 12:57, Wei Liu wrote:
> > We will soon implement Hyper-V support for Xen. Add a framework for
> > that.
> > 
> > This requires moving some of the hypervisor_* functions from xen.h to
> > hypervisor.h.
> > 
> > Signed-off-by: Wei Liu <liuwe@microsoft.com>
> 
> Acked-by: Jan Beulich <jbeulich@suse.com>
[...]
> > +#include <asm/guest/hypervisor.h>
> > +
> > +static const struct hypervisor_ops __read_mostly *ops;
> 
> The __read_mostly is misplaced - it's an attribute of the variable,
> not its type, and hence belongs after the * . It just so happens
> that the compiler is (still) relatively relaxed in what it accepts,
> but I think at least the gcc manual has a warning towards future
> more strict behavior.

Fixed.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH v5 6/8] x86: switch xen guest implementation to use hypervisor framework
  2019-12-03 14:52   ` Jan Beulich
@ 2019-12-03 16:29     ` Wei Liu
  0 siblings, 0 replies; 19+ messages in thread
From: Wei Liu @ 2019-12-03 16:29 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley,
	Xen Development List, Roger Pau Monné

On Tue, Dec 03, 2019 at 03:52:47PM +0100, Jan Beulich wrote:
> On 30.11.2019 12:57, Wei Liu wrote:
> > Signed-off-by: Wei Liu <liuwe@microsoft.com>
> 
> Acked-by: Jan Beulich <jbeulich@suse.com>
> again with one more remark:
> 
> > @@ -326,6 +310,31 @@ void hypervisor_resume(void)
> >          pv_console_init();
> >  }
> >  
> > +static const struct hypervisor_ops xg_ops = {
> 
> Along with other static variable not having an xg_ prefix,
> this one could lose its one, too. But I'm not going to make
> this a requirement.

I will drop the xg_ prefix locally per your comment here.

Wei.

> 
> Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH v5 7/8] x86: be more verbose when running on a hypervisor
  2019-12-03 14:54   ` Jan Beulich
@ 2019-12-03 16:37     ` Wei Liu
  2019-12-03 16:58       ` Jan Beulich
  0 siblings, 1 reply; 19+ messages in thread
From: Wei Liu @ 2019-12-03 16:37 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley,
	Xen Development List, Roger Pau Monné

On Tue, Dec 03, 2019 at 03:54:35PM +0100, Jan Beulich wrote:
> On 30.11.2019 12:57, Wei Liu wrote:
> > Also replace reference to xen_guest.
> > 
> > Signed-off-by: Wei Liu <liuwe@microsoft.com>
> 
> Acked-by: Jan Beulich <jbeulich@suse.com>

Thanks.

> 
> However, ...
> 
> > --- a/xen/arch/x86/setup.c
> > +++ b/xen/arch/x86/setup.c
> > @@ -700,6 +700,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
> >          .max_grant_frames = -1,
> >          .max_maptrack_frames = -1,
> >      };
> > +    const char *hypervisor_name;
> >  
> >      /* Critical region without IDT or TSS.  Any fault is deadly! */
> >  
> > @@ -763,7 +764,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
> >       * allocing any xenheap structures wanted in lower memory. */
> >      kexec_early_calculations();
> >  
> > -    hypervisor_probe();
> > +    hypervisor_name = hypervisor_probe();
> 
> ... you no longer calling this function multiple time, why does
> patch 4 still put in a respective guard?

Remnant from previous iterations.

I can submit a follow-up patch to drop that -- do really want to
invalidate all the reviews and acks I got so far.

Wei.

> 
> Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH v5 8/8] x86: introduce CONFIG_HYPERV and detection code
  2019-11-30 11:57 ` [Xen-devel] [PATCH v5 8/8] x86: introduce CONFIG_HYPERV and detection code Wei Liu
@ 2019-12-03 16:54   ` Wei Liu
  0 siblings, 0 replies; 19+ messages in thread
From: Wei Liu @ 2019-12-03 16:54 UTC (permalink / raw)
  To: Xen Development List
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Paul Durrant, Michael Kelley,
	Jan Beulich, Roger Pau Monné

On Sat, Nov 30, 2019 at 11:57:37AM +0000, Wei Liu wrote:
[...]
> + */
> +#include <xen/init.h>
> +
> +#include <asm/guest.h>
> +
> +static const struct hypervisor_ops hyperv_ops = {

Since xg_ops has lost its xg_ prefix, I also take the liberty to drop
the hyperv_ prefix here to make things more consistent.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH v5 7/8] x86: be more verbose when running on a hypervisor
  2019-12-03 16:37     ` Wei Liu
@ 2019-12-03 16:58       ` Jan Beulich
  2019-12-03 17:09         ` Wei Liu
  0 siblings, 1 reply; 19+ messages in thread
From: Jan Beulich @ 2019-12-03 16:58 UTC (permalink / raw)
  To: Wei Liu
  Cc: Andrew Cooper, Michael Kelley, Wei Liu, Xen Development List,
	Roger Pau Monné

On 03.12.2019 17:37, Wei Liu wrote:
> On Tue, Dec 03, 2019 at 03:54:35PM +0100, Jan Beulich wrote:
>> On 30.11.2019 12:57, Wei Liu wrote:
>>> Also replace reference to xen_guest.
>>>
>>> Signed-off-by: Wei Liu <liuwe@microsoft.com>
>>
>> Acked-by: Jan Beulich <jbeulich@suse.com>
> 
> Thanks.
> 
>>
>> However, ...
>>
>>> --- a/xen/arch/x86/setup.c
>>> +++ b/xen/arch/x86/setup.c
>>> @@ -700,6 +700,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
>>>          .max_grant_frames = -1,
>>>          .max_maptrack_frames = -1,
>>>      };
>>> +    const char *hypervisor_name;
>>>  
>>>      /* Critical region without IDT or TSS.  Any fault is deadly! */
>>>  
>>> @@ -763,7 +764,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
>>>       * allocing any xenheap structures wanted in lower memory. */
>>>      kexec_early_calculations();
>>>  
>>> -    hypervisor_probe();
>>> +    hypervisor_name = hypervisor_probe();
>>
>> ... you no longer calling this function multiple time, why does
>> patch 4 still put in a respective guard?
> 
> Remnant from previous iterations.
> 
> I can submit a follow-up patch to drop that -- do really want to
> invalidate all the reviews and acks I got so far.

According to my records patch 4 had no acks except mine, which you
could keep with this change (in fact I was thinking of making it
dependent upon the dropping of this leftover). Subsequent patches
may only need re-basing, which doesn't imply dropping of any acks.

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH v5 7/8] x86: be more verbose when running on a hypervisor
  2019-12-03 16:58       ` Jan Beulich
@ 2019-12-03 17:09         ` Wei Liu
  2019-12-03 17:22           ` Wei Liu
  0 siblings, 1 reply; 19+ messages in thread
From: Wei Liu @ 2019-12-03 17:09 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley,
	Xen Development List, Roger Pau Monné

On Tue, Dec 03, 2019 at 05:58:28PM +0100, Jan Beulich wrote:
> On 03.12.2019 17:37, Wei Liu wrote:
> > On Tue, Dec 03, 2019 at 03:54:35PM +0100, Jan Beulich wrote:
> >> On 30.11.2019 12:57, Wei Liu wrote:
> >>> Also replace reference to xen_guest.
> >>>
> >>> Signed-off-by: Wei Liu <liuwe@microsoft.com>
> >>
> >> Acked-by: Jan Beulich <jbeulich@suse.com>
> > 
> > Thanks.
> > 
> >>
> >> However, ...
> >>
> >>> --- a/xen/arch/x86/setup.c
> >>> +++ b/xen/arch/x86/setup.c
> >>> @@ -700,6 +700,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
> >>>          .max_grant_frames = -1,
> >>>          .max_maptrack_frames = -1,
> >>>      };
> >>> +    const char *hypervisor_name;
> >>>  
> >>>      /* Critical region without IDT or TSS.  Any fault is deadly! */
> >>>  
> >>> @@ -763,7 +764,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
> >>>       * allocing any xenheap structures wanted in lower memory. */
> >>>      kexec_early_calculations();
> >>>  
> >>> -    hypervisor_probe();
> >>> +    hypervisor_name = hypervisor_probe();
> >>
> >> ... you no longer calling this function multiple time, why does
> >> patch 4 still put in a respective guard?
> > 
> > Remnant from previous iterations.
> > 
> > I can submit a follow-up patch to drop that -- do really want to
> > invalidate all the reviews and acks I got so far.
> 
> According to my records patch 4 had no acks except mine, which you
> could keep with this change (in fact I was thinking of making it
> dependent upon the dropping of this leftover). Subsequent patches
> may only need re-basing, which doesn't imply dropping of any acks.

OK. In that case, I will drop it locally. If that causes any substantial
changes, I will post another version; otherwise I will just keep all the
tags and push this series soon-ish.

How does that sound to you?

Wei.

> 
> Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH v5 7/8] x86: be more verbose when running on a hypervisor
  2019-12-03 17:09         ` Wei Liu
@ 2019-12-03 17:22           ` Wei Liu
  0 siblings, 0 replies; 19+ messages in thread
From: Wei Liu @ 2019-12-03 17:22 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley,
	Xen Development List, Roger Pau Monné

On Tue, Dec 03, 2019 at 05:09:43PM +0000, Wei Liu wrote:
> On Tue, Dec 03, 2019 at 05:58:28PM +0100, Jan Beulich wrote:
> > On 03.12.2019 17:37, Wei Liu wrote:
> > > On Tue, Dec 03, 2019 at 03:54:35PM +0100, Jan Beulich wrote:
> > >> On 30.11.2019 12:57, Wei Liu wrote:
> > >>> Also replace reference to xen_guest.
> > >>>
> > >>> Signed-off-by: Wei Liu <liuwe@microsoft.com>
> > >>
> > >> Acked-by: Jan Beulich <jbeulich@suse.com>
> > > 
> > > Thanks.
> > > 
> > >>
> > >> However, ...
> > >>
> > >>> --- a/xen/arch/x86/setup.c
> > >>> +++ b/xen/arch/x86/setup.c
> > >>> @@ -700,6 +700,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
> > >>>          .max_grant_frames = -1,
> > >>>          .max_maptrack_frames = -1,
> > >>>      };
> > >>> +    const char *hypervisor_name;
> > >>>  
> > >>>      /* Critical region without IDT or TSS.  Any fault is deadly! */
> > >>>  
> > >>> @@ -763,7 +764,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
> > >>>       * allocing any xenheap structures wanted in lower memory. */
> > >>>      kexec_early_calculations();
> > >>>  
> > >>> -    hypervisor_probe();
> > >>> +    hypervisor_name = hypervisor_probe();
> > >>
> > >> ... you no longer calling this function multiple time, why does
> > >> patch 4 still put in a respective guard?
> > > 
> > > Remnant from previous iterations.
> > > 
> > > I can submit a follow-up patch to drop that -- do really want to
> > > invalidate all the reviews and acks I got so far.
> > 
> > According to my records patch 4 had no acks except mine, which you
> > could keep with this change (in fact I was thinking of making it
> > dependent upon the dropping of this leftover). Subsequent patches
> > may only need re-basing, which doesn't imply dropping of any acks.
> 
> OK. In that case, I will drop it locally. If that causes any substantial
> changes, I will post another version; otherwise I will just keep all the
> tags and push this series soon-ish.
> 
> How does that sound to you?

And it turns out it is indeed trivial. Dropping that hunk in patch 4
only requires a minor fixup to patch 6.

Wei.

> 
> Wei.
> 
> > 
> > Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

end of thread, other threads:[~2019-12-03 17:23 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-30 11:57 [Xen-devel] [PATCH v5 0/8] Port Xen to Hyper-V Wei Liu
2019-11-30 11:57 ` [Xen-devel] [PATCH v5 1/8] x86: introduce CONFIG_GUEST and move code Wei Liu
2019-11-30 11:57 ` [Xen-devel] [PATCH v5 2/8] x86: add missing headers in hypercall.h Wei Liu
2019-11-30 11:57 ` [Xen-devel] [PATCH v5 3/8] x86: drop hypervisor_cpuid_base Wei Liu
2019-11-30 11:57 ` [Xen-devel] [PATCH v5 4/8] x86: introduce hypervisor framework Wei Liu
2019-12-03 14:49   ` Jan Beulich
2019-12-03 16:29     ` Wei Liu
2019-11-30 11:57 ` [Xen-devel] [PATCH v5 5/8] x86: rename hypervisor_{alloc, free}_unused_page Wei Liu
2019-11-30 11:57 ` [Xen-devel] [PATCH v5 6/8] x86: switch xen guest implementation to use hypervisor framework Wei Liu
2019-12-03 14:52   ` Jan Beulich
2019-12-03 16:29     ` Wei Liu
2019-11-30 11:57 ` [Xen-devel] [PATCH v5 7/8] x86: be more verbose when running on a hypervisor Wei Liu
2019-12-03 14:54   ` Jan Beulich
2019-12-03 16:37     ` Wei Liu
2019-12-03 16:58       ` Jan Beulich
2019-12-03 17:09         ` Wei Liu
2019-12-03 17:22           ` Wei Liu
2019-11-30 11:57 ` [Xen-devel] [PATCH v5 8/8] x86: introduce CONFIG_HYPERV and detection code Wei Liu
2019-12-03 16:54   ` Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.