.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | #ifndef _ASM_POWERPC_PROCESSOR_H |
---|
2 | 3 | #define _ASM_POWERPC_PROCESSOR_H |
---|
3 | 4 | |
---|
4 | 5 | /* |
---|
5 | 6 | * Copyright (C) 2001 PPC 64 Team, IBM Corp |
---|
6 | | - * |
---|
7 | | - * This program is free software; you can redistribute it and/or |
---|
8 | | - * modify it under the terms of the GNU General Public License |
---|
9 | | - * as published by the Free Software Foundation; either version |
---|
10 | | - * 2 of the License, or (at your option) any later version. |
---|
11 | 7 | */ |
---|
12 | 8 | |
---|
13 | 9 | #include <asm/reg.h> |
---|
.. | .. |
---|
32 | 28 | /* Default SMT priority is set to 3. Use 11- 13bits to save priority. */ |
---|
33 | 29 | #define PPR_PRIORITY 3 |
---|
34 | 30 | #ifdef __ASSEMBLY__ |
---|
35 | | -#define INIT_PPR (PPR_PRIORITY << 50) |
---|
| 31 | +#define DEFAULT_PPR (PPR_PRIORITY << 50) |
---|
36 | 32 | #else |
---|
37 | | -#define INIT_PPR ((u64)PPR_PRIORITY << 50) |
---|
| 33 | +#define DEFAULT_PPR ((u64)PPR_PRIORITY << 50) |
---|
38 | 34 | #endif /* __ASSEMBLY__ */ |
---|
39 | 35 | #endif /* CONFIG_PPC64 */ |
---|
40 | 36 | |
---|
41 | 37 | #ifndef __ASSEMBLY__ |
---|
42 | 38 | #include <linux/types.h> |
---|
43 | | -#include <asm/thread_info.h> |
---|
| 39 | +#include <linux/thread_info.h> |
---|
44 | 40 | #include <asm/ptrace.h> |
---|
45 | 41 | #include <asm/hw_breakpoint.h> |
---|
46 | 42 | |
---|
.. | .. |
---|
67 | 63 | |
---|
68 | 64 | #endif /* defined(__KERNEL__) && defined(CONFIG_PPC32) */ |
---|
69 | 65 | |
---|
70 | | -/* |
---|
71 | | - * Default implementation of macro that returns current |
---|
72 | | - * instruction pointer ("program counter"). |
---|
73 | | - */ |
---|
74 | | -#define current_text_addr() ({ __label__ _l; _l: &&_l;}) |
---|
75 | | - |
---|
76 | 66 | /* Macros for adjusting thread priority (hardware multi-threading) */ |
---|
77 | 67 | #define HMT_very_low() asm volatile("or 31,31,31 # very low priority") |
---|
78 | 68 | #define HMT_low() asm volatile("or 1,1,1 # low priority") |
---|
.. | .. |
---|
83 | 73 | |
---|
84 | 74 | #ifdef __KERNEL__ |
---|
85 | 75 | |
---|
| 76 | +#ifdef CONFIG_PPC64 |
---|
| 77 | +#include <asm/task_size_64.h> |
---|
| 78 | +#else |
---|
| 79 | +#include <asm/task_size_32.h> |
---|
| 80 | +#endif |
---|
| 81 | + |
---|
86 | 82 | struct task_struct; |
---|
87 | 83 | void start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp); |
---|
88 | 84 | void release_thread(struct task_struct *); |
---|
89 | | - |
---|
90 | | -#ifdef CONFIG_PPC32 |
---|
91 | | - |
---|
92 | | -#if CONFIG_TASK_SIZE > CONFIG_KERNEL_START |
---|
93 | | -#error User TASK_SIZE overlaps with KERNEL_START address |
---|
94 | | -#endif |
---|
95 | | -#define TASK_SIZE (CONFIG_TASK_SIZE) |
---|
96 | | - |
---|
97 | | -/* This decides where the kernel will search for a free chunk of vm |
---|
98 | | - * space during mmap's. |
---|
99 | | - */ |
---|
100 | | -#define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3) |
---|
101 | | -#endif |
---|
102 | | - |
---|
103 | | -#ifdef CONFIG_PPC64 |
---|
104 | | -/* |
---|
105 | | - * 64-bit user address space can have multiple limits |
---|
106 | | - * For now supported values are: |
---|
107 | | - */ |
---|
108 | | -#define TASK_SIZE_64TB (0x0000400000000000UL) |
---|
109 | | -#define TASK_SIZE_128TB (0x0000800000000000UL) |
---|
110 | | -#define TASK_SIZE_512TB (0x0002000000000000UL) |
---|
111 | | -#define TASK_SIZE_1PB (0x0004000000000000UL) |
---|
112 | | -#define TASK_SIZE_2PB (0x0008000000000000UL) |
---|
113 | | -/* |
---|
114 | | - * With 52 bits in the address we can support |
---|
115 | | - * upto 4PB of range. |
---|
116 | | - */ |
---|
117 | | -#define TASK_SIZE_4PB (0x0010000000000000UL) |
---|
118 | | - |
---|
119 | | -/* |
---|
120 | | - * For now 512TB is only supported with book3s and 64K linux page size. |
---|
121 | | - */ |
---|
122 | | -#if defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_PPC_64K_PAGES) |
---|
123 | | -/* |
---|
124 | | - * Max value currently used: |
---|
125 | | - */ |
---|
126 | | -#define TASK_SIZE_USER64 TASK_SIZE_4PB |
---|
127 | | -#define DEFAULT_MAP_WINDOW_USER64 TASK_SIZE_128TB |
---|
128 | | -#define TASK_CONTEXT_SIZE TASK_SIZE_512TB |
---|
129 | | -#else |
---|
130 | | -#define TASK_SIZE_USER64 TASK_SIZE_64TB |
---|
131 | | -#define DEFAULT_MAP_WINDOW_USER64 TASK_SIZE_64TB |
---|
132 | | -/* |
---|
133 | | - * We don't need to allocate extended context ids for 4K page size, because |
---|
134 | | - * we limit the max effective address on this config to 64TB. |
---|
135 | | - */ |
---|
136 | | -#define TASK_CONTEXT_SIZE TASK_SIZE_64TB |
---|
137 | | -#endif |
---|
138 | | - |
---|
139 | | -/* |
---|
140 | | - * 32-bit user address space is 4GB - 1 page |
---|
141 | | - * (this 1 page is needed so referencing of 0xFFFFFFFF generates EFAULT |
---|
142 | | - */ |
---|
143 | | -#define TASK_SIZE_USER32 (0x0000000100000000UL - (1*PAGE_SIZE)) |
---|
144 | | - |
---|
145 | | -#define TASK_SIZE_OF(tsk) (test_tsk_thread_flag(tsk, TIF_32BIT) ? \ |
---|
146 | | - TASK_SIZE_USER32 : TASK_SIZE_USER64) |
---|
147 | | -#define TASK_SIZE TASK_SIZE_OF(current) |
---|
148 | | -/* This decides where the kernel will search for a free chunk of vm |
---|
149 | | - * space during mmap's. |
---|
150 | | - */ |
---|
151 | | -#define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4)) |
---|
152 | | -#define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(DEFAULT_MAP_WINDOW_USER64 / 4)) |
---|
153 | | - |
---|
154 | | -#define TASK_UNMAPPED_BASE ((is_32bit_task()) ? \ |
---|
155 | | - TASK_UNMAPPED_BASE_USER32 : TASK_UNMAPPED_BASE_USER64 ) |
---|
156 | | -#endif |
---|
157 | | - |
---|
158 | | -/* |
---|
159 | | - * Initial task size value for user applications. For book3s 64 we start |
---|
160 | | - * with 128TB and conditionally enable upto 512TB |
---|
161 | | - */ |
---|
162 | | -#ifdef CONFIG_PPC_BOOK3S_64 |
---|
163 | | -#define DEFAULT_MAP_WINDOW ((is_32bit_task()) ? \ |
---|
164 | | - TASK_SIZE_USER32 : DEFAULT_MAP_WINDOW_USER64) |
---|
165 | | -#else |
---|
166 | | -#define DEFAULT_MAP_WINDOW TASK_SIZE |
---|
167 | | -#endif |
---|
168 | | - |
---|
169 | | -#ifdef __powerpc64__ |
---|
170 | | - |
---|
171 | | -#define STACK_TOP_USER64 DEFAULT_MAP_WINDOW_USER64 |
---|
172 | | -#define STACK_TOP_USER32 TASK_SIZE_USER32 |
---|
173 | | - |
---|
174 | | -#define STACK_TOP (is_32bit_task() ? \ |
---|
175 | | - STACK_TOP_USER32 : STACK_TOP_USER64) |
---|
176 | | - |
---|
177 | | -#define STACK_TOP_MAX TASK_SIZE_USER64 |
---|
178 | | - |
---|
179 | | -#else /* __powerpc64__ */ |
---|
180 | | - |
---|
181 | | -#define STACK_TOP TASK_SIZE |
---|
182 | | -#define STACK_TOP_MAX STACK_TOP |
---|
183 | | - |
---|
184 | | -#endif /* __powerpc64__ */ |
---|
185 | | - |
---|
186 | | -typedef struct { |
---|
187 | | - unsigned long seg; |
---|
188 | | -} mm_segment_t; |
---|
189 | 85 | |
---|
190 | 86 | #define TS_FPR(i) fp_state.fpr[i][TS_FPROFFSET] |
---|
191 | 87 | #define TS_CKFPR(i) ckfp_state.fpr[i][TS_FPROFFSET] |
---|
.. | .. |
---|
248 | 144 | unsigned long ksp_vsid; |
---|
249 | 145 | #endif |
---|
250 | 146 | struct pt_regs *regs; /* Pointer to saved register state */ |
---|
251 | | - mm_segment_t addr_limit; /* for get_fs() validation */ |
---|
252 | 147 | #ifdef CONFIG_BOOKE |
---|
253 | 148 | /* BookE base exception scratch space; align on cacheline */ |
---|
254 | 149 | unsigned long normsave[8] ____cacheline_aligned; |
---|
.. | .. |
---|
256 | 151 | #ifdef CONFIG_PPC32 |
---|
257 | 152 | void *pgdir; /* root of page-table tree */ |
---|
258 | 153 | unsigned long ksp_limit; /* if ksp <= ksp_limit stack overflow */ |
---|
| 154 | +#ifdef CONFIG_PPC_RTAS |
---|
| 155 | + unsigned long rtas_sp; /* stack pointer for when in RTAS */ |
---|
| 156 | +#endif |
---|
| 157 | +#endif |
---|
| 158 | +#if defined(CONFIG_PPC_BOOK3S_32) && defined(CONFIG_PPC_KUAP) |
---|
| 159 | + unsigned long kuap; /* opened segments for user access */ |
---|
| 160 | +#endif |
---|
| 161 | +#ifdef CONFIG_VMAP_STACK |
---|
| 162 | + unsigned long srr0; |
---|
| 163 | + unsigned long srr1; |
---|
| 164 | + unsigned long dar; |
---|
| 165 | + unsigned long dsisr; |
---|
| 166 | +#ifdef CONFIG_PPC_BOOK3S_32 |
---|
| 167 | + unsigned long r0, r3, r4, r5, r6, r8, r9, r11; |
---|
| 168 | + unsigned long lr, ctr; |
---|
| 169 | +#endif |
---|
259 | 170 | #endif |
---|
260 | 171 | /* Debug Registers */ |
---|
261 | 172 | struct debug_reg debug; |
---|
.. | .. |
---|
264 | 175 | int fpexc_mode; /* floating-point exception mode */ |
---|
265 | 176 | unsigned int align_ctl; /* alignment handling control */ |
---|
266 | 177 | #ifdef CONFIG_HAVE_HW_BREAKPOINT |
---|
267 | | - struct perf_event *ptrace_bps[HBP_NUM]; |
---|
| 178 | + struct perf_event *ptrace_bps[HBP_NUM_MAX]; |
---|
268 | 179 | /* |
---|
269 | 180 | * Helps identify source of single-step exception and subsequent |
---|
270 | 181 | * hw-breakpoint enablement |
---|
271 | 182 | */ |
---|
272 | | - struct perf_event *last_hit_ubp; |
---|
| 183 | + struct perf_event *last_hit_ubp[HBP_NUM_MAX]; |
---|
273 | 184 | #endif /* CONFIG_HAVE_HW_BREAKPOINT */ |
---|
274 | | - struct arch_hw_breakpoint hw_brk; /* info on the hardware breakpoint */ |
---|
| 185 | + struct arch_hw_breakpoint hw_brk[HBP_NUM_MAX]; /* hardware breakpoint info */ |
---|
275 | 186 | unsigned long trap_nr; /* last trap # on this thread */ |
---|
| 187 | + u8 load_slb; /* Ages out SLB preload cache entries */ |
---|
276 | 188 | u8 load_fp; |
---|
277 | 189 | #ifdef CONFIG_ALTIVEC |
---|
278 | 190 | u8 load_vec; |
---|
.. | .. |
---|
303 | 215 | unsigned long tm_tar; |
---|
304 | 216 | unsigned long tm_ppr; |
---|
305 | 217 | unsigned long tm_dscr; |
---|
| 218 | + unsigned long tm_amr; |
---|
306 | 219 | |
---|
307 | 220 | /* |
---|
308 | 221 | * Checkpointed FP and VSX 0-31 register set. |
---|
.. | .. |
---|
320 | 233 | #ifdef CONFIG_PPC_MEM_KEYS |
---|
321 | 234 | unsigned long amr; |
---|
322 | 235 | unsigned long iamr; |
---|
323 | | - unsigned long uamor; |
---|
324 | 236 | #endif |
---|
325 | 237 | #ifdef CONFIG_KVM_BOOK3S_32_HANDLER |
---|
326 | 238 | void* kvm_shadow_vcpu; /* KVM internal data */ |
---|
.. | .. |
---|
341 | 253 | * onwards. |
---|
342 | 254 | */ |
---|
343 | 255 | int dscr_inherit; |
---|
344 | | - unsigned long ppr; /* used to save/restore SMT priority */ |
---|
345 | 256 | unsigned long tidr; |
---|
346 | 257 | #endif |
---|
347 | 258 | #ifdef CONFIG_PPC_BOOK3S_64 |
---|
.. | .. |
---|
356 | 267 | unsigned mmcr0; |
---|
357 | 268 | |
---|
358 | 269 | unsigned used_ebb; |
---|
359 | | - unsigned int used_vas; |
---|
| 270 | + unsigned long mmcr3; |
---|
| 271 | + unsigned long sier2; |
---|
| 272 | + unsigned long sier3; |
---|
| 273 | + |
---|
360 | 274 | #endif |
---|
361 | 275 | }; |
---|
362 | 276 | |
---|
363 | 277 | #define ARCH_MIN_TASKALIGN 16 |
---|
364 | 278 | |
---|
365 | 279 | #define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack) |
---|
366 | | -#define INIT_SP_LIMIT \ |
---|
367 | | - (_ALIGN_UP(sizeof(init_thread_info), 16) + (unsigned long) &init_stack) |
---|
| 280 | +#define INIT_SP_LIMIT ((unsigned long)&init_stack) |
---|
368 | 281 | |
---|
369 | 282 | #ifdef CONFIG_SPE |
---|
370 | 283 | #define SPEFSCR_INIT \ |
---|
.. | .. |
---|
378 | 291 | #define INIT_THREAD { \ |
---|
379 | 292 | .ksp = INIT_SP, \ |
---|
380 | 293 | .ksp_limit = INIT_SP_LIMIT, \ |
---|
381 | | - .addr_limit = KERNEL_DS, \ |
---|
382 | 294 | .pgdir = swapper_pg_dir, \ |
---|
383 | 295 | .fpexc_mode = MSR_FE0 | MSR_FE1, \ |
---|
384 | 296 | SPEFSCR_INIT \ |
---|
.. | .. |
---|
386 | 298 | #else |
---|
387 | 299 | #define INIT_THREAD { \ |
---|
388 | 300 | .ksp = INIT_SP, \ |
---|
389 | | - .addr_limit = KERNEL_DS, \ |
---|
390 | 301 | .fpexc_mode = 0, \ |
---|
391 | | - .ppr = INIT_PPR, \ |
---|
392 | | - .fscr = FSCR_TAR | FSCR_EBB \ |
---|
393 | 302 | } |
---|
394 | 303 | #endif |
---|
395 | 304 | |
---|
396 | | -#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.regs) |
---|
| 305 | +#define task_pt_regs(tsk) ((tsk)->thread.regs) |
---|
397 | 306 | |
---|
398 | 307 | unsigned long get_wchan(struct task_struct *p); |
---|
399 | 308 | |
---|
.. | .. |
---|
440 | 349 | #define spin_begin() HMT_low() |
---|
441 | 350 | |
---|
442 | 351 | #define spin_cpu_relax() barrier() |
---|
443 | | - |
---|
444 | | -#define spin_cpu_yield() spin_cpu_relax() |
---|
445 | 352 | |
---|
446 | 353 | #define spin_end() HMT_medium() |
---|
447 | 354 | |
---|
.. | .. |
---|
505 | 412 | } |
---|
506 | 413 | #endif |
---|
507 | 414 | |
---|
| 415 | +/* asm stubs */ |
---|
| 416 | +extern unsigned long isa300_idle_stop_noloss(unsigned long psscr_val); |
---|
| 417 | +extern unsigned long isa300_idle_stop_mayloss(unsigned long psscr_val); |
---|
| 418 | +extern unsigned long isa206_idle_insn_mayloss(unsigned long type); |
---|
| 419 | +#ifdef CONFIG_PPC_970_NAP |
---|
| 420 | +extern void power4_idle_nap(void); |
---|
| 421 | +#endif |
---|
| 422 | + |
---|
508 | 423 | extern unsigned long cpuidle_disable; |
---|
509 | 424 | enum idle_boot_override {IDLE_NO_OVERRIDE = 0, IDLE_POWERSAVE_OFF}; |
---|
510 | 425 | |
---|
511 | 426 | extern int powersave_nap; /* set if nap mode can be used in idle loop */ |
---|
512 | | -extern unsigned long power7_idle_insn(unsigned long type); /* PNV_THREAD_NAP/etc*/ |
---|
| 427 | + |
---|
513 | 428 | extern void power7_idle_type(unsigned long type); |
---|
514 | | -extern unsigned long power9_idle_stop(unsigned long psscr_val); |
---|
515 | | -extern unsigned long power9_offline_stop(unsigned long psscr_val); |
---|
516 | | -extern void power9_idle_type(unsigned long stop_psscr_val, |
---|
| 429 | +extern void arch300_idle_type(unsigned long stop_psscr_val, |
---|
517 | 430 | unsigned long stop_psscr_mask); |
---|
518 | 431 | |
---|
519 | | -extern void flush_instruction_cache(void); |
---|
520 | | -extern void hard_reset_now(void); |
---|
521 | | -extern void poweroff_now(void); |
---|
522 | 432 | extern int fix_alignment(struct pt_regs *); |
---|
523 | | -extern void cvt_fd(float *from, double *to); |
---|
524 | | -extern void cvt_df(double *from, float *to); |
---|
525 | | -extern void _nmask_and_or_msr(unsigned long nmask, unsigned long or_val); |
---|
526 | 433 | |
---|
527 | 434 | #ifdef CONFIG_PPC64 |
---|
528 | 435 | /* |
---|