mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
x86: introduce hypervisor framework
We will soon implement Hyper-V support for Xen. Add a framework for that. This requires moving some of the hypervisor_* functions from xen.h to hypervisor.h. Signed-off-by: Wei Liu <liuwe@microsoft.com> Acked-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
1c178ffb29
commit
49bd351aee
5 files changed
+107
-12
No files matched your search
@@ -1 +1,3 @@
|
||||
obj-y += hypervisor.o
|
||||
|
||||
subdir-$(CONFIG_XEN_GUEST) += xen
|
||||
@@ -0,0 +1,42 @@
|
||||
/******************************************************************************
|
||||
* arch/x86/guest/hypervisor.c
|
||||
*
|
||||
* Support for detecting and running under a hypervisor.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Copyright (c) 2019 Microsoft.
|
||||
*/
|
||||
#include <xen/init.h>
|
||||
#include <xen/types.h>
|
||||
|
||||
#include <asm/cache.h>
|
||||
#include <asm/guest/hypervisor.h>
|
||||
|
||||
static const struct hypervisor_ops *__read_mostly ops;
|
||||
|
||||
const char *__init hypervisor_probe(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: C
|
||||
* c-file-style: "BSD"
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
@@ -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>
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/******************************************************************************
|
||||
* asm-x86/guest/hypervisor.h
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms and conditions of the GNU General Public
|
||||
* License, version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program; If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Copyright (c) 2019 Microsoft.
|
||||
*/
|
||||
|
||||
#ifndef __X86_HYPERVISOR_H__
|
||||
#define __X86_HYPERVISOR_H__
|
||||
|
||||
struct hypervisor_ops {
|
||||
/* Name of the hypervisor */
|
||||
const char *name;
|
||||
/* Main setup routine */
|
||||
void (*setup)(void);
|
||||
/* AP setup */
|
||||
void (*ap_setup)(void);
|
||||
/* Resume from suspension */
|
||||
void (*resume)(void);
|
||||
};
|
||||
|
||||
#ifdef CONFIG_GUEST
|
||||
|
||||
const char *hypervisor_probe(void);
|
||||
void hypervisor_setup(void);
|
||||
void hypervisor_ap_setup(void);
|
||||
void hypervisor_resume(void);
|
||||
|
||||
#else
|
||||
|
||||
#include <xen/lib.h>
|
||||
#include <xen/types.h>
|
||||
|
||||
static inline const char *hypervisor_probe(void) { return NULL; }
|
||||
static inline void hypervisor_setup(void) { ASSERT_UNREACHABLE(); }
|
||||
static inline void hypervisor_ap_setup(void) { ASSERT_UNREACHABLE(); }
|
||||
static inline void hypervisor_resume(void) { ASSERT_UNREACHABLE(); }
|
||||
|
||||
#endif /* CONFIG_GUEST */
|
||||
|
||||
#endif /* __X86_HYPERVISOR_H__ */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: C
|
||||
* c-file-style: "BSD"
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
@@ -33,11 +33,8 @@ extern bool pv_console;
|
||||
extern uint32_t xen_cpuid_base;
|
||||
|
||||
void probe_hypervisor(void);
|
||||
void hypervisor_setup(void);
|
||||
void hypervisor_ap_setup(void);
|
||||
int hypervisor_alloc_unused_page(mfn_t *mfn);
|
||||
int hypervisor_free_unused_page(mfn_t mfn);
|
||||
void hypervisor_resume(void);
|
||||
|
||||
DECLARE_PER_CPU(unsigned int, vcpu_id);
|
||||
DECLARE_PER_CPU(struct vcpu_info *, vcpu_info);
|
||||
@@ -49,15 +46,6 @@ DECLARE_PER_CPU(struct vcpu_info *, vcpu_info);
|
||||
|
||||
static inline void probe_hypervisor(void) {}
|
||||
|
||||
static inline void hypervisor_setup(void)
|
||||
{
|
||||
ASSERT_UNREACHABLE();
|
||||
}
|
||||
static inline void hypervisor_ap_setup(void)
|
||||
{
|
||||
ASSERT_UNREACHABLE();
|
||||
}
|
||||
|
||||
#endif /* CONFIG_XEN_GUEST */
|
||||
#endif /* __X86_GUEST_XEN_H__ */
|
||||
|
||||
|
||||