Take the chance to change probe_hypervisor to hypervisor_probe.
Signed-off-by: Wei Liu <liuwe@microsoft.com>
Reviewed-by: Paul Durrant <paul@xen.org>
---
V3:
1. Address Roger's comments
2. Change xen_hypervisor_ops to xen_ops
#include <xen/types.h>
#include <asm/cache.h>
-#include <asm/guest/hypervisor.h>
+#include <asm/guest.h>
static struct hypervisor_ops *hops __read_mostly;
if ( hops )
return true;
+ /* Too early to use cpu_has_hypervisor */
+ if ( !(cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_HYPERVISOR)) )
+ return false;
+
+#ifdef CONFIG_XEN_GUEST
+ if ( xen_probe() )
+ {
+ hops = &xen_ops;
+ return true;
+ }
+#endif
+
return false;
}
+void hypervisor_setup(void)
+{
+ if ( hops && hops->setup )
+ hops->setup();
+}
+
+void hypervisor_ap_setup(void)
+{
+ if ( hops && hops->ap_setup )
+ hops->ap_setup();
+}
+
+void hypervisor_resume(void)
+{
+ if ( hops && hops->resume )
+ hops->resume();
+}
+
/*
* Local variables:
* mode: C
{
convert_pvh_info(mbi, mod);
- probe_hypervisor();
+ hypervisor_probe();
ASSERT(xen_guest);
get_memory_map();
}
}
-void __init probe_hypervisor(void)
+bool __init xen_probe(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 )
- 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)
}
}
-void __init hypervisor_setup(void)
+static void __init xen_setup(void)
{
init_memmap();
init_evtchn();
}
-void hypervisor_ap_setup(void)
+static void xen_ap_setup(void)
{
set_vcpu_id();
map_vcpuinfo();
init_evtchn();
}
-void hypervisor_resume(void)
+static void xen_resume(void)
{
/* Reset shared info page. */
map_shared_info();
pv_console_init();
}
+struct hypervisor_ops xen_ops = {
+ .name = "Xen",
+ .setup = xen_setup,
+ .ap_setup = xen_ap_setup,
+ .resume = xen_resume,
+};
+
/*
* Local variables:
* mode: C
* allocing any xenheap structures wanted in lower memory. */
kexec_early_calculations();
- probe_hypervisor();
+ hypervisor_probe();
parse_video_info();
#include <asm/e820.h>
#include <asm/fixmap.h>
+#include <asm/guest/hypervisor.h>
#define XEN_shared_info ((struct shared_info *)fix_to_virt(FIX_XEN_SHARED_INFO))
extern bool xen_guest;
extern bool pv_console;
extern uint32_t xen_cpuid_base;
+extern struct hypervisor_ops xen_ops;
-void probe_hypervisor(void);
+bool xen_probe(void);
int xen_alloc_unused_page(mfn_t *mfn);
int xen_free_unused_page(mfn_t mfn);
#define xen_guest 0
#define pv_console 0
-static inline void probe_hypervisor(void) {}
+static inline bool xen_probe(void) { return false; }
#endif /* CONFIG_XEN_GUEST */
#endif /* __X86_GUEST_XEN_H__ */