This source file includes following definitions.
- sanitize_boot_params
1
2 #ifndef _ASM_X86_BOOTPARAM_UTILS_H
3 #define _ASM_X86_BOOTPARAM_UTILS_H
4
5 #include <asm/bootparam.h>
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 #define sizeof_mbr(type, member) ({ sizeof(((type *)0)->member); })
23
24 #define BOOT_PARAM_PRESERVE(struct_member) \
25 { \
26 .start = offsetof(struct boot_params, struct_member), \
27 .len = sizeof_mbr(struct boot_params, struct_member), \
28 }
29
30 struct boot_params_to_save {
31 unsigned int start;
32 unsigned int len;
33 };
34
35 static void sanitize_boot_params(struct boot_params *boot_params)
36 {
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 if (boot_params->sentinel) {
52 static struct boot_params scratch;
53 char *bp_base = (char *)boot_params;
54 char *save_base = (char *)&scratch;
55 int i;
56
57 const struct boot_params_to_save to_save[] = {
58 BOOT_PARAM_PRESERVE(screen_info),
59 BOOT_PARAM_PRESERVE(apm_bios_info),
60 BOOT_PARAM_PRESERVE(tboot_addr),
61 BOOT_PARAM_PRESERVE(ist_info),
62 BOOT_PARAM_PRESERVE(hd0_info),
63 BOOT_PARAM_PRESERVE(hd1_info),
64 BOOT_PARAM_PRESERVE(sys_desc_table),
65 BOOT_PARAM_PRESERVE(olpc_ofw_header),
66 BOOT_PARAM_PRESERVE(efi_info),
67 BOOT_PARAM_PRESERVE(alt_mem_k),
68 BOOT_PARAM_PRESERVE(scratch),
69 BOOT_PARAM_PRESERVE(e820_entries),
70 BOOT_PARAM_PRESERVE(eddbuf_entries),
71 BOOT_PARAM_PRESERVE(edd_mbr_sig_buf_entries),
72 BOOT_PARAM_PRESERVE(edd_mbr_sig_buffer),
73 BOOT_PARAM_PRESERVE(secure_boot),
74 BOOT_PARAM_PRESERVE(hdr),
75 BOOT_PARAM_PRESERVE(e820_table),
76 BOOT_PARAM_PRESERVE(eddbuf),
77 };
78
79 memset(&scratch, 0, sizeof(scratch));
80
81 for (i = 0; i < ARRAY_SIZE(to_save); i++) {
82 memcpy(save_base + to_save[i].start,
83 bp_base + to_save[i].start, to_save[i].len);
84 }
85
86 memcpy(boot_params, save_base, sizeof(*boot_params));
87 }
88 }
89
90 #endif