powerpc: Add memory management headers for new 64-bit BookE
PATCH 14/20 powerpc: Add memory management headers for new 64-bit BookE
This adds the PTE and pgtable format definitions, along with changes to the kernel memory map and other definitions related to implementing support for 64-bit Book3E. This also shields some asm-offset bits that are currently only relevant on 32-bit
Signed-off-by Benjamin Herrenschmidt <[email protected]>
---
arch/powerpc/include/asm/mmu-book3e.h | 50 ++++++++++++++++++++++ arch/powerpc/include/asm/mmu.h | 1 arch/powerpc/include/asm/page.h | 4 + arch/powerpc/include/asm/page_64.h | 10 ++++ arch/powerpc/include/asm/pgtable-ppc64.h | 61 +++++++++++++++++++-------- arch/powerpc/include/asm/pte-book3e.h | 70 +++++++++++++++++++++++++++++++ arch/powerpc/include/asm/pte-common.h | 3 + arch/powerpc/kernel/asm-offsets.c | 5 +- 8 files changed, 186 insertions(+), 18 deletions(-)
arch/powerpc/include/asm/pte-book3e.h new file +70 -0
@@ -0,0 +1,70 @@ +#ifndef _ASM_POWERPC_PTE_BOOK3E_H +#define _ASM_POWERPC_PTE_BOOK3E_H +#ifdef __KERNEL__ + +/* PTE bit definitions for processors compliant to the Book3E +* architecture 2.06 or later. The position of the PTE bits +* matches the HW definition of the optional Embedded Page Table +* category. +*/ + +/* Architected bits */ +#define _PAGE_PRESENT 0x000001/* software: pte contains a translation */ +#define _PAGE_FILE 0x000002/* (!present only) software: pte holds file offset */ +#define _PAGE_SW1 0x000002 +#define _PAGE_BAP_SR 0x000004 +#define _PAGE_BAP_UR 0x000008 +#define _PAGE_BAP_SW 0x000010 +#define _PAGE_BAP_UW 0x000020 +#define _PAGE_BAP_SX 0x000040 +#define _PAGE_BAP_UX 0x000080 +#define _PAGE_PSIZE_MSK 0x000f00 +#define _PAGE_PSIZE_4K 0x000200 +#define _PAGE_PSIZE_64K 0x000600 +#define _PAGE_PSIZE_1M 0x000a00 +#define _PAGE_PSIZE_16M 0x000e00 +#define _PAGE_DIRTY 0x001000/* C: page changed */ +#define _PAGE_SW0 0x002000 +#define _PAGE_U3 0x004000 +#define _PAGE_U2 0x008000 +#define _PAGE_U1 0x010000 +#define _PAGE_U0 0x020000 +#define _PAGE_ACCESSED 0x040000 +#define _PAGE_LENDIAN 0x080000 +#define _PAGE_GUARDED 0x100000 +#define _PAGE_COHERENT 0x200000/* M: enforce memory coherence */ +#define _PAGE_NO_CACHE 0x400000/* I: cache inhibit */ +#define _PAGE_WRITETHRU 0x800000/* W: cache write-through */ + +/* "Higher level" linux bit combinations */ +#define _PAGE_EXEC _PAGE_BAP_SX/* Can be executed from potentially */ +#define _PAGE_HWEXEC _PAGE_BAP_UX/* .. and was cache cleaned */ +#define _PAGE_RW (_PAGE_BAP_SW | _PAGE_BAP_UW)/* User write permission */ +#define _PAGE_KERNEL_RW (_PAGE_BAP_SW | _PAGE_BAP_SR | _PAGE_DIRTY) +#define _PAGE_KERNEL_RO (_PAGE_BAP_SR) +#define _PAGE_USER (_PAGE_BAP_UR | _PAGE_BAP_SR)/* Can be read */ + +#define _PAGE_HASHPTE 0 +#define _PAGE_BUSY 0 + +#define _PAGE_SPECIAL _PAGE_SW0 + +/* Flags to be preserved on PTE modifications */ +#define _PAGE_HPTEFLAGS _PAGE_BUSY + +/* Base page size */ +#ifdef CONFIG_PPC_64K_PAGES +#define _PAGE_PSIZE _PAGE_PSIZE_64K +#define PTE_RPN_SHIFT (28) +#else +#define _PAGE_PSIZE _PAGE_PSIZE_4K +#define PTE_RPN_SHIFT (24) +#endif + +/* On 32-bit, we never clear the top part of the PTE */ +#ifdef CONFIG_PPC32 +#define _PTE_NONE_MASK 0xffffffff00000000ULL +#endif + +#endif /* __KERNEL__ */ +#endif /* _ASM_POWERPC_PTE_FSL_BOOKE_H */
arch/powerpc/include/asm/pgtable-ppc64.h +44 -17
106 lines not on this page · raw message
arch/powerpc/include/asm/pte-common.h +3 -0
@@ -34,6 +34,9 @@#ifndef _PAGE_4K_PFN#define _PAGE_4K_PFN 0#endif +#ifndef _PAGE_SAO +#define _PAGE_SAO 0 +#endif #ifndef _PAGE_PSIZE#define _PAGE_PSIZE 0#endif
arch/powerpc/include/asm/mmu-book3e.h +50 -0
62 lines not on this page · raw message
arch/powerpc/include/asm/page_64.h +10 -0
@@ -135,12 +135,22 @@ extern void slice_set_range_psize(struct#endif /* __ASSEMBLY__ */ #else #define slice_init () +#ifdef CONFIG_PPC_STD_MMU_64 #define get_slice_psize (mm, addr) ((mm)->context.user_psize)#define slice_set_user_psize (mm, psize) \ do { \ (mm)->context.user_psize = (psize); \ (mm)->context.sllp = SLB_VSID_USER | mmu_psize_defs[(psize)].sllp; \ } while (0) +#else /* CONFIG_PPC_STD_MMU_64 */ +#ifdef CONFIG_PPC_64K_PAGES +#define get_slice_psize (mm, addr) MMU_PAGE_64K +#else /* CONFIG_PPC_64K_PAGES */ +#define get_slice_psize (mm, addr) MMU_PAGE_4K +#endif /* !CONFIG_PPC_64K_PAGES */ +#define slice_set_user_psize (mm, psize) do { BUG(); } while(0) +#endif /* !CONFIG_PPC_STD_MMU_64 */ +#define slice_set_range_psize (mm, start, len, psize) \ slice_set_user_psize((mm), (psize))#define slice_mm_new_context (mm) 1
arch/powerpc/include/asm/mmu.h +1 -0
@@ -17,6 +17,7 @@#define MMU_FTR_TYPE_40x ASM_CONST(0x00000004)#define MMU_FTR_TYPE_44x ASM_CONST(0x00000008)#define MMU_FTR_TYPE_FSL_E ASM_CONST(0x00000010) +#define MMU_FTR_TYPE_3E ASM_CONST(0x00000020)/* * This is individual features
arch/powerpc/kernel/asm-offsets.c +4 -1
@@ -52,9 +52,11 @@#include <linux/kvm_host.h> #endif +#ifdef CONFIG_PPC32 #if defined(CONFIG_BOOKE ) || defined(CONFIG_40x)#include "head_booke.h" #endif +#endif #if defined(CONFIG_FSL_BOOKE )#include "../mm/mmu_decl.h"
@@ -260,6 +276,7 @@ int main(void)DEFINE (_SRR1,STACK_FRAME_OVERHEAD +sizeof (struct pt_regs )+8 );#endif /* CONFIG_PPC64 */ +#if defined(CONFIG_PPC32 )#if defined(CONFIG_BOOKE ) || defined(CONFIG_40x)DEFINE (EXC_LVL_SIZE ,STACK_EXC_LVL_FRAME_SIZE );DEFINE (MAS0 ,STACK_INT_FRAME_SIZE +offsetof(struct exception_regs , mas0));
@@ -278,7 +295,7 @@ int main(void)DEFINE (_DSRR1,STACK_INT_FRAME_SIZE +offsetof(struct exception_regs , dsrr1));DEFINE (SAVED_KSP_LIMIT ,STACK_INT_FRAME_SIZE +offsetof(struct exception_regs , saved_ksp_limit));#endif - +#endif DEFINE (CLONE_VM ,CLONE_VM );DEFINE (CLONE_UNTRACED ,CLONE_UNTRACED );
arch/powerpc/include/asm/page.h +4 -0
@@ -139,7 +139,11 @@ extern phys_addr_t kernstart_addr;* Don't compare things with KERNELBASE or PAGE_OFFSET to test for * "kernelness", use is_kernel_addr() - it should do what you want. */ +#ifdef CONFIG_PPC_BOOK3E_64 +#define is_kernel_addr (x) ((x) >= 0x8000000000000000ul) +#else #define is_kernel_addr (x) ((x) >= PAGE_OFFSET) +#endif #ifndef __ASSEMBLY__