Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tile: parameterize VA and PA space more cleanly

The existing code relied on the hardware definition (<arch/chip.h>)
to specify how much VA and PA space was available. It's convenient
to allow customizing this for some configurations, so provide symbols
MAX_PA_WIDTH and MAX_VA_WIDTH in <asm/page.h> that can be modified
if desired.

Additionally, move away from the MEM_XX_INTRPT nomenclature to
define the start of various regions within the VA space. In fact
the cleaner symbol is, for example, MEM_SV_START, to indicate the
start of the area used for supervisor code; the actual address of the
interrupt vectors is not as important, and can be changed if desired.
As part of this change, convert from "intrpt1" nomenclature (which
built in the old privilege-level 1 model) to a simple "intrpt".

Also strip out some tilepro-specific code supporting modifying the
PL the kernel could run at, since we don't actually support using
different PLs in tilepro, only tilegx.

Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>

+51 -60
+21 -31
arch/tile/include/asm/page.h
··· 148 148 #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA 149 149 #endif 150 150 151 + /* Allow overriding how much VA or PA the kernel will use. */ 152 + #define MAX_PA_WIDTH CHIP_PA_WIDTH() 153 + #define MAX_VA_WIDTH CHIP_VA_WIDTH() 154 + 151 155 /* Each memory controller has PAs distinct in their high bits. */ 152 - #define NR_PA_HIGHBIT_SHIFT (CHIP_PA_WIDTH() - CHIP_LOG_NUM_MSHIMS()) 156 + #define NR_PA_HIGHBIT_SHIFT (MAX_PA_WIDTH - CHIP_LOG_NUM_MSHIMS()) 153 157 #define NR_PA_HIGHBIT_VALUES (1 << CHIP_LOG_NUM_MSHIMS()) 154 158 #define __pa_to_highbits(pa) ((phys_addr_t)(pa) >> NR_PA_HIGHBIT_SHIFT) 155 159 #define __pfn_to_highbits(pfn) ((pfn) >> (NR_PA_HIGHBIT_SHIFT - PAGE_SHIFT)) ··· 164 160 * We reserve the lower half of memory for user-space programs, and the 165 161 * upper half for system code. We re-map all of physical memory in the 166 162 * upper half, which takes a quarter of our VA space. Then we have 167 - * the vmalloc regions. The supervisor code lives at 0xfffffff700000000, 163 + * the vmalloc regions. The supervisor code lives at the highest address, 168 164 * with the hypervisor above that. 169 165 * 170 166 * Loadable kernel modules are placed immediately after the static ··· 176 172 * Similarly, for now we don't play any struct page mapping games. 177 173 */ 178 174 179 - #if CHIP_PA_WIDTH() + 2 > CHIP_VA_WIDTH() 175 + #if MAX_PA_WIDTH + 2 > MAX_VA_WIDTH 180 176 # error Too much PA to map with the VA available! 181 177 #endif 182 - #define HALF_VA_SPACE (_AC(1, UL) << (CHIP_VA_WIDTH() - 1)) 183 178 184 - #define MEM_LOW_END (HALF_VA_SPACE - 1) /* low half */ 185 - #define MEM_HIGH_START (-HALF_VA_SPACE) /* high half */ 186 - #define PAGE_OFFSET MEM_HIGH_START 187 - #define FIXADDR_BASE _AC(0xfffffff400000000, UL) /* 4 GB */ 188 - #define FIXADDR_TOP _AC(0xfffffff500000000, UL) /* 4 GB */ 179 + #define PAGE_OFFSET (-(_AC(1, UL) << (MAX_VA_WIDTH - 1))) 180 + #define KERNEL_HIGH_VADDR _AC(0xfffffff800000000, UL) /* high 32GB */ 181 + #define FIXADDR_BASE (KERNEL_HIGH_VADDR - 0x400000000) /* 4 GB */ 182 + #define FIXADDR_TOP (KERNEL_HIGH_VADDR - 0x300000000) /* 4 GB */ 189 183 #define _VMALLOC_START FIXADDR_TOP 190 - #define HUGE_VMAP_BASE _AC(0xfffffff600000000, UL) /* 4 GB */ 191 - #define MEM_SV_START _AC(0xfffffff700000000, UL) /* 256 MB */ 192 - #define MEM_SV_INTRPT MEM_SV_START 193 - #define MEM_MODULE_START _AC(0xfffffff710000000, UL) /* 256 MB */ 184 + #define HUGE_VMAP_BASE (KERNEL_HIGH_VADDR - 0x200000000) /* 4 GB */ 185 + #define MEM_SV_START (KERNEL_HIGH_VADDR - 0x100000000) /* 256 MB */ 186 + #define MEM_MODULE_START (MEM_SV_START + (256*1024*1024)) /* 256 MB */ 194 187 #define MEM_MODULE_END (MEM_MODULE_START + (256*1024*1024)) 195 - #define MEM_HV_START _AC(0xfffffff800000000, UL) /* 32 GB */ 196 - 197 - /* Highest DTLB address we will use */ 198 - #define KERNEL_HIGH_VADDR MEM_SV_START 199 188 200 189 #else /* !__tilegx__ */ 201 190 ··· 210 213 * values, and after that, we show "typical" values, since the actual 211 214 * addresses depend on kernel #defines. 212 215 * 213 - * MEM_HV_INTRPT 0xfe000000 214 - * MEM_SV_INTRPT (kernel code) 0xfd000000 216 + * MEM_HV_START 0xfe000000 217 + * MEM_SV_START (kernel code) 0xfd000000 215 218 * MEM_USER_INTRPT (user vector) 0xfc000000 216 - * FIX_KMAP_xxx 0xf8000000 (via NR_CPUS * KM_TYPE_NR) 217 - * PKMAP_BASE 0xf7000000 (via LAST_PKMAP) 218 - * HUGE_VMAP 0xf3000000 (via CONFIG_NR_HUGE_VMAPS) 219 - * VMALLOC_START 0xf0000000 (via __VMALLOC_RESERVE) 219 + * FIX_KMAP_xxx 0xfa000000 (via NR_CPUS * KM_TYPE_NR) 220 + * PKMAP_BASE 0xf9000000 (via LAST_PKMAP) 221 + * VMALLOC_START 0xf7000000 (via VMALLOC_RESERVE) 220 222 * mapped LOWMEM 0xc0000000 221 223 */ 222 224 223 225 #define MEM_USER_INTRPT _AC(0xfc000000, UL) 224 - #if CONFIG_KERNEL_PL == 1 225 - #define MEM_SV_INTRPT _AC(0xfd000000, UL) 226 - #define MEM_HV_INTRPT _AC(0xfe000000, UL) 227 - #else 228 - #define MEM_GUEST_INTRPT _AC(0xfd000000, UL) 229 - #define MEM_SV_INTRPT _AC(0xfe000000, UL) 230 - #define MEM_HV_INTRPT _AC(0xff000000, UL) 231 - #endif 226 + #define MEM_SV_START _AC(0xfd000000, UL) 227 + #define MEM_HV_START _AC(0xfe000000, UL) 232 228 233 229 #define INTRPT_SIZE 0x4000 234 230
+1 -1
arch/tile/include/asm/pgtable_32.h
··· 89 89 /* We don't define any pgds for these addresses. */ 90 90 static inline int pgd_addr_invalid(unsigned long addr) 91 91 { 92 - return addr >= MEM_HV_INTRPT; 92 + return addr >= MEM_HV_START; 93 93 } 94 94 95 95 /*
+1 -2
arch/tile/include/asm/pgtable_64.h
··· 140 140 /* We don't define any pgds for these addresses. */ 141 141 static inline int pgd_addr_invalid(unsigned long addr) 142 142 { 143 - return addr >= MEM_HV_START || 144 - (addr > MEM_LOW_END && addr < MEM_HIGH_START); 143 + return addr >= KERNEL_HIGH_VADDR || addr != pgd_addr_normalize(addr); 145 144 } 146 145 147 146 /*
+1 -1
arch/tile/include/asm/processor.h
··· 168 168 #ifndef __ASSEMBLY__ 169 169 170 170 #ifdef __tilegx__ 171 - #define TASK_SIZE_MAX (MEM_LOW_END + 1) 171 + #define TASK_SIZE_MAX (_AC(1, UL) << (MAX_VA_WIDTH - 1)) 172 172 #else 173 173 #define TASK_SIZE_MAX PAGE_OFFSET 174 174 #endif
+2 -2
arch/tile/kernel/head_32.S
··· 162 162 .set addr, addr + PGDIR_SIZE 163 163 .endr 164 164 165 - /* The true text VAs are mapped as VA = PA + MEM_SV_INTRPT */ 166 - PTE MEM_SV_INTRPT, 0, (1 << (HV_PTE_INDEX_READABLE - 32)) | \ 165 + /* The true text VAs are mapped as VA = PA + MEM_SV_START */ 166 + PTE MEM_SV_START, 0, (1 << (HV_PTE_INDEX_READABLE - 32)) | \ 167 167 (1 << (HV_PTE_INDEX_EXECUTABLE - 32)) 168 168 .org swapper_pg_dir + PGDIR_SIZE 169 169 END(swapper_pg_dir)
+3 -3
arch/tile/kernel/head_64.S
··· 135 135 1: 136 136 137 137 /* Install the interrupt base. */ 138 - moveli r0, hw2_last(MEM_SV_START) 139 - shl16insli r0, r0, hw1(MEM_SV_START) 140 - shl16insli r0, r0, hw0(MEM_SV_START) 138 + moveli r0, hw2_last(intrpt_start) 139 + shl16insli r0, r0, hw1(intrpt_start) 140 + shl16insli r0, r0, hw0(intrpt_start) 141 141 mtspr SPR_INTERRUPT_VECTOR_BASE_K, r0 142 142 143 143 /* Get our processor number and save it away in SAVE_K_0. */
+3 -3
arch/tile/kernel/intvec_32.S
··· 353 353 #ifdef __COLLECT_LINKER_FEEDBACK__ 354 354 .pushsection .text.intvec_feedback,"ax" 355 355 .org (\vecnum << 5) 356 - FEEDBACK_ENTER_EXPLICIT(intvec_\vecname, .intrpt1, 1 << 8) 356 + FEEDBACK_ENTER_EXPLICIT(intvec_\vecname, .intrpt, 1 << 8) 357 357 jrp lr 358 358 .popsection 359 359 #endif ··· 1890 1890 push_extra_callee_saves r0 1891 1891 j do_trap 1892 1892 1893 - /* Include .intrpt1 array of interrupt vectors */ 1894 - .section ".intrpt1", "ax" 1893 + /* Include .intrpt array of interrupt vectors */ 1894 + .section ".intrpt", "ax" 1895 1895 1896 1896 #define op_handle_perf_interrupt bad_intr 1897 1897 #define op_handle_aux_perf_interrupt bad_intr
+5 -3
arch/tile/kernel/intvec_64.S
··· 535 535 #ifdef __COLLECT_LINKER_FEEDBACK__ 536 536 .pushsection .text.intvec_feedback,"ax" 537 537 .org (\vecnum << 5) 538 - FEEDBACK_ENTER_EXPLICIT(intvec_\vecname, .intrpt1, 1 << 8) 538 + FEEDBACK_ENTER_EXPLICIT(intvec_\vecname, .intrpt, 1 << 8) 539 539 jrp lr 540 540 .popsection 541 541 #endif ··· 1485 1485 __int_hand \vecnum, \vecname, \c_routine, \processing 1486 1486 .endm 1487 1487 1488 - /* Include .intrpt1 array of interrupt vectors */ 1489 - .section ".intrpt1", "ax" 1488 + /* Include .intrpt array of interrupt vectors */ 1489 + .section ".intrpt", "ax" 1490 + .global intrpt_start 1491 + intrpt_start: 1490 1492 1491 1493 #define op_handle_perf_interrupt bad_intr 1492 1494 #define op_handle_aux_perf_interrupt bad_intr
+4 -4
arch/tile/kernel/setup.c
··· 268 268 /* 269 269 * Determine for each controller where its lowmem is mapped and how much of 270 270 * it is mapped there. On controller zero, the first few megabytes are 271 - * already mapped in as code at MEM_SV_INTRPT, so in principle we could 271 + * already mapped in as code at MEM_SV_START, so in principle we could 272 272 * start our data mappings higher up, but for now we don't bother, to avoid 273 273 * additional confusion. 274 274 * ··· 1242 1242 #ifndef __tilegx__ /* FIXME: GX: probably some validation relevant here */ 1243 1243 /* 1244 1244 * Similarly, make sure we're only using allowed VAs. 1245 - * We assume we can contiguously use MEM_USER_INTRPT .. MEM_HV_INTRPT, 1245 + * We assume we can contiguously use MEM_USER_INTRPT .. MEM_HV_START, 1246 1246 * and 0 .. KERNEL_HIGH_VADDR. 1247 1247 * In addition, make sure we CAN'T use the end of memory, since 1248 1248 * we use the last chunk of each pgd for the pgd_list. ··· 1257 1257 if (range.size == 0) 1258 1258 break; 1259 1259 if (range.start <= MEM_USER_INTRPT && 1260 - range.start + range.size >= MEM_HV_INTRPT) 1260 + range.start + range.size >= MEM_HV_START) 1261 1261 user_kernel_ok = 1; 1262 1262 if (range.start == 0) 1263 1263 max_va = range.size; ··· 1693 1693 static int __init request_standard_resources(void) 1694 1694 { 1695 1695 int i; 1696 - enum { CODE_DELTA = MEM_SV_INTRPT - PAGE_OFFSET }; 1696 + enum { CODE_DELTA = MEM_SV_START - PAGE_OFFSET }; 1697 1697 1698 1698 #if defined(CONFIG_PCI) && !defined(__tilegx__) 1699 1699 insert_non_bus_resource();
+1 -1
arch/tile/kernel/traps.c
··· 30 30 31 31 void __init trap_init(void) 32 32 { 33 - /* Nothing needed here since we link code at .intrpt1 */ 33 + /* Nothing needed here since we link code at .intrpt */ 34 34 } 35 35 36 36 int unaligned_fixup = 1;
+5 -5
arch/tile/kernel/vmlinux.lds.S
··· 5 5 #include <hv/hypervisor.h> 6 6 7 7 /* Text loads starting from the supervisor interrupt vector address. */ 8 - #define TEXT_OFFSET MEM_SV_INTRPT 8 + #define TEXT_OFFSET MEM_SV_START 9 9 10 10 OUTPUT_ARCH(tile) 11 11 ENTRY(_start) ··· 13 13 14 14 PHDRS 15 15 { 16 - intrpt1 PT_LOAD ; 16 + intrpt PT_LOAD ; 17 17 text PT_LOAD ; 18 18 data PT_LOAD ; 19 19 } ··· 24 24 #define LOAD_OFFSET TEXT_OFFSET 25 25 26 26 /* Interrupt vectors */ 27 - .intrpt1 (LOAD_OFFSET) : AT ( 0 ) /* put at the start of physical memory */ 27 + .intrpt (LOAD_OFFSET) : AT ( 0 ) /* put at the start of physical memory */ 28 28 { 29 29 _text = .; 30 - *(.intrpt1) 31 - } :intrpt1 =0 30 + *(.intrpt) 31 + } :intrpt =0 32 32 33 33 /* Hypervisor call vectors */ 34 34 . = ALIGN(0x10000);
+4 -4
arch/tile/mm/init.c
··· 234 234 { 235 235 int cpu; 236 236 unsigned long page; 237 - enum { CODE_DELTA = MEM_SV_INTRPT - PAGE_OFFSET }; 237 + enum { CODE_DELTA = MEM_SV_START - PAGE_OFFSET }; 238 238 239 239 #if CHIP_HAS_CBOX_HOME_MAP() 240 240 /* For kdata=huge, everything is just hash-for-home. */ ··· 538 538 } 539 539 } 540 540 541 - address = MEM_SV_INTRPT; 541 + address = MEM_SV_START; 542 542 pmd = get_pmd(pgtables, address); 543 543 pfn = 0; /* code starts at PA 0 */ 544 544 if (ktext_small) { ··· 1021 1021 1022 1022 void free_initmem(void) 1023 1023 { 1024 - const unsigned long text_delta = MEM_SV_INTRPT - PAGE_OFFSET; 1024 + const unsigned long text_delta = MEM_SV_START - PAGE_OFFSET; 1025 1025 1026 1026 /* 1027 1027 * Evict the dirty initdata on the boot cpu, evict the w1data ··· 1040 1040 1041 1041 /* 1042 1042 * Free the pages mapped from 0xc0000000 that correspond to code 1043 - * pages from MEM_SV_INTRPT that we won't use again after init. 1043 + * pages from MEM_SV_START that we won't use again after init. 1044 1044 */ 1045 1045 free_init_pages("unused kernel text", 1046 1046 (unsigned long)_sinittext - text_delta,