[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v4 4/8] x86: introduce hypervisor framework



> -----Original Message-----
> From: Xen-devel <xen-devel-bounces@xxxxxxxxxxxxxxxxxxxx> On Behalf Of Wei
> Liu
> Sent: 21 November 2019 19:51
> To: Xen Development List <xen-devel@xxxxxxxxxxxxxxxxxxxx>
> Cc: Wei Liu <liuwe@xxxxxxxxxxxxx>; Wei Liu <wl@xxxxxxx>; Andrew Cooper
> <andrew.cooper3@xxxxxxxxxx>; Michael Kelley <mikelley@xxxxxxxxxxxxx>; Jan
> Beulich <jbeulich@xxxxxxxx>; Roger Pau Monné <roger.pau@xxxxxxxxxx>
> Subject: [Xen-devel] [PATCH v4 4/8] 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@xxxxxxxxxxxxx>

Reviewed-by: Paul Durrant <pdurrant@xxxxxxxxxx>

> ---
> Changes in v4:
> 1. Add ASSERT_UNREACHABLE to stubs.
> 2. Move __read_mostly.
> 3. Return hops directly.
> 4. Drop Paul's review tag.
> ---
>  xen/arch/x86/guest/Makefile            |  2 +
>  xen/arch/x86/guest/hypervisor.c        | 42 +++++++++++++++++
>  xen/include/asm-x86/guest.h            |  1 +
>  xen/include/asm-x86/guest/hypervisor.h | 62 ++++++++++++++++++++++++++
>  xen/include/asm-x86/guest/xen.h        | 12 -----
>  5 files changed, 107 insertions(+), 12 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..103feba5d8
> --- /dev/null
> +++ b/xen/arch/x86/guest/hypervisor.c
> @@ -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/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:
> + */
> 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..2ab15a7108
> --- /dev/null
> +++ b/xen/include/asm-x86/guest/hypervisor.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 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:
> + */
> diff --git a/xen/include/asm-x86/guest/xen.h b/xen/include/asm-
> x86/guest/xen.h
> index b015ed1883..3145f75361 100644
> --- a/xen/include/asm-x86/guest/xen.h
> +++ b/xen/include/asm-x86/guest/xen.h
> @@ -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__ */
> 
> --
> 2.20.1
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxxx
> https://lists.xenproject.org/mailman/listinfo/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.