early PV on HVM
Subsystems (5)
PATCH 2/11 early PV on HVM
From: Sheng Yang <[email protected]>
--- arch/x86/include/asm/xen/hypervisor.h | 2 + arch/x86/kernel/setup.c | 2 + arch/x86/xen/enlighten.c | 87 +++++++++++++++++++++++++++++++++ drivers/input/xen-kbdfront.c | 2 +- drivers/video/xen-fbfront.c | 2 +- drivers/xen/xenbus/xenbus_probe.c | 14 ++++- 6 files changed, 104 insertions(+), 5 deletions(-)
arch/x86/include/asm/xen/hypervisor.h +2 -0
@@ -45,8 +45,10 @@ enum xen_domain_type {#ifdef CONFIG_XEN extern enum xen_domain_type xen_domain_type; +extern void xen_guest_init (void );#else #define xen_domain_type XEN_NATIVE +#define xen_guest_init () do { } while (0)#endif #define xen_domain () (xen_domain_type != XEN_NATIVE)
arch/x86/kernel/setup.c +2 -0
@@ -102,6 +102,7 @@#include <asm/paravirt.h> #include <asm/hypervisor.h> +#include <asm/xen/hypervisor.h> #include <asm/percpu.h> #include <asm/topology.h>
@@ -1014,6 +1015,7 @@ void __init setup_arch(char **cmdline_p)probe_nr_irqs_gsi ();kvm_guest_init (); +xen_guest_init ();e820_reserve_resources ();e820_mark_nosave_regions (max_low_pfn);
arch/x86/xen/enlighten.c +87 -0
96 lines not on this page · raw message
drivers/input/xen-kbdfront.c +1 -1
@@ -335,7 +335,7 @@ static struct xenbus_driver xenkbd_driver = {static int __init xenkbd_init (void ) { -if (!xen_domain ()) +if (!xen_domain () ||xen_hvm_domain ())return -ENODEV ;/* Nothing to do if running in dom0. */
drivers/video/xen-fbfront.c +1 -1
@@ -680,7 +680,7 @@ static struct xenbus_driver xenfb_driver = {static int __init xenfb_init (void ) { -if (!xen_domain ()) +if (!xen_domain () ||xen_hvm_domain ())return -ENODEV ;/* Nothing to do if running in dom0. */
drivers/xen/xenbus/xenbus_probe.c +11 -3
@@ -53,6 +53,8 @@#include <xen/events.h> #include <xen/page.h> +#include <xen/hvm.h> +#include "xenbus_comms.h" #include "xenbus_probe.h"
@@ -803,10 +805,16 @@ static int __init xenbus_probe_init(void)/* dom0 not yet supported */ }else { xenstored_ready =1 ; - xen_store_evtchn = xen_start_info->store_evtchn; - xen_store_mfn = xen_start_info->store_mfn; +if (xen_hvm_domain ()) { + xen_store_evtchn =hvm_get_parameter (HVM_PARAM_STORE_EVTCHN ); + xen_store_mfn =hvm_get_parameter (HVM_PARAM_STORE_PFN ); + xen_store_interface =ioremap (xen_store_mfn <<PAGE_SHIFT ,PAGE_SIZE ); + }else { + xen_store_evtchn = xen_start_info->store_evtchn; + xen_store_mfn = xen_start_info->store_mfn; + xen_store_interface =mfn_to_virt (xen_store_mfn); + } } - xen_store_interface =mfn_to_virt (xen_store_mfn);/* Initialize the interface to xenstore. */ err =xs_init ();
Signature · 1 line
1.5.4.3
Quoted 42 lines · Stefano Stabellini
From: Sheng Yang <[email protected]>
Signed-off-by Stefano Stabellini <[email protected]>Signed-off-by Sheng Yang <[email protected]>Signed-off-by Yaozu (Eddie) Dong <[email protected]>--- arch/x86/include/asm/xen/hypervisor.h | 2 + arch/x86/kernel/setup.c | 2 + arch/x86/xen/enlighten.c | 87 +++++++++++++++++++++++++++++++++ drivers/input/xen-kbdfront.c | 2 +- drivers/video/xen-fbfront.c | 2 +- drivers/xen/xenbus/xenbus_probe.c | 14 ++++- 6 files changed, 104 insertions(+), 5 deletions(-)arch/x86/include/asm/xen/hypervisor.h +2
-0@@ -45,8 +45,10 @@ enum xen_domain_type {#ifdef CONFIG_XEN extern enum xen_domain_type xen_domain_type; +extern void xen_guest_init (void );#else #define xen_domain_type XEN_NATIVE +#define xen_guest_init () do { } while (0)#endif #define xen_domain () (xen_domain_type != XEN_NATIVE)arch/x86/kernel/setup.c +1
-0@@ -102,6 +102,7 @@#include <asm/paravirt.h> #include <asm/hypervisor.h> +#include <asm/xen/hypervisor.h> #include <asm/percpu.h> #include <asm/topology.h>
arch/x86/kernel/setup.c void __init setup_arch(char **cmdline_p) · line 1018
Quoted 4 lines
arch/x86/kernel/setup.c +1
-0@@ -1014,6 +1015,7 @@ void __init setup_arch(char **cmdline_p)probe_nr_irqs_gsi ();kvm_guest_init (); +xen_guest_init ();
Upstream has this new mechanism for detecting hypervisors with a fancy data structure that makes '->detect' and other things. You might want to take that under consideration as when you post this patch upstream upstream they are going to ask why you aren't using it.
Quoted 29 lines
arch/x86/kernel/setup.c +0
-0e820_reserve_resources ();e820_mark_nosave_regions (max_low_pfn);arch/x86/xen/enlighten.c +11
-0@@ -32,6 +32,8 @@#include <xen/interface/version.h> #include <xen/interface/physdev.h> #include <xen/interface/vcpu.h> +#include <xen/interface/memory.h> +#include <xen/interface/hvm/hvm_op.h> #include <xen/features.h> #include <xen/page.h> #include <xen/hvc-console.h> @@ -1189,3 +1191,88 @@ asmlinkage void __init xen_start_kernel(void)x86_64_start_reservations ((char *)__pa_symbol (&boot_params));#endif } + +static uint32_t xen_cpuid_base (void ) +{ +uint32_t base, eax, ebx, ecx, edx; +char signature[13 ]; + +for (base =0x40000000 ; base <0x40010000 ; base +=0x100 ) { +cpuid (base, &eax, &ebx, &ecx, &edx); + *(uint32_t *)(signature +0 ) = ebx;
arch/x86/xen/enlighten.c asmlinkage void __init xen_start_kernel(void) · line 1212
Quoted 10 lines
arch/x86/xen/enlighten.c +10
-0+ *(uint32_t *)(signature +4 ) = ecx; + *(uint32_t *)(signature +8 ) = edx; + signature[12 ] =0 ; + +if (!strcmp ("XenVMMXenVMM" , signature) && ((eax - base) >=2 )) +return base; + } + +return 0 ; +}
And this seems to be used by the VMWare/HyperV detection engine too.
Maybe make another patch that makes a generic cpuid function that can be shared with VMWAre/HyperV/Xen?
Quoted 37 lines · Konrad Rzeszutek Wilk
arch/x86/kernel/setup.c void __init setup_arch(char **cmdline_p) · line 1018
Quoted 5 lines
arch/x86/kernel/setup.c +1
-0@@ -1014,6 +1015,7 @@ void __init setup_arch(char **cmdline_p)probe_nr_irqs_gsi ();kvm_guest_init (); +xen_guest_init ();Upstream has this new mechanism for detecting hypervisors with a fancy data structure that makes '->detect' and other things. You might want to take that under consideration as when you post this patch upstream upstream they are going to ask why you aren't using it.
Quoted 13 lines
arch/x86/xen/enlighten.c +9
-0@@ -1189,3 +1191,88 @@ asmlinkage void __init xen_start_kernel(void)x86_64_start_reservations ((char *)__pa_symbol (&boot_params));#endif } + +static uint32_t xen_cpuid_base (void ) +{ +uint32_t base, eax, ebx, ecx, edx; +char signature[13 ]; + +for (base =0x40000000 ; base <0x40010000 ; base +=0x100 ) { +cpuid (base, &eax, &ebx, &ecx, &edx); + *(uint32_t *)(signature +0 ) = ebx;arch/x86/xen/enlighten.c asmlinkage void __init xen_start_kernel(void) · line 1212
Quoted 10 lines
arch/x86/xen/enlighten.c +10
-0+ *(uint32_t *)(signature +4 ) = ecx; + *(uint32_t *)(signature +8 ) = edx; + signature[12 ] =0 ; + +if (!strcmp ("XenVMMXenVMM" , signature) && ((eax - base) >=2 )) +return base; + } + +return 0 ; +}And this seems to be used by the VMWare/HyperV detection engine too.
Quoted 3 lines
Maybe make another patch that makes a generic cpuid function that can be shared with VMWAre/HyperV/Xen?
When I rebased to upstream before sending the series to LKML I'll keep this in mind.
I am pretty sure I can at least avoid adding the call to xen_guest_init in setup.c, using init_hypervisor_platform instead.