From 0af44d28756f3df4ea9c8f62a99d73f80c6d0c1a Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 25 Jul 2020 02:47:07 -0700 Subject: [PATCH] kern: fix bug in page table mapping calculations --- libraries/libmesosphere/source/arch/arm64/kern_k_page_table.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/libmesosphere/source/arch/arm64/kern_k_page_table.cpp b/libraries/libmesosphere/source/arch/arm64/kern_k_page_table.cpp index a3f457219..9ad471b85 100644 --- a/libraries/libmesosphere/source/arch/arm64/kern_k_page_table.cpp +++ b/libraries/libmesosphere/source/arch/arm64/kern_k_page_table.cpp @@ -645,7 +645,7 @@ namespace ams::kern::arch::arm64 { size_t alignment; for (alignment = ContiguousPageSize; (virt_addr & (alignment - 1)) == (phys_addr & (alignment - 1)); alignment = GetLargerAlignment(alignment)) { /* Check if this would be our last map. */ - const size_t pages_to_map = (alignment - (virt_addr & (alignment - 1))) & (alignment - 1); + const size_t pages_to_map = ((alignment - (virt_addr & (alignment - 1))) & (alignment - 1)) / PageSize; if (pages_to_map + (alignment / PageSize) > remaining_pages) { break; }