aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/include/asm/bootparam_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/include/asm/bootparam_utils.h')
-rw-r--r--arch/x86/include/asm/bootparam_utils.h63
1 files changed, 48 insertions, 15 deletions
diff --git a/arch/x86/include/asm/bootparam_utils.h b/arch/x86/include/asm/bootparam_utils.h
index 101eb944f13c..9e5f3c722c33 100644
--- a/arch/x86/include/asm/bootparam_utils.h
+++ b/arch/x86/include/asm/bootparam_utils.h
@@ -18,6 +18,20 @@
18 * Note: efi_info is commonly left uninitialized, but that field has a 18 * Note: efi_info is commonly left uninitialized, but that field has a
19 * private magic, so it is better to leave it unchanged. 19 * private magic, so it is better to leave it unchanged.
20 */ 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
30struct boot_params_to_save {
31 unsigned int start;
32 unsigned int len;
33};
34
21static void sanitize_boot_params(struct boot_params *boot_params) 35static void sanitize_boot_params(struct boot_params *boot_params)
22{ 36{
23 /* 37 /*
@@ -35,21 +49,40 @@ static void sanitize_boot_params(struct boot_params *boot_params)
35 * problems again. 49 * problems again.
36 */ 50 */
37 if (boot_params->sentinel) { 51 if (boot_params->sentinel) {
38 /* fields in boot_params are left uninitialized, clear them */ 52 static struct boot_params scratch;
39 boot_params->acpi_rsdp_addr = 0; 53 char *bp_base = (char *)boot_params;
40 memset(&boot_params->ext_ramdisk_image, 0, 54 char *save_base = (char *)&scratch;
41 (char *)&boot_params->efi_info - 55 int i;
42 (char *)&boot_params->ext_ramdisk_image); 56
43 memset(&boot_params->kbd_status, 0, 57 const struct boot_params_to_save to_save[] = {
44 (char *)&boot_params->hdr - 58 BOOT_PARAM_PRESERVE(screen_info),
45 (char *)&boot_params->kbd_status); 59 BOOT_PARAM_PRESERVE(apm_bios_info),
46 memset(&boot_params->_pad7[0], 0, 60 BOOT_PARAM_PRESERVE(tboot_addr),
47 (char *)&boot_params->edd_mbr_sig_buffer[0] - 61 BOOT_PARAM_PRESERVE(ist_info),
48 (char *)&boot_params->_pad7[0]); 62 BOOT_PARAM_PRESERVE(hd0_info),
49 memset(&boot_params->_pad8[0], 0, 63 BOOT_PARAM_PRESERVE(hd1_info),
50 (char *)&boot_params->eddbuf[0] - 64 BOOT_PARAM_PRESERVE(sys_desc_table),
51 (char *)&boot_params->_pad8[0]); 65 BOOT_PARAM_PRESERVE(olpc_ofw_header),
52 memset(&boot_params->_pad9[0], 0, sizeof(boot_params->_pad9)); 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(hdr),
74 BOOT_PARAM_PRESERVE(e820_table),
75 BOOT_PARAM_PRESERVE(eddbuf),
76 };
77
78 memset(&scratch, 0, sizeof(scratch));
79
80 for (i = 0; i < ARRAY_SIZE(to_save); i++) {
81 memcpy(save_base + to_save[i].start,
82 bp_base + to_save[i].start, to_save[i].len);
83 }
84
85 memcpy(boot_params, save_base, sizeof(*boot_params));
53 } 86 }
54} 87}
55 88