Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions arch/riscv/include/asm/purgatory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_RISCV_PURGATORY_H
#define _ASM_RISCV_PURGATORY_H

#ifndef __ASSEMBLER__
#include <linux/purgatory.h>

extern void purgatory(void);
#endif /* __ASSEMBLER__ */

#endif /* _ASM_RISCV_PURGATORY_H */
14 changes: 5 additions & 9 deletions arch/riscv/purgatory/purgatory.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
*
*/

#include <linux/purgatory.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <asm/purgatory.h>
#include <asm/string.h>

u8 purgatory_sha256_digest[SHA256_DIGEST_SIZE] __section(".kexec-purgatory");

struct kexec_sha_region purgatory_sha_regions[KEXEC_SEGMENT_MAX] __section(".kexec-purgatory");

static int verify_sha256_digest(void)
static bool verify_sha256_digest(void)
{
struct kexec_sha_region *ptr, *end;
struct sha256_ctx sctx;
Expand All @@ -26,15 +26,11 @@ static int verify_sha256_digest(void)
sha256_init(&sctx);
end = purgatory_sha_regions + ARRAY_SIZE(purgatory_sha_regions);
for (ptr = purgatory_sha_regions; ptr < end; ptr++)
sha256_update(&sctx, (uint8_t *)(ptr->start), ptr->len);
sha256_update(&sctx, (const u8 *)(ptr->start), ptr->len);
sha256_final(&sctx, digest);
if (memcmp(digest, purgatory_sha256_digest, sizeof(digest)) != 0)
return 1;
return 0;
}

/* workaround for a warning with -Wmissing-prototypes */
void purgatory(void);
return memcmp(digest, purgatory_sha256_digest, sizeof(digest));
}

void purgatory(void)
{
Expand Down
Loading