Skip to content

Commit

Permalink
powerpc/mm: add a helper to populate hugepd
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Christophe Leroy authored and Michael Ellerman committed May 2, 2019
1 parent 8197af2 commit 5fb84fe
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
5 changes: 5 additions & 0 deletions arch/powerpc/include/asm/book3s/64/hugetlb.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr,
return hugepd_page(hpd) + idx;
}

static inline void hugepd_populate(hugepd_t *hpdp, pte_t *new, unsigned int pshift)
{
*hpdp = __hugepd(__pa(new) | HUGEPD_VAL_BITS | (shift_to_mmu_psize(pshift) << 2));
}

void flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr);

#endif
8 changes: 8 additions & 0 deletions arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#ifndef _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H
#define _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H

#define PAGE_SHIFT_8M 23

static inline pte_t *hugepd_page(hugepd_t hpd)
{
BUG_ON(!hugepd_ok(hpd));
Expand All @@ -28,4 +30,10 @@ static inline void flush_hugetlb_page(struct vm_area_struct *vma,
flush_tlb_page(vma, vmaddr);
}

static inline void hugepd_populate(hugepd_t *hpdp, pte_t *new, unsigned int pshift)
{
*hpdp = __hugepd(__pa(new) | _PMD_USER | _PMD_PRESENT |
(pshift == PAGE_SHIFT_8M ? _PMD_PAGE_8M : _PMD_PAGE_512K));
}

#endif /* _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H */
6 changes: 6 additions & 0 deletions arch/powerpc/include/asm/nohash/hugetlb-book3e.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,10 @@ static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr,

void flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr);

static inline void hugepd_populate(hugepd_t *hpdp, pte_t *new, unsigned int pshift)
{
/* We use the old format for PPC_FSL_BOOK3E */
*hpdp = __hugepd(((unsigned long)new & ~PD_HUGE) | pshift);
}

#endif /* _ASM_POWERPC_NOHASH_HUGETLB_BOOK3E_H */
20 changes: 1 addition & 19 deletions arch/powerpc/mm/hugetlbpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@
#include <asm/hugetlb.h>
#include <asm/pte-walk.h>

#define PAGE_SHIFT_64K 16
#define PAGE_SHIFT_512K 19
#define PAGE_SHIFT_8M 23
#define PAGE_SHIFT_16M 24
#define PAGE_SHIFT_16G 34

bool hugetlb_disabled = false;

unsigned int HPAGE_SHIFT;
Expand Down Expand Up @@ -95,19 +89,7 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
for (i = 0; i < num_hugepd; i++, hpdp++) {
if (unlikely(!hugepd_none(*hpdp)))
break;
else {
#ifdef CONFIG_PPC_BOOK3S_64
*hpdp = __hugepd(__pa(new) | HUGEPD_VAL_BITS |
(shift_to_mmu_psize(pshift) << 2));
#elif defined(CONFIG_PPC_8xx)
*hpdp = __hugepd(__pa(new) | _PMD_USER |
(pshift == PAGE_SHIFT_8M ? _PMD_PAGE_8M :
_PMD_PAGE_512K) | _PMD_PRESENT);
#else
/* We use the old format for PPC_FSL_BOOK3E */
*hpdp = __hugepd(((unsigned long)new & ~PD_HUGE) | pshift);
#endif
}
hugepd_populate(hpdp, new, pshift);
}
/* If we bailed from the for loop early, an error occurred, clean up */
if (i < num_hugepd) {
Expand Down

0 comments on commit 5fb84fe

Please sign in to comment.