* [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
@ 2019-09-23 10:09 Wei Liu
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 1/8] x86: introduce CONFIG_GUEST and move code Wei Liu
` (9 more replies)
0 siblings, 10 replies; 40+ messages in thread
From: Wei Liu @ 2019-09-23 10:09 UTC (permalink / raw)
To: Xen Development List
Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
Roger Pau Monné
Hi all
In case you're wondering, I can already run a fully fledged Xen system on
Hyper-V with emulated disk and network.
This is the very first stage for porting Xen to run on Hyper-V with all the
goodies Hyper-V has to offer. With this series, Xen can successfully detect
Hyper-V and prints out a message. I would like to first get the directory
structure and kconfig options agreed upon.
There are two major areas to be worked on:
* Make Dom0 able to use Hyper-V's synthetic devices.
* Make Xen use of the synthetic timer, reference TSC and enlightenment VMCS
and other interfaces.
They aren't trivial, and time can be scarce on my side, so I intend to post
patches piece meal when they are ready.
Questions and comments are welcome.
Thanks,
Wei.
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>
Wei Liu (8):
x86: introduce CONFIG_GUEST and move code
x86: include asm_defns.h directly in hypercall.h
x86: drop hypervisor_cpuid_base
x86: factor out xen variants for hypervisor setup code
x86: factor out hypervisor agnostic code
x86: make probe_xen return boolean value
x86: introduce CONFIG_HYPERV and hyperv directory
x86: be more verbose when running nested
xen/arch/x86/Kconfig | 13 ++
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 | 63 ++++++++++
xen/arch/x86/guest/hypervisor.c | 116 ++++++++++++++++++
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 | 73 ++---------
xen/arch/x86/pv/shim.c | 2 +-
xen/arch/x86/setup.c | 11 ++
xen/include/asm-x86/guest.h | 2 +
xen/include/asm-x86/guest/hypercall.h | 2 +
xen/include/asm-x86/guest/hyperv.h | 48 ++++++++
xen/include/asm-x86/guest/hypervisor.h | 58 +++++++++
xen/include/asm-x86/guest/xen.h | 23 +---
17 files changed, 337 insertions(+), 87 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 (100%)
rename xen/arch/x86/guest/{ => xen}/xen.c (80%)
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] 40+ messages in thread
* [Xen-devel] [PATCH for-next RFC 1/8] x86: introduce CONFIG_GUEST and move code
2019-09-23 10:09 [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V Wei Liu
@ 2019-09-23 10:09 ` Wei Liu
2019-09-25 9:59 ` Roger Pau Monné
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 2/8] x86: include asm_defns.h directly in hypercall.h Wei Liu
` (8 subsequent siblings)
9 siblings, 1 reply; 40+ messages in thread
From: Wei Liu @ 2019-09-23 10:09 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>
---
xen/arch/x86/Kconfig | 4 ++++
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, 10 insertions(+), 5 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 288dc6c042..584bdc1bb8 100644
--- a/xen/arch/x86/Kconfig
+++ b/xen/arch/x86/Kconfig
@@ -160,8 +160,12 @@ config XEN_ALIGN_2M
endchoice
+config GUEST
+ bool
+
config XEN_GUEST
def_bool n
+ select GUEST
prompt "Xen 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 2443fd2cc5..99a12d0090 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] 40+ messages in thread
* [Xen-devel] [PATCH for-next RFC 2/8] x86: include asm_defns.h directly in hypercall.h
2019-09-23 10:09 [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V Wei Liu
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 1/8] x86: introduce CONFIG_GUEST and move code Wei Liu
@ 2019-09-23 10:09 ` Wei Liu
2019-09-25 10:02 ` Roger Pau Monné
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 3/8] x86: drop hypervisor_cpuid_base Wei Liu
` (7 subsequent siblings)
9 siblings, 1 reply; 40+ messages in thread
From: Wei Liu @ 2019-09-23 10:09 UTC (permalink / raw)
To: Xen Development List
Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
Roger Pau Monné
ASM_CALL_CONSTRAINT is defined there.
No functional change.
Signed-off-by: Wei Liu <liuwe@microsoft.com>
---
xen/include/asm-x86/guest/hypercall.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/xen/include/asm-x86/guest/hypercall.h b/xen/include/asm-x86/guest/hypercall.h
index d548816b30..c9deca6ffc 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>
--
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] 40+ messages in thread
* [Xen-devel] [PATCH for-next RFC 3/8] x86: drop hypervisor_cpuid_base
2019-09-23 10:09 [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V Wei Liu
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 1/8] x86: introduce CONFIG_GUEST and move code Wei Liu
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 2/8] x86: include asm_defns.h directly in hypercall.h Wei Liu
@ 2019-09-23 10:09 ` Wei Liu
2019-09-25 10:07 ` Roger Pau Monné
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 4/8] x86: factor out xen variants for hypervisor setup code Wei Liu
` (6 subsequent siblings)
9 siblings, 1 reply; 40+ messages in thread
From: Wei Liu @ 2019-09-23 10:09 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.
Signed-off-by: Wei Liu <liuwe@microsoft.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 7b7a5badab..78fc603996 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;
+__read_mostly uint32_t xen_cpuid_base;
extern char hypercall_page[];
static struct rangeset *mem;
@@ -301,11 +301,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 324ca27f93..1b174c24df 100644
--- a/xen/arch/x86/pv/shim.c
+++ b/xen/arch/x86/pv/shim.c
@@ -992,7 +992,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] 40+ messages in thread
* [Xen-devel] [PATCH for-next RFC 4/8] x86: factor out xen variants for hypervisor setup code
2019-09-23 10:09 [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V Wei Liu
` (2 preceding siblings ...)
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 3/8] x86: drop hypervisor_cpuid_base Wei Liu
@ 2019-09-23 10:09 ` Wei Liu
2019-09-25 10:23 ` Roger Pau Monné
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 5/8] x86: factor out hypervisor agnostic code Wei Liu
` (5 subsequent siblings)
9 siblings, 1 reply; 40+ messages in thread
From: Wei Liu @ 2019-09-23 10:09 UTC (permalink / raw)
To: Xen Development List
Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
Roger Pau Monné
We will add Hyper-V specific implementations in the future.
No functional change.
Signed-off-by: Wei Liu <liuwe@microsoft.com>
---
xen/arch/x86/guest/xen/xen.c | 32 ++++++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)
diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c
index 78fc603996..f93c8fbd1c 100644
--- a/xen/arch/x86/guest/xen/xen.c
+++ b/xen/arch/x86/guest/xen/xen.c
@@ -67,7 +67,7 @@ static void __init find_xen_leaves(void)
}
}
-void __init probe_hypervisor(void)
+static void __init probe_xen(void)
{
if ( xen_guest )
return;
@@ -87,6 +87,11 @@ void __init probe_hypervisor(void)
xen_guest = true;
}
+void __init probe_hypervisor(void)
+{
+ probe_xen();
+}
+
static void map_shared_info(void)
{
mfn_t mfn;
@@ -249,10 +254,8 @@ static void init_evtchn(void)
}
}
-void __init hypervisor_setup(void)
+static void __init xen_setup(void)
{
- init_memmap();
-
map_shared_info();
set_vcpu_id();
@@ -277,13 +280,25 @@ void __init hypervisor_setup(void)
init_evtchn();
}
-void hypervisor_ap_setup(void)
+void __init hypervisor_setup(void)
+{
+ init_memmap();
+
+ xen_setup();
+}
+
+static void xen_ap_setup(void)
{
set_vcpu_id();
map_vcpuinfo();
init_evtchn();
}
+void hypervisor_ap_setup(void)
+{
+ xen_ap_setup();
+}
+
int hypervisor_alloc_unused_page(mfn_t *mfn)
{
unsigned long m;
@@ -307,7 +322,7 @@ static void ap_resume(void *unused)
init_evtchn();
}
-void hypervisor_resume(void)
+static void xen_resume(void)
{
/* Reset shared info page. */
map_shared_info();
@@ -330,6 +345,11 @@ void hypervisor_resume(void)
pv_console_init();
}
+void hypervisor_resume(void)
+{
+ xen_resume();
+}
+
/*
* Local variables:
* mode: 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] 40+ messages in thread
* [Xen-devel] [PATCH for-next RFC 5/8] x86: factor out hypervisor agnostic code
2019-09-23 10:09 [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V Wei Liu
` (3 preceding siblings ...)
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 4/8] x86: factor out xen variants for hypervisor setup code Wei Liu
@ 2019-09-23 10:09 ` Wei Liu
2019-09-25 10:39 ` Roger Pau Monné
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 6/8] x86: make probe_xen return boolean value Wei Liu
` (4 subsequent siblings)
9 siblings, 1 reply; 40+ messages in thread
From: Wei Liu @ 2019-09-23 10:09 UTC (permalink / raw)
To: Xen Development List
Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
Roger Pau Monné
The only implementation there is Xen.
No functional change.
Signed-off-by: Wei Liu <liuwe@microsoft.com>
---
xen/arch/x86/guest/Makefile | 2 +
xen/arch/x86/guest/hypervisor.c | 112 +++++++++++++++++++++++++
xen/arch/x86/guest/xen/xen.c | 81 +-----------------
xen/include/asm-x86/guest.h | 1 +
xen/include/asm-x86/guest/hypervisor.h | 58 +++++++++++++
xen/include/asm-x86/guest/xen.h | 21 ++---
6 files changed, 182 insertions(+), 93 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..b0a724bf13
--- /dev/null
+++ b/xen/arch/x86/guest/hypervisor.c
@@ -0,0 +1,112 @@
+/******************************************************************************
+ * 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) 2017 Citrix Systems Ltd.
+ */
+
+#include <xen/init.h>
+#include <xen/mm.h>
+#include <xen/rangeset.h>
+
+#include <asm/guest.h>
+#include <asm/processor.h>
+
+static struct rangeset *mem;
+
+void __init probe_hypervisor(void)
+{
+ /* Too early to use cpu_has_hypervisor */
+ if ( !(cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_HYPERVISOR)) )
+ return;
+
+ probe_xen();
+}
+
+static void __init init_memmap(void)
+{
+ unsigned int i;
+
+ mem = rangeset_new(NULL, "host memory map", 0);
+ if ( !mem )
+ panic("failed to allocate PFN usage rangeset\n");
+
+ /*
+ * Mark up to the last memory page (or 4GiB) as RAM. This is done because
+ * Xen doesn't know the position of possible MMIO holes, so at least try to
+ * avoid the know MMIO hole below 4GiB. Note that this is subject to future
+ * discussion and improvements.
+ */
+ if ( rangeset_add_range(mem, 0, max_t(unsigned long, max_page - 1,
+ PFN_DOWN(GB(4) - 1))) )
+ panic("unable to add RAM to in-use PFN rangeset\n");
+
+ for ( i = 0; i < e820.nr_map; i++ )
+ {
+ struct e820entry *e = &e820.map[i];
+
+ if ( rangeset_add_range(mem, PFN_DOWN(e->addr),
+ PFN_UP(e->addr + e->size - 1)) )
+ panic("unable to add range [%#lx, %#lx] to in-use PFN rangeset\n",
+ PFN_DOWN(e->addr), PFN_UP(e->addr + e->size - 1));
+ }
+}
+
+void __init hypervisor_setup(void)
+{
+ init_memmap();
+
+ xen_setup();
+}
+
+void hypervisor_ap_setup(void)
+{
+ xen_ap_setup();
+}
+
+int hypervisor_alloc_unused_page(mfn_t *mfn)
+{
+ unsigned long m;
+ int rc;
+
+ rc = rangeset_claim_range(mem, 1, &m);
+ if ( !rc )
+ *mfn = _mfn(m);
+
+ return rc;
+}
+
+int hypervisor_free_unused_page(mfn_t mfn)
+{
+ return rangeset_remove_range(mem, mfn_x(mfn), mfn_x(mfn));
+}
+
+void hypervisor_resume(void)
+{
+ xen_resume();
+}
+
+/*
+ * 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/xen/xen.c b/xen/arch/x86/guest/xen/xen.c
index f93c8fbd1c..a730e6ad1b 100644
--- a/xen/arch/x86/guest/xen/xen.c
+++ b/xen/arch/x86/guest/xen/xen.c
@@ -39,7 +39,6 @@ bool __read_mostly xen_guest;
__read_mostly uint32_t xen_cpuid_base;
extern char hypercall_page[];
-static struct rangeset *mem;
DEFINE_PER_CPU(unsigned int, vcpu_id);
@@ -67,15 +66,11 @@ static void __init find_xen_leaves(void)
}
}
-static void __init probe_xen(void)
+void __init probe_xen(void)
{
if ( xen_guest )
return;
- /* Too early to use cpu_has_hypervisor */
- if ( !(cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_HYPERVISOR)) )
- return;
-
find_xen_leaves();
if ( !xen_cpuid_base )
@@ -87,11 +82,6 @@ static void __init probe_xen(void)
xen_guest = true;
}
-void __init probe_hypervisor(void)
-{
- probe_xen();
-}
-
static void map_shared_info(void)
{
mfn_t mfn;
@@ -166,35 +156,6 @@ static void set_vcpu_id(void)
this_cpu(vcpu_id) = smp_processor_id();
}
-static void __init init_memmap(void)
-{
- unsigned int i;
-
- mem = rangeset_new(NULL, "host memory map", 0);
- if ( !mem )
- panic("failed to allocate PFN usage rangeset\n");
-
- /*
- * Mark up to the last memory page (or 4GiB) as RAM. This is done because
- * Xen doesn't know the position of possible MMIO holes, so at least try to
- * avoid the know MMIO hole below 4GiB. Note that this is subject to future
- * discussion and improvements.
- */
- if ( rangeset_add_range(mem, 0, max_t(unsigned long, max_page - 1,
- PFN_DOWN(GB(4) - 1))) )
- panic("unable to add RAM to in-use PFN rangeset\n");
-
- for ( i = 0; i < e820.nr_map; i++ )
- {
- struct e820entry *e = &e820.map[i];
-
- if ( rangeset_add_range(mem, PFN_DOWN(e->addr),
- PFN_UP(e->addr + e->size - 1)) )
- panic("unable to add range [%#lx, %#lx] to in-use PFN rangeset\n",
- PFN_DOWN(e->addr), PFN_UP(e->addr + e->size - 1));
- }
-}
-
static void xen_evtchn_upcall(struct cpu_user_regs *regs)
{
struct vcpu_info *vcpu_info = this_cpu(vcpu_info);
@@ -254,7 +215,7 @@ static void init_evtchn(void)
}
}
-static void __init xen_setup(void)
+void __init xen_setup(void)
{
map_shared_info();
@@ -280,49 +241,20 @@ static void __init xen_setup(void)
init_evtchn();
}
-void __init hypervisor_setup(void)
-{
- init_memmap();
-
- xen_setup();
-}
-
-static void xen_ap_setup(void)
+void xen_ap_setup(void)
{
set_vcpu_id();
map_vcpuinfo();
init_evtchn();
}
-void hypervisor_ap_setup(void)
-{
- xen_ap_setup();
-}
-
-int hypervisor_alloc_unused_page(mfn_t *mfn)
-{
- unsigned long m;
- int rc;
-
- rc = rangeset_claim_range(mem, 1, &m);
- if ( !rc )
- *mfn = _mfn(m);
-
- return rc;
-}
-
-int hypervisor_free_unused_page(mfn_t mfn)
-{
- return rangeset_remove_range(mem, mfn_x(mfn), mfn_x(mfn));
-}
-
static void ap_resume(void *unused)
{
map_vcpuinfo();
init_evtchn();
}
-static void xen_resume(void)
+void xen_resume(void)
{
/* Reset shared info page. */
map_shared_info();
@@ -345,11 +277,6 @@ static void xen_resume(void)
pv_console_init();
}
-void hypervisor_resume(void)
-{
- xen_resume();
-}
-
/*
* Local variables:
* mode: C
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..135ad36f72
--- /dev/null
+++ b/xen/include/asm-x86/guest/hypervisor.h
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * 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/>.
+ */
+
+#ifndef __X86_GUEST_HYPERVISOR_H__
+#define __X86_GUEST_HYPERVISOR_H__
+
+#ifdef CONFIG_GUEST
+
+#include <xen/mm.h>
+
+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);
+
+#else
+
+#include <xen/lib.h>
+
+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_GUEST */
+#endif /* __X86_GUEST_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..d031f1f70d 100644
--- a/xen/include/asm-x86/guest/xen.h
+++ b/xen/include/asm-x86/guest/xen.h
@@ -32,12 +32,10 @@ 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);
-void hypervisor_resume(void);
+void probe_xen(void);
+void xen_setup(void);
+void xen_ap_setup(void);
+void xen_resume(void);
DECLARE_PER_CPU(unsigned int, vcpu_id);
DECLARE_PER_CPU(struct vcpu_info *, vcpu_info);
@@ -47,16 +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 void hypervisor_setup(void)
-{
- ASSERT_UNREACHABLE();
-}
-static inline void hypervisor_ap_setup(void)
-{
- ASSERT_UNREACHABLE();
-}
+static inline void probe_xen(void) {}
#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] 40+ messages in thread
* [Xen-devel] [PATCH for-next RFC 6/8] x86: make probe_xen return boolean value
2019-09-23 10:09 [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V Wei Liu
` (4 preceding siblings ...)
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 5/8] x86: factor out hypervisor agnostic code Wei Liu
@ 2019-09-23 10:09 ` Wei Liu
2019-09-25 10:44 ` Roger Pau Monné
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 7/8] x86: introduce CONFIG_HYPERV and hyperv directory Wei Liu
` (3 subsequent siblings)
9 siblings, 1 reply; 40+ messages in thread
From: Wei Liu @ 2019-09-23 10:09 UTC (permalink / raw)
To: Xen Development List
Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
Roger Pau Monné
We need indication whether it has succeeded or not.
Signed-off-by: Wei Liu <liuwe@microsoft.com>
---
xen/arch/x86/guest/hypervisor.c | 5 ++++-
xen/arch/x86/guest/xen/xen.c | 7 ++++---
xen/include/asm-x86/guest/xen.h | 4 ++--
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c
index b0a724bf13..fb572b0402 100644
--- a/xen/arch/x86/guest/hypervisor.c
+++ b/xen/arch/x86/guest/hypervisor.c
@@ -34,7 +34,10 @@ void __init probe_hypervisor(void)
if ( !(cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_HYPERVISOR)) )
return;
- probe_xen();
+ if ( probe_xen() )
+ return;
+
+ /* Hyper-V probing to follow. */
}
static void __init init_memmap(void)
diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c
index a730e6ad1b..8390b045f0 100644
--- a/xen/arch/x86/guest/xen/xen.c
+++ b/xen/arch/x86/guest/xen/xen.c
@@ -66,20 +66,21 @@ static void __init find_xen_leaves(void)
}
}
-void __init probe_xen(void)
+bool __init probe_xen(void)
{
if ( xen_guest )
- return;
+ return true;
find_xen_leaves();
if ( !xen_cpuid_base )
- return;
+ return false;
/* Fill the hypercall page. */
wrmsrl(cpuid_ebx(xen_cpuid_base + 2), __pa(hypercall_page));
xen_guest = true;
+ return true;
}
static void map_shared_info(void)
diff --git a/xen/include/asm-x86/guest/xen.h b/xen/include/asm-x86/guest/xen.h
index d031f1f70d..7eda3d4956 100644
--- a/xen/include/asm-x86/guest/xen.h
+++ b/xen/include/asm-x86/guest/xen.h
@@ -32,7 +32,7 @@ extern bool xen_guest;
extern bool pv_console;
extern uint32_t xen_cpuid_base;
-void probe_xen(void);
+bool probe_xen(void);
void xen_setup(void);
void xen_ap_setup(void);
void xen_resume(void);
@@ -45,7 +45,7 @@ DECLARE_PER_CPU(struct vcpu_info *, vcpu_info);
#define xen_guest 0
#define pv_console 0
-static inline void probe_xen(void) {}
+static inline bool probe_xen(void) { return false; }
#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] 40+ messages in thread
* [Xen-devel] [PATCH for-next RFC 7/8] x86: introduce CONFIG_HYPERV and hyperv directory
2019-09-23 10:09 [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V Wei Liu
` (5 preceding siblings ...)
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 6/8] x86: make probe_xen return boolean value Wei Liu
@ 2019-09-23 10:09 ` Wei Liu
2019-09-25 10:48 ` Roger Pau Monné
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 8/8] x86: be more verbose when running nested Wei Liu
` (2 subsequent siblings)
9 siblings, 1 reply; 40+ messages in thread
From: Wei Liu @ 2019-09-23 10:09 UTC (permalink / raw)
To: Xen Development List
Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
Roger Pau Monné
We use the same code structure as we did for Xen code.
As starters, detect Hyper-V in probe_hyperv. More complex
functionality will be added later.
Signed-off-by: Wei Liu <liuwe@microsoft.com>
---
xen/arch/x86/Kconfig | 9 +++++
xen/arch/x86/guest/Makefile | 1 +
xen/arch/x86/guest/hyperv/Makefile | 1 +
xen/arch/x86/guest/hyperv/hyperv.c | 63 ++++++++++++++++++++++++++++++
xen/arch/x86/guest/hypervisor.c | 3 +-
xen/include/asm-x86/guest.h | 1 +
xen/include/asm-x86/guest/hyperv.h | 48 +++++++++++++++++++++++
7 files changed, 125 insertions(+), 1 deletion(-)
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 584bdc1bb8..c5a93babfe 100644
--- a/xen/arch/x86/Kconfig
+++ b/xen/arch/x86/Kconfig
@@ -163,6 +163,15 @@ endchoice
config GUEST
bool
+config HYPERV_GUEST
+ def_bool n
+ select GUEST
+ prompt "Hyper-V Guest"
+ ---help---
+ Support for Xen detecting when it is running under Hyper-V.
+
+ If unsure, say N.
+
config XEN_GUEST
def_bool n
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..488e9c14a3
--- /dev/null
+++ b/xen/arch/x86/guest/hyperv/hyperv.c
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * 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>
+
+bool __read_mostly hyperv_guest;
+
+bool __init probe_hyperv(void)
+{
+ uint32_t eax, ebx, ecx, edx;
+
+ if ( hyperv_guest )
+ return true;
+
+ cpuid(0x40000000, &eax, &ebx, &ecx, &edx);
+ if ( (ebx == 0x7263694d) && /* "Micr" */
+ (ecx == 0x666f736f) && /* "osof" */
+ (edx == 0x76482074) ) /* "t Hv" */
+ hyperv_guest = true;
+
+ return hyperv_guest;
+}
+
+void __init hyperv_setup(void)
+{
+}
+
+void hyperv_ap_setup(void)
+{
+}
+
+void hyperv_resume(void)
+{
+}
+
+/*
+ * 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 fb572b0402..17d56cd05e 100644
--- a/xen/arch/x86/guest/hypervisor.c
+++ b/xen/arch/x86/guest/hypervisor.c
@@ -37,7 +37,8 @@ void __init probe_hypervisor(void)
if ( probe_xen() )
return;
- /* Hyper-V probing to follow. */
+ if ( probe_hyperv() )
+ return;
}
static void __init init_memmap(void)
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..30e5135a72
--- /dev/null
+++ b/xen/include/asm-x86/guest/hyperv.h
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * 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
+
+extern bool hyperv_guest;
+
+bool probe_hyperv(void);
+void hyperv_setup(void);
+void hyperv_ap_setup(void);
+void hyperv_resume(void);
+
+#else
+
+#define hyperv_guest 0
+
+static inline bool probe_hyperv(void) { return false; }
+
+#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] 40+ messages in thread
* [Xen-devel] [PATCH for-next RFC 8/8] x86: be more verbose when running nested
2019-09-23 10:09 [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V Wei Liu
` (6 preceding siblings ...)
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 7/8] x86: introduce CONFIG_HYPERV and hyperv directory Wei Liu
@ 2019-09-23 10:09 ` Wei Liu
2019-09-25 10:54 ` Roger Pau Monné
2019-09-23 10:48 ` [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V Paul Durrant
2019-09-25 11:02 ` Roger Pau Monné
9 siblings, 1 reply; 40+ messages in thread
From: Wei Liu @ 2019-09-23 10:09 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>
---
xen/arch/x86/setup.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index dec60d0301..bbcc5a503d 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -789,6 +789,17 @@ void __init noreturn __start_xen(unsigned long mbi_p)
printk("Xen image load base address: %#lx\n", xen_phys_start);
+#ifdef CONFIG_GUEST
+#ifdef CONFIG_XEN_GUEST
+ if ( xen_guest )
+ printk("Running on Xen hypervisor\n");
+#endif
+#ifdef CONFIG_HYPERV_GUEST
+ if ( hyperv_guest )
+ printk("Running on Hyper-V\n");
+#endif
+#endif
+
#ifdef CONFIG_VIDEO
printk("Video information:\n");
--
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] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
2019-09-23 10:09 [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V Wei Liu
` (7 preceding siblings ...)
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 8/8] x86: be more verbose when running nested Wei Liu
@ 2019-09-23 10:48 ` Paul Durrant
2019-09-23 11:27 ` Wei Liu
2019-09-25 11:02 ` Roger Pau Monné
9 siblings, 1 reply; 40+ messages in thread
From: Paul Durrant @ 2019-09-23 10:48 UTC (permalink / raw)
To: 'Wei Liu', Xen Development List
Cc: Andrew Cooper, Roger Pau Monne, Wei Liu, Jan Beulich,
Michael Kelley
> -----Original Message-----
> From: Xen-devel <xen-devel-bounces@lists.xenproject.org> On Behalf Of Wei Liu
> Sent: 23 September 2019 11:09
> To: Xen Development List <xen-devel@lists.xenproject.org>
> Cc: Wei Liu <liuwe@microsoft.com>; Wei Liu <wl@xen.org>; Andrew Cooper <Andrew.Cooper3@citrix.com>;
> Michael Kelley <mikelley@microsoft.com>; Jan Beulich <jbeulich@suse.com>; Roger Pau Monne
> <roger.pau@citrix.com>
> Subject: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
>
> Hi all
>
> In case you're wondering, I can already run a fully fledged Xen system on
> Hyper-V with emulated disk and network.
>
> This is the very first stage for porting Xen to run on Hyper-V with all the
> goodies Hyper-V has to offer. With this series, Xen can successfully detect
> Hyper-V and prints out a message. I would like to first get the directory
> structure and kconfig options agreed upon.
>
> There are two major areas to be worked on:
> * Make Dom0 able to use Hyper-V's synthetic devices.
> * Make Xen use of the synthetic timer, reference TSC and enlightenment VMCS
> and other interfaces.
>
> They aren't trivial, and time can be scarce on my side, so I intend to post
> patches piece meal when they are ready.
>
> Questions and comments are welcome.
Yay! Glad you found the time to do this :-) Making use of the synic, stimer, will be useful. To get the benefit for nested guests though, I assume we'll need to exposed enlightened VMCS, EPT flush, etc. through?
Cheers,
Paul
>
> Thanks,
> Wei.
>
> 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>
>
> Wei Liu (8):
> x86: introduce CONFIG_GUEST and move code
> x86: include asm_defns.h directly in hypercall.h
> x86: drop hypervisor_cpuid_base
> x86: factor out xen variants for hypervisor setup code
> x86: factor out hypervisor agnostic code
> x86: make probe_xen return boolean value
> x86: introduce CONFIG_HYPERV and hyperv directory
> x86: be more verbose when running nested
>
> xen/arch/x86/Kconfig | 13 ++
> 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 | 63 ++++++++++
> xen/arch/x86/guest/hypervisor.c | 116 ++++++++++++++++++
> 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 | 73 ++---------
> xen/arch/x86/pv/shim.c | 2 +-
> xen/arch/x86/setup.c | 11 ++
> xen/include/asm-x86/guest.h | 2 +
> xen/include/asm-x86/guest/hypercall.h | 2 +
> xen/include/asm-x86/guest/hyperv.h | 48 ++++++++
> xen/include/asm-x86/guest/hypervisor.h | 58 +++++++++
> xen/include/asm-x86/guest/xen.h | 23 +---
> 17 files changed, 337 insertions(+), 87 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 (100%)
> rename xen/arch/x86/guest/{ => xen}/xen.c (80%)
> 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
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
2019-09-23 10:48 ` [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V Paul Durrant
@ 2019-09-23 11:27 ` Wei Liu
2019-09-23 12:11 ` Paul Durrant
0 siblings, 1 reply; 40+ messages in thread
From: Wei Liu @ 2019-09-23 11:27 UTC (permalink / raw)
To: Paul Durrant
Cc: Wei Liu, 'Wei Liu', Andrew Cooper, Michael Kelley,
Jan Beulich, Xen Development List, Roger Pau Monne
On Mon, Sep 23, 2019 at 10:48:45AM +0000, Paul Durrant wrote:
> > -----Original Message-----
> > From: Xen-devel <xen-devel-bounces@lists.xenproject.org> On Behalf Of Wei Liu
> > Sent: 23 September 2019 11:09
> > To: Xen Development List <xen-devel@lists.xenproject.org>
> > Cc: Wei Liu <liuwe@microsoft.com>; Wei Liu <wl@xen.org>; Andrew Cooper <Andrew.Cooper3@citrix.com>;
> > Michael Kelley <mikelley@microsoft.com>; Jan Beulich <jbeulich@suse.com>; Roger Pau Monne
> > <roger.pau@citrix.com>
> > Subject: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
> >
> > Hi all
> >
> > In case you're wondering, I can already run a fully fledged Xen system on
> > Hyper-V with emulated disk and network.
> >
> > This is the very first stage for porting Xen to run on Hyper-V with all the
> > goodies Hyper-V has to offer. With this series, Xen can successfully detect
> > Hyper-V and prints out a message. I would like to first get the directory
> > structure and kconfig options agreed upon.
> >
> > There are two major areas to be worked on:
> > * Make Dom0 able to use Hyper-V's synthetic devices.
> > * Make Xen use of the synthetic timer, reference TSC and enlightenment VMCS
> > and other interfaces.
> >
> > They aren't trivial, and time can be scarce on my side, so I intend to post
> > patches piece meal when they are ready.
> >
> > Questions and comments are welcome.
>
> Yay! Glad you found the time to do this :-) Making use of the synic,
> stimer, will be useful. To get the benefit for nested guests though, I
> assume we'll need to exposed enlightened VMCS, EPT flush, etc.
> through?
Per TLFS, eVMCS should be used by L1 Xen.
Not sure what you meant by EPT flush. If you mean things like
HvFlushGuestPhysicalAddressSpace, I think they should be used by Xen
only as well. I'm not sure whether they should be expose to L2 guests.
There are hypercalls for virtual TLB management. We may choose to expose
them to L2 guests for better performance.
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
2019-09-23 11:27 ` Wei Liu
@ 2019-09-23 12:11 ` Paul Durrant
2019-09-23 12:54 ` Wei Liu
0 siblings, 1 reply; 40+ messages in thread
From: Paul Durrant @ 2019-09-23 12:11 UTC (permalink / raw)
To: 'Wei Liu'
Cc: Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
Xen Development List, Roger Pau Monne
> -----Original Message-----
> From: Wei Liu <wl@xen.org>
> Sent: 23 September 2019 12:27
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: 'Wei Liu' <wl@xen.org>; Xen Development List <xen-devel@lists.xenproject.org>; Wei Liu
> <liuwe@microsoft.com>; Andrew Cooper <Andrew.Cooper3@citrix.com>; Michael Kelley
> <mikelley@microsoft.com>; Jan Beulich <jbeulich@suse.com>; Roger Pau Monne <roger.pau@citrix.com>
> Subject: Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
>
> On Mon, Sep 23, 2019 at 10:48:45AM +0000, Paul Durrant wrote:
> > > -----Original Message-----
> > > From: Xen-devel <xen-devel-bounces@lists.xenproject.org> On Behalf Of Wei Liu
> > > Sent: 23 September 2019 11:09
> > > To: Xen Development List <xen-devel@lists.xenproject.org>
> > > Cc: Wei Liu <liuwe@microsoft.com>; Wei Liu <wl@xen.org>; Andrew Cooper
> <Andrew.Cooper3@citrix.com>;
> > > Michael Kelley <mikelley@microsoft.com>; Jan Beulich <jbeulich@suse.com>; Roger Pau Monne
> > > <roger.pau@citrix.com>
> > > Subject: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
> > >
> > > Hi all
> > >
> > > In case you're wondering, I can already run a fully fledged Xen system on
> > > Hyper-V with emulated disk and network.
> > >
> > > This is the very first stage for porting Xen to run on Hyper-V with all the
> > > goodies Hyper-V has to offer. With this series, Xen can successfully detect
> > > Hyper-V and prints out a message. I would like to first get the directory
> > > structure and kconfig options agreed upon.
> > >
> > > There are two major areas to be worked on:
> > > * Make Dom0 able to use Hyper-V's synthetic devices.
> > > * Make Xen use of the synthetic timer, reference TSC and enlightenment VMCS
> > > and other interfaces.
> > >
> > > They aren't trivial, and time can be scarce on my side, so I intend to post
> > > patches piece meal when they are ready.
> > >
> > > Questions and comments are welcome.
> >
> > Yay! Glad you found the time to do this :-) Making use of the synic,
> > stimer, will be useful. To get the benefit for nested guests though, I
> > assume we'll need to exposed enlightened VMCS, EPT flush, etc.
> > through?
>
> Per TLFS, eVMCS should be used by L1 Xen.
Yes, I guess it only needs to be used by L1, but Windows is using an increasing number of VMs for various purposes so I think making it stack well would be useful.
>
> Not sure what you meant by EPT flush. If you mean things like
> HvFlushGuestPhysicalAddressSpace, I think they should be used by Xen
> only as well. I'm not sure whether they should be expose to L2 guests.
>
Yes, that's what I meant and, again, I was thinking about the nested Windows guest using VMs itself.
> There are hypercalls for virtual TLB management. We may choose to expose
> them to L2 guests for better performance.
>
Do you mean 'Direct Virtual Flush'? The hypercalls in question are already handled in viridian for the purposes of remote TLB flush, so I guess it would be a question of wiring them through.
Paul
> Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
2019-09-23 12:11 ` Paul Durrant
@ 2019-09-23 12:54 ` Wei Liu
2019-09-23 13:33 ` Wei Liu
0 siblings, 1 reply; 40+ messages in thread
From: Wei Liu @ 2019-09-23 12:54 UTC (permalink / raw)
To: Paul Durrant
Cc: Wei Liu, 'Wei Liu', Andrew Cooper, Michael Kelley,
Jan Beulich, Xen Development List, Roger Pau Monne
On Mon, Sep 23, 2019 at 12:11:26PM +0000, Paul Durrant wrote:
> > -----Original Message-----
> > From: Wei Liu <wl@xen.org>
> > Sent: 23 September 2019 12:27
> > To: Paul Durrant <Paul.Durrant@citrix.com>
> > Cc: 'Wei Liu' <wl@xen.org>; Xen Development List <xen-devel@lists.xenproject.org>; Wei Liu
> > <liuwe@microsoft.com>; Andrew Cooper <Andrew.Cooper3@citrix.com>; Michael Kelley
> > <mikelley@microsoft.com>; Jan Beulich <jbeulich@suse.com>; Roger Pau Monne <roger.pau@citrix.com>
> > Subject: Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
> >
> > On Mon, Sep 23, 2019 at 10:48:45AM +0000, Paul Durrant wrote:
> > > > -----Original Message-----
> > > > From: Xen-devel <xen-devel-bounces@lists.xenproject.org> On Behalf Of Wei Liu
> > > > Sent: 23 September 2019 11:09
> > > > To: Xen Development List <xen-devel@lists.xenproject.org>
> > > > Cc: Wei Liu <liuwe@microsoft.com>; Wei Liu <wl@xen.org>; Andrew Cooper
> > <Andrew.Cooper3@citrix.com>;
> > > > Michael Kelley <mikelley@microsoft.com>; Jan Beulich <jbeulich@suse.com>; Roger Pau Monne
> > > > <roger.pau@citrix.com>
> > > > Subject: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
> > > >
> > > > Hi all
> > > >
> > > > In case you're wondering, I can already run a fully fledged Xen system on
> > > > Hyper-V with emulated disk and network.
> > > >
> > > > This is the very first stage for porting Xen to run on Hyper-V with all the
> > > > goodies Hyper-V has to offer. With this series, Xen can successfully detect
> > > > Hyper-V and prints out a message. I would like to first get the directory
> > > > structure and kconfig options agreed upon.
> > > >
> > > > There are two major areas to be worked on:
> > > > * Make Dom0 able to use Hyper-V's synthetic devices.
> > > > * Make Xen use of the synthetic timer, reference TSC and enlightenment VMCS
> > > > and other interfaces.
> > > >
> > > > They aren't trivial, and time can be scarce on my side, so I intend to post
> > > > patches piece meal when they are ready.
> > > >
> > > > Questions and comments are welcome.
> > >
> > > Yay! Glad you found the time to do this :-) Making use of the synic,
> > > stimer, will be useful. To get the benefit for nested guests though, I
> > > assume we'll need to exposed enlightened VMCS, EPT flush, etc.
> > > through?
> >
> > Per TLFS, eVMCS should be used by L1 Xen.
>
> Yes, I guess it only needs to be used by L1, but Windows is using an
> increasing number of VMs for various purposes so I think making it
> stack well would be useful.
>
> >
> > Not sure what you meant by EPT flush. If you mean things like
> > HvFlushGuestPhysicalAddressSpace, I think they should be used by Xen
> > only as well. I'm not sure whether they should be expose to L2 guests.
> >
>
> Yes, that's what I meant and, again, I was thinking about the nested
> Windows guest using VMs itself.
So this is basically nested on nested. I'm not sure how to make that
work yet. I'm also not sure how well these interfaces stack. TLFS only
describes one level of nesting. I will need to ask if we can make nested
on nested work.
>
> > There are hypercalls for virtual TLB management. We may choose to expose
> > them to L2 guests for better performance.
> >
>
> Do you mean 'Direct Virtual Flush'? The hypercalls in question are already handled in viridian for the purposes of remote TLB flush, so I guess it would be a question of wiring them through.
Yes. I meant that.
Wei.
>
> Paul
>
> > Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
2019-09-23 12:54 ` Wei Liu
@ 2019-09-23 13:33 ` Wei Liu
2019-09-23 13:47 ` Paul Durrant
0 siblings, 1 reply; 40+ messages in thread
From: Wei Liu @ 2019-09-23 13:33 UTC (permalink / raw)
To: Paul Durrant
Cc: Wei Liu, 'Wei Liu', Andrew Cooper, Michael Kelley,
Jan Beulich, Xen Development List, Roger Pau Monne
And a bit more thought.
On Mon, Sep 23, 2019 at 01:54:31PM +0100, Wei Liu wrote:
[...]
> > >
> > > Per TLFS, eVMCS should be used by L1 Xen.
> >
> > Yes, I guess it only needs to be used by L1, but Windows is using an
> > increasing number of VMs for various purposes so I think making it
> > stack well would be useful.
> >
> > >
> > > Not sure what you meant by EPT flush. If you mean things like
> > > HvFlushGuestPhysicalAddressSpace, I think they should be used by Xen
> > > only as well. I'm not sure whether they should be expose to L2 guests.
> > >
> >
> > Yes, that's what I meant and, again, I was thinking about the nested
> > Windows guest using VMs itself.
>
> So this is basically nested on nested. I'm not sure how to make that
> work yet. I'm also not sure how well these interfaces stack. TLFS only
> describes one level of nesting. I will need to ask if we can make nested
> on nested work.
>
Since L2 Root is Windows in a Hyper-V setup, chances are what you want
already works. Of course this depends on whether Windows, when running
as Root or Child, uses VM related features.
I'm not versed in Windows features. If you have specific things in mind,
I can ask for more details and think about how to implement them in Xen.
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
2019-09-23 13:33 ` Wei Liu
@ 2019-09-23 13:47 ` Paul Durrant
2019-09-23 14:21 ` Wei Liu
0 siblings, 1 reply; 40+ messages in thread
From: Paul Durrant @ 2019-09-23 13:47 UTC (permalink / raw)
To: 'Wei Liu'
Cc: Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
Xen Development List, Roger Pau Monne
> -----Original Message-----
> From: Wei Liu <wl@xen.org>
> Sent: 23 September 2019 14:34
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: 'Wei Liu' <wl@xen.org>; Xen Development List <xen-devel@lists.xenproject.org>; Wei Liu
> <liuwe@microsoft.com>; Andrew Cooper <Andrew.Cooper3@citrix.com>; Michael Kelley
> <mikelley@microsoft.com>; Jan Beulich <jbeulich@suse.com>; Roger Pau Monne <roger.pau@citrix.com>
> Subject: Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
>
> And a bit more thought.
>
> On Mon, Sep 23, 2019 at 01:54:31PM +0100, Wei Liu wrote:
> [...]
> > > >
> > > > Per TLFS, eVMCS should be used by L1 Xen.
> > >
> > > Yes, I guess it only needs to be used by L1, but Windows is using an
> > > increasing number of VMs for various purposes so I think making it
> > > stack well would be useful.
> > >
> > > >
> > > > Not sure what you meant by EPT flush. If you mean things like
> > > > HvFlushGuestPhysicalAddressSpace, I think they should be used by Xen
> > > > only as well. I'm not sure whether they should be expose to L2 guests.
> > > >
> > >
> > > Yes, that's what I meant and, again, I was thinking about the nested
> > > Windows guest using VMs itself.
> >
> > So this is basically nested on nested. I'm not sure how to make that
> > work yet. I'm also not sure how well these interfaces stack. TLFS only
> > describes one level of nesting. I will need to ask if we can make nested
> > on nested work.
> >
>
> Since L2 Root is Windows in a Hyper-V setup, chances are what you want
> already works. Of course this depends on whether Windows, when running
> as Root or Child, uses VM related features.
>
> I'm not versed in Windows features. If you have specific things in mind,
> I can ask for more details and think about how to implement them in Xen.
Well, eVMCS would be a major one. If the L2 Windows could be told to use that rather than L0 have to bounce individual VMREAD/VMWRITEs up to L1 then that would be a win.
Paul
>
> Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
2019-09-23 13:47 ` Paul Durrant
@ 2019-09-23 14:21 ` Wei Liu
2019-09-23 14:39 ` Paul Durrant
0 siblings, 1 reply; 40+ messages in thread
From: Wei Liu @ 2019-09-23 14:21 UTC (permalink / raw)
To: Paul Durrant
Cc: Wei Liu, 'Wei Liu', Andrew Cooper, Michael Kelley,
Jan Beulich, Xen Development List, Roger Pau Monne
On Mon, Sep 23, 2019 at 01:47:14PM +0000, Paul Durrant wrote:
> > -----Original Message-----
> > From: Wei Liu <wl@xen.org>
> > Sent: 23 September 2019 14:34
> > To: Paul Durrant <Paul.Durrant@citrix.com>
> > Cc: 'Wei Liu' <wl@xen.org>; Xen Development List <xen-devel@lists.xenproject.org>; Wei Liu
> > <liuwe@microsoft.com>; Andrew Cooper <Andrew.Cooper3@citrix.com>; Michael Kelley
> > <mikelley@microsoft.com>; Jan Beulich <jbeulich@suse.com>; Roger Pau Monne <roger.pau@citrix.com>
> > Subject: Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
> >
> > And a bit more thought.
> >
> > On Mon, Sep 23, 2019 at 01:54:31PM +0100, Wei Liu wrote:
> > [...]
> > > > >
> > > > > Per TLFS, eVMCS should be used by L1 Xen.
> > > >
> > > > Yes, I guess it only needs to be used by L1, but Windows is using an
> > > > increasing number of VMs for various purposes so I think making it
> > > > stack well would be useful.
> > > >
> > > > >
> > > > > Not sure what you meant by EPT flush. If you mean things like
> > > > > HvFlushGuestPhysicalAddressSpace, I think they should be used by Xen
> > > > > only as well. I'm not sure whether they should be expose to L2 guests.
> > > > >
> > > >
> > > > Yes, that's what I meant and, again, I was thinking about the nested
> > > > Windows guest using VMs itself.
> > >
> > > So this is basically nested on nested. I'm not sure how to make that
> > > work yet. I'm also not sure how well these interfaces stack. TLFS only
> > > describes one level of nesting. I will need to ask if we can make nested
> > > on nested work.
> > >
> >
> > Since L2 Root is Windows in a Hyper-V setup, chances are what you want
> > already works. Of course this depends on whether Windows, when running
> > as Root or Child, uses VM related features.
> >
> > I'm not versed in Windows features. If you have specific things in mind,
> > I can ask for more details and think about how to implement them in Xen.
>
> Well, eVMCS would be a major one. If the L2 Windows could be told to
> use that rather than L0 have to bounce individual VMREAD/VMWRITEs up
> to L1 then that would be a win.
Oh, I was thinking more about names of Windows specific high-level
features. Yes I can definitely ask whether eVMCS is exposed to L2 Dom0 /
Root.
Wei.
>
> Paul
>
> >
> > Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
2019-09-23 14:21 ` Wei Liu
@ 2019-09-23 14:39 ` Paul Durrant
2019-09-23 14:41 ` Wei Liu
0 siblings, 1 reply; 40+ messages in thread
From: Paul Durrant @ 2019-09-23 14:39 UTC (permalink / raw)
To: 'Wei Liu'
Cc: Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
Xen Development List, Roger Pau Monne
> -----Original Message-----
> From: Wei Liu <wl@xen.org>
> Sent: 23 September 2019 15:21
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: 'Wei Liu' <wl@xen.org>; Xen Development List <xen-devel@lists.xenproject.org>; Wei Liu
> <liuwe@microsoft.com>; Andrew Cooper <Andrew.Cooper3@citrix.com>; Michael Kelley
> <mikelley@microsoft.com>; Jan Beulich <jbeulich@suse.com>; Roger Pau Monne <roger.pau@citrix.com>
> Subject: Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
>
> On Mon, Sep 23, 2019 at 01:47:14PM +0000, Paul Durrant wrote:
> > > -----Original Message-----
> > > From: Wei Liu <wl@xen.org>
> > > Sent: 23 September 2019 14:34
> > > To: Paul Durrant <Paul.Durrant@citrix.com>
> > > Cc: 'Wei Liu' <wl@xen.org>; Xen Development List <xen-devel@lists.xenproject.org>; Wei Liu
> > > <liuwe@microsoft.com>; Andrew Cooper <Andrew.Cooper3@citrix.com>; Michael Kelley
> > > <mikelley@microsoft.com>; Jan Beulich <jbeulich@suse.com>; Roger Pau Monne <roger.pau@citrix.com>
> > > Subject: Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
> > >
> > > And a bit more thought.
> > >
> > > On Mon, Sep 23, 2019 at 01:54:31PM +0100, Wei Liu wrote:
> > > [...]
> > > > > >
> > > > > > Per TLFS, eVMCS should be used by L1 Xen.
> > > > >
> > > > > Yes, I guess it only needs to be used by L1, but Windows is using an
> > > > > increasing number of VMs for various purposes so I think making it
> > > > > stack well would be useful.
> > > > >
> > > > > >
> > > > > > Not sure what you meant by EPT flush. If you mean things like
> > > > > > HvFlushGuestPhysicalAddressSpace, I think they should be used by Xen
> > > > > > only as well. I'm not sure whether they should be expose to L2 guests.
> > > > > >
> > > > >
> > > > > Yes, that's what I meant and, again, I was thinking about the nested
> > > > > Windows guest using VMs itself.
> > > >
> > > > So this is basically nested on nested. I'm not sure how to make that
> > > > work yet. I'm also not sure how well these interfaces stack. TLFS only
> > > > describes one level of nesting. I will need to ask if we can make nested
> > > > on nested work.
> > > >
> > >
> > > Since L2 Root is Windows in a Hyper-V setup, chances are what you want
> > > already works. Of course this depends on whether Windows, when running
> > > as Root or Child, uses VM related features.
> > >
> > > I'm not versed in Windows features. If you have specific things in mind,
> > > I can ask for more details and think about how to implement them in Xen.
> >
> > Well, eVMCS would be a major one. If the L2 Windows could be told to
> > use that rather than L0 have to bounce individual VMREAD/VMWRITEs up
> > to L1 then that would be a win.
>
> Oh, I was thinking more about names of Windows specific high-level
> features. Yes I can definitely ask whether eVMCS is exposed to L2 Dom0 /
> Root.
Oh, I see. The main ones are 'credential guard' and the more recent 'sandbox'.
Paul
>
> Wei.
>
> >
> > Paul
> >
> > >
> > > Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
2019-09-23 14:39 ` Paul Durrant
@ 2019-09-23 14:41 ` Wei Liu
0 siblings, 0 replies; 40+ messages in thread
From: Wei Liu @ 2019-09-23 14:41 UTC (permalink / raw)
To: Paul Durrant
Cc: Wei Liu, 'Wei Liu', Andrew Cooper, Michael Kelley,
Jan Beulich, Xen Development List, Roger Pau Monne
On Mon, Sep 23, 2019 at 02:39:10PM +0000, Paul Durrant wrote:
> > -----Original Message-----
> > From: Wei Liu <wl@xen.org>
> > Sent: 23 September 2019 15:21
> > To: Paul Durrant <Paul.Durrant@citrix.com>
> > Cc: 'Wei Liu' <wl@xen.org>; Xen Development List <xen-devel@lists.xenproject.org>; Wei Liu
> > <liuwe@microsoft.com>; Andrew Cooper <Andrew.Cooper3@citrix.com>; Michael Kelley
> > <mikelley@microsoft.com>; Jan Beulich <jbeulich@suse.com>; Roger Pau Monne <roger.pau@citrix.com>
> > Subject: Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
> >
> > On Mon, Sep 23, 2019 at 01:47:14PM +0000, Paul Durrant wrote:
> > > > -----Original Message-----
> > > > From: Wei Liu <wl@xen.org>
> > > > Sent: 23 September 2019 14:34
> > > > To: Paul Durrant <Paul.Durrant@citrix.com>
> > > > Cc: 'Wei Liu' <wl@xen.org>; Xen Development List <xen-devel@lists.xenproject.org>; Wei Liu
> > > > <liuwe@microsoft.com>; Andrew Cooper <Andrew.Cooper3@citrix.com>; Michael Kelley
> > > > <mikelley@microsoft.com>; Jan Beulich <jbeulich@suse.com>; Roger Pau Monne <roger.pau@citrix.com>
> > > > Subject: Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
> > > >
> > > > And a bit more thought.
> > > >
> > > > On Mon, Sep 23, 2019 at 01:54:31PM +0100, Wei Liu wrote:
> > > > [...]
> > > > > > >
> > > > > > > Per TLFS, eVMCS should be used by L1 Xen.
> > > > > >
> > > > > > Yes, I guess it only needs to be used by L1, but Windows is using an
> > > > > > increasing number of VMs for various purposes so I think making it
> > > > > > stack well would be useful.
> > > > > >
> > > > > > >
> > > > > > > Not sure what you meant by EPT flush. If you mean things like
> > > > > > > HvFlushGuestPhysicalAddressSpace, I think they should be used by Xen
> > > > > > > only as well. I'm not sure whether they should be expose to L2 guests.
> > > > > > >
> > > > > >
> > > > > > Yes, that's what I meant and, again, I was thinking about the nested
> > > > > > Windows guest using VMs itself.
> > > > >
> > > > > So this is basically nested on nested. I'm not sure how to make that
> > > > > work yet. I'm also not sure how well these interfaces stack. TLFS only
> > > > > describes one level of nesting. I will need to ask if we can make nested
> > > > > on nested work.
> > > > >
> > > >
> > > > Since L2 Root is Windows in a Hyper-V setup, chances are what you want
> > > > already works. Of course this depends on whether Windows, when running
> > > > as Root or Child, uses VM related features.
> > > >
> > > > I'm not versed in Windows features. If you have specific things in mind,
> > > > I can ask for more details and think about how to implement them in Xen.
> > >
> > > Well, eVMCS would be a major one. If the L2 Windows could be told to
> > > use that rather than L0 have to bounce individual VMREAD/VMWRITEs up
> > > to L1 then that would be a win.
> >
> > Oh, I was thinking more about names of Windows specific high-level
> > features. Yes I can definitely ask whether eVMCS is exposed to L2 Dom0 /
> > Root.
>
> Oh, I see. The main ones are 'credential guard' and the more recent 'sandbox'.
>
Got it.
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 1/8] x86: introduce CONFIG_GUEST and move code
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 1/8] x86: introduce CONFIG_GUEST and move code Wei Liu
@ 2019-09-25 9:59 ` Roger Pau Monné
0 siblings, 0 replies; 40+ messages in thread
From: Roger Pau Monné @ 2019-09-25 9:59 UTC (permalink / raw)
To: Wei Liu
Cc: Xen Development List, Andrew Cooper, Wei Liu, Jan Beulich,
Michael Kelley
On Mon, Sep 23, 2019 at 11:09:24AM +0100, Wei Liu wrote:
> 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>
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 2/8] x86: include asm_defns.h directly in hypercall.h
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 2/8] x86: include asm_defns.h directly in hypercall.h Wei Liu
@ 2019-09-25 10:02 ` Roger Pau Monné
0 siblings, 0 replies; 40+ messages in thread
From: Roger Pau Monné @ 2019-09-25 10:02 UTC (permalink / raw)
To: Wei Liu
Cc: Xen Development List, Andrew Cooper, Wei Liu, Jan Beulich,
Michael Kelley
On Mon, Sep 23, 2019 at 11:09:25AM +0100, Wei Liu wrote:
> ASM_CALL_CONSTRAINT is defined there.
>
> No functional change.
>
> Signed-off-by: Wei Liu <liuwe@microsoft.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 3/8] x86: drop hypervisor_cpuid_base
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 3/8] x86: drop hypervisor_cpuid_base Wei Liu
@ 2019-09-25 10:07 ` Roger Pau Monné
0 siblings, 0 replies; 40+ messages in thread
From: Roger Pau Monné @ 2019-09-25 10:07 UTC (permalink / raw)
To: Wei Liu
Cc: Xen Development List, Andrew Cooper, Wei Liu, Jan Beulich,
Michael Kelley
On Mon, Sep 23, 2019 at 11:09:26AM +0100, Wei Liu wrote:
> The only user is Xen specific code in PV shim. We can therefore export
> the variable directly.
>
> Signed-off-by: Wei Liu <liuwe@microsoft.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 4/8] x86: factor out xen variants for hypervisor setup code
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 4/8] x86: factor out xen variants for hypervisor setup code Wei Liu
@ 2019-09-25 10:23 ` Roger Pau Monné
2019-09-27 11:30 ` Wei Liu
0 siblings, 1 reply; 40+ messages in thread
From: Roger Pau Monné @ 2019-09-25 10:23 UTC (permalink / raw)
To: Wei Liu
Cc: Xen Development List, Andrew Cooper, Wei Liu, Jan Beulich,
Michael Kelley
On Mon, Sep 23, 2019 at 11:09:27AM +0100, Wei Liu wrote:
> We will add Hyper-V specific implementations in the future.
>
> No functional change.
>
> Signed-off-by: Wei Liu <liuwe@microsoft.com>
> ---
> xen/arch/x86/guest/xen/xen.c | 32 ++++++++++++++++++++++++++------
> 1 file changed, 26 insertions(+), 6 deletions(-)
>
> diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c
> index 78fc603996..f93c8fbd1c 100644
> --- a/xen/arch/x86/guest/xen/xen.c
> +++ b/xen/arch/x86/guest/xen/xen.c
> @@ -67,7 +67,7 @@ static void __init find_xen_leaves(void)
> }
> }
>
> -void __init probe_hypervisor(void)
> +static void __init probe_xen(void)
While here I would rename to xen_probe, to match with the other
functions (ie: xen_setup below for example).
> {
> if ( xen_guest )
> return;
> @@ -87,6 +87,11 @@ void __init probe_hypervisor(void)
> xen_guest = true;
> }
>
> +void __init probe_hypervisor(void)
Shouldn't this live in a separate file, like guest/guest.c or some
such?
Also it might be nice to introduce something like:
enum guest_type {
XEN_GUEST,
} guest_type;
So that you can add a switch here, even if the only case is Xen ATM. I
guess this will be done in a later patch, or introduce an
hypervisor_ops struct that contain pointers to functions to allow for
different implementations.
> +{
> + probe_xen();
> +}
> +
> static void map_shared_info(void)
> {
> mfn_t mfn;
> @@ -249,10 +254,8 @@ static void init_evtchn(void)
> }
> }
>
> -void __init hypervisor_setup(void)
> +static void __init xen_setup(void)
> {
> - init_memmap();
> -
> map_shared_info();
>
> set_vcpu_id();
> @@ -277,13 +280,25 @@ void __init hypervisor_setup(void)
> init_evtchn();
> }
>
> -void hypervisor_ap_setup(void)
> +void __init hypervisor_setup(void)
> +{
> + init_memmap();
I wonder, do you also require to map hypervisor data into the guest
physmap when running on HyperV?
Is there a way when running on HyperV to request unused physical
address space ranges? What Xen currently does in init_memmap is quite
crappy.
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 5/8] x86: factor out hypervisor agnostic code
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 5/8] x86: factor out hypervisor agnostic code Wei Liu
@ 2019-09-25 10:39 ` Roger Pau Monné
2019-09-27 11:18 ` Wei Liu
0 siblings, 1 reply; 40+ messages in thread
From: Roger Pau Monné @ 2019-09-25 10:39 UTC (permalink / raw)
To: Wei Liu
Cc: Xen Development List, Andrew Cooper, Wei Liu, Jan Beulich,
Michael Kelley
On Mon, Sep 23, 2019 at 11:09:28AM +0100, Wei Liu wrote:
> The only implementation there is Xen.
>
> No functional change.
>
> Signed-off-by: Wei Liu <liuwe@microsoft.com>
> ---
> xen/arch/x86/guest/Makefile | 2 +
> xen/arch/x86/guest/hypervisor.c | 112 +++++++++++++++++++++++++
> xen/arch/x86/guest/xen/xen.c | 81 +-----------------
> xen/include/asm-x86/guest.h | 1 +
> xen/include/asm-x86/guest/hypervisor.h | 58 +++++++++++++
> xen/include/asm-x86/guest/xen.h | 21 ++---
> 6 files changed, 182 insertions(+), 93 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..b0a724bf13
> --- /dev/null
> +++ b/xen/arch/x86/guest/hypervisor.c
> @@ -0,0 +1,112 @@
> +/******************************************************************************
> + * 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) 2017 Citrix Systems Ltd.
> + */
> +
> +#include <xen/init.h>
> +#include <xen/mm.h>
> +#include <xen/rangeset.h>
> +
> +#include <asm/guest.h>
> +#include <asm/processor.h>
> +
> +static struct rangeset *mem;
> +
> +void __init probe_hypervisor(void)
IMO would be nice to take the opportunity to rename this to
hypervisor_probe, to match with the rest of the hypervisor_ functions.
> diff --git a/xen/include/asm-x86/guest/xen.h b/xen/include/asm-x86/guest/xen.h
> index b015ed1883..d031f1f70d 100644
> --- a/xen/include/asm-x86/guest/xen.h
> +++ b/xen/include/asm-x86/guest/xen.h
> @@ -32,12 +32,10 @@ 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);
> -void hypervisor_resume(void);
> +void probe_xen(void);
> +void xen_setup(void);
> +void xen_ap_setup(void);
> +void xen_resume(void);
>
> DECLARE_PER_CPU(unsigned int, vcpu_id);
> DECLARE_PER_CPU(struct vcpu_info *, vcpu_info);
> @@ -47,16 +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 void hypervisor_setup(void)
> -{
> - ASSERT_UNREACHABLE();
> -}
> -static inline void hypervisor_ap_setup(void)
> -{
> - ASSERT_UNREACHABLE();
> -}
> +static inline void probe_xen(void) {}
Why do you need this?
AFAICT probe_xen is used in the same way as the rest of the xen_*
functions, and hence I wonder why you need a stub for it?
I guess this is a forward-looking change for when probe_xen will be
called unconditionally to check for Xen support?
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 6/8] x86: make probe_xen return boolean value
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 6/8] x86: make probe_xen return boolean value Wei Liu
@ 2019-09-25 10:44 ` Roger Pau Monné
2019-09-27 11:18 ` Wei Liu
0 siblings, 1 reply; 40+ messages in thread
From: Roger Pau Monné @ 2019-09-25 10:44 UTC (permalink / raw)
To: Wei Liu
Cc: Xen Development List, Andrew Cooper, Wei Liu, Jan Beulich,
Michael Kelley
On Mon, Sep 23, 2019 at 11:09:29AM +0100, Wei Liu wrote:
> We need indication whether it has succeeded or not.
>
> Signed-off-by: Wei Liu <liuwe@microsoft.com>
The code LGTM, I have just a suggestion on the approach.
> ---
> xen/arch/x86/guest/hypervisor.c | 5 ++++-
> xen/arch/x86/guest/xen/xen.c | 7 ++++---
> xen/include/asm-x86/guest/xen.h | 4 ++--
> 3 files changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c
> index b0a724bf13..fb572b0402 100644
> --- a/xen/arch/x86/guest/hypervisor.c
> +++ b/xen/arch/x86/guest/hypervisor.c
> @@ -34,7 +34,10 @@ void __init probe_hypervisor(void)
> if ( !(cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_HYPERVISOR)) )
> return;
>
> - probe_xen();
> + if ( probe_xen() )
> + return;
> +
> + /* Hyper-V probing to follow. */
Instead of having to append a new probe_foo here every time support for
running on a new hypervisor is added, you could do something similar
to what's done in REGISTER_VPCI_INIT, where each hypervisor would
register it's own set of helpers and probe function in a specific
section, and then you would just iterate over all the guest support
that's compiled in Xen.
That would also prevent you from having to export a dummy probe_xen
helper if CONFIG_XEN_GUEST is not defined.
Anyway, maybe that's overkill...
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 7/8] x86: introduce CONFIG_HYPERV and hyperv directory
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 7/8] x86: introduce CONFIG_HYPERV and hyperv directory Wei Liu
@ 2019-09-25 10:48 ` Roger Pau Monné
2019-09-27 11:18 ` Wei Liu
0 siblings, 1 reply; 40+ messages in thread
From: Roger Pau Monné @ 2019-09-25 10:48 UTC (permalink / raw)
To: Wei Liu
Cc: Xen Development List, Andrew Cooper, Wei Liu, Jan Beulich,
Michael Kelley
On Mon, Sep 23, 2019 at 11:09:30AM +0100, Wei Liu wrote:
> We use the same code structure as we did for Xen code.
>
> As starters, detect Hyper-V in probe_hyperv. More complex
> functionality will be added later.
>
> Signed-off-by: Wei Liu <liuwe@microsoft.com>
> ---
> xen/arch/x86/Kconfig | 9 +++++
> xen/arch/x86/guest/Makefile | 1 +
> xen/arch/x86/guest/hyperv/Makefile | 1 +
> xen/arch/x86/guest/hyperv/hyperv.c | 63 ++++++++++++++++++++++++++++++
> xen/arch/x86/guest/hypervisor.c | 3 +-
> xen/include/asm-x86/guest.h | 1 +
> xen/include/asm-x86/guest/hyperv.h | 48 +++++++++++++++++++++++
> 7 files changed, 125 insertions(+), 1 deletion(-)
> 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 584bdc1bb8..c5a93babfe 100644
> --- a/xen/arch/x86/Kconfig
> +++ b/xen/arch/x86/Kconfig
> @@ -163,6 +163,15 @@ endchoice
> config GUEST
> bool
>
> +config HYPERV_GUEST
> + def_bool n
> + select GUEST
> + prompt "Hyper-V Guest"
> + ---help---
> + Support for Xen detecting when it is running under Hyper-V.
> +
> + If unsure, say N.
> +
> config XEN_GUEST
> def_bool n
> 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..488e9c14a3
> --- /dev/null
> +++ b/xen/arch/x86/guest/hyperv/hyperv.c
> @@ -0,0 +1,63 @@
> +/******************************************************************************
> + * 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>
> +
> +bool __read_mostly hyperv_guest;
static?
> +
> +bool __init probe_hyperv(void)
> +{
> + uint32_t eax, ebx, ecx, edx;
> +
> + if ( hyperv_guest )
> + return true;
> +
> + cpuid(0x40000000, &eax, &ebx, &ecx, &edx);
> + if ( (ebx == 0x7263694d) && /* "Micr" */
> + (ecx == 0x666f736f) && /* "osof" */
> + (edx == 0x76482074) ) /* "t Hv" */
> + hyperv_guest = true;
> +
> + return hyperv_guest;
> +}
> +
> +void __init hyperv_setup(void)
> +{
> +}
> +
> +void hyperv_ap_setup(void)
> +{
> +}
> +
> +void hyperv_resume(void)
> +{
> +}
Seems kind of pointless to add those dummy hyperv_ functions, AFAICT
they don't have any callers yet?
I would prefer that you introduce such dummy callers when they are
used.
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 8/8] x86: be more verbose when running nested
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 8/8] x86: be more verbose when running nested Wei Liu
@ 2019-09-25 10:54 ` Roger Pau Monné
0 siblings, 0 replies; 40+ messages in thread
From: Roger Pau Monné @ 2019-09-25 10:54 UTC (permalink / raw)
To: Wei Liu
Cc: Xen Development List, Andrew Cooper, Wei Liu, Jan Beulich,
Michael Kelley
On Mon, Sep 23, 2019 at 11:09:31AM +0100, Wei Liu wrote:
> Signed-off-by: Wei Liu <liuwe@microsoft.com>
> ---
> xen/arch/x86/setup.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> index dec60d0301..bbcc5a503d 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -789,6 +789,17 @@ void __init noreturn __start_xen(unsigned long mbi_p)
>
> printk("Xen image load base address: %#lx\n", xen_phys_start);
>
> +#ifdef CONFIG_GUEST
> +#ifdef CONFIG_XEN_GUEST
> + if ( xen_guest )
> + printk("Running on Xen hypervisor\n");
> +#endif
> +#ifdef CONFIG_HYPERV_GUEST
> + if ( hyperv_guest )
> + printk("Running on Hyper-V\n");
> +#endif
> +#endif
Urg, that's kind of ugly. Why not introduce a hypervisor_name helper
or some such?
You could even have a structure like:
struct hypervisor_ops {
const char *name;
bool (*probe)(void);
void (*setup)(void);
...
}
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
2019-09-23 10:09 [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V Wei Liu
` (8 preceding siblings ...)
2019-09-23 10:48 ` [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V Paul Durrant
@ 2019-09-25 11:02 ` Roger Pau Monné
2019-09-25 15:36 ` Wei Liu
9 siblings, 1 reply; 40+ messages in thread
From: Roger Pau Monné @ 2019-09-25 11:02 UTC (permalink / raw)
To: Wei Liu
Cc: Xen Development List, Andrew Cooper, Wei Liu, Jan Beulich,
Michael Kelley
On Mon, Sep 23, 2019 at 11:09:23AM +0100, Wei Liu wrote:
> Hi all
>
> In case you're wondering, I can already run a fully fledged Xen system on
> Hyper-V with emulated disk and network.
>
> This is the very first stage for porting Xen to run on Hyper-V with all the
> goodies Hyper-V has to offer. With this series, Xen can successfully detect
> Hyper-V and prints out a message. I would like to first get the directory
> structure and kconfig options agreed upon.
>
> There are two major areas to be worked on:
> * Make Dom0 able to use Hyper-V's synthetic devices.
> * Make Xen use of the synthetic timer, reference TSC and enlightenment VMCS
> and other interfaces.
>
> They aren't trivial, and time can be scarce on my side, so I intend to post
> patches piece meal when they are ready.
>
> Questions and comments are welcome.
Thanks for doing this!
In the past I've played with trying to get Xen to boot as a guest on
HyperV gen2 instances, and I did manage to get it booting, Linux
however would get extremely confused because gen2 lacks emulated
devices and instead the guest is forced to use the HyperV PV devices
AFAIK.
Anyway, I had the following patch on my backlog which allowed me to
boot on gen2 instances, posting it here in case it helps you if you
plan to go that route.
Roger.
---8<---
From 7c9fad735fdc3633ed401befda26c21dc7145af8 Mon Sep 17 00:00:00 2001
From: Roger Pau Monne <roger.pau@citrix.com>
Date: Tue, 18 Sep 2018 11:36:42 +0200
Subject: [PATCH] x86/lapic: remove the PIT usage to calibrate the lapic timer
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
And instead use NOW which is based on the TSC. This was already used
when running in shim mode, since there's likely no PIT in that
environment.
Remove printing the CPU frequency, since it's already printed earlier
at boot, and getting the CPU frequency against the TSC without any
external reference timer is pointless.
The motivation behind this change is to allow Xen to boot on HyperV
gen2 instances, which lack a PIT.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
I'm not sure about the reason behind the usage of the PIT instead of
the TSC, maybe this was done because the TSC wasn't available until
the Pentium? Xen certainly doesn't care about such hardware anymore,
and the TSC is already used unconditionally in Xen.
Linux seems to prefer to calibrate the lapic timer against the PM
timer and has already dropped PIT usage for that.
My early tests on a single box show no differences between the TSC or
the PIT for lapic timer calibration, but that's a single box.
The RFC is because I'm not sure I understand the motivation for using
the PIT in the first place, so I might be missing something relevant
that could make this patch moot.
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
---
xen/arch/x86/apic.c | 67 ++-------------------------------------------
1 file changed, 2 insertions(+), 65 deletions(-)
diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c
index 88ada9d0ec..21dbeb2298 100644
--- a/xen/arch/x86/apic.c
+++ b/xen/arch/x86/apic.c
@@ -1010,46 +1010,6 @@ __next:
/* used for system time scaling */
static u32 __read_mostly bus_scale; /* scaling factor: ns -> bus cycles */
-/*
- * The timer chip is already set up at HZ interrupts per second here,
- * but we do not accept timer interrupts yet. We only allow the BP
- * to calibrate.
- */
-static unsigned int __init get_8254_timer_count(void)
-{
- /*extern spinlock_t i8253_lock;*/
- /*unsigned long flags;*/
-
- unsigned int count;
-
- /*spin_lock_irqsave(&i8253_lock, flags);*/
-
- outb_p(0x00, PIT_MODE);
- count = inb_p(PIT_CH0);
- count |= inb_p(PIT_CH0) << 8;
-
- /*spin_unlock_irqrestore(&i8253_lock, flags);*/
-
- return count;
-}
-
-/* next tick in 8254 can be caught by catching timer wraparound */
-static void __init wait_8254_wraparound(void)
-{
- unsigned int curr_count, prev_count;
-
- curr_count = get_8254_timer_count();
- do {
- prev_count = curr_count;
- curr_count = get_8254_timer_count();
-
- /* workaround for broken Mercury/Neptune */
- if (prev_count >= curr_count + 0x100)
- curr_count = get_8254_timer_count();
-
- } while (prev_count >= curr_count);
-}
-
/*
* This function sets up the local APIC timer, with a timeout of
* 'clocks' APIC bus clock. During calibration we actually call
@@ -1092,7 +1052,7 @@ static void setup_APIC_timer(void)
local_irq_restore(flags);
}
-static void wait_tick_pvh(void)
+static void wait_tick(void)
{
u64 lapse_ns = 1000000000ULL / HZ;
s_time_t start, curr_time;
@@ -1121,7 +1081,6 @@ static void wait_tick_pvh(void)
static int __init calibrate_APIC_clock(void)
{
- unsigned long long t1, t2;
long tt1, tt2;
long result;
int i;
@@ -1138,33 +1097,15 @@ static int __init calibrate_APIC_clock(void)
*/
__setup_APIC_LVTT(1000000000);
- if ( !xen_guest )
- /*
- * The timer chip counts down to zero. Let's wait
- * for a wraparound to start exact measurement:
- * (the current tick might have been already half done)
- */
- wait_8254_wraparound();
- else
- wait_tick_pvh();
-
- /*
- * We wrapped around just now. Let's start:
- */
- t1 = rdtsc_ordered();
tt1 = apic_read(APIC_TMCCT);
/*
* Let's wait LOOPS ticks:
*/
for (i = 0; i < LOOPS; i++)
- if ( !xen_guest )
- wait_8254_wraparound();
- else
- wait_tick_pvh();
+ wait_tick();
tt2 = apic_read(APIC_TMCCT);
- t2 = rdtsc_ordered();
/*
* The APIC bus clock counter is 32 bits only, it
@@ -1176,10 +1117,6 @@ static int __init calibrate_APIC_clock(void)
result = (tt1-tt2)*APIC_DIVISOR/LOOPS;
- apic_printk(APIC_VERBOSE, "..... CPU clock speed is %ld.%04ld MHz.\n",
- ((long)(t2 - t1) / LOOPS) / (1000000 / HZ),
- ((long)(t2 - t1) / LOOPS) % (1000000 / HZ));
-
apic_printk(APIC_VERBOSE, "..... host bus clock speed is %ld.%04ld MHz.\n",
result / (1000000 / HZ), result % (1000000 / HZ));
--
2.22.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
2019-09-25 11:02 ` Roger Pau Monné
@ 2019-09-25 15:36 ` Wei Liu
2019-09-26 10:37 ` Wei Liu
2019-09-26 10:41 ` Roger Pau Monné
0 siblings, 2 replies; 40+ messages in thread
From: Wei Liu @ 2019-09-25 15:36 UTC (permalink / raw)
To: Roger Pau Monné
Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
Xen Development List
On Wed, Sep 25, 2019 at 01:02:50PM +0200, Roger Pau Monné wrote:
> On Mon, Sep 23, 2019 at 11:09:23AM +0100, Wei Liu wrote:
> > Hi all
> >
> > In case you're wondering, I can already run a fully fledged Xen system on
> > Hyper-V with emulated disk and network.
> >
> > This is the very first stage for porting Xen to run on Hyper-V with all the
> > goodies Hyper-V has to offer. With this series, Xen can successfully detect
> > Hyper-V and prints out a message. I would like to first get the directory
> > structure and kconfig options agreed upon.
> >
> > There are two major areas to be worked on:
> > * Make Dom0 able to use Hyper-V's synthetic devices.
> > * Make Xen use of the synthetic timer, reference TSC and enlightenment VMCS
> > and other interfaces.
> >
> > They aren't trivial, and time can be scarce on my side, so I intend to post
> > patches piece meal when they are ready.
> >
> > Questions and comments are welcome.
>
> Thanks for doing this!
>
> In the past I've played with trying to get Xen to boot as a guest on
> HyperV gen2 instances, and I did manage to get it booting, Linux
> however would get extremely confused because gen2 lacks emulated
> devices and instead the guest is forced to use the HyperV PV devices
> AFAIK.
How did you force Linux to use Hyper-V PV devices? AIUI Linux won't
have access to VMBus (like XenBus but with some differences) and SynIC
(Synthetic interrupt controller, think of it as an abstraction around
event channel in Xen world) in the first place. But I haven't tried
gen2 so I could be wrong.
>
> Anyway, I had the following patch on my backlog which allowed me to
> boot on gen2 instances, posting it here in case it helps you if you
> plan to go that route.
The long term plan for the time source is to use the reference TSC page
provided by Hyper-V, just like we did for Xen.
Your patch seems to be an useful thing to do on its own anyway.
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
2019-09-25 15:36 ` Wei Liu
@ 2019-09-26 10:37 ` Wei Liu
2019-09-26 10:41 ` Roger Pau Monné
1 sibling, 0 replies; 40+ messages in thread
From: Wei Liu @ 2019-09-26 10:37 UTC (permalink / raw)
To: Roger Pau Monné
Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
Xen Development List
On Wed, Sep 25, 2019 at 04:36:34PM +0100, Wei Liu wrote:
> On Wed, Sep 25, 2019 at 01:02:50PM +0200, Roger Pau Monné wrote:
> > On Mon, Sep 23, 2019 at 11:09:23AM +0100, Wei Liu wrote:
> > > Hi all
> > >
> > > In case you're wondering, I can already run a fully fledged Xen system on
> > > Hyper-V with emulated disk and network.
> > >
> > > This is the very first stage for porting Xen to run on Hyper-V with all the
> > > goodies Hyper-V has to offer. With this series, Xen can successfully detect
> > > Hyper-V and prints out a message. I would like to first get the directory
> > > structure and kconfig options agreed upon.
> > >
> > > There are two major areas to be worked on:
> > > * Make Dom0 able to use Hyper-V's synthetic devices.
> > > * Make Xen use of the synthetic timer, reference TSC and enlightenment VMCS
> > > and other interfaces.
> > >
> > > They aren't trivial, and time can be scarce on my side, so I intend to post
> > > patches piece meal when they are ready.
> > >
> > > Questions and comments are welcome.
> >
> > Thanks for doing this!
> >
> > In the past I've played with trying to get Xen to boot as a guest on
> > HyperV gen2 instances, and I did manage to get it booting, Linux
> > however would get extremely confused because gen2 lacks emulated
> > devices and instead the guest is forced to use the HyperV PV devices
> > AFAIK.
>
> How did you force Linux to use Hyper-V PV devices? AIUI Linux won't
> have access to VMBus (like XenBus but with some differences) and SynIC
> (Synthetic interrupt controller, think of it as an abstraction around
> event channel in Xen world) in the first place. But I haven't tried
> gen2 so I could be wrong.
>
I try Gen2 this morning. I need to apply your patch and give Xen noapic
option to boot. At the end I only get a blank screen so I don't think
Linux has booted successfully.
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
2019-09-25 15:36 ` Wei Liu
2019-09-26 10:37 ` Wei Liu
@ 2019-09-26 10:41 ` Roger Pau Monné
2019-09-26 10:50 ` Wei Liu
1 sibling, 1 reply; 40+ messages in thread
From: Roger Pau Monné @ 2019-09-26 10:41 UTC (permalink / raw)
To: Wei Liu
Cc: Xen Development List, Andrew Cooper, Wei Liu, Jan Beulich,
Michael Kelley
On Wed, Sep 25, 2019 at 04:36:34PM +0100, Wei Liu wrote:
> On Wed, Sep 25, 2019 at 01:02:50PM +0200, Roger Pau Monné wrote:
> > On Mon, Sep 23, 2019 at 11:09:23AM +0100, Wei Liu wrote:
> > > Hi all
> > >
> > > In case you're wondering, I can already run a fully fledged Xen system on
> > > Hyper-V with emulated disk and network.
> > >
> > > This is the very first stage for porting Xen to run on Hyper-V with all the
> > > goodies Hyper-V has to offer. With this series, Xen can successfully detect
> > > Hyper-V and prints out a message. I would like to first get the directory
> > > structure and kconfig options agreed upon.
> > >
> > > There are two major areas to be worked on:
> > > * Make Dom0 able to use Hyper-V's synthetic devices.
> > > * Make Xen use of the synthetic timer, reference TSC and enlightenment VMCS
> > > and other interfaces.
> > >
> > > They aren't trivial, and time can be scarce on my side, so I intend to post
> > > patches piece meal when they are ready.
> > >
> > > Questions and comments are welcome.
> >
> > Thanks for doing this!
> >
> > In the past I've played with trying to get Xen to boot as a guest on
> > HyperV gen2 instances, and I did manage to get it booting, Linux
> > however would get extremely confused because gen2 lacks emulated
> > devices and instead the guest is forced to use the HyperV PV devices
> > AFAIK.
>
> How did you force Linux to use Hyper-V PV devices?
I didn't, that's where I stopped. I just managed to get Xen
booting on gen2, but Linux dom0 won't boot due to what you pointed out
below.
Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V
2019-09-26 10:41 ` Roger Pau Monné
@ 2019-09-26 10:50 ` Wei Liu
0 siblings, 0 replies; 40+ messages in thread
From: Wei Liu @ 2019-09-26 10:50 UTC (permalink / raw)
To: Roger Pau Monné
Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
Xen Development List
On Thu, Sep 26, 2019 at 12:41:04PM +0200, Roger Pau Monné wrote:
> On Wed, Sep 25, 2019 at 04:36:34PM +0100, Wei Liu wrote:
> > On Wed, Sep 25, 2019 at 01:02:50PM +0200, Roger Pau Monné wrote:
> > > On Mon, Sep 23, 2019 at 11:09:23AM +0100, Wei Liu wrote:
> > > > Hi all
> > > >
> > > > In case you're wondering, I can already run a fully fledged Xen system on
> > > > Hyper-V with emulated disk and network.
> > > >
> > > > This is the very first stage for porting Xen to run on Hyper-V with all the
> > > > goodies Hyper-V has to offer. With this series, Xen can successfully detect
> > > > Hyper-V and prints out a message. I would like to first get the directory
> > > > structure and kconfig options agreed upon.
> > > >
> > > > There are two major areas to be worked on:
> > > > * Make Dom0 able to use Hyper-V's synthetic devices.
> > > > * Make Xen use of the synthetic timer, reference TSC and enlightenment VMCS
> > > > and other interfaces.
> > > >
> > > > They aren't trivial, and time can be scarce on my side, so I intend to post
> > > > patches piece meal when they are ready.
> > > >
> > > > Questions and comments are welcome.
> > >
> > > Thanks for doing this!
> > >
> > > In the past I've played with trying to get Xen to boot as a guest on
> > > HyperV gen2 instances, and I did manage to get it booting, Linux
> > > however would get extremely confused because gen2 lacks emulated
> > > devices and instead the guest is forced to use the HyperV PV devices
> > > AFAIK.
> >
> > How did you force Linux to use Hyper-V PV devices?
>
> I didn't, that's where I stopped. I just managed to get Xen
> booting on gen2, but Linux dom0 won't boot due to what you pointed out
> below.
OK. Thanks for clarification.
I think when the port is complete a Xen system should be able to boot on
both Gen1 and Gen2.
Wei.
>
> Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 5/8] x86: factor out hypervisor agnostic code
2019-09-25 10:39 ` Roger Pau Monné
@ 2019-09-27 11:18 ` Wei Liu
0 siblings, 0 replies; 40+ messages in thread
From: Wei Liu @ 2019-09-27 11:18 UTC (permalink / raw)
To: Roger Pau Monné
Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
Xen Development List
On Wed, Sep 25, 2019 at 12:39:11PM +0200, Roger Pau Monné wrote:
> On Mon, Sep 23, 2019 at 11:09:28AM +0100, Wei Liu wrote:
> > The only implementation there is Xen.
> >
> > No functional change.
> >
> > Signed-off-by: Wei Liu <liuwe@microsoft.com>
> > ---
> > xen/arch/x86/guest/Makefile | 2 +
> > xen/arch/x86/guest/hypervisor.c | 112 +++++++++++++++++++++++++
> > xen/arch/x86/guest/xen/xen.c | 81 +-----------------
> > xen/include/asm-x86/guest.h | 1 +
> > xen/include/asm-x86/guest/hypervisor.h | 58 +++++++++++++
> > xen/include/asm-x86/guest/xen.h | 21 ++---
> > 6 files changed, 182 insertions(+), 93 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..b0a724bf13
> > --- /dev/null
> > +++ b/xen/arch/x86/guest/hypervisor.c
> > @@ -0,0 +1,112 @@
> > +/******************************************************************************
> > + * 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) 2017 Citrix Systems Ltd.
> > + */
> > +
> > +#include <xen/init.h>
> > +#include <xen/mm.h>
> > +#include <xen/rangeset.h>
> > +
> > +#include <asm/guest.h>
> > +#include <asm/processor.h>
> > +
> > +static struct rangeset *mem;
> > +
> > +void __init probe_hypervisor(void)
>
> IMO would be nice to take the opportunity to rename this to
> hypervisor_probe, to match with the rest of the hypervisor_ functions.
No problem.
>
> > diff --git a/xen/include/asm-x86/guest/xen.h b/xen/include/asm-x86/guest/xen.h
> > index b015ed1883..d031f1f70d 100644
> > --- a/xen/include/asm-x86/guest/xen.h
> > +++ b/xen/include/asm-x86/guest/xen.h
> > @@ -32,12 +32,10 @@ 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);
> > -void hypervisor_resume(void);
> > +void probe_xen(void);
> > +void xen_setup(void);
> > +void xen_ap_setup(void);
> > +void xen_resume(void);
> >
> > DECLARE_PER_CPU(unsigned int, vcpu_id);
> > DECLARE_PER_CPU(struct vcpu_info *, vcpu_info);
> > @@ -47,16 +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 void hypervisor_setup(void)
> > -{
> > - ASSERT_UNREACHABLE();
> > -}
> > -static inline void hypervisor_ap_setup(void)
> > -{
> > - ASSERT_UNREACHABLE();
> > -}
> > +static inline void probe_xen(void) {}
>
> Why do you need this?
>
> AFAICT probe_xen is used in the same way as the rest of the xen_*
> functions, and hence I wonder why you need a stub for it?
>
> I guess this is a forward-looking change for when probe_xen will be
> called unconditionally to check for Xen support?
Yes when probing hypervisor support you will need to unconditionally
call these functions.
Wei.
>
> Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 6/8] x86: make probe_xen return boolean value
2019-09-25 10:44 ` Roger Pau Monné
@ 2019-09-27 11:18 ` Wei Liu
0 siblings, 0 replies; 40+ messages in thread
From: Wei Liu @ 2019-09-27 11:18 UTC (permalink / raw)
To: Roger Pau Monné
Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
Xen Development List
On Wed, Sep 25, 2019 at 12:44:27PM +0200, Roger Pau Monné wrote:
> On Mon, Sep 23, 2019 at 11:09:29AM +0100, Wei Liu wrote:
> > We need indication whether it has succeeded or not.
> >
> > Signed-off-by: Wei Liu <liuwe@microsoft.com>
>
> The code LGTM, I have just a suggestion on the approach.
>
> > ---
> > xen/arch/x86/guest/hypervisor.c | 5 ++++-
> > xen/arch/x86/guest/xen/xen.c | 7 ++++---
> > xen/include/asm-x86/guest/xen.h | 4 ++--
> > 3 files changed, 10 insertions(+), 6 deletions(-)
> >
> > diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c
> > index b0a724bf13..fb572b0402 100644
> > --- a/xen/arch/x86/guest/hypervisor.c
> > +++ b/xen/arch/x86/guest/hypervisor.c
> > @@ -34,7 +34,10 @@ void __init probe_hypervisor(void)
> > if ( !(cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_HYPERVISOR)) )
> > return;
> >
> > - probe_xen();
> > + if ( probe_xen() )
> > + return;
> > +
> > + /* Hyper-V probing to follow. */
>
> Instead of having to append a new probe_foo here every time support for
> running on a new hypervisor is added, you could do something similar
> to what's done in REGISTER_VPCI_INIT, where each hypervisor would
> register it's own set of helpers and probe function in a specific
> section, and then you would just iterate over all the guest support
> that's compiled in Xen.
>
> That would also prevent you from having to export a dummy probe_xen
> helper if CONFIG_XEN_GUEST is not defined.
>
> Anyway, maybe that's overkill...
Let's see what Andrew and Jan think.
Either works for me -- it is just a matter of writing code, but
obviously the less work the better. :-)
Wei.
>
> Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 7/8] x86: introduce CONFIG_HYPERV and hyperv directory
2019-09-25 10:48 ` Roger Pau Monné
@ 2019-09-27 11:18 ` Wei Liu
0 siblings, 0 replies; 40+ messages in thread
From: Wei Liu @ 2019-09-27 11:18 UTC (permalink / raw)
To: Roger Pau Monné
Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
Xen Development List
On Wed, Sep 25, 2019 at 12:48:42PM +0200, Roger Pau Monné wrote:
> On Mon, Sep 23, 2019 at 11:09:30AM +0100, Wei Liu wrote:
> > We use the same code structure as we did for Xen code.
> >
> > As starters, detect Hyper-V in probe_hyperv. More complex
> > functionality will be added later.
> >
> > Signed-off-by: Wei Liu <liuwe@microsoft.com>
> > ---
> > xen/arch/x86/Kconfig | 9 +++++
> > xen/arch/x86/guest/Makefile | 1 +
> > xen/arch/x86/guest/hyperv/Makefile | 1 +
> > xen/arch/x86/guest/hyperv/hyperv.c | 63 ++++++++++++++++++++++++++++++
> > xen/arch/x86/guest/hypervisor.c | 3 +-
> > xen/include/asm-x86/guest.h | 1 +
> > xen/include/asm-x86/guest/hyperv.h | 48 +++++++++++++++++++++++
> > 7 files changed, 125 insertions(+), 1 deletion(-)
> > 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 584bdc1bb8..c5a93babfe 100644
> > --- a/xen/arch/x86/Kconfig
> > +++ b/xen/arch/x86/Kconfig
> > @@ -163,6 +163,15 @@ endchoice
> > config GUEST
> > bool
> >
> > +config HYPERV_GUEST
> > + def_bool n
> > + select GUEST
> > + prompt "Hyper-V Guest"
> > + ---help---
> > + Support for Xen detecting when it is running under Hyper-V.
> > +
> > + If unsure, say N.
> > +
> > config XEN_GUEST
> > def_bool n
> > 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..488e9c14a3
> > --- /dev/null
> > +++ b/xen/arch/x86/guest/hyperv/hyperv.c
> > @@ -0,0 +1,63 @@
> > +/******************************************************************************
> > + * 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>
> > +
> > +bool __read_mostly hyperv_guest;
>
> static?
>
I expected this to be referenced elsewhere, hence I made it non-static.
> > +
> > +bool __init probe_hyperv(void)
> > +{
> > + uint32_t eax, ebx, ecx, edx;
> > +
> > + if ( hyperv_guest )
> > + return true;
> > +
> > + cpuid(0x40000000, &eax, &ebx, &ecx, &edx);
> > + if ( (ebx == 0x7263694d) && /* "Micr" */
> > + (ecx == 0x666f736f) && /* "osof" */
> > + (edx == 0x76482074) ) /* "t Hv" */
> > + hyperv_guest = true;
> > +
> > + return hyperv_guest;
> > +}
> > +
> > +void __init hyperv_setup(void)
> > +{
> > +}
> > +
> > +void hyperv_ap_setup(void)
> > +{
> > +}
> > +
> > +void hyperv_resume(void)
> > +{
> > +}
>
> Seems kind of pointless to add those dummy hyperv_ functions, AFAICT
> they don't have any callers yet?
>
> I would prefer that you introduce such dummy callers when they are
> used.
>
No problem.
Wei.
> Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 4/8] x86: factor out xen variants for hypervisor setup code
2019-09-25 10:23 ` Roger Pau Monné
@ 2019-09-27 11:30 ` Wei Liu
2019-09-27 11:39 ` Jan Beulich
2019-09-27 11:41 ` Roger Pau Monné
0 siblings, 2 replies; 40+ messages in thread
From: Wei Liu @ 2019-09-27 11:30 UTC (permalink / raw)
To: Roger Pau Monné
Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
Xen Development List
On Wed, Sep 25, 2019 at 12:23:54PM +0200, Roger Pau Monné wrote:
> > -void __init probe_hypervisor(void)
> > +static void __init probe_xen(void)
>
> While here I would rename to xen_probe, to match with the other
> functions (ie: xen_setup below for example).
Sure. I can do that. I always thought that strange too.
>
> > {
> > if ( xen_guest )
> > return;
> > @@ -87,6 +87,11 @@ void __init probe_hypervisor(void)
> > xen_guest = true;
> > }
> >
> > +void __init probe_hypervisor(void)
>
> Shouldn't this live in a separate file, like guest/guest.c or some
> such?
>
It's done in a later patch. I believe you've already seen it.
> Also it might be nice to introduce something like:
>
> enum guest_type {
> XEN_GUEST,
> } guest_type;
>
This works for me.
> So that you can add a switch here, even if the only case is Xen ATM. I
> guess this will be done in a later patch, or introduce an
> hypervisor_ops struct that contain pointers to functions to allow for
> different implementations.
>
I debated this. These changes require more code churn with no apparent
benefit, but if people agree this is better I can make those changes.
> > +{
> > + probe_xen();
> > +}
> > +
> > static void map_shared_info(void)
> > {
> > mfn_t mfn;
> > @@ -249,10 +254,8 @@ static void init_evtchn(void)
> > }
> > }
> >
> > -void __init hypervisor_setup(void)
> > +static void __init xen_setup(void)
> > {
> > - init_memmap();
> > -
> > map_shared_info();
> >
> > set_vcpu_id();
> > @@ -277,13 +280,25 @@ void __init hypervisor_setup(void)
> > init_evtchn();
> > }
> >
> > -void hypervisor_ap_setup(void)
> > +void __init hypervisor_setup(void)
> > +{
> > + init_memmap();
>
> I wonder, do you also require to map hypervisor data into the guest
> physmap when running on HyperV?
>
Yes. There are a lot of comparable concepts in Hyper-V. For example,
there is a page called VP assist page which is more or less the same as
Xen's vcpuinfo. Its format, content and interfaces may be different, but
conceptually it is the same as vcpuinfo.
> Is there a way when running on HyperV to request unused physical
> address space ranges? What Xen currently does in init_memmap is quite
> crappy.
>
Xen itself still needs to manage the address space, no?
I agree the rangeset code in xen.c isn't pretty, but it does the job and
is not too intrusive.
Wei.
> Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 4/8] x86: factor out xen variants for hypervisor setup code
2019-09-27 11:30 ` Wei Liu
@ 2019-09-27 11:39 ` Jan Beulich
2019-09-27 12:47 ` Wei Liu
2019-09-27 11:41 ` Roger Pau Monné
1 sibling, 1 reply; 40+ messages in thread
From: Jan Beulich @ 2019-09-27 11:39 UTC (permalink / raw)
To: Wei Liu
Cc: Andrew Cooper, Michael Kelley, Wei Liu, Xen Development List,
Roger Pau Monné
On 27.09.2019 13:30, Wei Liu wrote:
> On Wed, Sep 25, 2019 at 12:23:54PM +0200, Roger Pau Monné wrote:
>> Also it might be nice to introduce something like:
>>
>> enum guest_type {
>> XEN_GUEST,
>> } guest_type;
>>
>
> This works for me.
>
>> So that you can add a switch here, even if the only case is Xen ATM. I
>> guess this will be done in a later patch, or introduce an
>> hypervisor_ops struct that contain pointers to functions to allow for
>> different implementations.
>>
>
> I debated this. These changes require more code churn with no apparent
> benefit, but if people agree this is better I can make those changes.
Well, if the expectation is for the enum to grow (even just by one
further entry), then yes, I'd agree that a switch() would be nice.
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 4/8] x86: factor out xen variants for hypervisor setup code
2019-09-27 11:30 ` Wei Liu
2019-09-27 11:39 ` Jan Beulich
@ 2019-09-27 11:41 ` Roger Pau Monné
2019-09-27 12:46 ` Wei Liu
1 sibling, 1 reply; 40+ messages in thread
From: Roger Pau Monné @ 2019-09-27 11:41 UTC (permalink / raw)
To: Wei Liu
Cc: Xen Development List, Andrew Cooper, Wei Liu, Jan Beulich,
Michael Kelley
On Fri, Sep 27, 2019 at 12:30:58PM +0100, Wei Liu wrote:
> On Wed, Sep 25, 2019 at 12:23:54PM +0200, Roger Pau Monné wrote:
> > > -void __init probe_hypervisor(void)
> > > +static void __init probe_xen(void)
> >
> > While here I would rename to xen_probe, to match with the other
> > functions (ie: xen_setup below for example).
>
> Sure. I can do that. I always thought that strange too.
>
> >
> > > {
> > > if ( xen_guest )
> > > return;
> > > @@ -87,6 +87,11 @@ void __init probe_hypervisor(void)
> > > xen_guest = true;
> > > }
> > >
> > > +void __init probe_hypervisor(void)
> >
> > Shouldn't this live in a separate file, like guest/guest.c or some
> > such?
> >
>
> It's done in a later patch. I believe you've already seen it.
>
> > Also it might be nice to introduce something like:
> >
> > enum guest_type {
> > XEN_GUEST,
> > } guest_type;
> >
>
> This works for me.
>
> > So that you can add a switch here, even if the only case is Xen ATM. I
> > guess this will be done in a later patch, or introduce an
> > hypervisor_ops struct that contain pointers to functions to allow for
> > different implementations.
> >
>
> I debated this. These changes require more code churn with no apparent
> benefit, but if people agree this is better I can make those changes.
>
> > > +{
> > > + probe_xen();
> > > +}
> > > +
> > > static void map_shared_info(void)
> > > {
> > > mfn_t mfn;
> > > @@ -249,10 +254,8 @@ static void init_evtchn(void)
> > > }
> > > }
> > >
> > > -void __init hypervisor_setup(void)
> > > +static void __init xen_setup(void)
> > > {
> > > - init_memmap();
> > > -
> > > map_shared_info();
> > >
> > > set_vcpu_id();
> > > @@ -277,13 +280,25 @@ void __init hypervisor_setup(void)
> > > init_evtchn();
> > > }
> > >
> > > -void hypervisor_ap_setup(void)
> > > +void __init hypervisor_setup(void)
> > > +{
> > > + init_memmap();
> >
> > I wonder, do you also require to map hypervisor data into the guest
> > physmap when running on HyperV?
> >
>
> Yes. There are a lot of comparable concepts in Hyper-V. For example,
> there is a page called VP assist page which is more or less the same as
> Xen's vcpuinfo. Its format, content and interfaces may be different, but
> conceptually it is the same as vcpuinfo.
>
> > Is there a way when running on HyperV to request unused physical
> > address space ranges? What Xen currently does in init_memmap is quite
> > crappy.
> >
>
> Xen itself still needs to manage the address space, no?
>
> I agree the rangeset code in xen.c isn't pretty, but it does the job and
> is not too intrusive.
The problem with the current approach is that the nested Xen has no
way of knowing whether those holes are actually unused, or are MMIO
regions used by devices for example.
Hence I wondered if HyperV had a way to signal to guests that a
physical address range is safe to be used as scratch mapping space. We
had spoken avoid introducing something in Xen to be able to report to
guests safe ranges in the physmap to map stuff.
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 4/8] x86: factor out xen variants for hypervisor setup code
2019-09-27 11:41 ` Roger Pau Monné
@ 2019-09-27 12:46 ` Wei Liu
0 siblings, 0 replies; 40+ messages in thread
From: Wei Liu @ 2019-09-27 12:46 UTC (permalink / raw)
To: Roger Pau Monné
Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley, Jan Beulich,
Xen Development List
On Fri, Sep 27, 2019 at 01:41:59PM +0200, Roger Pau Monné wrote:
> > >
> > > I wonder, do you also require to map hypervisor data into the guest
> > > physmap when running on HyperV?
> > >
> >
> > Yes. There are a lot of comparable concepts in Hyper-V. For example,
> > there is a page called VP assist page which is more or less the same as
> > Xen's vcpuinfo. Its format, content and interfaces may be different, but
> > conceptually it is the same as vcpuinfo.
> >
> > > Is there a way when running on HyperV to request unused physical
> > > address space ranges? What Xen currently does in init_memmap is quite
> > > crappy.
> > >
> >
> > Xen itself still needs to manage the address space, no?
> >
> > I agree the rangeset code in xen.c isn't pretty, but it does the job and
> > is not too intrusive.
>
> The problem with the current approach is that the nested Xen has no
> way of knowing whether those holes are actually unused, or are MMIO
> regions used by devices for example.
>
> Hence I wondered if HyperV had a way to signal to guests that a
> physical address range is safe to be used as scratch mapping space. We
> had spoken avoid introducing something in Xen to be able to report to
> guests safe ranges in the physmap to map stuff.
AFAICT Hyper-V TLFS doesn't describe such functionality.
On the other hand, Hyper-V may not need this infrastructure at all
because it doesn't have grant table frame or shared info page. The most
likely outcome is in the next version the memmap stuff will be left to
Xen only until I find a use case for it.
Wei.
>
> Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 4/8] x86: factor out xen variants for hypervisor setup code
2019-09-27 11:39 ` Jan Beulich
@ 2019-09-27 12:47 ` Wei Liu
2019-09-27 12:56 ` Jan Beulich
0 siblings, 1 reply; 40+ messages in thread
From: Wei Liu @ 2019-09-27 12:47 UTC (permalink / raw)
To: Jan Beulich
Cc: Wei Liu, Wei Liu, Andrew Cooper, Michael Kelley,
Xen Development List, Roger Pau Monné
On Fri, Sep 27, 2019 at 01:39:14PM +0200, Jan Beulich wrote:
> On 27.09.2019 13:30, Wei Liu wrote:
> > On Wed, Sep 25, 2019 at 12:23:54PM +0200, Roger Pau Monné wrote:
> >> Also it might be nice to introduce something like:
> >>
> >> enum guest_type {
> >> XEN_GUEST,
> >> } guest_type;
> >>
> >
> > This works for me.
> >
> >> So that you can add a switch here, even if the only case is Xen ATM. I
> >> guess this will be done in a later patch, or introduce an
> >> hypervisor_ops struct that contain pointers to functions to allow for
> >> different implementations.
> >>
> >
> > I debated this. These changes require more code churn with no apparent
> > benefit, but if people agree this is better I can make those changes.
>
> Well, if the expectation is for the enum to grow (even just by one
> further entry), then yes, I'd agree that a switch() would be nice.
Not sure if you notice comments in a later email.
Do you prefer enum+switch solution or hypervisor_op struct?
Wei.
>
> Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [Xen-devel] [PATCH for-next RFC 4/8] x86: factor out xen variants for hypervisor setup code
2019-09-27 12:47 ` Wei Liu
@ 2019-09-27 12:56 ` Jan Beulich
0 siblings, 0 replies; 40+ messages in thread
From: Jan Beulich @ 2019-09-27 12:56 UTC (permalink / raw)
To: Wei Liu
Cc: Andrew Cooper, Michael Kelley, Wei Liu, Xen Development List,
Roger Pau Monné
On 27.09.2019 14:47, Wei Liu wrote:
> On Fri, Sep 27, 2019 at 01:39:14PM +0200, Jan Beulich wrote:
>> On 27.09.2019 13:30, Wei Liu wrote:
>>> On Wed, Sep 25, 2019 at 12:23:54PM +0200, Roger Pau Monné wrote:
>>>> Also it might be nice to introduce something like:
>>>>
>>>> enum guest_type {
>>>> XEN_GUEST,
>>>> } guest_type;
>>>>
>>>
>>> This works for me.
>>>
>>>> So that you can add a switch here, even if the only case is Xen ATM. I
>>>> guess this will be done in a later patch, or introduce an
>>>> hypervisor_ops struct that contain pointers to functions to allow for
>>>> different implementations.
>>>>
>>>
>>> I debated this. These changes require more code churn with no apparent
>>> benefit, but if people agree this is better I can make those changes.
>>
>> Well, if the expectation is for the enum to grow (even just by one
>> further entry), then yes, I'd agree that a switch() would be nice.
>
> Not sure if you notice comments in a later email.
>
> Do you prefer enum+switch solution or hypervisor_op struct?
Hard to tell without knowing how many switch() there would
end up being. The more of them, the better I'd like the ops
structure variant.
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 40+ messages in thread
end of thread, other threads:[~2019-09-27 12:56 UTC | newest]
Thread overview: 40+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-23 10:09 [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V Wei Liu
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 1/8] x86: introduce CONFIG_GUEST and move code Wei Liu
2019-09-25 9:59 ` Roger Pau Monné
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 2/8] x86: include asm_defns.h directly in hypercall.h Wei Liu
2019-09-25 10:02 ` Roger Pau Monné
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 3/8] x86: drop hypervisor_cpuid_base Wei Liu
2019-09-25 10:07 ` Roger Pau Monné
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 4/8] x86: factor out xen variants for hypervisor setup code Wei Liu
2019-09-25 10:23 ` Roger Pau Monné
2019-09-27 11:30 ` Wei Liu
2019-09-27 11:39 ` Jan Beulich
2019-09-27 12:47 ` Wei Liu
2019-09-27 12:56 ` Jan Beulich
2019-09-27 11:41 ` Roger Pau Monné
2019-09-27 12:46 ` Wei Liu
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 5/8] x86: factor out hypervisor agnostic code Wei Liu
2019-09-25 10:39 ` Roger Pau Monné
2019-09-27 11:18 ` Wei Liu
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 6/8] x86: make probe_xen return boolean value Wei Liu
2019-09-25 10:44 ` Roger Pau Monné
2019-09-27 11:18 ` Wei Liu
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 7/8] x86: introduce CONFIG_HYPERV and hyperv directory Wei Liu
2019-09-25 10:48 ` Roger Pau Monné
2019-09-27 11:18 ` Wei Liu
2019-09-23 10:09 ` [Xen-devel] [PATCH for-next RFC 8/8] x86: be more verbose when running nested Wei Liu
2019-09-25 10:54 ` Roger Pau Monné
2019-09-23 10:48 ` [Xen-devel] [PATCH for-next RFC 0/8] Port Xen to Hyper-V Paul Durrant
2019-09-23 11:27 ` Wei Liu
2019-09-23 12:11 ` Paul Durrant
2019-09-23 12:54 ` Wei Liu
2019-09-23 13:33 ` Wei Liu
2019-09-23 13:47 ` Paul Durrant
2019-09-23 14:21 ` Wei Liu
2019-09-23 14:39 ` Paul Durrant
2019-09-23 14:41 ` Wei Liu
2019-09-25 11:02 ` Roger Pau Monné
2019-09-25 15:36 ` Wei Liu
2019-09-26 10:37 ` Wei Liu
2019-09-26 10:41 ` Roger Pau Monné
2019-09-26 10:50 ` 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.