+obj-y += hypervisor.o
+
subdir-$(CONFIG_XEN_GUEST) += xen
--- /dev/null
+/******************************************************************************
+ * arch/x86/guest/hypervisor.c
+ *
+ * Support for detecting and running under a hypervisor.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (c) 2019 Microsoft.
+ */
+
+#include <xen/types.h>
+
+#include <asm/cache.h>
+#include <asm/guest/hypervisor.h>
+
+static const struct hypervisor_ops __read_mostly *hops;
+
+const struct hypervisor_ops *hypervisor_probe(void)
+{
+ return hops;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
#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>
--- /dev/null
+/******************************************************************************
+ * asm-x86/guest/hypervisor.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (c) 2019 Microsoft.
+ */
+
+#ifndef __X86_HYPERVISOR_H__
+#define __X86_HYPERVISOR_H__
+
+struct hypervisor_ops {
+ /* Name of the hypervisor */
+ const char *name;
+ /* Main setup routine */
+ void (*setup)(void);
+ /* AP setup */
+ void (*ap_setup)(void);
+ /* Resume from suspension */
+ void (*resume)(void);
+};
+
+#ifdef CONFIG_GUEST
+
+const struct hypervisor_ops *hypervisor_probe(void);
+void hypervisor_setup(void);
+void hypervisor_ap_setup(void);
+void hypervisor_resume(void);
+
+#else
+
+#include <xen/lib.h>
+#include <xen/types.h>
+
+static inline const struct hypervisor_ops *hypervisor_probe(void) { return NULL; }
+static inline void hypervisor_setup(void) { ASSERT_UNREACHABLE(); }
+static inline void hypervisor_ap_setup(void) { ASSERT_UNREACHABLE(); }
+static inline void hypervisor_resume(void) { ASSERT_UNREACHABLE(); }
+
+#endif /* CONFIG_GUEST */
+
+#endif /* __X86_HYPERVISOR_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
extern uint32_t xen_cpuid_base;
void probe_hypervisor(void);
-void hypervisor_setup(void);
-void hypervisor_ap_setup(void);
int hypervisor_alloc_unused_page(mfn_t *mfn);
int hypervisor_free_unused_page(mfn_t mfn);
-void hypervisor_resume(void);
DECLARE_PER_CPU(unsigned int, vcpu_id);
DECLARE_PER_CPU(struct vcpu_info *, vcpu_info);
static inline void probe_hypervisor(void) {}
-static inline void hypervisor_setup(void)
-{
- ASSERT_UNREACHABLE();
-}
-static inline void hypervisor_ap_setup(void)
-{
- ASSERT_UNREACHABLE();
-}
-
#endif /* CONFIG_XEN_GUEST */
#endif /* __X86_GUEST_XEN_H__ */