Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * fixmap.h: compile-time virtual memory allocation
0003  *
0004  * This file is subject to the terms and conditions of the GNU General Public
0005  * License.  See the file "COPYING" in the main directory of this archive
0006  * for more details.
0007  *
0008  * Copyright (C) 1998 Ingo Molnar
0009  *
0010  * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
0011  * x86_32 and x86_64 integration by Gustavo F. Padovan, February 2009
0012  */
0013 
0014 #ifndef _ASM_X86_FIXMAP_H
0015 #define _ASM_X86_FIXMAP_H
0016 
0017 #include <asm/kmap_size.h>
0018 
0019 /*
0020  * Exposed to assembly code for setting up initial page tables. Cannot be
0021  * calculated in assembly code (fixmap entries are an enum), but is sanity
0022  * checked in the actual fixmap C code to make sure that the fixmap is
0023  * covered fully.
0024  */
0025 #ifndef CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP
0026 # define FIXMAP_PMD_NUM 2
0027 #else
0028 # define KM_PMDS    (KM_MAX_IDX * ((CONFIG_NR_CPUS + 511) / 512))
0029 # define FIXMAP_PMD_NUM (KM_PMDS + 2)
0030 #endif
0031 /* fixmap starts downwards from the 507th entry in level2_fixmap_pgt */
0032 #define FIXMAP_PMD_TOP  507
0033 
0034 #ifndef __ASSEMBLY__
0035 #include <linux/kernel.h>
0036 #include <asm/apicdef.h>
0037 #include <asm/page.h>
0038 #include <asm/pgtable_types.h>
0039 #ifdef CONFIG_X86_32
0040 #include <linux/threads.h>
0041 #else
0042 #include <uapi/asm/vsyscall.h>
0043 #endif
0044 
0045 /*
0046  * We can't declare FIXADDR_TOP as variable for x86_64 because vsyscall
0047  * uses fixmaps that relies on FIXADDR_TOP for proper address calculation.
0048  * Because of this, FIXADDR_TOP x86 integration was left as later work.
0049  */
0050 #ifdef CONFIG_X86_32
0051 /*
0052  * Leave one empty page between vmalloc'ed areas and
0053  * the start of the fixmap.
0054  */
0055 extern unsigned long __FIXADDR_TOP;
0056 #define FIXADDR_TOP ((unsigned long)__FIXADDR_TOP)
0057 #else
0058 #define FIXADDR_TOP (round_up(VSYSCALL_ADDR + PAGE_SIZE, 1<<PMD_SHIFT) - \
0059              PAGE_SIZE)
0060 #endif
0061 
0062 /*
0063  * Here we define all the compile-time 'special' virtual
0064  * addresses. The point is to have a constant address at
0065  * compile time, but to set the physical address only
0066  * in the boot process.
0067  * for x86_32: We allocate these special addresses
0068  * from the end of virtual memory (0xfffff000) backwards.
0069  * Also this lets us do fail-safe vmalloc(), we
0070  * can guarantee that these special addresses and
0071  * vmalloc()-ed addresses never overlap.
0072  *
0073  * These 'compile-time allocated' memory buffers are
0074  * fixed-size 4k pages (or larger if used with an increment
0075  * higher than 1). Use set_fixmap(idx,phys) to associate
0076  * physical memory with fixmap indices.
0077  *
0078  * TLB entries of such buffers will not be flushed across
0079  * task switches.
0080  */
0081 enum fixed_addresses {
0082 #ifdef CONFIG_X86_32
0083     FIX_HOLE,
0084 #else
0085 #ifdef CONFIG_X86_VSYSCALL_EMULATION
0086     VSYSCALL_PAGE = (FIXADDR_TOP - VSYSCALL_ADDR) >> PAGE_SHIFT,
0087 #endif
0088 #endif
0089     FIX_DBGP_BASE,
0090     FIX_EARLYCON_MEM_BASE,
0091 #ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
0092     FIX_OHCI1394_BASE,
0093 #endif
0094 #ifdef CONFIG_X86_LOCAL_APIC
0095     FIX_APIC_BASE,  /* local (CPU) APIC) -- required for SMP or not */
0096 #endif
0097 #ifdef CONFIG_X86_IO_APIC
0098     FIX_IO_APIC_BASE_0,
0099     FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS - 1,
0100 #endif
0101 #ifdef CONFIG_KMAP_LOCAL
0102     FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
0103     FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_MAX_IDX * NR_CPUS) - 1,
0104 #ifdef CONFIG_PCI_MMCONFIG
0105     FIX_PCIE_MCFG,
0106 #endif
0107 #endif
0108 #ifdef CONFIG_PARAVIRT_XXL
0109     FIX_PARAVIRT_BOOTMAP,
0110 #endif
0111 
0112 #ifdef CONFIG_ACPI_APEI_GHES
0113     /* Used for GHES mapping from assorted contexts */
0114     FIX_APEI_GHES_IRQ,
0115     FIX_APEI_GHES_NMI,
0116 #endif
0117 
0118     __end_of_permanent_fixed_addresses,
0119 
0120     /*
0121      * 512 temporary boot-time mappings, used by early_ioremap(),
0122      * before ioremap() is functional.
0123      *
0124      * If necessary we round it up to the next 512 pages boundary so
0125      * that we can have a single pmd entry and a single pte table:
0126      */
0127 #define NR_FIX_BTMAPS       64
0128 #define FIX_BTMAPS_SLOTS    8
0129 #define TOTAL_FIX_BTMAPS    (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS)
0130     FIX_BTMAP_END =
0131      (__end_of_permanent_fixed_addresses ^
0132       (__end_of_permanent_fixed_addresses + TOTAL_FIX_BTMAPS - 1)) &
0133      -PTRS_PER_PTE
0134      ? __end_of_permanent_fixed_addresses + TOTAL_FIX_BTMAPS -
0135        (__end_of_permanent_fixed_addresses & (TOTAL_FIX_BTMAPS - 1))
0136      : __end_of_permanent_fixed_addresses,
0137     FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1,
0138 #ifdef CONFIG_X86_32
0139     FIX_WP_TEST,
0140 #endif
0141 #ifdef CONFIG_INTEL_TXT
0142     FIX_TBOOT_BASE,
0143 #endif
0144     __end_of_fixed_addresses
0145 };
0146 
0147 
0148 extern void reserve_top_address(unsigned long reserve);
0149 
0150 #define FIXADDR_SIZE        (__end_of_permanent_fixed_addresses << PAGE_SHIFT)
0151 #define FIXADDR_START       (FIXADDR_TOP - FIXADDR_SIZE)
0152 #define FIXADDR_TOT_SIZE    (__end_of_fixed_addresses << PAGE_SHIFT)
0153 #define FIXADDR_TOT_START   (FIXADDR_TOP - FIXADDR_TOT_SIZE)
0154 
0155 extern int fixmaps_set;
0156 
0157 extern pte_t *pkmap_page_table;
0158 
0159 void __native_set_fixmap(enum fixed_addresses idx, pte_t pte);
0160 void native_set_fixmap(unsigned /* enum fixed_addresses */ idx,
0161                phys_addr_t phys, pgprot_t flags);
0162 
0163 #ifndef CONFIG_PARAVIRT_XXL
0164 static inline void __set_fixmap(enum fixed_addresses idx,
0165                 phys_addr_t phys, pgprot_t flags)
0166 {
0167     native_set_fixmap(idx, phys, flags);
0168 }
0169 #endif
0170 
0171 /*
0172  * FIXMAP_PAGE_NOCACHE is used for MMIO. Memory encryption is not
0173  * supported for MMIO addresses, so make sure that the memory encryption
0174  * mask is not part of the page attributes.
0175  */
0176 #define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_IO_NOCACHE
0177 
0178 /*
0179  * Early memremap routines used for in-place encryption. The mappings created
0180  * by these routines are intended to be used as temporary mappings.
0181  */
0182 void __init *early_memremap_encrypted(resource_size_t phys_addr,
0183                       unsigned long size);
0184 void __init *early_memremap_encrypted_wp(resource_size_t phys_addr,
0185                      unsigned long size);
0186 void __init *early_memremap_decrypted(resource_size_t phys_addr,
0187                       unsigned long size);
0188 void __init *early_memremap_decrypted_wp(resource_size_t phys_addr,
0189                      unsigned long size);
0190 
0191 #include <asm-generic/fixmap.h>
0192 
0193 #define __late_set_fixmap(idx, phys, flags) __set_fixmap(idx, phys, flags)
0194 #define __late_clear_fixmap(idx) __set_fixmap(idx, 0, __pgprot(0))
0195 
0196 void __early_set_fixmap(enum fixed_addresses idx,
0197             phys_addr_t phys, pgprot_t flags);
0198 
0199 #endif /* !__ASSEMBLY__ */
0200 #endif /* _ASM_X86_FIXMAP_H */