Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 #ifndef _ASM_POWERPC_PAGE_64_H
0003 #define _ASM_POWERPC_PAGE_64_H
0004 
0005 /*
0006  * Copyright (C) 2001 PPC64 Team, IBM Corp
0007  */
0008 
0009 #include <asm/asm-const.h>
0010 
0011 /*
0012  * We always define HW_PAGE_SHIFT to 12 as use of 64K pages remains Linux
0013  * specific, every notion of page number shared with the firmware, TCEs,
0014  * iommu, etc... still uses a page size of 4K.
0015  */
0016 #define HW_PAGE_SHIFT       12
0017 #define HW_PAGE_SIZE        (ASM_CONST(1) << HW_PAGE_SHIFT)
0018 #define HW_PAGE_MASK        (~(HW_PAGE_SIZE-1))
0019 
0020 /*
0021  * PAGE_FACTOR is the number of bits factor between PAGE_SHIFT and
0022  * HW_PAGE_SHIFT, that is 4K pages.
0023  */
0024 #define PAGE_FACTOR     (PAGE_SHIFT - HW_PAGE_SHIFT)
0025 
0026 /* Segment size; normal 256M segments */
0027 #define SID_SHIFT       28
0028 #define SID_MASK        ASM_CONST(0xfffffffff)
0029 #define ESID_MASK       0xfffffffff0000000UL
0030 #define GET_ESID(x)     (((x) >> SID_SHIFT) & SID_MASK)
0031 
0032 /* 1T segments */
0033 #define SID_SHIFT_1T        40
0034 #define SID_MASK_1T     0xffffffUL
0035 #define ESID_MASK_1T        0xffffff0000000000UL
0036 #define GET_ESID_1T(x)      (((x) >> SID_SHIFT_1T) & SID_MASK_1T)
0037 
0038 #ifndef __ASSEMBLY__
0039 #include <asm/cache.h>
0040 
0041 typedef unsigned long pte_basic_t;
0042 
0043 static inline void clear_page(void *addr)
0044 {
0045     unsigned long iterations;
0046     unsigned long onex, twox, fourx, eightx;
0047 
0048     iterations = ppc64_caches.l1d.blocks_per_page / 8;
0049 
0050     /*
0051      * Some verisions of gcc use multiply instructions to
0052      * calculate the offsets so lets give it a hand to
0053      * do better.
0054      */
0055     onex = ppc64_caches.l1d.block_size;
0056     twox = onex << 1;
0057     fourx = onex << 2;
0058     eightx = onex << 3;
0059 
0060     asm volatile(
0061     "mtctr  %1  # clear_page\n\
0062     .balign 16\n\
0063 1:  dcbz    0,%0\n\
0064     dcbz    %3,%0\n\
0065     dcbz    %4,%0\n\
0066     dcbz    %5,%0\n\
0067     dcbz    %6,%0\n\
0068     dcbz    %7,%0\n\
0069     dcbz    %8,%0\n\
0070     dcbz    %9,%0\n\
0071     add %0,%0,%10\n\
0072     bdnz+   1b"
0073     : "=&r" (addr)
0074     : "r" (iterations), "0" (addr), "b" (onex), "b" (twox),
0075         "b" (twox+onex), "b" (fourx), "b" (fourx+onex),
0076         "b" (twox+fourx), "b" (eightx-onex), "r" (eightx)
0077     : "ctr", "memory");
0078 }
0079 
0080 extern void copy_page(void *to, void *from);
0081 
0082 /* Log 2 of page table size */
0083 extern u64 ppc64_pft_size;
0084 
0085 #endif /* __ASSEMBLY__ */
0086 
0087 #define VM_DATA_DEFAULT_FLAGS \
0088     (is_32bit_task() ? \
0089      VM_DATA_DEFAULT_FLAGS32 : VM_DATA_DEFAULT_FLAGS64)
0090 
0091 /*
0092  * This is the default if a program doesn't have a PT_GNU_STACK
0093  * program header entry. The PPC64 ELF ABI has a non executable stack
0094  * stack by default, so in the absence of a PT_GNU_STACK program header
0095  * we turn execute permission off.
0096  */
0097 #define VM_STACK_DEFAULT_FLAGS32    VM_DATA_FLAGS_EXEC
0098 #define VM_STACK_DEFAULT_FLAGS64    VM_DATA_FLAGS_NON_EXEC
0099 
0100 #define VM_STACK_DEFAULT_FLAGS \
0101     (is_32bit_task() ? \
0102      VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
0103 
0104 #include <asm-generic/getorder.h>
0105 
0106 #endif /* _ASM_POWERPC_PAGE_64_H */