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

powerpc/mm: add a helper to populate hugepd

This patchs adds a subarch helper to populate hugepd.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Christophe Leroy and committed by
Michael Ellerman
5fb84fec 8197af22

+20 -19
+5
arch/powerpc/include/asm/book3s/64/hugetlb.h
··· 100 100 return hugepd_page(hpd) + idx; 101 101 } 102 102 103 + static inline void hugepd_populate(hugepd_t *hpdp, pte_t *new, unsigned int pshift) 104 + { 105 + *hpdp = __hugepd(__pa(new) | HUGEPD_VAL_BITS | (shift_to_mmu_psize(pshift) << 2)); 106 + } 107 + 103 108 void flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr); 104 109 105 110 #endif
+8
arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h
··· 2 2 #ifndef _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H 3 3 #define _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H 4 4 5 + #define PAGE_SHIFT_8M 23 6 + 5 7 static inline pte_t *hugepd_page(hugepd_t hpd) 6 8 { 7 9 BUG_ON(!hugepd_ok(hpd)); ··· 28 26 unsigned long vmaddr) 29 27 { 30 28 flush_tlb_page(vma, vmaddr); 29 + } 30 + 31 + static inline void hugepd_populate(hugepd_t *hpdp, pte_t *new, unsigned int pshift) 32 + { 33 + *hpdp = __hugepd(__pa(new) | _PMD_USER | _PMD_PRESENT | 34 + (pshift == PAGE_SHIFT_8M ? _PMD_PAGE_8M : _PMD_PAGE_512K)); 31 35 } 32 36 33 37 #endif /* _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H */
+6
arch/powerpc/include/asm/nohash/hugetlb-book3e.h
··· 28 28 29 29 void flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr); 30 30 31 + static inline void hugepd_populate(hugepd_t *hpdp, pte_t *new, unsigned int pshift) 32 + { 33 + /* We use the old format for PPC_FSL_BOOK3E */ 34 + *hpdp = __hugepd(((unsigned long)new & ~PD_HUGE) | pshift); 35 + } 36 + 31 37 #endif /* _ASM_POWERPC_NOHASH_HUGETLB_BOOK3E_H */
+1 -19
arch/powerpc/mm/hugetlbpage.c
··· 26 26 #include <asm/hugetlb.h> 27 27 #include <asm/pte-walk.h> 28 28 29 - #define PAGE_SHIFT_64K 16 30 - #define PAGE_SHIFT_512K 19 31 - #define PAGE_SHIFT_8M 23 32 - #define PAGE_SHIFT_16M 24 33 - #define PAGE_SHIFT_16G 34 34 - 35 29 bool hugetlb_disabled = false; 36 30 37 31 unsigned int HPAGE_SHIFT; ··· 89 95 for (i = 0; i < num_hugepd; i++, hpdp++) { 90 96 if (unlikely(!hugepd_none(*hpdp))) 91 97 break; 92 - else { 93 - #ifdef CONFIG_PPC_BOOK3S_64 94 - *hpdp = __hugepd(__pa(new) | HUGEPD_VAL_BITS | 95 - (shift_to_mmu_psize(pshift) << 2)); 96 - #elif defined(CONFIG_PPC_8xx) 97 - *hpdp = __hugepd(__pa(new) | _PMD_USER | 98 - (pshift == PAGE_SHIFT_8M ? _PMD_PAGE_8M : 99 - _PMD_PAGE_512K) | _PMD_PRESENT); 100 - #else 101 - /* We use the old format for PPC_FSL_BOOK3E */ 102 - *hpdp = __hugepd(((unsigned long)new & ~PD_HUGE) | pshift); 103 - #endif 104 - } 98 + hugepd_populate(hpdp, new, pshift); 105 99 } 106 100 /* If we bailed from the for loop early, an error occurred, clean up */ 107 101 if (i < num_hugepd) {