[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 02/23] x86/entry: Probe for Xen early during boot
From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- v1 -> v2 - ARM stubs --- xen/arch/x86/Makefile | 1 + xen/arch/x86/guest/Makefile | 1 + xen/arch/x86/guest/xen.c | 75 +++++++++++++++++++++++++++++++++++++++++ xen/arch/x86/setup.c | 4 +++ xen/include/asm-arm/guest.h | 22 ++++++++++++ xen/include/asm-x86/guest.h | 34 +++++++++++++++++++ xen/include/asm-x86/guest/xen.h | 47 ++++++++++++++++++++++++++ 7 files changed, 184 insertions(+) create mode 100644 xen/arch/x86/guest/Makefile create mode 100644 xen/arch/x86/guest/xen.c create mode 100644 xen/include/asm-arm/guest.h create mode 100644 xen/include/asm-x86/guest.h create mode 100644 xen/include/asm-x86/guest/xen.h diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index d5d58a2..c1977d1 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -1,6 +1,7 @@ subdir-y += acpi subdir-y += cpu subdir-y += genapic +subdir-$(CONFIG_XEN_GUEST) += guest subdir-$(CONFIG_HVM) += hvm subdir-y += mm subdir-$(CONFIG_XENOPROF) += oprofile diff --git a/xen/arch/x86/guest/Makefile b/xen/arch/x86/guest/Makefile new file mode 100644 index 0000000..7f67396 --- /dev/null +++ b/xen/arch/x86/guest/Makefile @@ -0,0 +1 @@ +obj-y += xen.o diff --git a/xen/arch/x86/guest/xen.c b/xen/arch/x86/guest/xen.c new file mode 100644 index 0000000..9446a46 --- /dev/null +++ b/xen/arch/x86/guest/xen.c @@ -0,0 +1,75 @@ +/****************************************************************************** + * arch/x86/guest/xen.c + * + * Support for detecting and running under Xen. + * + * 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) 2017 Citrix Systems Ltd. + */ +#include <xen/init.h> +#include <xen/types.h> + +#include <asm/guest.h> +#include <asm/processor.h> + +#include <public/arch-x86/cpuid.h> + +bool xen_guest; + +static uint32_t xen_cpuid_base; + +static void __init find_xen_leaves(void) +{ + uint32_t eax, ebx, ecx, edx, base; + + for ( base = XEN_CPUID_FIRST_LEAF; + base < XEN_CPUID_FIRST_LEAF + 0x10000; base += 0x100 ) + { + cpuid(base, &eax, &ebx, &ecx, &edx); + + if ( (ebx == XEN_CPUID_SIGNATURE_EBX) && + (ecx == XEN_CPUID_SIGNATURE_ECX) && + (edx == XEN_CPUID_SIGNATURE_EDX) && + ((eax - base) >= 2) ) + { + xen_cpuid_base = base; + break; + } + } +} + +void __init probe_hypervisor(void) +{ + /* 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; + + xen_guest = true; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 2e10c6b..7627c3f 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -51,6 +51,8 @@ #include <asm/alternative.h> #include <asm/mc146818rtc.h> #include <asm/cpuid.h> +#include <asm/guest.h> +#include <public/arch-x86/cpuid.h> /* opt_nosmp: If true, secondary processors are ignored. */ static bool __initdata opt_nosmp; @@ -704,6 +706,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) * allocing any xenheap structures wanted in lower memory. */ kexec_early_calculations(); + probe_hypervisor(); + parse_video_info(); rdmsrl(MSR_EFER, this_cpu(efer)); diff --git a/xen/include/asm-arm/guest.h b/xen/include/asm-arm/guest.h new file mode 100644 index 0000000..4d143d7 --- /dev/null +++ b/xen/include/asm-arm/guest.h @@ -0,0 +1,22 @@ +/****************************************************************************** + * include/asm-x86/guest.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 2018 Amazon.com, Inc. or its affiliates. + */ + +#ifndef __ARM_GUEST_H__ +#define __ARM_GUEST_H__ + +#endif diff --git a/xen/include/asm-x86/guest.h b/xen/include/asm-x86/guest.h new file mode 100644 index 0000000..eb08434 --- /dev/null +++ b/xen/include/asm-x86/guest.h @@ -0,0 +1,34 @@ +/****************************************************************************** + * asm-x86/guest.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) 2017 Citrix Systems Ltd. + */ + +#ifndef __X86_GUEST_H__ +#define __X86_GUEST_H__ + +#include <asm/guest/xen.h> + +#endif /* __X86_GUEST_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 new file mode 100644 index 0000000..97a7c8d --- /dev/null +++ b/xen/include/asm-x86/guest/xen.h @@ -0,0 +1,47 @@ +/****************************************************************************** + * asm-x86/guest/xen.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) 2017 Citrix Systems Ltd. + */ + +#ifndef __X86_GUEST_XEN_H__ +#define __X86_GUEST_XEN_H__ + +#include <xen/types.h> + +#ifdef CONFIG_XEN_GUEST + +extern bool xen_guest; + +void probe_hypervisor(void); + +#else + +#define xen_guest 0 + +static inline void probe_hypervisor(void) {}; + +#endif /* CONFIG_XEN_GUEST */ +#endif /* __X86_GUEST_XEN_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |