2 * purgatory: Runs between two kernels
4 * Copyright (C) 2014 Red Hat Inc.
7 * Vivek Goyal <vgoyal@redhat.com>
9 * This source code is licensed under the GNU General Public License,
10 * Version 2. See the file COPYING for more details.
14 #include "../boot/string.h"
21 unsigned long backup_dest = 0;
22 unsigned long backup_src = 0;
23 unsigned long backup_sz = 0;
25 u8 sha256_digest[SHA256_DIGEST_SIZE] = { 0 };
27 struct sha_region sha_regions[16] = {};
30 * On x86, second kernel requries first 640K of memory to boot. Copy
31 * first 640K to a backup region in reserved memory range so that second
32 * kernel can use first 640K.
34 static int copy_backup_region(void)
37 memcpy((void *)backup_dest, (void *)backup_src, backup_sz);
42 int verify_sha256_digest(void)
44 struct sha_region *ptr, *end;
45 u8 digest[SHA256_DIGEST_SIZE];
46 struct sha256_state sctx;
49 end = &sha_regions[sizeof(sha_regions)/sizeof(sha_regions[0])];
50 for (ptr = sha_regions; ptr < end; ptr++)
51 sha256_update(&sctx, (uint8_t *)(ptr->start), ptr->len);
53 sha256_final(&sctx, digest);
55 if (memcmp(digest, sha256_digest, sizeof(digest)))
65 ret = verify_sha256_digest();