efi.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Extensible Firmware Interface
  3. *
  4. * Based on Extensible Firmware Interface Specification version 2.4
  5. *
  6. * Copyright (C) 2013, 2014 Linaro Ltd.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. */
  13. #include <linux/dmi.h>
  14. #include <linux/efi.h>
  15. #include <linux/init.h>
  16. #include <asm/efi.h>
  17. int __init efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md)
  18. {
  19. pteval_t prot_val;
  20. /*
  21. * Only regions of type EFI_RUNTIME_SERVICES_CODE need to be
  22. * executable, everything else can be mapped with the XN bits
  23. * set.
  24. */
  25. if ((md->attribute & EFI_MEMORY_WB) == 0)
  26. prot_val = PROT_DEVICE_nGnRE;
  27. else if (md->type == EFI_RUNTIME_SERVICES_CODE ||
  28. !PAGE_ALIGNED(md->phys_addr))
  29. prot_val = pgprot_val(PAGE_KERNEL_EXEC);
  30. else
  31. prot_val = pgprot_val(PAGE_KERNEL);
  32. create_pgd_mapping(mm, md->phys_addr, md->virt_addr,
  33. md->num_pages << EFI_PAGE_SHIFT,
  34. __pgprot(prot_val | PTE_NG));
  35. return 0;
  36. }
  37. static int __init arm64_dmi_init(void)
  38. {
  39. /*
  40. * On arm64, DMI depends on UEFI, and dmi_scan_machine() needs to
  41. * be called early because dmi_id_init(), which is an arch_initcall
  42. * itself, depends on dmi_scan_machine() having been called already.
  43. */
  44. dmi_scan_machine();
  45. if (dmi_available)
  46. dmi_set_dump_stack_arch_desc();
  47. return 0;
  48. }
  49. core_initcall(arm64_dmi_init);
  50. /*
  51. * UpdateCapsule() depends on the system being shutdown via
  52. * ResetSystem().
  53. */
  54. bool efi_poweroff_required(void)
  55. {
  56. return efi_enabled(EFI_RUNTIME_SERVICES);
  57. }