aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/purgatory/Makefile3
-rw-r--r--arch/x86/purgatory/purgatory.c2
-rw-r--r--arch/x86/purgatory/string.c12
-rw-r--r--include/linux/sha256.h (renamed from arch/x86/purgatory/sha256.h)11
-rw-r--r--lib/sha256.c (renamed from arch/x86/purgatory/sha256.c)4
5 files changed, 28 insertions, 4 deletions
diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile
index d70c15de417b..2e9ee023e6bc 100644
--- a/arch/x86/purgatory/Makefile
+++ b/arch/x86/purgatory/Makefile
@@ -6,6 +6,9 @@ purgatory-y := purgatory.o stack.o setup-x86_$(BITS).o sha256.o entry64.o string
6targets += $(purgatory-y) 6targets += $(purgatory-y)
7PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y)) 7PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y))
8 8
9$(obj)/sha256.o: $(srctree)/lib/sha256.c
10 $(call if_changed_rule,cc_o_c)
11
9LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined -nostdlib -z nodefaultlib 12LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined -nostdlib -z nodefaultlib
10targets += purgatory.ro 13targets += purgatory.ro
11 14
diff --git a/arch/x86/purgatory/purgatory.c b/arch/x86/purgatory/purgatory.c
index 470edad96bb9..025c34ac0d84 100644
--- a/arch/x86/purgatory/purgatory.c
+++ b/arch/x86/purgatory/purgatory.c
@@ -11,9 +11,9 @@
11 */ 11 */
12 12
13#include <linux/bug.h> 13#include <linux/bug.h>
14#include <linux/sha256.h>
14#include <asm/purgatory.h> 15#include <asm/purgatory.h>
15 16
16#include "sha256.h"
17#include "../boot/string.h" 17#include "../boot/string.h"
18 18
19unsigned long purgatory_backup_dest __section(.kexec-purgatory); 19unsigned long purgatory_backup_dest __section(.kexec-purgatory);
diff --git a/arch/x86/purgatory/string.c b/arch/x86/purgatory/string.c
index d886b1fa36f0..795ca4f2cb3c 100644
--- a/arch/x86/purgatory/string.c
+++ b/arch/x86/purgatory/string.c
@@ -10,4 +10,16 @@
10 * Version 2. See the file COPYING for more details. 10 * Version 2. See the file COPYING for more details.
11 */ 11 */
12 12
13#include <linux/types.h>
14
13#include "../boot/string.c" 15#include "../boot/string.c"
16
17void *memcpy(void *dst, const void *src, size_t len)
18{
19 return __builtin_memcpy(dst, src, len);
20}
21
22void *memset(void *dst, int c, size_t len)
23{
24 return __builtin_memset(dst, c, len);
25}
diff --git a/arch/x86/purgatory/sha256.h b/include/linux/sha256.h
index 2867d9825a57..244fe01a65fb 100644
--- a/arch/x86/purgatory/sha256.h
+++ b/include/linux/sha256.h
@@ -13,9 +13,18 @@
13#include <linux/types.h> 13#include <linux/types.h>
14#include <crypto/sha.h> 14#include <crypto/sha.h>
15 15
16/*
17 * Stand-alone implementation of the SHA256 algorithm. It is designed to
18 * have as little dependencies as possible so it can be used in the
19 * kexec_file purgatory. In other cases you should use the implementation in
20 * crypto/.
21 *
22 * For details see lib/sha256.c
23 */
24
16extern int sha256_init(struct sha256_state *sctx); 25extern int sha256_init(struct sha256_state *sctx);
17extern int sha256_update(struct sha256_state *sctx, const u8 *input, 26extern int sha256_update(struct sha256_state *sctx, const u8 *input,
18 unsigned int length); 27 unsigned int length);
19extern int sha256_final(struct sha256_state *sctx, u8 *hash); 28extern int sha256_final(struct sha256_state *sctx, u8 *hash);
20 29
21#endif /* SHA256_H */ 30#endif /* SHA256_H */
diff --git a/arch/x86/purgatory/sha256.c b/lib/sha256.c
index 548ca675a14a..4400c832e2aa 100644
--- a/arch/x86/purgatory/sha256.c
+++ b/lib/sha256.c
@@ -16,9 +16,9 @@
16 */ 16 */
17 17
18#include <linux/bitops.h> 18#include <linux/bitops.h>
19#include <linux/sha256.h>
20#include <linux/string.h>
19#include <asm/byteorder.h> 21#include <asm/byteorder.h>
20#include "sha256.h"
21#include "../boot/string.h"
22 22
23static inline u32 Ch(u32 x, u32 y, u32 z) 23static inline u32 Ch(u32 x, u32 y, u32 z)
24{ 24{