bootparam_utils.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef _ASM_X86_BOOTPARAM_UTILS_H
  2. #define _ASM_X86_BOOTPARAM_UTILS_H
  3. #include <asm/bootparam.h>
  4. /*
  5. * This file is included from multiple environments. Do not
  6. * add completing #includes to make it standalone.
  7. */
  8. /*
  9. * Deal with bootloaders which fail to initialize unknown fields in
  10. * boot_params to zero. The list fields in this list are taken from
  11. * analysis of kexec-tools; if other broken bootloaders initialize a
  12. * different set of fields we will need to figure out how to disambiguate.
  13. *
  14. * Note: efi_info is commonly left uninitialized, but that field has a
  15. * private magic, so it is better to leave it unchanged.
  16. */
  17. static void sanitize_boot_params(struct boot_params *boot_params)
  18. {
  19. /*
  20. * IMPORTANT NOTE TO BOOTLOADER AUTHORS: do not simply clear
  21. * this field. The purpose of this field is to guarantee
  22. * compliance with the x86 boot spec located in
  23. * Documentation/x86/boot.txt . That spec says that the
  24. * *whole* structure should be cleared, after which only the
  25. * portion defined by struct setup_header (boot_params->hdr)
  26. * should be copied in.
  27. *
  28. * If you're having an issue because the sentinel is set, you
  29. * need to change the whole structure to be cleared, not this
  30. * (or any other) individual field, or you will soon have
  31. * problems again.
  32. */
  33. if (boot_params->sentinel) {
  34. /* fields in boot_params are left uninitialized, clear them */
  35. memset(&boot_params->olpc_ofw_header, 0,
  36. (char *)&boot_params->efi_info -
  37. (char *)&boot_params->olpc_ofw_header);
  38. memset(&boot_params->kbd_status, 0,
  39. (char *)&boot_params->hdr -
  40. (char *)&boot_params->kbd_status);
  41. memset(&boot_params->_pad7[0], 0,
  42. (char *)&boot_params->edd_mbr_sig_buffer[0] -
  43. (char *)&boot_params->_pad7[0]);
  44. memset(&boot_params->_pad8[0], 0,
  45. (char *)&boot_params->eddbuf[0] -
  46. (char *)&boot_params->_pad8[0]);
  47. memset(&boot_params->_pad9[0], 0, sizeof(boot_params->_pad9));
  48. }
  49. }
  50. #endif /* _ASM_X86_BOOTPARAM_UTILS_H */