mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-15 23:14:31 +08:00
powerpc/mm: Remove RPN_SHIFT and RPN_SIZE
PTE_RPN_SHIFT is actually page size dependent. Even though PowerISA 3.0 expects only the lower 12 bits to be zero, we will always find the pages to be PAGE_SHIFT aligned. In case of hash config, this also allows us to use the additional 3 bits to track pte specific information. We need to make sure we use these bits only for hash specific pte flags. For both 4K and 64K config, pte now can hold 57 bits address. Inorder to keep things simpler, drop PTE_RPN_SHIFT and PTE_RPN_SIZE and specify the 57 bit detail explicitly. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:
parent
ac29c64089
commit
96270b1fc2
@ -51,10 +51,6 @@
|
|||||||
#define _PAGE_HPTEFLAGS (_PAGE_BUSY | _PAGE_HASHPTE | \
|
#define _PAGE_HPTEFLAGS (_PAGE_BUSY | _PAGE_HASHPTE | \
|
||||||
_PAGE_F_SECOND | _PAGE_F_GIX)
|
_PAGE_F_SECOND | _PAGE_F_GIX)
|
||||||
|
|
||||||
/* shift to put page number into pte */
|
|
||||||
#define PTE_RPN_SHIFT (12)
|
|
||||||
#define PTE_RPN_SIZE (45) /* gives 57-bit real addresses */
|
|
||||||
|
|
||||||
#define _PAGE_4K_PFN 0
|
#define _PAGE_4K_PFN 0
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
/*
|
/*
|
||||||
|
@ -40,15 +40,6 @@
|
|||||||
/* PTE flags to conserve for HPTE identification */
|
/* PTE flags to conserve for HPTE identification */
|
||||||
#define _PAGE_HPTEFLAGS (_PAGE_BUSY | _PAGE_F_SECOND | \
|
#define _PAGE_HPTEFLAGS (_PAGE_BUSY | _PAGE_F_SECOND | \
|
||||||
_PAGE_F_GIX | _PAGE_HASHPTE | _PAGE_COMBO)
|
_PAGE_F_GIX | _PAGE_HASHPTE | _PAGE_COMBO)
|
||||||
|
|
||||||
/* Shift to put page number into pte.
|
|
||||||
*
|
|
||||||
* That gives us a max RPN of 41 bits, which means a max of 57 bits
|
|
||||||
* of addressable physical space, or 53 bits for the special 4k PFNs.
|
|
||||||
*/
|
|
||||||
#define PTE_RPN_SHIFT (16)
|
|
||||||
#define PTE_RPN_SIZE (41)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* we support 16 fragments per PTE page of 64K size.
|
* we support 16 fragments per PTE page of 64K size.
|
||||||
*/
|
*/
|
||||||
@ -68,6 +59,7 @@
|
|||||||
#define PGD_MASKED_BITS 0xc0000000000000ffUL
|
#define PGD_MASKED_BITS 0xc0000000000000ffUL
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
|
#include <asm/errno.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* With 64K pages on hash table, we have a special PTE format that
|
* With 64K pages on hash table, we have a special PTE format that
|
||||||
@ -124,10 +116,18 @@ extern bool __rpte_sub_valid(real_pte_t rpte, unsigned long index);
|
|||||||
#define pte_pagesize_index(mm, addr, pte) \
|
#define pte_pagesize_index(mm, addr, pte) \
|
||||||
(((pte) & _PAGE_COMBO)? MMU_PAGE_4K: MMU_PAGE_64K)
|
(((pte) & _PAGE_COMBO)? MMU_PAGE_4K: MMU_PAGE_64K)
|
||||||
|
|
||||||
#define remap_4k_pfn(vma, addr, pfn, prot) \
|
extern int remap_pfn_range(struct vm_area_struct *, unsigned long addr,
|
||||||
(WARN_ON(((pfn) >= (1UL << PTE_RPN_SIZE))) ? -EINVAL : \
|
unsigned long pfn, unsigned long size, pgprot_t);
|
||||||
remap_pfn_range((vma), (addr), (pfn), PAGE_SIZE, \
|
static inline int remap_4k_pfn(struct vm_area_struct *vma, unsigned long addr,
|
||||||
__pgprot(pgprot_val((prot)) | _PAGE_4K_PFN)))
|
unsigned long pfn, pgprot_t prot)
|
||||||
|
{
|
||||||
|
if (pfn > (PTE_RPN_MASK >> PAGE_SHIFT)) {
|
||||||
|
WARN(1, "remap_4k_pfn called with wrong pfn value\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
return remap_pfn_range(vma, addr, pfn, PAGE_SIZE,
|
||||||
|
__pgprot(pgprot_val(prot) | _PAGE_4K_PFN));
|
||||||
|
}
|
||||||
|
|
||||||
#define PTE_TABLE_SIZE PTE_FRAG_SIZE
|
#define PTE_TABLE_SIZE PTE_FRAG_SIZE
|
||||||
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
||||||
|
@ -49,7 +49,11 @@
|
|||||||
* page, since THP huge page also need to track real subpage details
|
* page, since THP huge page also need to track real subpage details
|
||||||
*/
|
*/
|
||||||
#define _PAGE_THP_HUGE _PAGE_4K_PFN
|
#define _PAGE_THP_HUGE _PAGE_4K_PFN
|
||||||
|
/*
|
||||||
|
* We support 57 bit real address in pte. Clear everything above 57, and
|
||||||
|
* every thing below PAGE_SHIFT;
|
||||||
|
*/
|
||||||
|
#define PTE_RPN_MASK (((1UL << 57) - 1) & (PAGE_MASK))
|
||||||
/*
|
/*
|
||||||
* set of bits not changed in pmd_modify.
|
* set of bits not changed in pmd_modify.
|
||||||
*/
|
*/
|
||||||
@ -133,11 +137,6 @@
|
|||||||
#define _PTEIDX_GROUP_IX 0x7
|
#define _PTEIDX_GROUP_IX 0x7
|
||||||
|
|
||||||
#define _PTE_NONE_MASK _PAGE_HPTEFLAGS
|
#define _PTE_NONE_MASK _PAGE_HPTEFLAGS
|
||||||
/*
|
|
||||||
* The mask convered by the RPN must be a ULL on 32-bit platforms with
|
|
||||||
* 64-bit PTEs
|
|
||||||
*/
|
|
||||||
#define PTE_RPN_MASK (((1UL << PTE_RPN_SIZE) - 1) << PTE_RPN_SHIFT)
|
|
||||||
/*
|
/*
|
||||||
* _PAGE_CHG_MASK masks of bits that are to be preserved across
|
* _PAGE_CHG_MASK masks of bits that are to be preserved across
|
||||||
* pgprot changes
|
* pgprot changes
|
||||||
@ -437,13 +436,13 @@ static inline int pte_present(pte_t pte)
|
|||||||
*/
|
*/
|
||||||
static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot)
|
static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot)
|
||||||
{
|
{
|
||||||
return __pte((((pte_basic_t)(pfn) << PTE_RPN_SHIFT) & PTE_RPN_MASK) |
|
return __pte((((pte_basic_t)(pfn) << PAGE_SHIFT) & PTE_RPN_MASK) |
|
||||||
pgprot_val(pgprot));
|
pgprot_val(pgprot));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned long pte_pfn(pte_t pte)
|
static inline unsigned long pte_pfn(pte_t pte)
|
||||||
{
|
{
|
||||||
return (pte_val(pte) & PTE_RPN_MASK) >> PTE_RPN_SHIFT;
|
return (pte_val(pte) & PTE_RPN_MASK) >> PAGE_SHIFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Generic modifiers for PTE bits */
|
/* Generic modifiers for PTE bits */
|
||||||
|
@ -172,10 +172,10 @@ extern struct page *pgd_page(pgd_t pgd);
|
|||||||
#define SWP_TYPE_BITS 5
|
#define SWP_TYPE_BITS 5
|
||||||
#define __swp_type(x) (((x).val >> _PAGE_BIT_SWAP_TYPE) \
|
#define __swp_type(x) (((x).val >> _PAGE_BIT_SWAP_TYPE) \
|
||||||
& ((1UL << SWP_TYPE_BITS) - 1))
|
& ((1UL << SWP_TYPE_BITS) - 1))
|
||||||
#define __swp_offset(x) (((x).val & PTE_RPN_MASK) >> PTE_RPN_SHIFT)
|
#define __swp_offset(x) (((x).val & PTE_RPN_MASK) >> PAGE_SHIFT)
|
||||||
#define __swp_entry(type, offset) ((swp_entry_t) { \
|
#define __swp_entry(type, offset) ((swp_entry_t) { \
|
||||||
((type) << _PAGE_BIT_SWAP_TYPE) \
|
((type) << _PAGE_BIT_SWAP_TYPE) \
|
||||||
| (((offset) << PTE_RPN_SHIFT) & PTE_RPN_MASK)})
|
| (((offset) << PAGE_SHIFT) & PTE_RPN_MASK)})
|
||||||
/*
|
/*
|
||||||
* swp_entry_t must be independent of pte bits. We build a swp_entry_t from
|
* swp_entry_t must be independent of pte bits. We build a swp_entry_t from
|
||||||
* swap type and offset we get from swap and convert that to pte to find a
|
* swap type and offset we get from swap and convert that to pte to find a
|
||||||
|
@ -757,7 +757,7 @@ pmd_t pfn_pmd(unsigned long pfn, pgprot_t pgprot)
|
|||||||
{
|
{
|
||||||
unsigned long pmdv;
|
unsigned long pmdv;
|
||||||
|
|
||||||
pmdv = (pfn << PTE_RPN_SHIFT) & PTE_RPN_MASK;
|
pmdv = (pfn << PAGE_SHIFT) & PTE_RPN_MASK;
|
||||||
return pmd_set_protbits(__pmd(pmdv), pgprot);
|
return pmd_set_protbits(__pmd(pmdv), pgprot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user