[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [MINI-OS PATCH 01/12] kexec: add kexec framework
Add a new config option CONFIG_KEXEC for support of kexec-ing into a new mini-os kernel. Add a related kexec.c source and a kexec.h header. For now allow CONFIG_KEXEC to be set only for PVH variant of mini-os. Signed-off-by: Juergen Gross <jgross@xxxxxxxx> --- Config.mk | 1 + Makefile | 1 + arch/x86/testbuild/all-no | 1 + arch/x86/testbuild/all-yes | 2 ++ arch/x86/testbuild/kexec | 4 +++ include/kexec.h | 7 +++++ kexec.c | 62 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 78 insertions(+) create mode 100644 arch/x86/testbuild/kexec create mode 100644 include/kexec.h create mode 100644 kexec.c diff --git a/Config.mk b/Config.mk index e493533a..e2afb1b4 100644 --- a/Config.mk +++ b/Config.mk @@ -204,6 +204,7 @@ CONFIG-n += CONFIG_LIBXENGUEST CONFIG-n += CONFIG_LIBXENTOOLCORE CONFIG-n += CONFIG_LIBXENTOOLLOG CONFIG-n += CONFIG_LIBXENMANAGE +CONFIG-n += CONFIG_KEXEC # Setting CONFIG_USE_XEN_CONSOLE copies all print output to the Xen emergency # console apart of standard dom0 handled console. CONFIG-n += CONFIG_USE_XEN_CONSOLE diff --git a/Makefile b/Makefile index d094858a..a64913ad 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,7 @@ src-y += gntmap.c src-y += gnttab.c src-y += hypervisor.c src-y += kernel.c +src-$(CONFIG_KEXEC) += kexec.c src-y += lock.c src-y += main.c src-y += mm.c diff --git a/arch/x86/testbuild/all-no b/arch/x86/testbuild/all-no index 5b3e99ed..b2ee5ce8 100644 --- a/arch/x86/testbuild/all-no +++ b/arch/x86/testbuild/all-no @@ -18,3 +18,4 @@ CONFIG_LIBXS = n CONFIG_LWIP = n CONFIG_BALLOON = n CONFIG_USE_XEN_CONSOLE = n +CONFIG_KEXEC = n diff --git a/arch/x86/testbuild/all-yes b/arch/x86/testbuild/all-yes index 8ae489a4..99ba75dd 100644 --- a/arch/x86/testbuild/all-yes +++ b/arch/x86/testbuild/all-yes @@ -19,3 +19,5 @@ CONFIG_BALLOON = y CONFIG_USE_XEN_CONSOLE = y # The following are special: they need support from outside CONFIG_LWIP = n +# KEXEC only without PARAVIRT +CONFIG_KEXEC = n diff --git a/arch/x86/testbuild/kexec b/arch/x86/testbuild/kexec new file mode 100644 index 00000000..ea17b4d9 --- /dev/null +++ b/arch/x86/testbuild/kexec @@ -0,0 +1,4 @@ +CONFIG_PARAVIRT = n +CONFIG_BALLOON = y +CONFIG_USE_XEN_CONSOLE = y +CONFIG_KEXEC = y diff --git a/include/kexec.h b/include/kexec.h new file mode 100644 index 00000000..6fd96774 --- /dev/null +++ b/include/kexec.h @@ -0,0 +1,7 @@ +#ifndef _KEXEC_H +#define _KEXEC_H + +int kexec(void *kernel, unsigned long kernel_size, + const char *cmdline); + +#endif /* _KEXEC_H */ diff --git a/kexec.c b/kexec.c new file mode 100644 index 00000000..53528169 --- /dev/null +++ b/kexec.c @@ -0,0 +1,62 @@ +/****************************************************************************** + * kexec.c + * + * Support of kexec (reboot locally into new mini-os kernel). + * + * Copyright (c) 2024, Juergen Gross, SUSE Linux GmbH + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifdef CONFIG_PARAVIRT +#error "kexec support not implemented in PV variant" +#endif + +#include <errno.h> +#include <mini-os/os.h> +#include <mini-os/lib.h> +#include <mini-os/kexec.h> + +/* + * General approach for kexec support (PVH only) is as follows: + * + * - New kernel needs to be in memory in form of a ELF file in a virtual + * memory region. + * - A new start_info structure is constructed in memory with the final + * memory locations included. + * - All memory areas needed for kexec execution are being finalized. + * - From here on a graceful failure is no longer possible. + * - Grants and event channels are torn down. + * - A temporary set of page tables is constructed at a location where it + * doesn't conflict with old and new kernel or start_info. + * - The final kexec execution stage is copied to a memory area below 4G which + * doesn't conflict with the target areas of kernel etc. + * - Cr3 is switched to the new set of page tables. + * - Execution continues in the final execution stage. + * - All data is copied to its final addresses. + * - Processing is switched to 32-bit mode without address translation. + * - The new kernel is activated. + */ + +int kexec(void *kernel, unsigned long kernel_size, + const char *cmdline) +{ + return ENOSYS; +} +EXPORT_SYMBOL(kexec); -- 2.43.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |