diff --git a/src/system/boot/platform/efi/arch/arm64/arch_cache.cpp b/src/system/boot/platform/efi/arch/arm64/arch_cache.cpp index e8c679e16b..097d72c191 100644 --- a/src/system/boot/platform/efi/arch/arm64/arch_cache.cpp +++ b/src/system/boot/platform/efi/arch/arm64/arch_cache.cpp @@ -13,10 +13,9 @@ arch_cache_disable() { if (arch_mmu_cache_enabled()) { uint64 sctlr = _arch_mmu_get_sctlr(); - sctlr &= ~(SCTLR_M | SCTLR_C); + sctlr &= ~(SCTLR_M | SCTLR_C | SCTLR_I); _arch_mmu_set_sctlr(sctlr); -// _arch_cache_flush_invalidate_all(); _arch_cache_clean_poc(); _arch_mmu_invalidate_tlb_all(arch_exception_level()); } @@ -28,7 +27,7 @@ arch_cache_enable() { if (!arch_mmu_cache_enabled()) { uint64 sctlr = _arch_mmu_get_sctlr(); - sctlr |= (SCTLR_M | SCTLR_C); + sctlr |= (SCTLR_M | SCTLR_C | SCTLR_I); _arch_mmu_set_sctlr(sctlr); } } diff --git a/src/system/boot/platform/efi/arch/arm64/arch_mmu.cpp b/src/system/boot/platform/efi/arch/arm64/arch_mmu.cpp index e41e2b95ad..a98e8b4bc8 100644 --- a/src/system/boot/platform/efi/arch/arm64/arch_mmu.cpp +++ b/src/system/boot/platform/efi/arch/arm64/arch_mmu.cpp @@ -348,7 +348,9 @@ arch_mmu_allocate_kernel_page_tables(void) if (page == NULL) { page = CurrentRegime.AllocatePage(); if (page != NULL) { + arch_cache_disable(); WRITE_SPECIALREG(TTBR1_EL1, page); + arch_cache_enable(); } else { panic("Not enough memory for kernel initial page\n"); } diff --git a/src/system/boot/platform/efi/arch/arm64/arch_start.cpp b/src/system/boot/platform/efi/arch/arm64/arch_start.cpp index 3dafc5f613..0cbd1fec0a 100644 --- a/src/system/boot/platform/efi/arch/arm64/arch_start.cpp +++ b/src/system/boot/platform/efi/arch/arm64/arch_start.cpp @@ -115,11 +115,6 @@ arch_start_kernel(addr_t kernelEntry) dprintf("Kernel entry accessibility W: %x R: %x\n", arch_mmu_write_access(kernelEntry), arch_mmu_read_access(kernelEntry)); - - if (el == 1) { - // Disable CACHE & MMU before dealing with TTBRx - arch_cache_disable(); - } } // Generate page tables for use after ExitBootServices.