0001
0002 #ifndef _ASM_X86_BOOTPARAM_UTILS_H
0003 #define _ASM_X86_BOOTPARAM_UTILS_H
0004
0005 #include <asm/bootparam.h>
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #define sizeof_mbr(type, member) ({ sizeof(((type *)0)->member); })
0023
0024 #define BOOT_PARAM_PRESERVE(struct_member) \
0025 { \
0026 .start = offsetof(struct boot_params, struct_member), \
0027 .len = sizeof_mbr(struct boot_params, struct_member), \
0028 }
0029
0030 struct boot_params_to_save {
0031 unsigned int start;
0032 unsigned int len;
0033 };
0034
0035 static void sanitize_boot_params(struct boot_params *boot_params)
0036 {
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 if (boot_params->sentinel) {
0052 static struct boot_params scratch;
0053 char *bp_base = (char *)boot_params;
0054 char *save_base = (char *)&scratch;
0055 int i;
0056
0057 const struct boot_params_to_save to_save[] = {
0058 BOOT_PARAM_PRESERVE(screen_info),
0059 BOOT_PARAM_PRESERVE(apm_bios_info),
0060 BOOT_PARAM_PRESERVE(tboot_addr),
0061 BOOT_PARAM_PRESERVE(ist_info),
0062 BOOT_PARAM_PRESERVE(hd0_info),
0063 BOOT_PARAM_PRESERVE(hd1_info),
0064 BOOT_PARAM_PRESERVE(sys_desc_table),
0065 BOOT_PARAM_PRESERVE(olpc_ofw_header),
0066 BOOT_PARAM_PRESERVE(efi_info),
0067 BOOT_PARAM_PRESERVE(alt_mem_k),
0068 BOOT_PARAM_PRESERVE(scratch),
0069 BOOT_PARAM_PRESERVE(e820_entries),
0070 BOOT_PARAM_PRESERVE(eddbuf_entries),
0071 BOOT_PARAM_PRESERVE(edd_mbr_sig_buf_entries),
0072 BOOT_PARAM_PRESERVE(edd_mbr_sig_buffer),
0073 BOOT_PARAM_PRESERVE(secure_boot),
0074 BOOT_PARAM_PRESERVE(hdr),
0075 BOOT_PARAM_PRESERVE(e820_table),
0076 BOOT_PARAM_PRESERVE(eddbuf),
0077 BOOT_PARAM_PRESERVE(cc_blob_address),
0078 };
0079
0080 memset(&scratch, 0, sizeof(scratch));
0081
0082 for (i = 0; i < ARRAY_SIZE(to_save); i++) {
0083 memcpy(save_base + to_save[i].start,
0084 bp_base + to_save[i].start, to_save[i].len);
0085 }
0086
0087 memcpy(boot_params, save_base, sizeof(*boot_params));
0088 }
0089 }
0090
0091 #endif