• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright 2021 Google LLC
4  *
5  * This file is automatically included by all files built into fips140.ko, via
6  * the "-include" compiler flag.
7  */
8 
9 /*
10  * fips140.ko is built from various unmodified or minimally modified kernel
11  * source files, many of which are normally meant to be buildable into different
12  * modules themselves.  That results in conflicting instances of module_init()
13  * and related macros such as MODULE_LICENSE().
14  *
15  * To solve that, we undefine MODULE to trick the kernel headers into thinking
16  * the code is being compiled as built-in.  That causes module_init() and
17  * related macros to be expanded as they would be for built-in code; e.g.,
18  * module_init() adds the function to the .initcalls section of the binary.
19  *
20  * The .c files that contain the real module_init, module license, and module
21  * parameters for fips140.ko are then responsible for redefining MODULE.  The
22  * real module_init executes all initcalls that were collected into .initcalls.
23  */
24 #undef MODULE
25 
26 /*
27  * Defining KBUILD_MODFILE is also required, since the kernel headers expect it
28  * to be defined when code that can be a module is compiled as built-in.
29  */
30 #define KBUILD_MODFILE "crypto/fips140"
31 
32 /*
33  * Disable symbol exports by default.  fips140.ko includes various files that
34  * use EXPORT_SYMBOL*(), but it's unwanted to export any symbols from fips140.ko
35  * except where explicitly needed for FIPS certification reasons.
36  */
37 #define __DISABLE_EXPORTS
38 
39 /*
40  * Redirect all calls to algorithm registration functions to the wrapper
41  * functions defined within the module.
42  */
43 #define aead_register_instance		fips140_aead_register_instance
44 #define ahash_register_instance		fips140_ahash_register_instance
45 #define crypto_register_aead		fips140_crypto_register_aead
46 #define crypto_register_aeads		fips140_crypto_register_aeads
47 #define crypto_register_ahash		fips140_crypto_register_ahash
48 #define crypto_register_ahashes		fips140_crypto_register_ahashes
49 #define crypto_register_alg		fips140_crypto_register_alg
50 #define crypto_register_algs		fips140_crypto_register_algs
51 #define crypto_register_rng		fips140_crypto_register_rng
52 #define crypto_register_rngs		fips140_crypto_register_rngs
53 #define crypto_register_shash		fips140_crypto_register_shash
54 #define crypto_register_shashes		fips140_crypto_register_shashes
55 #define crypto_register_skcipher	fips140_crypto_register_skcipher
56 #define crypto_register_skciphers	fips140_crypto_register_skciphers
57 #define shash_register_instance		fips140_shash_register_instance
58 #define skcipher_register_instance	fips140_skcipher_register_instance
59