1c577b098SGustavo F. Padovan /* 2c577b098SGustavo F. Padovan * fixmap.h: compile-time virtual memory allocation 3c577b098SGustavo F. Padovan * 4c577b098SGustavo F. Padovan * This file is subject to the terms and conditions of the GNU General Public 5c577b098SGustavo F. Padovan * License. See the file "COPYING" in the main directory of this archive 6c577b098SGustavo F. Padovan * for more details. 7c577b098SGustavo F. Padovan * 8c577b098SGustavo F. Padovan * Copyright (C) 1998 Ingo Molnar 9c577b098SGustavo F. Padovan * 10c577b098SGustavo F. Padovan * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999 11c577b098SGustavo F. Padovan * x86_32 and x86_64 integration by Gustavo F. Padovan, February 2009 12c577b098SGustavo F. Padovan */ 13c577b098SGustavo F. Padovan 141965aae3SH. Peter Anvin #ifndef _ASM_X86_FIXMAP_H 151965aae3SH. Peter Anvin #define _ASM_X86_FIXMAP_H 16bb898558SAl Viro 17*14df3267SThomas Gleixner #include <asm/kmap_size.h> 18*14df3267SThomas Gleixner 1905ab1d8aSFeng Tang /* 2005ab1d8aSFeng Tang * Exposed to assembly code for setting up initial page tables. Cannot be 2105ab1d8aSFeng Tang * calculated in assembly code (fixmap entries are an enum), but is sanity 2205ab1d8aSFeng Tang * checked in the actual fixmap C code to make sure that the fixmap is 2305ab1d8aSFeng Tang * covered fully. 2405ab1d8aSFeng Tang */ 25*14df3267SThomas Gleixner #ifndef CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP 2605ab1d8aSFeng Tang # define FIXMAP_PMD_NUM 2 27*14df3267SThomas Gleixner #else 28*14df3267SThomas Gleixner # define KM_PMDS (KM_MAX_IDX * ((CONFIG_NR_CPUS + 511) / 512)) 29*14df3267SThomas Gleixner # define FIXMAP_PMD_NUM (KM_PMDS + 2) 30*14df3267SThomas Gleixner #endif 3105ab1d8aSFeng Tang /* fixmap starts downwards from the 507th entry in level2_fixmap_pgt */ 3205ab1d8aSFeng Tang #define FIXMAP_PMD_TOP 507 3305ab1d8aSFeng Tang 34c577b098SGustavo F. Padovan #ifndef __ASSEMBLY__ 35c577b098SGustavo F. Padovan #include <linux/kernel.h> 36c577b098SGustavo F. Padovan #include <asm/apicdef.h> 37c577b098SGustavo F. Padovan #include <asm/page.h> 380cd39f46SPeter Zijlstra #include <asm/pgtable_types.h> 39bb898558SAl Viro #ifdef CONFIG_X86_32 40c577b098SGustavo F. Padovan #include <linux/threads.h> 41bb898558SAl Viro #else 42f40c3300SAndy Lutomirski #include <uapi/asm/vsyscall.h> 43c577b098SGustavo F. Padovan #endif 44c577b098SGustavo F. Padovan 45c577b098SGustavo F. Padovan /* 46c577b098SGustavo F. Padovan * We can't declare FIXADDR_TOP as variable for x86_64 because vsyscall 47c577b098SGustavo F. Padovan * uses fixmaps that relies on FIXADDR_TOP for proper address calculation. 48c577b098SGustavo F. Padovan * Because of this, FIXADDR_TOP x86 integration was left as later work. 49c577b098SGustavo F. Padovan */ 50c577b098SGustavo F. Padovan #ifdef CONFIG_X86_32 51c84b82ddSCao jin /* 52c577b098SGustavo F. Padovan * Leave one empty page between vmalloc'ed areas and 53c577b098SGustavo F. Padovan * the start of the fixmap. 54c577b098SGustavo F. Padovan */ 55c577b098SGustavo F. Padovan extern unsigned long __FIXADDR_TOP; 56c577b098SGustavo F. Padovan #define FIXADDR_TOP ((unsigned long)__FIXADDR_TOP) 57c577b098SGustavo F. Padovan #else 58f40c3300SAndy Lutomirski #define FIXADDR_TOP (round_up(VSYSCALL_ADDR + PAGE_SIZE, 1<<PMD_SHIFT) - \ 59f40c3300SAndy Lutomirski PAGE_SIZE) 60c577b098SGustavo F. Padovan #endif 61c577b098SGustavo F. Padovan 62ef8813abSAndy Lutomirski /* 63c577b098SGustavo F. Padovan * Here we define all the compile-time 'special' virtual 64c577b098SGustavo F. Padovan * addresses. The point is to have a constant address at 65c577b098SGustavo F. Padovan * compile time, but to set the physical address only 66c577b098SGustavo F. Padovan * in the boot process. 67c577b098SGustavo F. Padovan * for x86_32: We allocate these special addresses 68c577b098SGustavo F. Padovan * from the end of virtual memory (0xfffff000) backwards. 69c577b098SGustavo F. Padovan * Also this lets us do fail-safe vmalloc(), we 70c577b098SGustavo F. Padovan * can guarantee that these special addresses and 71c577b098SGustavo F. Padovan * vmalloc()-ed addresses never overlap. 72c577b098SGustavo F. Padovan * 73c577b098SGustavo F. Padovan * These 'compile-time allocated' memory buffers are 74c577b098SGustavo F. Padovan * fixed-size 4k pages (or larger if used with an increment 75c577b098SGustavo F. Padovan * higher than 1). Use set_fixmap(idx,phys) to associate 76c577b098SGustavo F. Padovan * physical memory with fixmap indices. 77c577b098SGustavo F. Padovan * 78c577b098SGustavo F. Padovan * TLB entries of such buffers will not be flushed across 79c577b098SGustavo F. Padovan * task switches. 80c577b098SGustavo F. Padovan */ 81c577b098SGustavo F. Padovan enum fixed_addresses { 82c577b098SGustavo F. Padovan #ifdef CONFIG_X86_32 83c577b098SGustavo F. Padovan FIX_HOLE, 84c577b098SGustavo F. Padovan #else 851ad83c85SAndy Lutomirski #ifdef CONFIG_X86_VSYSCALL_EMULATION 86f40c3300SAndy Lutomirski VSYSCALL_PAGE = (FIXADDR_TOP - VSYSCALL_ADDR) >> PAGE_SHIFT, 871ad83c85SAndy Lutomirski #endif 88cbdce7b2SJan Beulich #endif 89c577b098SGustavo F. Padovan FIX_DBGP_BASE, 90c577b098SGustavo F. Padovan FIX_EARLYCON_MEM_BASE, 91ff30a054SJan Beulich #ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT 92ff30a054SJan Beulich FIX_OHCI1394_BASE, 93ff30a054SJan Beulich #endif 94c577b098SGustavo F. Padovan #ifdef CONFIG_X86_LOCAL_APIC 95c577b098SGustavo F. Padovan FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */ 96c577b098SGustavo F. Padovan #endif 97c577b098SGustavo F. Padovan #ifdef CONFIG_X86_IO_APIC 98c577b098SGustavo F. Padovan FIX_IO_APIC_BASE_0, 99c577b098SGustavo F. Padovan FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS - 1, 100c577b098SGustavo F. Padovan #endif 101*14df3267SThomas Gleixner #ifdef CONFIG_KMAP_LOCAL 102c577b098SGustavo F. Padovan FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ 103157e118bSThomas Gleixner FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_MAX_IDX * NR_CPUS) - 1, 104c577b098SGustavo F. Padovan #ifdef CONFIG_PCI_MMCONFIG 105c577b098SGustavo F. Padovan FIX_PCIE_MCFG, 106c577b098SGustavo F. Padovan #endif 107c577b098SGustavo F. Padovan #endif 108ecac7181SJuergen Gross #ifdef CONFIG_PARAVIRT_XXL 109c577b098SGustavo F. Padovan FIX_PARAVIRT_BOOTMAP, 110c577b098SGustavo F. Padovan #endif 111933b9463SAlan Cox #ifdef CONFIG_X86_INTEL_MID 1127309282cSFeng Tang FIX_LNW_VRTC, 1137309282cSFeng Tang #endif 11469218e47SThomas Garnier 1154f89fa28SJames Morse #ifdef CONFIG_ACPI_APEI_GHES 1164f89fa28SJames Morse /* Used for GHES mapping from assorted contexts */ 1174f89fa28SJames Morse FIX_APEI_GHES_IRQ, 1184f89fa28SJames Morse FIX_APEI_GHES_NMI, 1194f89fa28SJames Morse #endif 1204f89fa28SJames Morse 121fa36e956SArjan van de Ven __end_of_permanent_fixed_addresses, 122fa36e956SArjan van de Ven 123c577b098SGustavo F. Padovan /* 1243eddc69fSDave Young * 512 temporary boot-time mappings, used by early_ioremap(), 125c577b098SGustavo F. Padovan * before ioremap() is functional. 126c577b098SGustavo F. Padovan * 1273eddc69fSDave Young * If necessary we round it up to the next 512 pages boundary so 128c84b82ddSCao jin * that we can have a single pmd entry and a single pte table: 129c577b098SGustavo F. Padovan */ 130c577b098SGustavo F. Padovan #define NR_FIX_BTMAPS 64 1313eddc69fSDave Young #define FIX_BTMAPS_SLOTS 8 132499a5f1eSJan Beulich #define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS) 133499a5f1eSJan Beulich FIX_BTMAP_END = 134499a5f1eSJan Beulich (__end_of_permanent_fixed_addresses ^ 135499a5f1eSJan Beulich (__end_of_permanent_fixed_addresses + TOTAL_FIX_BTMAPS - 1)) & 136499a5f1eSJan Beulich -PTRS_PER_PTE 137499a5f1eSJan Beulich ? __end_of_permanent_fixed_addresses + TOTAL_FIX_BTMAPS - 138499a5f1eSJan Beulich (__end_of_permanent_fixed_addresses & (TOTAL_FIX_BTMAPS - 1)) 139499a5f1eSJan Beulich : __end_of_permanent_fixed_addresses, 140499a5f1eSJan Beulich FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1, 141c577b098SGustavo F. Padovan #ifdef CONFIG_X86_32 142c577b098SGustavo F. Padovan FIX_WP_TEST, 143c577b098SGustavo F. Padovan #endif 14431625340SJoseph Cihula #ifdef CONFIG_INTEL_TXT 14531625340SJoseph Cihula FIX_TBOOT_BASE, 14631625340SJoseph Cihula #endif 147c577b098SGustavo F. Padovan __end_of_fixed_addresses 148c577b098SGustavo F. Padovan }; 149c577b098SGustavo F. Padovan 150c577b098SGustavo F. Padovan 151c577b098SGustavo F. Padovan extern void reserve_top_address(unsigned long reserve); 152c577b098SGustavo F. Padovan 153c577b098SGustavo F. Padovan #define FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT) 154c577b098SGustavo F. Padovan #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) 15555f49fcbSWilliam Grant #define FIXADDR_TOT_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) 15655f49fcbSWilliam Grant #define FIXADDR_TOT_START (FIXADDR_TOP - FIXADDR_TOT_SIZE) 157bb898558SAl Viro 158bb898558SAl Viro extern int fixmaps_set; 159bb898558SAl Viro 160fd940934SKeith Packard extern pte_t *pkmap_page_table; 161fd940934SKeith Packard 162bb898558SAl Viro void __native_set_fixmap(enum fixed_addresses idx, pte_t pte); 163f53e2cd0SSami Tolvanen void native_set_fixmap(unsigned /* enum fixed_addresses */ idx, 1643b3809acSMasami Hiramatsu phys_addr_t phys, pgprot_t flags); 165bb898558SAl Viro 166fdc0269eSJuergen Gross #ifndef CONFIG_PARAVIRT_XXL 167bb898558SAl Viro static inline void __set_fixmap(enum fixed_addresses idx, 1683b3809acSMasami Hiramatsu phys_addr_t phys, pgprot_t flags) 169bb898558SAl Viro { 170bb898558SAl Viro native_set_fixmap(idx, phys, flags); 171bb898558SAl Viro } 172bb898558SAl Viro #endif 173bb898558SAl Viro 17421729f81STom Lendacky /* 17521729f81STom Lendacky * FIXMAP_PAGE_NOCACHE is used for MMIO. Memory encryption is not 17621729f81STom Lendacky * supported for MMIO addresses, so make sure that the memory encryption 17721729f81STom Lendacky * mask is not part of the page attributes. 17821729f81STom Lendacky */ 17921729f81STom Lendacky #define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_IO_NOCACHE 18021729f81STom Lendacky 181f88a68faSTom Lendacky /* 182f88a68faSTom Lendacky * Early memremap routines used for in-place encryption. The mappings created 183f88a68faSTom Lendacky * by these routines are intended to be used as temporary mappings. 184f88a68faSTom Lendacky */ 185f88a68faSTom Lendacky void __init *early_memremap_encrypted(resource_size_t phys_addr, 186f88a68faSTom Lendacky unsigned long size); 187f88a68faSTom Lendacky void __init *early_memremap_encrypted_wp(resource_size_t phys_addr, 188f88a68faSTom Lendacky unsigned long size); 189f88a68faSTom Lendacky void __init *early_memremap_decrypted(resource_size_t phys_addr, 190f88a68faSTom Lendacky unsigned long size); 191f88a68faSTom Lendacky void __init *early_memremap_decrypted_wp(resource_size_t phys_addr, 192f88a68faSTom Lendacky unsigned long size); 193f88a68faSTom Lendacky 194114cefc8SMark Salter #include <asm-generic/fixmap.h> 1955a47c7daSFeng Tang 1965b7c73e0SMark Salter #define __late_set_fixmap(idx, phys, flags) __set_fixmap(idx, phys, flags) 1975b7c73e0SMark Salter #define __late_clear_fixmap(idx) __set_fixmap(idx, 0, __pgprot(0)) 1985b7c73e0SMark Salter 1995b7c73e0SMark Salter void __early_set_fixmap(enum fixed_addresses idx, 2005b7c73e0SMark Salter phys_addr_t phys, pgprot_t flags); 2015b7c73e0SMark Salter 202c577b098SGustavo F. Padovan #endif /* !__ASSEMBLY__ */ 2031965aae3SH. Peter Anvin #endif /* _ASM_X86_FIXMAP_H */ 204