xref: /openbmc/linux/arch/s390/include/asm/processor.h (revision c929500d)
1c6557e7fSMartin Schwidefsky /*
2c6557e7fSMartin Schwidefsky  *  S390 version
3a53c8fabSHeiko Carstens  *    Copyright IBM Corp. 1999
4c6557e7fSMartin Schwidefsky  *    Author(s): Hartmut Penner (hp@de.ibm.com),
5c6557e7fSMartin Schwidefsky  *               Martin Schwidefsky (schwidefsky@de.ibm.com)
6c6557e7fSMartin Schwidefsky  *
7c6557e7fSMartin Schwidefsky  *  Derived from "include/asm-i386/processor.h"
8c6557e7fSMartin Schwidefsky  *    Copyright (C) 1994, Linus Torvalds
9c6557e7fSMartin Schwidefsky  */
10c6557e7fSMartin Schwidefsky 
11c6557e7fSMartin Schwidefsky #ifndef __ASM_S390_PROCESSOR_H
12c6557e7fSMartin Schwidefsky #define __ASM_S390_PROCESSOR_H
13c6557e7fSMartin Schwidefsky 
1492778b99SHeiko Carstens #include <linux/const.h>
1592778b99SHeiko Carstens 
16d3a73acbSMartin Schwidefsky #define CIF_MCCK_PENDING	0	/* machine check handling is pending */
17606aa4aaSHeiko Carstens #define CIF_ASCE_PRIMARY	1	/* primary asce needs fixup / uaccess */
18b5a882fcSHeiko Carstens #define CIF_ASCE_SECONDARY	2	/* secondary asce needs fixup / uaccess */
19b5a882fcSHeiko Carstens #define CIF_NOHZ_DELAY		3	/* delay HZ disable for a tick */
20b5a882fcSHeiko Carstens #define CIF_FPU			4	/* restore FPU registers */
21b5a882fcSHeiko Carstens #define CIF_IGNORE_IRQ		5	/* ignore interrupt (for udelay) */
22b5a882fcSHeiko Carstens #define CIF_ENABLED_WAIT	6	/* in enabled wait state */
23c929500dSQingFeng Hao #define CIF_MCCK_GUEST		7	/* machine check happening in guest */
24d3a73acbSMartin Schwidefsky 
2592778b99SHeiko Carstens #define _CIF_MCCK_PENDING	_BITUL(CIF_MCCK_PENDING)
26606aa4aaSHeiko Carstens #define _CIF_ASCE_PRIMARY	_BITUL(CIF_ASCE_PRIMARY)
27b5a882fcSHeiko Carstens #define _CIF_ASCE_SECONDARY	_BITUL(CIF_ASCE_SECONDARY)
2892778b99SHeiko Carstens #define _CIF_NOHZ_DELAY		_BITUL(CIF_NOHZ_DELAY)
2992778b99SHeiko Carstens #define _CIF_FPU		_BITUL(CIF_FPU)
3092778b99SHeiko Carstens #define _CIF_IGNORE_IRQ		_BITUL(CIF_IGNORE_IRQ)
31419123f9SMartin Schwidefsky #define _CIF_ENABLED_WAIT	_BITUL(CIF_ENABLED_WAIT)
32c929500dSQingFeng Hao #define _CIF_MCCK_GUEST		_BITUL(CIF_MCCK_GUEST)
33d3a73acbSMartin Schwidefsky 
34eb608fb3SHeiko Carstens #ifndef __ASSEMBLY__
35eb608fb3SHeiko Carstens 
36edd53787SHeiko Carstens #include <linux/linkage.h>
37a0616cdeSDavid Howells #include <linux/irqflags.h>
38e86a6ed6SHeiko Carstens #include <asm/cpu.h>
3925097bf1SChristian Ehrhardt #include <asm/page.h>
40c6557e7fSMartin Schwidefsky #include <asm/ptrace.h>
4125097bf1SChristian Ehrhardt #include <asm/setup.h>
42e4b8b3f3SJan Glauber #include <asm/runtime_instr.h>
43b0753902SHendrik Brueckner #include <asm/fpu/types.h>
44b0753902SHendrik Brueckner #include <asm/fpu/internal.h>
45c6557e7fSMartin Schwidefsky 
46d3a73acbSMartin Schwidefsky static inline void set_cpu_flag(int flag)
47d3a73acbSMartin Schwidefsky {
48ac25e790SHeiko Carstens 	S390_lowcore.cpu_flags |= (1UL << flag);
49d3a73acbSMartin Schwidefsky }
50d3a73acbSMartin Schwidefsky 
51d3a73acbSMartin Schwidefsky static inline void clear_cpu_flag(int flag)
52d3a73acbSMartin Schwidefsky {
53ac25e790SHeiko Carstens 	S390_lowcore.cpu_flags &= ~(1UL << flag);
54d3a73acbSMartin Schwidefsky }
55d3a73acbSMartin Schwidefsky 
56d3a73acbSMartin Schwidefsky static inline int test_cpu_flag(int flag)
57d3a73acbSMartin Schwidefsky {
58ac25e790SHeiko Carstens 	return !!(S390_lowcore.cpu_flags & (1UL << flag));
59d3a73acbSMartin Schwidefsky }
60d3a73acbSMartin Schwidefsky 
61419123f9SMartin Schwidefsky /*
62419123f9SMartin Schwidefsky  * Test CIF flag of another CPU. The caller needs to ensure that
63419123f9SMartin Schwidefsky  * CPU hotplug can not happen, e.g. by disabling preemption.
64419123f9SMartin Schwidefsky  */
65419123f9SMartin Schwidefsky static inline int test_cpu_flag_of(int flag, int cpu)
66419123f9SMartin Schwidefsky {
67c667aeacSHeiko Carstens 	struct lowcore *lc = lowcore_ptr[cpu];
68419123f9SMartin Schwidefsky 	return !!(lc->cpu_flags & (1UL << flag));
69419123f9SMartin Schwidefsky }
70419123f9SMartin Schwidefsky 
71fe0f4976SMartin Schwidefsky #define arch_needs_cpu() test_cpu_flag(CIF_NOHZ_DELAY)
72fe0f4976SMartin Schwidefsky 
73c6557e7fSMartin Schwidefsky /*
74c6557e7fSMartin Schwidefsky  * Default implementation of macro that returns current
75c6557e7fSMartin Schwidefsky  * instruction pointer ("program counter").
76c6557e7fSMartin Schwidefsky  */
77c6557e7fSMartin Schwidefsky #define current_text_addr() ({ void *pc; asm("basr %0,0" : "=a" (pc)); pc; })
78c6557e7fSMartin Schwidefsky 
79e86a6ed6SHeiko Carstens static inline void get_cpu_id(struct cpuid *ptr)
80c6557e7fSMartin Schwidefsky {
81987bcdacSMartin Schwidefsky 	asm volatile("stidp %0" : "=Q" (*ptr));
82c6557e7fSMartin Schwidefsky }
83c6557e7fSMartin Schwidefsky 
84097a116cSHeiko Carstens void s390_adjust_jiffies(void);
85097a116cSHeiko Carstens void s390_update_cpu_mhz(void);
86097a116cSHeiko Carstens void cpu_detect_mhz_feature(void);
87097a116cSHeiko Carstens 
88638ad34aSMartin Schwidefsky extern const struct seq_operations cpuinfo_op;
89638ad34aSMartin Schwidefsky extern int sysctl_ieee_emulation_warnings;
9065f22a90SAl Viro extern void execve_tail(void);
91c6557e7fSMartin Schwidefsky 
92c6557e7fSMartin Schwidefsky /*
93f481bfafSMartin Schwidefsky  * User space process size: 2GB for 31 bit, 4TB or 8PT for 64 bit.
94c6557e7fSMartin Schwidefsky  */
95c6557e7fSMartin Schwidefsky 
96ee71d16dSMartin Schwidefsky #define TASK_SIZE_OF(tsk)	(test_tsk_thread_flag(tsk, TIF_31BIT) ? \
97ee71d16dSMartin Schwidefsky 					(1UL << 31) : (1UL << 53))
98c6557e7fSMartin Schwidefsky #define TASK_UNMAPPED_BASE	(test_thread_flag(TIF_31BIT) ? \
99c6557e7fSMartin Schwidefsky 					(1UL << 30) : (1UL << 41))
100c6557e7fSMartin Schwidefsky #define TASK_SIZE		TASK_SIZE_OF(current)
101ee71d16dSMartin Schwidefsky #define TASK_SIZE_MAX		(1UL << 53)
102c6557e7fSMartin Schwidefsky 
103ee71d16dSMartin Schwidefsky #define STACK_TOP		(test_thread_flag(TIF_31BIT) ? \
104ee71d16dSMartin Schwidefsky 					(1UL << 31) : (1UL << 42))
105c6557e7fSMartin Schwidefsky #define STACK_TOP_MAX		(1UL << 42)
106c6557e7fSMartin Schwidefsky 
107c6557e7fSMartin Schwidefsky #define HAVE_ARCH_PICK_MMAP_LAYOUT
108c6557e7fSMartin Schwidefsky 
109c6557e7fSMartin Schwidefsky typedef struct {
110c6557e7fSMartin Schwidefsky         __u32 ar4;
111c6557e7fSMartin Schwidefsky } mm_segment_t;
112c6557e7fSMartin Schwidefsky 
113c6557e7fSMartin Schwidefsky /*
114c6557e7fSMartin Schwidefsky  * Thread structure
115c6557e7fSMartin Schwidefsky  */
116c6557e7fSMartin Schwidefsky struct thread_struct {
117c6557e7fSMartin Schwidefsky 	unsigned int  acrs[NUM_ACRS];
118c6557e7fSMartin Schwidefsky         unsigned long ksp;              /* kernel stack pointer             */
11990c53e65SMartin Schwidefsky 	unsigned long user_timer;	/* task cputime in user space */
120b7394a5fSMartin Schwidefsky 	unsigned long guest_timer;	/* task cputime in kvm guest */
12190c53e65SMartin Schwidefsky 	unsigned long system_timer;	/* task cputime in kernel space */
122b7394a5fSMartin Schwidefsky 	unsigned long hardirq_timer;	/* task cputime in hardirq context */
123b7394a5fSMartin Schwidefsky 	unsigned long softirq_timer;	/* task cputime in softirq context */
124ef280c85SMartin Schwidefsky 	unsigned long sys_call_table;	/* system call table address */
125c6557e7fSMartin Schwidefsky 	mm_segment_t mm_segment;
126e5992f2eSMartin Schwidefsky 	unsigned long gmap_addr;	/* address of last gmap fault. */
1274be130a0SMartin Schwidefsky 	unsigned int gmap_write_flag;	/* gmap fault write indication */
1284a494439SDavid Hildenbrand 	unsigned int gmap_int_code;	/* int code of last gmap fault */
12924eb3a82SDominik Dingel 	unsigned int gmap_pfault;	/* signal of a pending guest pfault */
130f8fc82b4SMartin Schwidefsky 	/* Per-thread information related to debugging */
1315e9a2692SMartin Schwidefsky 	struct per_regs per_user;	/* User specified PER registers */
1325e9a2692SMartin Schwidefsky 	struct per_event per_event;	/* Cause of the last PER trap */
133d35339a4SMartin Schwidefsky 	unsigned long per_flags;	/* Flags to control debug behavior */
134f8fc82b4SMartin Schwidefsky 	unsigned int system_call;	/* system call number in signal */
135ef280c85SMartin Schwidefsky 	unsigned long last_break;	/* last breaking-event-address. */
136c6557e7fSMartin Schwidefsky         /* pfault_wait is used to block the process on a pfault event */
137c6557e7fSMartin Schwidefsky 	unsigned long pfault_wait;
138f2db2e6cSHeiko Carstens 	struct list_head list;
139e4b8b3f3SJan Glauber 	/* cpu runtime instrumentation */
140e4b8b3f3SJan Glauber 	struct runtime_instr_cb *ri_cb;
141916cda1aSMartin Schwidefsky 	struct gs_cb *gs_cb;		/* Current guarded storage cb */
142916cda1aSMartin Schwidefsky 	struct gs_cb *gs_bc_cb;		/* Broadcast guarded storage cb */
143d35339a4SMartin Schwidefsky 	unsigned char trap_tdb[256];	/* Transaction abort diagnose block */
1443f6813b9SMartin Schwidefsky 	/*
1453f6813b9SMartin Schwidefsky 	 * Warning: 'fpu' is dynamically-sized. It *MUST* be at
1463f6813b9SMartin Schwidefsky 	 * the end.
1473f6813b9SMartin Schwidefsky 	 */
1483f6813b9SMartin Schwidefsky 	struct fpu fpu;			/* FP and VX register save area */
149c6557e7fSMartin Schwidefsky };
150c6557e7fSMartin Schwidefsky 
15164597f9dSMichael Mueller /* Flag to disable transactions. */
15264597f9dSMichael Mueller #define PER_FLAG_NO_TE			1UL
15364597f9dSMichael Mueller /* Flag to enable random transaction aborts. */
15464597f9dSMichael Mueller #define PER_FLAG_TE_ABORT_RAND		2UL
15564597f9dSMichael Mueller /* Flag to specify random transaction abort mode:
15664597f9dSMichael Mueller  * - abort each transaction at a random instruction before TEND if set.
15764597f9dSMichael Mueller  * - abort random transactions at a random instruction if cleared.
15864597f9dSMichael Mueller  */
15964597f9dSMichael Mueller #define PER_FLAG_TE_ABORT_RAND_TEND	4UL
160d35339a4SMartin Schwidefsky 
161c6557e7fSMartin Schwidefsky typedef struct thread_struct thread_struct;
162c6557e7fSMartin Schwidefsky 
163c6557e7fSMartin Schwidefsky /*
164c6557e7fSMartin Schwidefsky  * Stack layout of a C stack frame.
165c6557e7fSMartin Schwidefsky  */
166c6557e7fSMartin Schwidefsky #ifndef __PACK_STACK
167c6557e7fSMartin Schwidefsky struct stack_frame {
168c6557e7fSMartin Schwidefsky 	unsigned long back_chain;
169c6557e7fSMartin Schwidefsky 	unsigned long empty1[5];
170c6557e7fSMartin Schwidefsky 	unsigned long gprs[10];
171c6557e7fSMartin Schwidefsky 	unsigned int  empty2[8];
172c6557e7fSMartin Schwidefsky };
173c6557e7fSMartin Schwidefsky #else
174c6557e7fSMartin Schwidefsky struct stack_frame {
175c6557e7fSMartin Schwidefsky 	unsigned long empty1[5];
176c6557e7fSMartin Schwidefsky 	unsigned int  empty2[8];
177c6557e7fSMartin Schwidefsky 	unsigned long gprs[10];
178c6557e7fSMartin Schwidefsky 	unsigned long back_chain;
179c6557e7fSMartin Schwidefsky };
180c6557e7fSMartin Schwidefsky #endif
181c6557e7fSMartin Schwidefsky 
182c6557e7fSMartin Schwidefsky #define ARCH_MIN_TASKALIGN	8
183c6557e7fSMartin Schwidefsky 
184c6557e7fSMartin Schwidefsky #define INIT_THREAD {							\
185c6557e7fSMartin Schwidefsky 	.ksp = sizeof(init_stack) + (unsigned long) &init_stack,	\
1863f6813b9SMartin Schwidefsky 	.fpu.regs = (void *) init_task.thread.fpu.fprs,			\
187c6557e7fSMartin Schwidefsky }
188c6557e7fSMartin Schwidefsky 
189c6557e7fSMartin Schwidefsky /*
190c6557e7fSMartin Schwidefsky  * Do necessary setup to start up a new thread.
191c6557e7fSMartin Schwidefsky  */
192c6557e7fSMartin Schwidefsky #define start_thread(regs, new_psw, new_stackp) do {			\
193e258d719SMartin Schwidefsky 	regs->psw.mask	= PSW_USER_BITS | PSW_MASK_EA | PSW_MASK_BA;	\
194fecc868aSHeiko Carstens 	regs->psw.addr	= new_psw;					\
195c6557e7fSMartin Schwidefsky 	regs->gprs[15]	= new_stackp;					\
19665f22a90SAl Viro 	execve_tail();							\
197c6557e7fSMartin Schwidefsky } while (0)
198c6557e7fSMartin Schwidefsky 
199c6557e7fSMartin Schwidefsky #define start_thread31(regs, new_psw, new_stackp) do {			\
200e258d719SMartin Schwidefsky 	regs->psw.mask	= PSW_USER_BITS | PSW_MASK_BA;			\
201fecc868aSHeiko Carstens 	regs->psw.addr	= new_psw;					\
202c6557e7fSMartin Schwidefsky 	regs->gprs[15]	= new_stackp;					\
203723cacbdSGerald Schaefer 	crst_table_downgrade(current->mm);				\
20465f22a90SAl Viro 	execve_tail();							\
205c6557e7fSMartin Schwidefsky } while (0)
206c6557e7fSMartin Schwidefsky 
207c6557e7fSMartin Schwidefsky /* Forward declaration, a strange C thing */
208c6557e7fSMartin Schwidefsky struct task_struct;
209c6557e7fSMartin Schwidefsky struct mm_struct;
210c6557e7fSMartin Schwidefsky struct seq_file;
211b5a882fcSHeiko Carstens struct pt_regs;
212c6557e7fSMartin Schwidefsky 
213d0208639SHeiko Carstens typedef int (*dump_trace_func_t)(void *data, unsigned long address, int reliable);
214758d39ebSHeiko Carstens void dump_trace(dump_trace_func_t func, void *data,
215758d39ebSHeiko Carstens 		struct task_struct *task, unsigned long sp);
216b5a882fcSHeiko Carstens void show_registers(struct pt_regs *regs);
217758d39ebSHeiko Carstens 
2185a79859aSHeiko Carstens void show_cacheinfo(struct seq_file *m);
2196668022cSHeiko Carstens 
220c6557e7fSMartin Schwidefsky /* Free all resources held by a thread. */
221c6557e7fSMartin Schwidefsky extern void release_thread(struct task_struct *);
222c6557e7fSMartin Schwidefsky 
223916cda1aSMartin Schwidefsky /* Free guarded storage control block for current */
224916cda1aSMartin Schwidefsky void exit_thread_gs(void);
225916cda1aSMartin Schwidefsky 
226c6557e7fSMartin Schwidefsky /*
227c6557e7fSMartin Schwidefsky  * Return saved PC of a blocked thread.
228c6557e7fSMartin Schwidefsky  */
229c6557e7fSMartin Schwidefsky extern unsigned long thread_saved_pc(struct task_struct *t);
230c6557e7fSMartin Schwidefsky 
231c6557e7fSMartin Schwidefsky unsigned long get_wchan(struct task_struct *p);
232c6557e7fSMartin Schwidefsky #define task_pt_regs(tsk) ((struct pt_regs *) \
233c6557e7fSMartin Schwidefsky         (task_stack_page(tsk) + THREAD_SIZE) - 1)
234c6557e7fSMartin Schwidefsky #define KSTK_EIP(tsk)	(task_pt_regs(tsk)->psw.addr)
235c6557e7fSMartin Schwidefsky #define KSTK_ESP(tsk)	(task_pt_regs(tsk)->gprs[15])
236c6557e7fSMartin Schwidefsky 
2375ebf250dSHeiko Carstens /* Has task runtime instrumentation enabled ? */
2385ebf250dSHeiko Carstens #define is_ri_task(tsk) (!!(tsk)->thread.ri_cb)
2395ebf250dSHeiko Carstens 
24076737ce1SHeiko Carstens static inline unsigned long current_stack_pointer(void)
24176737ce1SHeiko Carstens {
24276737ce1SHeiko Carstens 	unsigned long sp;
24376737ce1SHeiko Carstens 
24476737ce1SHeiko Carstens 	asm volatile("la %0,0(15)" : "=a" (sp));
24576737ce1SHeiko Carstens 	return sp;
24676737ce1SHeiko Carstens }
24776737ce1SHeiko Carstens 
248a0616cdeSDavid Howells static inline unsigned short stap(void)
249a0616cdeSDavid Howells {
250a0616cdeSDavid Howells 	unsigned short cpu_address;
251a0616cdeSDavid Howells 
252a0616cdeSDavid Howells 	asm volatile("stap %0" : "=m" (cpu_address));
253a0616cdeSDavid Howells 	return cpu_address;
254a0616cdeSDavid Howells }
255a0616cdeSDavid Howells 
256c6557e7fSMartin Schwidefsky /*
257c6557e7fSMartin Schwidefsky  * Give up the time slice of the virtual PU.
258c6557e7fSMartin Schwidefsky  */
2596d0d2878SChristian Borntraeger #define cpu_relax_yield cpu_relax_yield
26079ab11cdSChristian Borntraeger void cpu_relax_yield(void);
261c6557e7fSMartin Schwidefsky 
26222b6430dSChristian Borntraeger #define cpu_relax() barrier()
263083986e8SHeiko Carstens 
264097a116cSHeiko Carstens #define ECAG_CACHE_ATTRIBUTE	0
265097a116cSHeiko Carstens #define ECAG_CPU_ATTRIBUTE	1
266097a116cSHeiko Carstens 
267097a116cSHeiko Carstens static inline unsigned long __ecag(unsigned int asi, unsigned char parm)
268097a116cSHeiko Carstens {
269097a116cSHeiko Carstens 	unsigned long val;
270097a116cSHeiko Carstens 
271097a116cSHeiko Carstens 	asm volatile(".insn	rsy,0xeb000000004c,%0,0,0(%1)" /* ecag */
272097a116cSHeiko Carstens 		     : "=d" (val) : "a" (asi << 8 | parm));
273097a116cSHeiko Carstens 	return val;
274097a116cSHeiko Carstens }
275097a116cSHeiko Carstens 
276c6557e7fSMartin Schwidefsky static inline void psw_set_key(unsigned int key)
277c6557e7fSMartin Schwidefsky {
278c6557e7fSMartin Schwidefsky 	asm volatile("spka 0(%0)" : : "d" (key));
279c6557e7fSMartin Schwidefsky }
280c6557e7fSMartin Schwidefsky 
281c6557e7fSMartin Schwidefsky /*
282c6557e7fSMartin Schwidefsky  * Set PSW to specified value.
283c6557e7fSMartin Schwidefsky  */
284c6557e7fSMartin Schwidefsky static inline void __load_psw(psw_t psw)
285c6557e7fSMartin Schwidefsky {
286987bcdacSMartin Schwidefsky 	asm volatile("lpswe %0" : : "Q" (psw) : "cc");
287c6557e7fSMartin Schwidefsky }
288c6557e7fSMartin Schwidefsky 
289c6557e7fSMartin Schwidefsky /*
290c6557e7fSMartin Schwidefsky  * Set PSW mask to specified value, while leaving the
291c6557e7fSMartin Schwidefsky  * PSW addr pointing to the next instruction.
292c6557e7fSMartin Schwidefsky  */
293c6557e7fSMartin Schwidefsky static inline void __load_psw_mask(unsigned long mask)
294c6557e7fSMartin Schwidefsky {
295c6557e7fSMartin Schwidefsky 	unsigned long addr;
296c6557e7fSMartin Schwidefsky 	psw_t psw;
297c6557e7fSMartin Schwidefsky 
298c6557e7fSMartin Schwidefsky 	psw.mask = mask;
299c6557e7fSMartin Schwidefsky 
300c6557e7fSMartin Schwidefsky 	asm volatile(
301c6557e7fSMartin Schwidefsky 		"	larl	%0,1f\n"
302987bcdacSMartin Schwidefsky 		"	stg	%0,%O1+8(%R1)\n"
303987bcdacSMartin Schwidefsky 		"	lpswe	%1\n"
304c6557e7fSMartin Schwidefsky 		"1:"
305987bcdacSMartin Schwidefsky 		: "=&d" (addr), "=Q" (psw) : "Q" (psw) : "memory", "cc");
306c6557e7fSMartin Schwidefsky }
307c6557e7fSMartin Schwidefsky 
308c6557e7fSMartin Schwidefsky /*
30922362a0eSMartin Schwidefsky  * Extract current PSW mask
31022362a0eSMartin Schwidefsky  */
31122362a0eSMartin Schwidefsky static inline unsigned long __extract_psw(void)
31222362a0eSMartin Schwidefsky {
31322362a0eSMartin Schwidefsky 	unsigned int reg1, reg2;
31422362a0eSMartin Schwidefsky 
31522362a0eSMartin Schwidefsky 	asm volatile("epsw %0,%1" : "=d" (reg1), "=a" (reg2));
31622362a0eSMartin Schwidefsky 	return (((unsigned long) reg1) << 32) | ((unsigned long) reg2);
31722362a0eSMartin Schwidefsky }
31822362a0eSMartin Schwidefsky 
319ecbafda8SHeiko Carstens static inline void local_mcck_enable(void)
320ecbafda8SHeiko Carstens {
321ecbafda8SHeiko Carstens 	__load_psw_mask(__extract_psw() | PSW_MASK_MCHECK);
322ecbafda8SHeiko Carstens }
323ecbafda8SHeiko Carstens 
324ecbafda8SHeiko Carstens static inline void local_mcck_disable(void)
325ecbafda8SHeiko Carstens {
326ecbafda8SHeiko Carstens 	__load_psw_mask(__extract_psw() & ~PSW_MASK_MCHECK);
327ecbafda8SHeiko Carstens }
328ecbafda8SHeiko Carstens 
32922362a0eSMartin Schwidefsky /*
330ccf45cafSMartin Schwidefsky  * Rewind PSW instruction address by specified number of bytes.
331ccf45cafSMartin Schwidefsky  */
332ccf45cafSMartin Schwidefsky static inline unsigned long __rewind_psw(psw_t psw, unsigned long ilc)
333ccf45cafSMartin Schwidefsky {
334ccf45cafSMartin Schwidefsky 	unsigned long mask;
335ccf45cafSMartin Schwidefsky 
336ccf45cafSMartin Schwidefsky 	mask = (psw.mask & PSW_MASK_EA) ? -1UL :
337ccf45cafSMartin Schwidefsky 	       (psw.mask & PSW_MASK_BA) ? (1UL << 31) - 1 :
338ccf45cafSMartin Schwidefsky 					  (1UL << 24) - 1;
339ccf45cafSMartin Schwidefsky 	return (psw.addr - ilc) & mask;
340ccf45cafSMartin Schwidefsky }
341ccf45cafSMartin Schwidefsky 
342b5f87f15SMartin Schwidefsky /*
343b5f87f15SMartin Schwidefsky  * Function to stop a processor until the next interrupt occurs
344b5f87f15SMartin Schwidefsky  */
345b5f87f15SMartin Schwidefsky void enabled_wait(void);
346b5f87f15SMartin Schwidefsky 
347ccf45cafSMartin Schwidefsky /*
348c6557e7fSMartin Schwidefsky  * Function to drop a processor into disabled wait state
349c6557e7fSMartin Schwidefsky  */
350ff2d8b19SJoe Perches static inline void __noreturn disabled_wait(unsigned long code)
351c6557e7fSMartin Schwidefsky {
352f9e6edfbSHeiko Carstens 	psw_t psw;
353c6557e7fSMartin Schwidefsky 
354f9e6edfbSHeiko Carstens 	psw.mask = PSW_MASK_BASE | PSW_MASK_WAIT | PSW_MASK_BA | PSW_MASK_EA;
355f9e6edfbSHeiko Carstens 	psw.addr = code;
356f9e6edfbSHeiko Carstens 	__load_psw(psw);
357edd53787SHeiko Carstens 	while (1);
358c6557e7fSMartin Schwidefsky }
359c6557e7fSMartin Schwidefsky 
360c6557e7fSMartin Schwidefsky /*
361c6557e7fSMartin Schwidefsky  * Basic Machine Check/Program Check Handler.
362c6557e7fSMartin Schwidefsky  */
363c6557e7fSMartin Schwidefsky 
364c6557e7fSMartin Schwidefsky extern void s390_base_mcck_handler(void);
365c6557e7fSMartin Schwidefsky extern void s390_base_pgm_handler(void);
366c6557e7fSMartin Schwidefsky extern void s390_base_ext_handler(void);
367c6557e7fSMartin Schwidefsky 
368c6557e7fSMartin Schwidefsky extern void (*s390_base_mcck_handler_fn)(void);
369c6557e7fSMartin Schwidefsky extern void (*s390_base_pgm_handler_fn)(void);
370c6557e7fSMartin Schwidefsky extern void (*s390_base_ext_handler_fn)(void);
371c6557e7fSMartin Schwidefsky 
372c6557e7fSMartin Schwidefsky #define ARCH_LOW_ADDRESS_LIMIT	0x7fffffffUL
373c6557e7fSMartin Schwidefsky 
374fbe76568SHeiko Carstens extern int memcpy_real(void *, void *, size_t);
375fbe76568SHeiko Carstens extern void memcpy_absolute(void *, void *, size_t);
376fbe76568SHeiko Carstens 
3771228f7beSHeiko Carstens #define mem_assign_absolute(dest, val) do {			\
378fbe76568SHeiko Carstens 	__typeof__(dest) __tmp = (val);				\
379fbe76568SHeiko Carstens 								\
380fbe76568SHeiko Carstens 	BUILD_BUG_ON(sizeof(__tmp) != sizeof(val));		\
381fbe76568SHeiko Carstens 	memcpy_absolute(&(dest), &__tmp, sizeof(__tmp));	\
3821228f7beSHeiko Carstens } while (0)
383fbe76568SHeiko Carstens 
384eb608fb3SHeiko Carstens #endif /* __ASSEMBLY__ */
385eb608fb3SHeiko Carstens 
386c6557e7fSMartin Schwidefsky #endif /* __ASM_S390_PROCESSOR_H */
387