1 #ifndef _ASM_X86_BOOTPARAM_UTILS_H
2 #define _ASM_X86_BOOTPARAM_UTILS_H
3 
4 #include <asm/bootparam.h>
5 
6 /*
7  * This file is included from multiple environments.  Do not
8  * add completing #includes to make it standalone.
9  */
10 
11 /*
12  * Deal with bootloaders which fail to initialize unknown fields in
13  * boot_params to zero.  The list fields in this list are taken from
14  * analysis of kexec-tools; if other broken bootloaders initialize a
15  * different set of fields we will need to figure out how to disambiguate.
16  *
17  */
18 static void sanitize_boot_params(struct boot_params *boot_params)
19 {
20 	if (boot_params->sentinel) {
21 		/*fields in boot_params are not valid, clear them */
22 		memset(&boot_params->olpc_ofw_header, 0,
23 		       (char *)&boot_params->alt_mem_k -
24 			(char *)&boot_params->olpc_ofw_header);
25 		memset(&boot_params->kbd_status, 0,
26 		       (char *)&boot_params->hdr -
27 		       (char *)&boot_params->kbd_status);
28 		memset(&boot_params->_pad7[0], 0,
29 		       (char *)&boot_params->edd_mbr_sig_buffer[0] -
30 			(char *)&boot_params->_pad7[0]);
31 		memset(&boot_params->_pad8[0], 0,
32 		       (char *)&boot_params->eddbuf[0] -
33 			(char *)&boot_params->_pad8[0]);
34 		memset(&boot_params->_pad9[0], 0, sizeof(boot_params->_pad9));
35 	}
36 }
37 
38 #endif /* _ASM_X86_BOOTPARAM_UTILS_H */
39