source: src/linux/universal/linux-4.4/arch/s390/include/asm/processor.h @ 31662

Last change on this file since 31662 was 31662, checked in by brainslayer, 2 months ago

use new squashfs in all kernels

File size: 8.0 KB
Line 
1/*
2 *  S390 version
3 *    Copyright IBM Corp. 1999
4 *    Author(s): Hartmut Penner (hp@de.ibm.com),
5 *               Martin Schwidefsky (schwidefsky@de.ibm.com)
6 *
7 *  Derived from "include/asm-i386/processor.h"
8 *    Copyright (C) 1994, Linus Torvalds
9 */
10
11#ifndef __ASM_S390_PROCESSOR_H
12#define __ASM_S390_PROCESSOR_H
13
14#include <linux/const.h>
15
16#define CIF_MCCK_PENDING        0       /* machine check handling is pending */
17#define CIF_ASCE                1       /* user asce needs fixup / uaccess */
18#define CIF_NOHZ_DELAY          2       /* delay HZ disable for a tick */
19#define CIF_FPU                 3       /* restore FPU registers */
20#define CIF_IGNORE_IRQ          4       /* ignore interrupt (for udelay) */
21
22#define _CIF_MCCK_PENDING       _BITUL(CIF_MCCK_PENDING)
23#define _CIF_ASCE               _BITUL(CIF_ASCE)
24#define _CIF_NOHZ_DELAY         _BITUL(CIF_NOHZ_DELAY)
25#define _CIF_FPU                _BITUL(CIF_FPU)
26#define _CIF_IGNORE_IRQ         _BITUL(CIF_IGNORE_IRQ)
27
28#ifndef __ASSEMBLY__
29
30#include <linux/linkage.h>
31#include <linux/irqflags.h>
32#include <asm/cpu.h>
33#include <asm/page.h>
34#include <asm/ptrace.h>
35#include <asm/setup.h>
36#include <asm/runtime_instr.h>
37#include <asm/fpu/types.h>
38#include <asm/fpu/internal.h>
39
40static inline void set_cpu_flag(int flag)
41{
42        S390_lowcore.cpu_flags |= (1UL << flag);
43}
44
45static inline void clear_cpu_flag(int flag)
46{
47        S390_lowcore.cpu_flags &= ~(1UL << flag);
48}
49
50static inline int test_cpu_flag(int flag)
51{
52        return !!(S390_lowcore.cpu_flags & (1UL << flag));
53}
54
55#define arch_needs_cpu() test_cpu_flag(CIF_NOHZ_DELAY)
56
57/*
58 * Default implementation of macro that returns current
59 * instruction pointer ("program counter").
60 */
61#define current_text_addr() ({ void *pc; asm("basr %0,0" : "=a" (pc)); pc; })
62
63static inline void get_cpu_id(struct cpuid *ptr)
64{
65        asm volatile("stidp %0" : "=Q" (*ptr));
66}
67
68extern void s390_adjust_jiffies(void);
69extern const struct seq_operations cpuinfo_op;
70extern int sysctl_ieee_emulation_warnings;
71extern void execve_tail(void);
72
73/*
74 * User space process size: 2GB for 31 bit, 4TB or 8PT for 64 bit.
75 */
76
77#define TASK_SIZE_OF(tsk)       ((tsk)->mm ? \
78                                 (tsk)->mm->context.asce_limit : TASK_MAX_SIZE)
79#define TASK_UNMAPPED_BASE      (test_thread_flag(TIF_31BIT) ? \
80                                        (1UL << 30) : (1UL << 41))
81#define TASK_SIZE               TASK_SIZE_OF(current)
82#define TASK_MAX_SIZE           (1UL << 53)
83
84#define STACK_TOP               (1UL << (test_thread_flag(TIF_31BIT) ? 31:42))
85#define STACK_TOP_MAX           (1UL << 42)
86
87#define HAVE_ARCH_PICK_MMAP_LAYOUT
88
89typedef struct {
90        __u32 ar4;
91} mm_segment_t;
92
93/*
94 * Thread structure
95 */
96struct thread_struct {
97        struct fpu fpu;                 /* FP and VX register save area */
98        unsigned int  acrs[NUM_ACRS];
99        unsigned long ksp;              /* kernel stack pointer             */
100        mm_segment_t mm_segment;
101        unsigned long gmap_addr;        /* address of last gmap fault. */
102        unsigned int gmap_pfault;       /* signal of a pending guest pfault */
103        struct per_regs per_user;       /* User specified PER registers */
104        struct per_event per_event;     /* Cause of the last PER trap */
105        unsigned long per_flags;        /* Flags to control debug behavior */
106        /* pfault_wait is used to block the process on a pfault event */
107        unsigned long pfault_wait;
108        struct list_head list;
109        /* cpu runtime instrumentation */
110        struct runtime_instr_cb *ri_cb;
111        unsigned char trap_tdb[256];    /* Transaction abort diagnose block */
112};
113
114/* Flag to disable transactions. */
115#define PER_FLAG_NO_TE                  1UL
116/* Flag to enable random transaction aborts. */
117#define PER_FLAG_TE_ABORT_RAND          2UL
118/* Flag to specify random transaction abort mode:
119 * - abort each transaction at a random instruction before TEND if set.
120 * - abort random transactions at a random instruction if cleared.
121 */
122#define PER_FLAG_TE_ABORT_RAND_TEND     4UL
123
124typedef struct thread_struct thread_struct;
125
126/*
127 * Stack layout of a C stack frame.
128 */
129#ifndef __PACK_STACK
130struct stack_frame {
131        unsigned long back_chain;
132        unsigned long empty1[5];
133        unsigned long gprs[10];
134        unsigned int  empty2[8];
135};
136#else
137struct stack_frame {
138        unsigned long empty1[5];
139        unsigned int  empty2[8];
140        unsigned long gprs[10];
141        unsigned long back_chain;
142};
143#endif
144
145#define ARCH_MIN_TASKALIGN      8
146
147extern __vector128 init_task_fpu_regs[__NUM_VXRS];
148#define INIT_THREAD {                                                   \
149        .ksp = sizeof(init_stack) + (unsigned long) &init_stack,        \
150        .fpu.regs = (void *)&init_task_fpu_regs,                        \
151}
152
153/*
154 * Do necessary setup to start up a new thread.
155 */
156#define start_thread(regs, new_psw, new_stackp) do {                    \
157        regs->psw.mask  = PSW_USER_BITS | PSW_MASK_EA | PSW_MASK_BA;    \
158        regs->psw.addr  = new_psw | PSW_ADDR_AMODE;                     \
159        regs->gprs[15]  = new_stackp;                                   \
160        execve_tail();                                                  \
161} while (0)
162
163#define start_thread31(regs, new_psw, new_stackp) do {                  \
164        regs->psw.mask  = PSW_USER_BITS | PSW_MASK_BA;                  \
165        regs->psw.addr  = new_psw | PSW_ADDR_AMODE;                     \
166        regs->gprs[15]  = new_stackp;                                   \
167        crst_table_downgrade(current->mm);                              \
168        execve_tail();                                                  \
169} while (0)
170
171/* Forward declaration, a strange C thing */
172struct task_struct;
173struct mm_struct;
174struct seq_file;
175
176void show_cacheinfo(struct seq_file *m);
177
178/* Free all resources held by a thread. */
179extern void release_thread(struct task_struct *);
180
181/*
182 * Return saved PC of a blocked thread.
183 */
184extern unsigned long thread_saved_pc(struct task_struct *t);
185
186unsigned long get_wchan(struct task_struct *p);
187#define task_pt_regs(tsk) ((struct pt_regs *) \
188        (task_stack_page(tsk) + THREAD_SIZE) - 1)
189#define KSTK_EIP(tsk)   (task_pt_regs(tsk)->psw.addr)
190#define KSTK_ESP(tsk)   (task_pt_regs(tsk)->gprs[15])
191
192/* Has task runtime instrumentation enabled ? */
193#define is_ri_task(tsk) (!!(tsk)->thread.ri_cb)
194
195static inline unsigned short stap(void)
196{
197        unsigned short cpu_address;
198
199        asm volatile("stap %0" : "=m" (cpu_address));
200        return cpu_address;
201}
202
203/*
204 * Give up the time slice of the virtual PU.
205 */
206void cpu_relax(void);
207
208#define cpu_relax_lowlatency()  barrier()
209
210static inline void psw_set_key(unsigned int key)
211{
212        asm volatile("spka 0(%0)" : : "d" (key));
213}
214
215/*
216 * Set PSW to specified value.
217 */
218static inline void __load_psw(psw_t psw)
219{
220        asm volatile("lpswe %0" : : "Q" (psw) : "cc");
221}
222
223/*
224 * Set PSW mask to specified value, while leaving the
225 * PSW addr pointing to the next instruction.
226 */
227static inline void __load_psw_mask(unsigned long mask)
228{
229        unsigned long addr;
230        psw_t psw;
231
232        psw.mask = mask;
233
234        asm volatile(
235                "       larl    %0,1f\n"
236                "       stg     %0,%O1+8(%R1)\n"
237                "       lpswe   %1\n"
238                "1:"
239                : "=&d" (addr), "=Q" (psw) : "Q" (psw) : "memory", "cc");
240}
241
242/*
243 * Extract current PSW mask
244 */
245static inline unsigned long __extract_psw(void)
246{
247        unsigned int reg1, reg2;
248
249        asm volatile("epsw %0,%1" : "=d" (reg1), "=a" (reg2));
250        return (((unsigned long) reg1) << 32) | ((unsigned long) reg2);
251}
252
253static inline void local_mcck_enable(void)
254{
255        __load_psw_mask(__extract_psw() | PSW_MASK_MCHECK);
256}
257
258static inline void local_mcck_disable(void)
259{
260        __load_psw_mask(__extract_psw() & ~PSW_MASK_MCHECK);
261}
262
263/*
264 * Rewind PSW instruction address by specified number of bytes.
265 */
266static inline unsigned long __rewind_psw(psw_t psw, unsigned long ilc)
267{
268        unsigned long mask;
269
270        mask = (psw.mask & PSW_MASK_EA) ? -1UL :
271               (psw.mask & PSW_MASK_BA) ? (1UL << 31) - 1 :
272                                          (1UL << 24) - 1;
273        return (psw.addr - ilc) & mask;
274}
275
276/*
277 * Function to stop a processor until the next interrupt occurs
278 */
279void enabled_wait(void);
280
281/*
282 * Function to drop a processor into disabled wait state
283 */
284static inline void __noreturn disabled_wait(unsigned long code)
285{
286        psw_t psw;
287
288        psw.mask = PSW_MASK_BASE | PSW_MASK_WAIT | PSW_MASK_BA | PSW_MASK_EA;
289        psw.addr = code;
290        __load_psw(psw);
291        while (1);
292}
293
294/*
295 * Basic Machine Check/Program Check Handler.
296 */
297
298extern void s390_base_mcck_handler(void);
299extern void s390_base_pgm_handler(void);
300extern void s390_base_ext_handler(void);
301
302extern void (*s390_base_mcck_handler_fn)(void);
303extern void (*s390_base_pgm_handler_fn)(void);
304extern void (*s390_base_ext_handler_fn)(void);
305
306#define ARCH_LOW_ADDRESS_LIMIT  0x7fffffffUL
307
308extern int memcpy_real(void *, void *, size_t);
309extern void memcpy_absolute(void *, void *, size_t);
310
311#define mem_assign_absolute(dest, val) {                        \
312        __typeof__(dest) __tmp = (val);                         \
313                                                                \
314        BUILD_BUG_ON(sizeof(__tmp) != sizeof(val));             \
315        memcpy_absolute(&(dest), &__tmp, sizeof(__tmp));        \
316}
317
318#endif /* __ASSEMBLY__ */
319
320#endif /* __ASM_S390_PROCESSOR_H */
Note: See TracBrowser for help on using the repository browser.