forked from luck/tmp_suning_uos_patched
sh: Abstract the number of page table levels
Keep the dimensions of the page tables in a separate header file in preparation for allowing a three level page table structure. Signed-off-by: Matt Fleming <matt@console-pimps.org> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
This commit is contained in:
parent
2f7bb2dfed
commit
b73c806341
@ -4,9 +4,10 @@
|
||||
#include <linux/quicklist.h>
|
||||
#include <asm/page.h>
|
||||
|
||||
#define QUICK_PGD 0 /* We preserve special mappings over free */
|
||||
#define QUICK_PT 1 /* Other page table pages that are zero on free */
|
||||
|
||||
#include <asm/pgalloc_nopmd.h>
|
||||
|
||||
static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
|
||||
pte_t *pte)
|
||||
{
|
||||
@ -20,28 +21,9 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
|
||||
}
|
||||
#define pmd_pgtable(pmd) pmd_page(pmd)
|
||||
|
||||
static inline void pgd_ctor(void *x)
|
||||
{
|
||||
pgd_t *pgd = x;
|
||||
|
||||
memcpy(pgd + USER_PTRS_PER_PGD,
|
||||
swapper_pg_dir + USER_PTRS_PER_PGD,
|
||||
(PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate and free page tables.
|
||||
*/
|
||||
static inline pgd_t *pgd_alloc(struct mm_struct *mm)
|
||||
{
|
||||
return quicklist_alloc(QUICK_PGD, GFP_KERNEL | __GFP_REPEAT, pgd_ctor);
|
||||
}
|
||||
|
||||
static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
|
||||
{
|
||||
quicklist_free(QUICK_PGD, NULL, pgd);
|
||||
}
|
||||
|
||||
static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
|
||||
unsigned long address)
|
||||
{
|
||||
@ -81,7 +63,7 @@ do { \
|
||||
|
||||
static inline void check_pgt_cache(void)
|
||||
{
|
||||
quicklist_trim(QUICK_PGD, NULL, 25, 16);
|
||||
__check_pgt_cache();
|
||||
quicklist_trim(QUICK_PT, NULL, 25, 16);
|
||||
}
|
||||
|
||||
|
30
arch/sh/include/asm/pgalloc_nopmd.h
Normal file
30
arch/sh/include/asm/pgalloc_nopmd.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef __ASM_SH_PGALLOC_NOPMD_H
|
||||
#define __ASM_SH_PGALLOC_NOPMD_H
|
||||
|
||||
#define QUICK_PGD 0 /* We preserve special mappings over free */
|
||||
|
||||
static inline void pgd_ctor(void *x)
|
||||
{
|
||||
pgd_t *pgd = x;
|
||||
|
||||
memcpy(pgd + USER_PTRS_PER_PGD,
|
||||
swapper_pg_dir + USER_PTRS_PER_PGD,
|
||||
(PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
|
||||
}
|
||||
|
||||
static inline pgd_t *pgd_alloc(struct mm_struct *mm)
|
||||
{
|
||||
return quicklist_alloc(QUICK_PGD, GFP_KERNEL | __GFP_REPEAT, pgd_ctor);
|
||||
}
|
||||
|
||||
static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
|
||||
{
|
||||
quicklist_free(QUICK_PGD, NULL, pgd);
|
||||
}
|
||||
|
||||
static inline void __check_pgt_cache(void)
|
||||
{
|
||||
quicklist_trim(QUICK_PGD, NULL, 25, 16);
|
||||
}
|
||||
|
||||
#endif /* __ASM_SH_PGALLOC_NOPMD_H */
|
@ -12,7 +12,7 @@
|
||||
#ifndef __ASM_SH_PGTABLE_H
|
||||
#define __ASM_SH_PGTABLE_H
|
||||
|
||||
#include <asm-generic/pgtable-nopmd.h>
|
||||
#include <asm/pgtable_nopmd.h>
|
||||
#include <asm/page.h>
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
@ -51,28 +51,12 @@ static inline unsigned long long neff_sign_extend(unsigned long val)
|
||||
#define NPHYS_SIGN (1LL << (NPHYS - 1))
|
||||
#define NPHYS_MASK (-1LL << NPHYS)
|
||||
|
||||
/*
|
||||
* traditional two-level paging structure
|
||||
*/
|
||||
/* PTE bits */
|
||||
#if defined(CONFIG_X2TLB) || defined(CONFIG_SUPERH64)
|
||||
# define PTE_MAGNITUDE 3 /* 64-bit PTEs on extended mode SH-X2 TLB */
|
||||
#else
|
||||
# define PTE_MAGNITUDE 2 /* 32-bit PTEs */
|
||||
#endif
|
||||
#define PTE_SHIFT PAGE_SHIFT
|
||||
#define PTE_BITS (PTE_SHIFT - PTE_MAGNITUDE)
|
||||
|
||||
/* PGD bits */
|
||||
#define PGDIR_SHIFT (PTE_SHIFT + PTE_BITS)
|
||||
#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
|
||||
#define PGDIR_MASK (~(PGDIR_SIZE-1))
|
||||
|
||||
/* Entries per level */
|
||||
#define PTRS_PER_PTE (PAGE_SIZE / (1 << PTE_MAGNITUDE))
|
||||
#define PTRS_PER_PGD (PAGE_SIZE / sizeof(pgd_t))
|
||||
|
||||
#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
|
||||
#define FIRST_USER_ADDRESS 0
|
||||
|
||||
#define PHYS_ADDR_MASK29 0x1fffffff
|
||||
|
22
arch/sh/include/asm/pgtable_nopmd.h
Normal file
22
arch/sh/include/asm/pgtable_nopmd.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef __ASM_SH_PGTABLE_NOPMD_H
|
||||
#define __ASM_SH_PGTABLE_NOPMD_H
|
||||
|
||||
#include <asm-generic/pgtable-nopmd.h>
|
||||
|
||||
/*
|
||||
* traditional two-level paging structure
|
||||
*/
|
||||
|
||||
/* PTE bits */
|
||||
#define PTE_MAGNITUDE 2 /* 32-bit PTEs */
|
||||
|
||||
#define PTE_SHIFT PAGE_SHIFT
|
||||
#define PTE_BITS (PTE_SHIFT - PTE_MAGNITUDE)
|
||||
|
||||
/* PGD bits */
|
||||
#define PGDIR_SHIFT (PTE_SHIFT + PTE_BITS)
|
||||
|
||||
#define PTRS_PER_PGD (PAGE_SIZE / (1 << PTE_MAGNITUDE))
|
||||
#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
|
||||
|
||||
#endif /* __ASM_SH_PGTABLE_NOPMD_H */
|
Loading…
Reference in New Issue
Block a user