[PATCH v4 05/14] kexec: Add Kexec HandOver (KHO) generation helpers
Thomas Weißschuh
linux at weissschuh.net
Wed Feb 12 04:29:00 PST 2025
On 2025-02-06 15:27:45+0200, Mike Rapoport wrote:
> From: Alexander Graf <graf at amazon.com>
>
> This patch adds the core infrastructure to generate Kexec HandOver
> metadata. Kexec HandOver is a mechanism that allows Linux to preserve
> state - arbitrary properties as well as memory locations - across kexec.
>
> It does so using 2 concepts:
>
> 1) Device Tree - Every KHO kexec carries a KHO specific flattened
> device tree blob that describes the state of the system. Device
> drivers can register to KHO to serialize their state before kexec.
>
> 2) Scratch Regions - CMA regions that we allocate in the first kernel.
> CMA gives us the guarantee that no handover pages land in those
> regions, because handover pages must be at a static physical memory
> location. We use these regions as the place to load future kexec
> images so that they won't collide with any handover data.
>
> Signed-off-by: Alexander Graf <graf at amazon.com>
> Co-developed-by: Mike Rapoport (Microsoft) <rppt at kernel.org>
> Signed-off-by: Mike Rapoport (Microsoft) <rppt at kernel.org>
> ---
> Documentation/ABI/testing/sysfs-kernel-kho | 53 +++
> .../admin-guide/kernel-parameters.txt | 24 +
> MAINTAINERS | 1 +
> include/linux/cma.h | 2 +
> include/linux/kexec.h | 18 +
> include/linux/kexec_handover.h | 10 +
> kernel/Makefile | 1 +
> kernel/kexec_handover.c | 450 ++++++++++++++++++
> mm/internal.h | 3 -
> mm/mm_init.c | 8 +
> 10 files changed, 567 insertions(+), 3 deletions(-)
> create mode 100644 Documentation/ABI/testing/sysfs-kernel-kho
> create mode 100644 include/linux/kexec_handover.h
> create mode 100644 kernel/kexec_handover.c
<snip>
> --- /dev/null
> +++ b/include/linux/kexec_handover.h
> @@ -0,0 +1,10 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef LINUX_KEXEC_HANDOVER_H
> +#define LINUX_KEXEC_HANDOVER_H
#include <linux/types.h>
> +
> +struct kho_mem {
> + phys_addr_t addr;
> + phys_addr_t size;
> +};
> +
> +#endif /* LINUX_KEXEC_HANDOVER_H */
<snip>
> +static ssize_t dt_read(struct file *file, struct kobject *kobj,
> + struct bin_attribute *attr, char *buf,
Please make the bin_attribute argument const. Currently both work, but
the non-const variant will go away.
This way I can test my stuff on linux-next.
> + loff_t pos, size_t count)
> +{
> + mutex_lock(&kho_out.lock);
> + memcpy(buf, attr->private + pos, count);
> + mutex_unlock(&kho_out.lock);
> +
> + return count;
> +}
> +
> +struct bin_attribute bin_attr_dt_kern = __BIN_ATTR(dt, 0400, dt_read, NULL, 0);
The new __BIN_ATTR_ADMIN_RO() could make this slightly shorter.
<snip>
More information about the linux-arm-kernel
mailing list