Merge branch 'kexec-misc' into kexec-next

This commit is contained in:
Mike Rapoport (Microsoft) 2026-08-04 10:48:15 +03:00
commit 42b847795b
2 changed files with 28 additions and 1 deletions

View File

@ -13,7 +13,7 @@
#define IND_SOURCE (1 << IND_SOURCE_BIT)
#define IND_FLAGS (IND_DESTINATION | IND_INDIRECTION | IND_DONE | IND_SOURCE)
#if !defined(__ASSEMBLY__)
#if !defined(__ASSEMBLER__)
#include <linux/vmcore_info.h>
#include <linux/crash_reserve.h>

View File

@ -27,6 +27,7 @@
#include <linux/syscalls.h>
#include <linux/vmalloc.h>
#include <linux/dma-map-ops.h>
#include <linux/kexec_handover.h>
#include "kexec_internal.h"
#ifdef CONFIG_KEXEC_SIG
@ -798,6 +799,16 @@ int kexec_add_buffer(struct kexec_buf *kbuf)
return 0;
}
static bool kexec_only_cma_segments(struct kimage *image)
{
for (int i = 0; i < image->nr_segments; i++) {
if (!image->segment_cma[i])
return false;
}
return true;
}
/* Calculate and store the digest of segments */
static int kexec_calculate_store_digests(struct kimage *image)
{
@ -822,6 +833,21 @@ static int kexec_calculate_store_digests(struct kimage *image)
sha256_init(&sctx);
/*
* If KHO is enabled, the destinations are located in KHO scratch.
* KHO scratch can only contain early boot allocations and movable
* allocations. That means there is no risk of memory corruption by
* uncancelled DMA.
*
* If all segments were loaded into contiguous memory, there will be no
* relocations at all, so also no risk of corruption.
*/
if (image->type != KEXEC_TYPE_CRASH &&
(kho_is_enabled() || kexec_only_cma_segments(image))) {
pr_debug("disabling checksum verification in purgatory\n");
goto skip_checksum;
}
for (j = i = 0; i < image->nr_segments; i++) {
struct kexec_segment *ksegment;
@ -867,6 +893,7 @@ static int kexec_calculate_store_digests(struct kimage *image)
j++;
}
skip_checksum:
sha256_final(&sctx, digest);
ret = kexec_purgatory_get_set_symbol(image, "purgatory_sha_regions",