[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [mini-os master] add kexec framework
commit e447eec022ac3f3d2c5181b494c97f8438be4175 Author: Juergen Gross <jgross@xxxxxxxx> AuthorDate: Mon Jun 23 10:38:57 2025 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Mon Jun 23 10:38:57 2025 +0200 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> Reviewed-by: Jason Andryuk <jason.andryuk@xxxxxxx> --- 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 | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 76 insertions(+) diff --git a/Config.mk b/Config.mk index e493533..e2afb1b 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 d094858..a64913a 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 5b3e99e..b2ee5ce 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 8ae489a..c9a990f 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 not implemented for PARAVIRT +CONFIG_KEXEC = n diff --git a/arch/x86/testbuild/kexec b/arch/x86/testbuild/kexec new file mode 100644 index 0000000..ea17b4d --- /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 0000000..6fd9677 --- /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 0000000..7fcc5c6 --- /dev/null +++ b/kexec.c @@ -0,0 +1,60 @@ +/****************************************************************************** + * 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 binary in a virtual + * memory region. + * - A new start_info structure is constructed in memory with the final + * memory locations included. + * - Page tables and memory pages of the new kernel binary conflicting with the + * final memory layout are moved to non-conflicting locations. + * - All memory areas needed for kexec execution are being finalized. + * - The final kexec execution stage is copied to a memory area below 4G which + * doesn't conflict with the target areas of kernel etc. + * - From here on a graceful failure is no longer possible. + * - Grants and event channels are torn down. + * - Execution continues in the final execution stage. + * - All data is copied to its final addresses. + * - CPU is switched to 32-bit mode with paging disabled. + * - The new kernel is activated. + */ + +int kexec(void *kernel, unsigned long kernel_size, const char *cmdline) +{ + return ENOSYS; +} +EXPORT_SYMBOL(kexec); -- generated by git-patchbot for /home/xen/git/mini-os.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |