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> 2271056ae2SMarcelo Tosatti #include <asm/pvclock.h> 23bb898558SAl Viro #ifdef CONFIG_X86_32 24c577b098SGustavo F. Padovan #include <linux/threads.h> 25c577b098SGustavo F. Padovan #include <asm/kmap_types.h> 26bb898558SAl Viro #else 27f40c3300SAndy Lutomirski #include <uapi/asm/vsyscall.h> 28c577b098SGustavo F. Padovan #endif 29c577b098SGustavo F. Padovan 30c577b098SGustavo F. Padovan /* 31c577b098SGustavo F. Padovan * We can't declare FIXADDR_TOP as variable for x86_64 because vsyscall 32c577b098SGustavo F. Padovan * uses fixmaps that relies on FIXADDR_TOP for proper address calculation. 33c577b098SGustavo F. Padovan * Because of this, FIXADDR_TOP x86 integration was left as later work. 34c577b098SGustavo F. Padovan */ 35c577b098SGustavo F. Padovan #ifdef CONFIG_X86_32 36c577b098SGustavo F. Padovan /* used by vmalloc.c, vsyscall.lds.S. 37c577b098SGustavo F. Padovan * 38c577b098SGustavo F. Padovan * Leave one empty page between vmalloc'ed areas and 39c577b098SGustavo F. Padovan * the start of the fixmap. 40c577b098SGustavo F. Padovan */ 41c577b098SGustavo F. Padovan extern unsigned long __FIXADDR_TOP; 42c577b098SGustavo F. Padovan #define FIXADDR_TOP ((unsigned long)__FIXADDR_TOP) 43c577b098SGustavo F. Padovan #else 44f40c3300SAndy Lutomirski #define FIXADDR_TOP (round_up(VSYSCALL_ADDR + PAGE_SIZE, 1<<PMD_SHIFT) - \ 45f40c3300SAndy Lutomirski PAGE_SIZE) 46c577b098SGustavo F. Padovan #endif 47c577b098SGustavo F. Padovan 48c577b098SGustavo F. Padovan 49c577b098SGustavo F. Padovan /* 50c577b098SGustavo F. Padovan * Here we define all the compile-time 'special' virtual 51c577b098SGustavo F. Padovan * addresses. The point is to have a constant address at 52c577b098SGustavo F. Padovan * compile time, but to set the physical address only 53c577b098SGustavo F. Padovan * in the boot process. 54c577b098SGustavo F. Padovan * for x86_32: We allocate these special addresses 55c577b098SGustavo F. Padovan * from the end of virtual memory (0xfffff000) backwards. 56c577b098SGustavo F. Padovan * Also this lets us do fail-safe vmalloc(), we 57c577b098SGustavo F. Padovan * can guarantee that these special addresses and 58c577b098SGustavo F. Padovan * vmalloc()-ed addresses never overlap. 59c577b098SGustavo F. Padovan * 60c577b098SGustavo F. Padovan * These 'compile-time allocated' memory buffers are 61c577b098SGustavo F. Padovan * fixed-size 4k pages (or larger if used with an increment 62c577b098SGustavo F. Padovan * higher than 1). Use set_fixmap(idx,phys) to associate 63c577b098SGustavo F. Padovan * physical memory with fixmap indices. 64c577b098SGustavo F. Padovan * 65c577b098SGustavo F. Padovan * TLB entries of such buffers will not be flushed across 66c577b098SGustavo F. Padovan * task switches. 67c577b098SGustavo F. Padovan */ 68c577b098SGustavo F. Padovan enum fixed_addresses { 69c577b098SGustavo F. Padovan #ifdef CONFIG_X86_32 70c577b098SGustavo F. Padovan FIX_HOLE, 71c577b098SGustavo F. Padovan #else 721ad83c85SAndy Lutomirski #ifdef CONFIG_X86_VSYSCALL_EMULATION 73f40c3300SAndy Lutomirski VSYSCALL_PAGE = (FIXADDR_TOP - VSYSCALL_ADDR) >> PAGE_SHIFT, 741ad83c85SAndy Lutomirski #endif 7571056ae2SMarcelo Tosatti #ifdef CONFIG_PARAVIRT_CLOCK 7671056ae2SMarcelo Tosatti PVCLOCK_FIXMAP_BEGIN, 7771056ae2SMarcelo Tosatti PVCLOCK_FIXMAP_END = PVCLOCK_FIXMAP_BEGIN+PVCLOCK_VSYSCALL_NR_PAGES-1, 7871056ae2SMarcelo Tosatti #endif 79cbdce7b2SJan Beulich #endif 80c577b098SGustavo F. Padovan FIX_DBGP_BASE, 81c577b098SGustavo F. Padovan FIX_EARLYCON_MEM_BASE, 82ff30a054SJan Beulich #ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT 83ff30a054SJan Beulich FIX_OHCI1394_BASE, 84ff30a054SJan Beulich #endif 85c577b098SGustavo F. Padovan #ifdef CONFIG_X86_LOCAL_APIC 86c577b098SGustavo F. Padovan FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */ 87c577b098SGustavo F. Padovan #endif 88c577b098SGustavo F. Padovan #ifdef CONFIG_X86_IO_APIC 89c577b098SGustavo F. Padovan FIX_IO_APIC_BASE_0, 90c577b098SGustavo F. Padovan FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS - 1, 91c577b098SGustavo F. Padovan #endif 924eefbe79SKees Cook FIX_RO_IDT, /* Virtual mapping for read-only IDT */ 93c577b098SGustavo F. Padovan #ifdef CONFIG_X86_32 94c577b098SGustavo F. Padovan FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ 95c577b098SGustavo F. Padovan FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1, 96c577b098SGustavo F. Padovan #ifdef CONFIG_PCI_MMCONFIG 97c577b098SGustavo F. Padovan FIX_PCIE_MCFG, 98c577b098SGustavo F. Padovan #endif 99c577b098SGustavo F. Padovan #endif 100c577b098SGustavo F. Padovan #ifdef CONFIG_PARAVIRT 101c577b098SGustavo F. Padovan FIX_PARAVIRT_BOOTMAP, 102c577b098SGustavo F. Padovan #endif 10312b9d7ccSMathieu Desnoyers FIX_TEXT_POKE1, /* reserve 2 pages for text_poke() */ 10412b9d7ccSMathieu Desnoyers FIX_TEXT_POKE0, /* first page is last, because allocation is backward */ 105933b9463SAlan Cox #ifdef CONFIG_X86_INTEL_MID 1067309282cSFeng Tang FIX_LNW_VRTC, 1077309282cSFeng Tang #endif 108fa36e956SArjan van de Ven __end_of_permanent_fixed_addresses, 109fa36e956SArjan van de Ven 110c577b098SGustavo F. Padovan /* 1113eddc69fSDave Young * 512 temporary boot-time mappings, used by early_ioremap(), 112c577b098SGustavo F. Padovan * before ioremap() is functional. 113c577b098SGustavo F. Padovan * 1143eddc69fSDave Young * If necessary we round it up to the next 512 pages boundary so 115499a5f1eSJan Beulich * that we can have a single pgd entry and a single pte table: 116c577b098SGustavo F. Padovan */ 117c577b098SGustavo F. Padovan #define NR_FIX_BTMAPS 64 1183eddc69fSDave Young #define FIX_BTMAPS_SLOTS 8 119499a5f1eSJan Beulich #define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS) 120499a5f1eSJan Beulich FIX_BTMAP_END = 121499a5f1eSJan Beulich (__end_of_permanent_fixed_addresses ^ 122499a5f1eSJan Beulich (__end_of_permanent_fixed_addresses + TOTAL_FIX_BTMAPS - 1)) & 123499a5f1eSJan Beulich -PTRS_PER_PTE 124499a5f1eSJan Beulich ? __end_of_permanent_fixed_addresses + TOTAL_FIX_BTMAPS - 125499a5f1eSJan Beulich (__end_of_permanent_fixed_addresses & (TOTAL_FIX_BTMAPS - 1)) 126499a5f1eSJan Beulich : __end_of_permanent_fixed_addresses, 127499a5f1eSJan Beulich FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1, 128c577b098SGustavo F. Padovan #ifdef CONFIG_X86_32 129c577b098SGustavo F. Padovan FIX_WP_TEST, 130c577b098SGustavo F. Padovan #endif 13131625340SJoseph Cihula #ifdef CONFIG_INTEL_TXT 13231625340SJoseph Cihula FIX_TBOOT_BASE, 13331625340SJoseph Cihula #endif 134c577b098SGustavo F. Padovan __end_of_fixed_addresses 135c577b098SGustavo F. Padovan }; 136c577b098SGustavo F. Padovan 137c577b098SGustavo F. Padovan 138c577b098SGustavo F. Padovan extern void reserve_top_address(unsigned long reserve); 139c577b098SGustavo F. Padovan 140c577b098SGustavo F. Padovan #define FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT) 141c577b098SGustavo F. Padovan #define FIXADDR_BOOT_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) 142c577b098SGustavo F. Padovan #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) 143c577b098SGustavo F. Padovan #define FIXADDR_BOOT_START (FIXADDR_TOP - FIXADDR_BOOT_SIZE) 144bb898558SAl Viro 145bb898558SAl Viro extern int fixmaps_set; 146bb898558SAl Viro 147fd940934SKeith Packard extern pte_t *kmap_pte; 148fd940934SKeith Packard extern pgprot_t kmap_prot; 149fd940934SKeith Packard extern pte_t *pkmap_page_table; 150fd940934SKeith Packard 151bb898558SAl Viro void __native_set_fixmap(enum fixed_addresses idx, pte_t pte); 152bb898558SAl Viro void native_set_fixmap(enum fixed_addresses idx, 1533b3809acSMasami Hiramatsu phys_addr_t phys, pgprot_t flags); 154bb898558SAl Viro 155bb898558SAl Viro #ifndef CONFIG_PARAVIRT 156bb898558SAl Viro static inline void __set_fixmap(enum fixed_addresses idx, 1573b3809acSMasami Hiramatsu phys_addr_t phys, pgprot_t flags) 158bb898558SAl Viro { 159bb898558SAl Viro native_set_fixmap(idx, phys, flags); 160bb898558SAl Viro } 161bb898558SAl Viro #endif 162bb898558SAl Viro 163114cefc8SMark Salter #include <asm-generic/fixmap.h> 1645a47c7daSFeng Tang 1655b7c73e0SMark Salter #define __late_set_fixmap(idx, phys, flags) __set_fixmap(idx, phys, flags) 1665b7c73e0SMark Salter #define __late_clear_fixmap(idx) __set_fixmap(idx, 0, __pgprot(0)) 1675b7c73e0SMark Salter 1685b7c73e0SMark Salter void __early_set_fixmap(enum fixed_addresses idx, 1695b7c73e0SMark Salter phys_addr_t phys, pgprot_t flags); 1705b7c73e0SMark Salter 171c577b098SGustavo F. Padovan #endif /* !__ASSEMBLY__ */ 1721965aae3SH. Peter Anvin #endif /* _ASM_X86_FIXMAP_H */ 173