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 17c577b098SGustavo F. Padovan #ifndef __ASSEMBLY__ 18c577b098SGustavo F. Padovan #include <linux/kernel.h> 19c577b098SGustavo F. Padovan #include <asm/acpi.h> 20c577b098SGustavo F. Padovan #include <asm/apicdef.h> 21c577b098SGustavo F. Padovan #include <asm/page.h> 22bb898558SAl Viro #ifdef CONFIG_X86_32 23c577b098SGustavo F. Padovan #include <linux/threads.h> 24c577b098SGustavo F. Padovan #include <asm/kmap_types.h> 25bb898558SAl Viro #else 26f40c3300SAndy Lutomirski #include <uapi/asm/vsyscall.h> 27c577b098SGustavo F. Padovan #endif 28c577b098SGustavo F. Padovan 29c577b098SGustavo F. Padovan /* 30c577b098SGustavo F. Padovan * We can't declare FIXADDR_TOP as variable for x86_64 because vsyscall 31c577b098SGustavo F. Padovan * uses fixmaps that relies on FIXADDR_TOP for proper address calculation. 32c577b098SGustavo F. Padovan * Because of this, FIXADDR_TOP x86 integration was left as later work. 33c577b098SGustavo F. Padovan */ 34c577b098SGustavo F. Padovan #ifdef CONFIG_X86_32 35c577b098SGustavo F. Padovan /* used by vmalloc.c, vsyscall.lds.S. 36c577b098SGustavo F. Padovan * 37c577b098SGustavo F. Padovan * Leave one empty page between vmalloc'ed areas and 38c577b098SGustavo F. Padovan * the start of the fixmap. 39c577b098SGustavo F. Padovan */ 40c577b098SGustavo F. Padovan extern unsigned long __FIXADDR_TOP; 41c577b098SGustavo F. Padovan #define FIXADDR_TOP ((unsigned long)__FIXADDR_TOP) 42c577b098SGustavo F. Padovan #else 43f40c3300SAndy Lutomirski #define FIXADDR_TOP (round_up(VSYSCALL_ADDR + PAGE_SIZE, 1<<PMD_SHIFT) - \ 44f40c3300SAndy Lutomirski PAGE_SIZE) 45c577b098SGustavo F. Padovan #endif 46c577b098SGustavo F. Padovan 47c577b098SGustavo F. Padovan 48c577b098SGustavo F. Padovan /* 49c577b098SGustavo F. Padovan * Here we define all the compile-time 'special' virtual 50c577b098SGustavo F. Padovan * addresses. The point is to have a constant address at 51c577b098SGustavo F. Padovan * compile time, but to set the physical address only 52c577b098SGustavo F. Padovan * in the boot process. 53c577b098SGustavo F. Padovan * for x86_32: We allocate these special addresses 54c577b098SGustavo F. Padovan * from the end of virtual memory (0xfffff000) backwards. 55c577b098SGustavo F. Padovan * Also this lets us do fail-safe vmalloc(), we 56c577b098SGustavo F. Padovan * can guarantee that these special addresses and 57c577b098SGustavo F. Padovan * vmalloc()-ed addresses never overlap. 58c577b098SGustavo F. Padovan * 59c577b098SGustavo F. Padovan * These 'compile-time allocated' memory buffers are 60c577b098SGustavo F. Padovan * fixed-size 4k pages (or larger if used with an increment 61c577b098SGustavo F. Padovan * higher than 1). Use set_fixmap(idx,phys) to associate 62c577b098SGustavo F. Padovan * physical memory with fixmap indices. 63c577b098SGustavo F. Padovan * 64c577b098SGustavo F. Padovan * TLB entries of such buffers will not be flushed across 65c577b098SGustavo F. Padovan * task switches. 66c577b098SGustavo F. Padovan */ 67c577b098SGustavo F. Padovan enum fixed_addresses { 68c577b098SGustavo F. Padovan #ifdef CONFIG_X86_32 69c577b098SGustavo F. Padovan FIX_HOLE, 70c577b098SGustavo F. Padovan #else 711ad83c85SAndy Lutomirski #ifdef CONFIG_X86_VSYSCALL_EMULATION 72f40c3300SAndy Lutomirski VSYSCALL_PAGE = (FIXADDR_TOP - VSYSCALL_ADDR) >> PAGE_SHIFT, 731ad83c85SAndy Lutomirski #endif 74cbdce7b2SJan Beulich #endif 75c577b098SGustavo F. Padovan FIX_DBGP_BASE, 76c577b098SGustavo F. Padovan FIX_EARLYCON_MEM_BASE, 77ff30a054SJan Beulich #ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT 78ff30a054SJan Beulich FIX_OHCI1394_BASE, 79ff30a054SJan Beulich #endif 80c577b098SGustavo F. Padovan #ifdef CONFIG_X86_LOCAL_APIC 81c577b098SGustavo F. Padovan FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */ 82c577b098SGustavo F. Padovan #endif 83c577b098SGustavo F. Padovan #ifdef CONFIG_X86_IO_APIC 84c577b098SGustavo F. Padovan FIX_IO_APIC_BASE_0, 85c577b098SGustavo F. Padovan FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS - 1, 86c577b098SGustavo F. Padovan #endif 874eefbe79SKees Cook FIX_RO_IDT, /* Virtual mapping for read-only IDT */ 88c577b098SGustavo F. Padovan #ifdef CONFIG_X86_32 89c577b098SGustavo F. Padovan FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ 90c577b098SGustavo F. Padovan FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1, 91c577b098SGustavo F. Padovan #ifdef CONFIG_PCI_MMCONFIG 92c577b098SGustavo F. Padovan FIX_PCIE_MCFG, 93c577b098SGustavo F. Padovan #endif 94c577b098SGustavo F. Padovan #endif 95c577b098SGustavo F. Padovan #ifdef CONFIG_PARAVIRT 96c577b098SGustavo F. Padovan FIX_PARAVIRT_BOOTMAP, 97c577b098SGustavo F. Padovan #endif 9812b9d7ccSMathieu Desnoyers FIX_TEXT_POKE1, /* reserve 2 pages for text_poke() */ 9912b9d7ccSMathieu Desnoyers FIX_TEXT_POKE0, /* first page is last, because allocation is backward */ 100933b9463SAlan Cox #ifdef CONFIG_X86_INTEL_MID 1017309282cSFeng Tang FIX_LNW_VRTC, 1027309282cSFeng Tang #endif 10369218e47SThomas Garnier /* Fixmap entries to remap the GDTs, one per processor. */ 10469218e47SThomas Garnier FIX_GDT_REMAP_BEGIN, 10569218e47SThomas Garnier FIX_GDT_REMAP_END = FIX_GDT_REMAP_BEGIN + NR_CPUS - 1, 10669218e47SThomas Garnier 1074f89fa28SJames Morse #ifdef CONFIG_ACPI_APEI_GHES 1084f89fa28SJames Morse /* Used for GHES mapping from assorted contexts */ 1094f89fa28SJames Morse FIX_APEI_GHES_IRQ, 1104f89fa28SJames Morse FIX_APEI_GHES_NMI, 1114f89fa28SJames Morse #endif 1124f89fa28SJames Morse 113fa36e956SArjan van de Ven __end_of_permanent_fixed_addresses, 114fa36e956SArjan van de Ven 115c577b098SGustavo F. Padovan /* 1163eddc69fSDave Young * 512 temporary boot-time mappings, used by early_ioremap(), 117c577b098SGustavo F. Padovan * before ioremap() is functional. 118c577b098SGustavo F. Padovan * 1193eddc69fSDave Young * If necessary we round it up to the next 512 pages boundary so 120499a5f1eSJan Beulich * that we can have a single pgd entry and a single pte table: 121c577b098SGustavo F. Padovan */ 122c577b098SGustavo F. Padovan #define NR_FIX_BTMAPS 64 1233eddc69fSDave Young #define FIX_BTMAPS_SLOTS 8 124499a5f1eSJan Beulich #define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS) 125499a5f1eSJan Beulich FIX_BTMAP_END = 126499a5f1eSJan Beulich (__end_of_permanent_fixed_addresses ^ 127499a5f1eSJan Beulich (__end_of_permanent_fixed_addresses + TOTAL_FIX_BTMAPS - 1)) & 128499a5f1eSJan Beulich -PTRS_PER_PTE 129499a5f1eSJan Beulich ? __end_of_permanent_fixed_addresses + TOTAL_FIX_BTMAPS - 130499a5f1eSJan Beulich (__end_of_permanent_fixed_addresses & (TOTAL_FIX_BTMAPS - 1)) 131499a5f1eSJan Beulich : __end_of_permanent_fixed_addresses, 132499a5f1eSJan Beulich FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1, 133c577b098SGustavo F. Padovan #ifdef CONFIG_X86_32 134c577b098SGustavo F. Padovan FIX_WP_TEST, 135c577b098SGustavo F. Padovan #endif 13631625340SJoseph Cihula #ifdef CONFIG_INTEL_TXT 13731625340SJoseph Cihula FIX_TBOOT_BASE, 13831625340SJoseph Cihula #endif 139c577b098SGustavo F. Padovan __end_of_fixed_addresses 140c577b098SGustavo F. Padovan }; 141c577b098SGustavo F. Padovan 142c577b098SGustavo F. Padovan 143c577b098SGustavo F. Padovan extern void reserve_top_address(unsigned long reserve); 144c577b098SGustavo F. Padovan 145c577b098SGustavo F. Padovan #define FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT) 146c577b098SGustavo F. Padovan #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) 147bb898558SAl Viro 148bb898558SAl Viro extern int fixmaps_set; 149bb898558SAl Viro 150fd940934SKeith Packard extern pte_t *kmap_pte; 1517c360572SAndy Lutomirski #define kmap_prot PAGE_KERNEL 152fd940934SKeith Packard extern pte_t *pkmap_page_table; 153fd940934SKeith Packard 154bb898558SAl Viro void __native_set_fixmap(enum fixed_addresses idx, pte_t pte); 155bb898558SAl Viro void native_set_fixmap(enum fixed_addresses idx, 1563b3809acSMasami Hiramatsu phys_addr_t phys, pgprot_t flags); 157bb898558SAl Viro 158bb898558SAl Viro #ifndef CONFIG_PARAVIRT 159bb898558SAl Viro static inline void __set_fixmap(enum fixed_addresses idx, 1603b3809acSMasami Hiramatsu phys_addr_t phys, pgprot_t flags) 161bb898558SAl Viro { 162bb898558SAl Viro native_set_fixmap(idx, phys, flags); 163bb898558SAl Viro } 164bb898558SAl Viro #endif 165bb898558SAl Viro 16621729f81STom Lendacky /* 16721729f81STom Lendacky * FIXMAP_PAGE_NOCACHE is used for MMIO. Memory encryption is not 16821729f81STom Lendacky * supported for MMIO addresses, so make sure that the memory encryption 16921729f81STom Lendacky * mask is not part of the page attributes. 17021729f81STom Lendacky */ 17121729f81STom Lendacky #define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_IO_NOCACHE 17221729f81STom Lendacky 173f88a68faSTom Lendacky /* 174f88a68faSTom Lendacky * Early memremap routines used for in-place encryption. The mappings created 175f88a68faSTom Lendacky * by these routines are intended to be used as temporary mappings. 176f88a68faSTom Lendacky */ 177f88a68faSTom Lendacky void __init *early_memremap_encrypted(resource_size_t phys_addr, 178f88a68faSTom Lendacky unsigned long size); 179f88a68faSTom Lendacky void __init *early_memremap_encrypted_wp(resource_size_t phys_addr, 180f88a68faSTom Lendacky unsigned long size); 181f88a68faSTom Lendacky void __init *early_memremap_decrypted(resource_size_t phys_addr, 182f88a68faSTom Lendacky unsigned long size); 183f88a68faSTom Lendacky void __init *early_memremap_decrypted_wp(resource_size_t phys_addr, 184f88a68faSTom Lendacky unsigned long size); 185f88a68faSTom Lendacky 186114cefc8SMark Salter #include <asm-generic/fixmap.h> 1875a47c7daSFeng Tang 1885b7c73e0SMark Salter #define __late_set_fixmap(idx, phys, flags) __set_fixmap(idx, phys, flags) 1895b7c73e0SMark Salter #define __late_clear_fixmap(idx) __set_fixmap(idx, 0, __pgprot(0)) 1905b7c73e0SMark Salter 1915b7c73e0SMark Salter void __early_set_fixmap(enum fixed_addresses idx, 1925b7c73e0SMark Salter phys_addr_t phys, pgprot_t flags); 1935b7c73e0SMark Salter 194c577b098SGustavo F. Padovan #endif /* !__ASSEMBLY__ */ 1951965aae3SH. Peter Anvin #endif /* _ASM_X86_FIXMAP_H */ 196