efi-entry.S 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * EFI entry point.
  4. *
  5. * Copyright (C) 2013, 2014 Red Hat, Inc.
  6. * Author: Mark Salter <msalter@redhat.com>
  7. */
  8. #include <linux/linkage.h>
  9. #include <linux/init.h>
  10. #include <asm/assembler.h>
  11. __INIT
  12. SYM_CODE_START(efi_enter_kernel)
  13. /*
  14. * efi_pe_entry() will have copied the kernel image if necessary and we
  15. * end up here with device tree address in x1 and the kernel entry
  16. * point stored in x0. Save those values in registers which are
  17. * callee preserved.
  18. */
  19. ldr w2, =primary_entry_offset
  20. add x19, x0, x2 // relocated Image entrypoint
  21. mov x20, x1 // DTB address
  22. /*
  23. * Clean the copied Image to the PoC, and ensure it is not shadowed by
  24. * stale icache entries from before relocation.
  25. */
  26. ldr w1, =kernel_size
  27. add x1, x0, x1
  28. bl dcache_clean_poc
  29. ic ialluis
  30. /*
  31. * Clean the remainder of this routine to the PoC
  32. * so that we can safely disable the MMU and caches.
  33. */
  34. adr x0, 0f
  35. adr x1, 3f
  36. bl dcache_clean_poc
  37. 0:
  38. /* Turn off Dcache and MMU */
  39. mrs x0, CurrentEL
  40. cmp x0, #CurrentEL_EL2
  41. b.ne 1f
  42. mrs x0, sctlr_el2
  43. bic x0, x0, #1 << 0 // clear SCTLR.M
  44. bic x0, x0, #1 << 2 // clear SCTLR.C
  45. pre_disable_mmu_workaround
  46. msr sctlr_el2, x0
  47. isb
  48. b 2f
  49. 1:
  50. mrs x0, sctlr_el1
  51. bic x0, x0, #1 << 0 // clear SCTLR.M
  52. bic x0, x0, #1 << 2 // clear SCTLR.C
  53. pre_disable_mmu_workaround
  54. msr sctlr_el1, x0
  55. isb
  56. 2:
  57. /* Jump to kernel entry point */
  58. mov x0, x20
  59. mov x1, xzr
  60. mov x2, xzr
  61. mov x3, xzr
  62. br x19
  63. 3:
  64. SYM_CODE_END(efi_enter_kernel)