From fdee3b6ba80091430b693ed4d7a66f5c75cbc00b Mon Sep 17 00:00:00 2001 From: Sudarshan Rajagopalan Date: Thu, 14 Mar 2019 15:33:45 -0700 Subject: [PATCH] soc: qcom: mem-offline: Clear page-table entries after offline After a memory block is offlined, the page-table entries should be removed in order to avoid any CPU speculative accesses happening on this region. Clear off the entries at the leaf levels (PUD or PMD) on a block mapped memory region. This only zeroes the entries and does not free the page table memory. During online, we create mappings again for these regions. Change-Id: I71091c33589645567c60457ba569dd393ddcab59 Signed-off-by: Sudarshan Rajagopalan [isaacm@codeaurora.org: resolve merge conflicts] Signed-off-by: Isaac J. Manjarres --- arch/arm64/mm/mmu.c | 8 ++++++++ include/linux/memblock.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index a26295fa1f8d..49a0309ab794 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -391,6 +391,14 @@ static phys_addr_t pgd_pgtable_alloc(int shift) return pa; } +void create_pgtable_mapping(phys_addr_t start, phys_addr_t end) +{ + unsigned long virt = (unsigned long)phys_to_virt(start); + + __create_pgd_mapping(init_mm.pgd, start, virt, end - start, + PAGE_KERNEL, NULL, 0); +} + /* * This function can only be used to modify existing table entries, * without allocating new levels of table. Note that this permits the diff --git a/include/linux/memblock.h b/include/linux/memblock.h index ead74b4b6725..4fd77c758c27 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -145,7 +145,7 @@ void __next_reserved_mem_region(u64 *idx, phys_addr_t *out_start, phys_addr_t *out_end); void __memblock_free_late(phys_addr_t base, phys_addr_t size); - +void create_pgtable_mapping(phys_addr_t start, phys_addr_t end); /** * for_each_mem_range - iterate through memblock areas from type_a and not * included in type_b. Or just type_a if type_b is NULL.