summaryrefstree
path: root/kernel/crypto/fips_helper.c
blob: 17d10fd918942ca6d8f331778f573d1eb8a7b1ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * Symbol helper for FIPS
 *
 * Copyright (C) 2015 Samsung Electronics Co., Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */
#include <linux/kernel.h>

extern void first_crypto_text(void);
extern void first_crypto_init(void);
extern const int first_crypto_rodata;
extern void last_crypto_text(void);
extern const int last_crypto_rodata;
extern void last_crypto_init(void);
extern const int first_crypto_asm_rodata;
extern void first_crypto_asm_text(void);
extern void first_crypto_asm_init(void);
extern const int last_crypto_asm_rodata;
extern void last_crypto_asm_text(void);
extern void last_crypto_asm_init(void);

unsigned long get_fips_symbol_address(const char *symname)
{
	if (!strcmp(symname, "first_crypto_text"))
		return (unsigned long)first_crypto_text;
	else if (!strcmp(symname, "last_crypto_text"))
		return (unsigned long)last_crypto_text;
	else if (!strcmp(symname, "first_crypto_rodata"))
		return (unsigned long)&first_crypto_rodata;
	else if (!strcmp(symname, "last_crypto_rodata"))
		return (unsigned long)&last_crypto_rodata;
	else if (!strcmp(symname, "first_crypto_init"))
		return (unsigned long)first_crypto_init;
	else if (!strcmp(symname, "last_crypto_init"))
		return (unsigned long)last_crypto_init;
	else if (!strcmp(symname, "first_crypto_asm_text"))
		return (unsigned long)first_crypto_asm_text;
	else if (!strcmp(symname, "last_crypto_asm_text"))
		return (unsigned long)last_crypto_asm_text;
	else if (!strcmp(symname, "first_crypto_asm_rodata"))
		return (unsigned long)&first_crypto_asm_rodata;
	else if (!strcmp(symname, "last_crypto_asm_rodata"))
		return (unsigned long)&last_crypto_asm_rodata;
	else if (!strcmp(symname, "first_crypto_asm_init"))
		return (unsigned long)first_crypto_asm_init;
	else if (!strcmp(symname, "last_crypto_asm_init"))
		return (unsigned long)last_crypto_asm_init;

	return 0;
}