hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/arch/powerpc/include/asm/processor.h
....@@ -1,13 +1,9 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 #ifndef _ASM_POWERPC_PROCESSOR_H
23 #define _ASM_POWERPC_PROCESSOR_H
34
45 /*
56 * 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.
117 */
128
139 #include <asm/reg.h>
....@@ -32,15 +28,15 @@
3228 /* Default SMT priority is set to 3. Use 11- 13bits to save priority. */
3329 #define PPR_PRIORITY 3
3430 #ifdef __ASSEMBLY__
35
-#define INIT_PPR (PPR_PRIORITY << 50)
31
+#define DEFAULT_PPR (PPR_PRIORITY << 50)
3632 #else
37
-#define INIT_PPR ((u64)PPR_PRIORITY << 50)
33
+#define DEFAULT_PPR ((u64)PPR_PRIORITY << 50)
3834 #endif /* __ASSEMBLY__ */
3935 #endif /* CONFIG_PPC64 */
4036
4137 #ifndef __ASSEMBLY__
4238 #include <linux/types.h>
43
-#include <asm/thread_info.h>
39
+#include <linux/thread_info.h>
4440 #include <asm/ptrace.h>
4541 #include <asm/hw_breakpoint.h>
4642
....@@ -67,12 +63,6 @@
6763
6864 #endif /* defined(__KERNEL__) && defined(CONFIG_PPC32) */
6965
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
-
7666 /* Macros for adjusting thread priority (hardware multi-threading) */
7767 #define HMT_very_low() asm volatile("or 31,31,31 # very low priority")
7868 #define HMT_low() asm volatile("or 1,1,1 # low priority")
....@@ -83,109 +73,15 @@
8373
8474 #ifdef __KERNEL__
8575
76
+#ifdef CONFIG_PPC64
77
+#include <asm/task_size_64.h>
78
+#else
79
+#include <asm/task_size_32.h>
80
+#endif
81
+
8682 struct task_struct;
8783 void start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp);
8884 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;
18985
19086 #define TS_FPR(i) fp_state.fpr[i][TS_FPROFFSET]
19187 #define TS_CKFPR(i) ckfp_state.fpr[i][TS_FPROFFSET]
....@@ -248,7 +144,6 @@
248144 unsigned long ksp_vsid;
249145 #endif
250146 struct pt_regs *regs; /* Pointer to saved register state */
251
- mm_segment_t addr_limit; /* for get_fs() validation */
252147 #ifdef CONFIG_BOOKE
253148 /* BookE base exception scratch space; align on cacheline */
254149 unsigned long normsave[8] ____cacheline_aligned;
....@@ -256,6 +151,22 @@
256151 #ifdef CONFIG_PPC32
257152 void *pgdir; /* root of page-table tree */
258153 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
259170 #endif
260171 /* Debug Registers */
261172 struct debug_reg debug;
....@@ -264,15 +175,16 @@
264175 int fpexc_mode; /* floating-point exception mode */
265176 unsigned int align_ctl; /* alignment handling control */
266177 #ifdef CONFIG_HAVE_HW_BREAKPOINT
267
- struct perf_event *ptrace_bps[HBP_NUM];
178
+ struct perf_event *ptrace_bps[HBP_NUM_MAX];
268179 /*
269180 * Helps identify source of single-step exception and subsequent
270181 * hw-breakpoint enablement
271182 */
272
- struct perf_event *last_hit_ubp;
183
+ struct perf_event *last_hit_ubp[HBP_NUM_MAX];
273184 #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 */
275186 unsigned long trap_nr; /* last trap # on this thread */
187
+ u8 load_slb; /* Ages out SLB preload cache entries */
276188 u8 load_fp;
277189 #ifdef CONFIG_ALTIVEC
278190 u8 load_vec;
....@@ -303,6 +215,7 @@
303215 unsigned long tm_tar;
304216 unsigned long tm_ppr;
305217 unsigned long tm_dscr;
218
+ unsigned long tm_amr;
306219
307220 /*
308221 * Checkpointed FP and VSX 0-31 register set.
....@@ -320,7 +233,6 @@
320233 #ifdef CONFIG_PPC_MEM_KEYS
321234 unsigned long amr;
322235 unsigned long iamr;
323
- unsigned long uamor;
324236 #endif
325237 #ifdef CONFIG_KVM_BOOK3S_32_HANDLER
326238 void* kvm_shadow_vcpu; /* KVM internal data */
....@@ -341,7 +253,6 @@
341253 * onwards.
342254 */
343255 int dscr_inherit;
344
- unsigned long ppr; /* used to save/restore SMT priority */
345256 unsigned long tidr;
346257 #endif
347258 #ifdef CONFIG_PPC_BOOK3S_64
....@@ -356,15 +267,17 @@
356267 unsigned mmcr0;
357268
358269 unsigned used_ebb;
359
- unsigned int used_vas;
270
+ unsigned long mmcr3;
271
+ unsigned long sier2;
272
+ unsigned long sier3;
273
+
360274 #endif
361275 };
362276
363277 #define ARCH_MIN_TASKALIGN 16
364278
365279 #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)
368281
369282 #ifdef CONFIG_SPE
370283 #define SPEFSCR_INIT \
....@@ -378,7 +291,6 @@
378291 #define INIT_THREAD { \
379292 .ksp = INIT_SP, \
380293 .ksp_limit = INIT_SP_LIMIT, \
381
- .addr_limit = KERNEL_DS, \
382294 .pgdir = swapper_pg_dir, \
383295 .fpexc_mode = MSR_FE0 | MSR_FE1, \
384296 SPEFSCR_INIT \
....@@ -386,14 +298,11 @@
386298 #else
387299 #define INIT_THREAD { \
388300 .ksp = INIT_SP, \
389
- .addr_limit = KERNEL_DS, \
390301 .fpexc_mode = 0, \
391
- .ppr = INIT_PPR, \
392
- .fscr = FSCR_TAR | FSCR_EBB \
393302 }
394303 #endif
395304
396
-#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.regs)
305
+#define task_pt_regs(tsk) ((tsk)->thread.regs)
397306
398307 unsigned long get_wchan(struct task_struct *p);
399308
....@@ -440,8 +349,6 @@
440349 #define spin_begin() HMT_low()
441350
442351 #define spin_cpu_relax() barrier()
443
-
444
-#define spin_cpu_yield() spin_cpu_relax()
445352
446353 #define spin_end() HMT_medium()
447354
....@@ -505,24 +412,24 @@
505412 }
506413 #endif
507414
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
+
508423 extern unsigned long cpuidle_disable;
509424 enum idle_boot_override {IDLE_NO_OVERRIDE = 0, IDLE_POWERSAVE_OFF};
510425
511426 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
+
513428 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,
517430 unsigned long stop_psscr_mask);
518431
519
-extern void flush_instruction_cache(void);
520
-extern void hard_reset_now(void);
521
-extern void poweroff_now(void);
522432 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);
526433
527434 #ifdef CONFIG_PPC64
528435 /*