Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/64/kexec: Fix MMU cleanup on radix

Just using the hash ops won't work anymore since radix will have
NULL in there. Instead create an mmu_cleanup_all() function which
will do the right thing based on the MMU mode.

For Radix, for now I clear UPRT and the PTCR, effectively switching
back to Radix with no partition table setup.

Currently set it to NULL on BookE thought it might be a good idea
to wipe the TLB there (Scott ?)

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Acked-by: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Benjamin Herrenschmidt and committed by
Michael Ellerman
fe036a06 fc48bad5

+30 -10
+3
arch/powerpc/include/asm/mmu-book3e.h
··· 313 313 * return 1, indicating that the tlb requires preloading. 314 314 */ 315 315 #define HUGETLB_NEED_PRELOAD 316 + 317 + #define mmu_cleanup_all NULL 318 + 316 319 #endif 317 320 318 321 #endif /* !__ASSEMBLY__ */
+4
arch/powerpc/include/asm/mmu.h
··· 204 204 * make it match the size our of bolted TLB area 205 205 */ 206 206 extern u64 ppc64_rma_size; 207 + 208 + /* Cleanup function used by kexec */ 209 + extern void mmu_cleanup_all(void); 210 + extern void radix__mmu_cleanup_all(void); 207 211 #endif /* CONFIG_PPC64 */ 208 212 209 213 struct mm_struct;
+2 -10
arch/powerpc/kernel/machine_kexec_64.c
··· 55 55 const unsigned long *basep; 56 56 const unsigned int *sizep; 57 57 58 - if (!mmu_hash_ops.hpte_clear_all) 59 - return -ENOENT; 60 - 61 58 /* 62 59 * Since we use the kernel fault handlers and paging code to 63 60 * handle the virtual mode, we must make sure no destination ··· 376 379 * a toc is easier in C, so pass in what we can. 377 380 */ 378 381 kexec_sequence(&kexec_stack, image->start, image, 379 - page_address(image->control_code_page), 380 - #ifdef CONFIG_PPC_STD_MMU 381 - mmu_hash_ops.hpte_clear_all 382 - #else 383 - NULL 384 - #endif 385 - ); 382 + page_address(image->control_code_page), 383 + mmu_cleanup_all); 386 384 /* NOTREACHED */ 387 385 } 388 386
+9
arch/powerpc/mm/pgtable-book3s64.c
··· 116 116 return; 117 117 } 118 118 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ 119 + 120 + /* For use by kexec */ 121 + void mmu_cleanup_all(void) 122 + { 123 + if (radix_enabled()) 124 + radix__mmu_cleanup_all(); 125 + else if (mmu_hash_ops.hpte_clear_all) 126 + mmu_hash_ops.hpte_clear_all(); 127 + }
+12
arch/powerpc/mm/pgtable-radix.c
··· 396 396 } 397 397 } 398 398 399 + void radix__mmu_cleanup_all(void) 400 + { 401 + unsigned long lpcr; 402 + 403 + if (!firmware_has_feature(FW_FEATURE_LPAR)) { 404 + lpcr = mfspr(SPRN_LPCR); 405 + mtspr(SPRN_LPCR, lpcr & ~LPCR_UPRT); 406 + mtspr(SPRN_PTCR, 0); 407 + radix__flush_tlb_all(); 408 + } 409 + } 410 + 399 411 void radix__setup_initial_memory_limit(phys_addr_t first_memblock_base, 400 412 phys_addr_t first_memblock_size) 401 413 {