arm64 fixes:

- Fix a kernel fault during page table walking in huge_pte_alloc() with
   PTABLE_LEVELS=5 due to using p4d_offset() instead of p4d_alloc()
 
 - head.S fix and cleanup to disable the MMU before toggling the
   HCR_EL2.E2H bit when entering the kernel with the MMU on from the EFI
   stub. Changing this bit (currently from VHE to nVHE) causes some
   system registers as well as page table descriptors to be interpreted
   differently, potentially resulting in spurious MMU faults
 
 - Fix translation fault in swsusp_save() accessing MEMBLOCK_NOMAP memory
   ranges due to kernel_page_present() returning true in most
   configurations other than rodata_full == true,
   CONFIG_DEBUG_PAGEALLOC=y or CONFIG_KFENCE=y
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE5RElWfyWxS+3PLO2a9axLQDIXvEFAmYirgQACgkQa9axLQDI
 XvFbhQ/+MD6ziCPeVxpYNW44rWrG0p3VQ1uZniALSH2rsauNqSZiwGkXJskC5jmj
 rgh2RF5reAokDeDNPSNlBzSpXvjknJNb4cJwYZzzhoOF+P3Oi0t6LQOeh07mi7sM
 SjnklzoPWa88i5SjTQGmqnJTMe3okdFxHEsT+0Szuu1UZqOC63/Nf/LlBvAFcR0x
 CP5I5701+1tlgPiW9YnaBBKMuPFqdYVtBsG1BLsUFBhkKr39vcmYfwo0gGzThJuP
 XmvL3zWR53ec9yksBElXgWy38J0ixOxsZlHe1dQaxyQeUMK8ioFpsf/OdXRvs9nb
 u3ezwRsgByZ4X+4Y1LwGHnYTOuKqOg/FDNUZAcg3ZDY2AOF4c7mPNmquEQJYaM5J
 Ac//IRGAdZxZO6An7UrTv1lESjvsJ/8PosbyM5CPu+kIUwezvBL2xmJ22lTOmKrz
 mtHIzH7pc0DfGvlu8czizH1oCuW20YviwNMb7PxzsSkIkDJsuHloefhcrmOm8BCM
 LD5DfgzwONr6nlEMPdbRZcRz52RZAXgvgJml/qU4eZxvT8h8sQbgm/KiEBjuC/BO
 4TgJ1z8w1Svu8ulLMVtLj0+zgtRlMCHHldiBVUIXZ5vvsJgtM9ALgTWGl05RLquu
 EL4j3izYaFhCHY2PHwoMCWRh5We68xgU8r8mgq/cO7mEJAj3JCM=
 =UvpI
 -----END PGP SIGNATURE-----

Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux

Pull arm64 fixes from Catalin Marinas:

 - Fix a kernel fault during page table walking in huge_pte_alloc() with
   PTABLE_LEVELS=5 due to using p4d_offset() instead of p4d_alloc()

 - head.S fix and cleanup to disable the MMU before toggling the
   HCR_EL2.E2H bit when entering the kernel with the MMU on from the EFI
   stub. Changing this bit (currently from VHE to nVHE) causes some
   system registers as well as page table descriptors to be interpreted
   differently, potentially resulting in spurious MMU faults

 - Fix translation fault in swsusp_save() accessing MEMBLOCK_NOMAP
   memory ranges due to kernel_page_present() returning true in most
   configurations other than rodata_full == true,
   CONFIG_DEBUG_PAGEALLOC=y or CONFIG_KFENCE=y

* tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
  arm64: hibernate: Fix level3 translation fault in swsusp_save()
  arm64/head: Disable MMU at EL2 before clearing HCR_EL2.E2H
  arm64/head: Drop unnecessary pre-disable-MMU workaround
  arm64/hugetlb: Fix page table walk in huge_pte_alloc()
This commit is contained in:
Linus Torvalds 2024-04-19 13:04:21 -07:00
commit 25ec51ec86
3 changed files with 9 additions and 6 deletions

View File

@ -289,6 +289,11 @@ SYM_INNER_LABEL(init_el2, SYM_L_LOCAL)
adr_l x1, __hyp_text_end
adr_l x2, dcache_clean_poc
blr x2
mov_q x0, INIT_SCTLR_EL2_MMU_OFF
pre_disable_mmu_workaround
msr sctlr_el2, x0
isb
0:
mov_q x0, HCR_HOST_NVHE_FLAGS
@ -323,13 +328,11 @@ SYM_INNER_LABEL(init_el2, SYM_L_LOCAL)
cbz x0, 2f
/* Set a sane SCTLR_EL1, the VHE way */
pre_disable_mmu_workaround
msr_s SYS_SCTLR_EL12, x1
mov x2, #BOOT_CPU_FLAG_E2H
b 3f
2:
pre_disable_mmu_workaround
msr sctlr_el1, x1
mov x2, xzr
3:

View File

@ -276,7 +276,10 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
pte_t *ptep = NULL;
pgdp = pgd_offset(mm, addr);
p4dp = p4d_offset(pgdp, addr);
p4dp = p4d_alloc(mm, pgdp, addr);
if (!p4dp)
return NULL;
pudp = pud_alloc(mm, p4dp, addr);
if (!pudp)
return NULL;

View File

@ -219,9 +219,6 @@ bool kernel_page_present(struct page *page)
pte_t *ptep;
unsigned long addr = (unsigned long)page_address(page);
if (!can_set_direct_map())
return true;
pgdp = pgd_offset_k(addr);
if (pgd_none(READ_ONCE(*pgdp)))
return false;