Reviewed-by: Nadav Har'El <n...@scylladb.com>

One nitpick below.

On Fri, Jan 20, 2017 at 1:04 PM, 'Sergiy Kibrik' via OSv Development <
osv-dev@googlegroups.com> wrote:

> Xen crafts and provides a DTB with special node by which we can know
> which hypervisor we're using and load corresponding drivers.
>
> xen::is_xen_found flag is set up for future use.
>
> Signed-off-by: Sergiy Kibrik <sergiy.kib...@globallogic.com>
> ---
>  Makefile                 |  1 +
>  arch/aarch64/arch-dtb.cc |  8 ++++++++
>  arch/aarch64/arch-dtb.hh |  7 +++++++
>  arch/aarch64/boot.S      |  3 +++
>  arch/aarch64/xen.cc      | 27 +++++++++++++++++++++++++++
>  arch/aarch64/xen.hh      | 17 +++++++++++++++++
>  6 files changed, 63 insertions(+)
>  create mode 100644 arch/aarch64/xen.cc
>  create mode 100644 arch/aarch64/xen.hh
>
> diff --git a/Makefile b/Makefile
> index 4f3d9b5..9d47ce3 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -858,6 +858,7 @@ objects += arch/$(arch)/psci.o
>  objects += arch/$(arch)/arm-clock.o
>  objects += arch/$(arch)/gic.o
>  objects += arch/$(arch)/arch-dtb.o
> +objects += arch/$(arch)/xen.o
>

We already have a Makefile line with xen.o for x64, so instead of having
two of these lines, maybe we should move the $(arch)/xen.o entry to outside
the if, to apply to both architectures?



>  objects += $(libfdt)
>  endif
>
> diff --git a/arch/aarch64/arch-dtb.cc b/arch/aarch64/arch-dtb.cc
> index 0cc507f..986b3c3 100644
> --- a/arch/aarch64/arch-dtb.cc
> +++ b/arch/aarch64/arch-dtb.cc
> @@ -569,3 +569,11 @@ bool dtb_get_pci_irqmap(u32 *bdfs, int *irq_ids, int
> n)
>      }
>      return true;
>  }
> +
> +bool dtb_get_vmm_is_xen()
> +{
> +    if (fdt_check_header(dtb) != 0)
> +        return false; /* broken header will be handled later */
> +
> +    return fdt_node_offset_by_compatible(dtb, -1, "xen,xen") >= 0;
> +}
> diff --git a/arch/aarch64/arch-dtb.hh b/arch/aarch64/arch-dtb.hh
> index ef3a3a6..9acacd9 100644
> --- a/arch/aarch64/arch-dtb.hh
> +++ b/arch/aarch64/arch-dtb.hh
> @@ -131,4 +131,11 @@ bool dtb_get_pci_irqmap(u32 *bdfs, int *irq_ids, int
> n);
>  #define DTB_PHYSHI_D_SH 11
>  #define DTB_PHYSHI_F_SH 8
>
> +/* bool dtb_get_vmm_is_xen();
> + *
> + * Returns true if Xen hypervisor is detected.
> + */
> +
> +bool dtb_get_vmm_is_xen();
> +
>  #endif /* ARCH_DTB_HH */
> diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S
> index 072c95b..f415cee 100644
> --- a/arch/aarch64/boot.S
> +++ b/arch/aarch64/boot.S
> @@ -31,6 +31,9 @@ start_elf:
>          str     x5, [x1, #:lo12:dtb]
>
>          mov     x29, xzr
> +        bl      init_xen
>
+
> +        mov     x29, xzr
>          bl      premain
>
>          adrp    x3, __argc
> diff --git a/arch/aarch64/xen.cc b/arch/aarch64/xen.cc
> new file mode 100644
> index 0000000..ccdc687
> --- /dev/null
> +++ b/arch/aarch64/xen.cc
> @@ -0,0 +1,27 @@
> +/*
> + * Copyright (C) 2017 Sergiy Kibrik <sergiy.kib...@globallogic.com>
> + *
> + * This work is open source software, licensed under the terms of the
> + * BSD license as described in the LICENSE file in the top-level
> directory.
> + */
> +
> +#include <osv/types.h>
> +#include <xen/interface/xen.h>
> +
> +#include "arch-dtb.hh"
> +#include "xen.hh"
> +
> +shared_info_t *HYPERVISOR_shared_info;
> +
> +namespace xen {
> +
> +bool is_xen_found;
> +
> +}
> +
> +extern "C" {
> +void init_xen()
> +{
> +    xen::is_xen_found = dtb_get_vmm_is_xen();
> +}
> +}
> diff --git a/arch/aarch64/xen.hh b/arch/aarch64/xen.hh
> new file mode 100644
> index 0000000..ba9b7ec
> --- /dev/null
> +++ b/arch/aarch64/xen.hh
> @@ -0,0 +1,17 @@
> +/*
> + * Copyright (C) 2017 Sergiy Kibrik <sergiy.kib...@globallogic.com>
> + *
> + * This work is open source software, licensed under the terms of the
> + * BSD license as described in the LICENSE file in the top-level
> directory.
> + */
> +
> +#ifndef XEN_HH
> +#define XEN_HH
> +
> +namespace xen {
> +
> +extern bool is_xen_found;
> +
> +}
>
+
> +#endif /* XEN_HH */
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups
> "OSv Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to osv-dev+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to