[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 5/7] x86/kexec: Implement new EFI load type


  • To: Kevin Lampis <kevin.lampis@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 23 Jun 2026 16:55:20 +0200
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:In-Reply-To:Autocrypt:From:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID"
  • Autocrypt: addr=jbeulich@xxxxxxxx; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL
  • Cc: andrew.cooper3@xxxxxxxxxx, roger.pau@xxxxxxxxxx, ross.lagerwall@xxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 23 Jun 2026 14:55:33 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 22.06.2026 17:18, Kevin Lampis wrote:
> --- a/xen/arch/x86/Makefile
> +++ b/xen/arch/x86/Makefile
> @@ -71,6 +71,7 @@ obj-$(CONFIG_TBOOT) += tboot.o
>  obj-y += hpet.o
>  obj-$(CONFIG_VM_EVENT) += vm_event.o
>  obj-y += xstate.o
> +obj-$(CONFIG_KEXEC) += kexec.o

While there are some anomalies down here, most of this block is suitably
sorted (alphabetically). Please insert accordingly.

> --- /dev/null
> +++ b/xen/arch/x86/kexec.c
> @@ -0,0 +1,58 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +
> +#include <xen/kexec.h>
> +#include <xen/kimage.h>
> +#include <xen/guest_access.h>
> +#include <asm/bzimage.h>
> +
> +/*
> + * Find the entry point to the new kernel, we need to map the crash region 
> into
> + * memory in order to read the kernel header.
> + */
> +#define KERNEL_SEGMENT_IDX 0
> +int64_t kimage_find_kernel_entry_maddr(struct kexec_image *image)
> +{
> +    uint64_t dest_maddr;
> +    uint32_t alignment, magic;
> +    uint16_t version;
> +    void *dest_va;
> +    const struct bzimage_header *hdr;
> +    int setup_sects;
> +    size_t kern16_size;
> +
> +    dest_maddr = image->segments[KERNEL_SEGMENT_IDX].dest_maddr +
> +                 image->segments[KERNEL_SEGMENT_IDX].dest_offset;
> +
> +    dest_va = map_domain_page(maddr_to_mfn(dest_maddr));
> +
> +    hdr = (const struct bzimage_header *)dest_va;
> +    magic = hdr->header;
> +    version = hdr->version;
> +    alignment = hdr->kernel_alignment;
> +    setup_sects = hdr->setup_sects == 0 ? 4 : hdr->setup_sects;
> +    kern16_size = (setup_sects + 1 )  * 512;
> +
> +    unmap_domain_page(dest_va);
> +
> +    if ( magic != 0x53726448 || version < 0x0202 )
> +        return -EINVAL;
> +
> +    /*
> +     * Ensure the kernel alignment is a valid LOAD_PHYSICAL_ADDR,
> +     * which ranges from 0x200000 (2MiB) to 0x1000000 (16MiB) on 64-bit 
> systems
> +     * as defined in the kernel x86 Kconfig
> +     */
> +    if ( alignment % 0x200000 != 0 ||
> +         alignment < 0x200000 ||
> +         alignment > 0x1000000 )

Use MB() to cover some of what the comment currently says? (The second of the
checks would also be easier as !alignment, seeing that the first check already
excluded all other values below MB(2).)

> --- a/xen/include/public/kexec.h
> +++ b/xen/include/public/kexec.h
> @@ -54,13 +54,16 @@
>   * - kexec into a regular kernel, very similar to a standard reboot
>   *   - KEXEC_TYPE_DEFAULT is used to specify this type
>   * - kexec into a special "crash kernel", aka kexec-on-panic
> - *   - KEXEC_TYPE_CRASH is used to specify this type
> + *   - KEXEC_TYPE_CRASH or KEXEC_TYPE_CRASH_EFI are used to specify this type
> + *   - in case of KEXEC_TYPE_CRASH_EFI the first segment will point to the
> + *     full kernel to load and entry point will point to boot params
>   *   - parts of our system may be broken at kexec-on-panic time
>   *     - the code should be kept as simple and self-contained as possible
>   */
>  
>  #define KEXEC_TYPE_DEFAULT 0
>  #define KEXEC_TYPE_CRASH   1
> +#define KEXEC_TYPE_CRASH_EFI 3
>  
>  /*
>   * Perform kexec having previously loaded a kexec or kdump kernel
> @@ -167,7 +170,11 @@ typedef struct xen_kexec_load {
>          XEN_GUEST_HANDLE(xen_kexec_segment_t) h;
>          uint64_t _pad;
>      } segments;
> -    uint64_t entry_maddr; /* image entry point machine address. */
> +    /* image entry point machine address or parameters in case of EFI. */

Nit: As you touch comments, please also correct style issues.

> +    union {
> +        uint64_t entry_maddr;
> +        uint64_t parameters;
> +    };

We don't want to use language extensions in public headers. I'm actually
surprised this still passes the -ansi header check that we do from
include/Makefile. Maybe with recent compilers this doesn't do anymore
what we expect it to do?

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.