Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * S390 version |
Heiko Carstens | a53c8fa | 2012-07-20 11:15:04 +0200 | [diff] [blame] | 3 | * Copyright IBM Corp. 1999 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Martin Schwidefsky | d3a73ac | 2014-04-15 12:55:07 +0200 | [diff] [blame] | 14 | #define CIF_MCCK_PENDING 0 /* machine check handling is pending */ |
| 15 | #define CIF_ASCE 1 /* user asce needs fixup / uaccess */ |
Martin Schwidefsky | fe0f497 | 2014-09-30 17:37:52 +0200 | [diff] [blame] | 16 | #define CIF_NOHZ_DELAY 2 /* delay HZ disable for a tick */ |
Hendrik Brueckner | 9977e88 | 2015-06-10 12:53:42 +0200 | [diff] [blame] | 17 | #define CIF_FPU 3 /* restore vector registers */ |
Heiko Carstens | db7e007 | 2015-08-15 11:42:21 +0200 | [diff] [blame] | 18 | #define CIF_IGNORE_IRQ 4 /* ignore interrupt (for udelay) */ |
Martin Schwidefsky | d3a73ac | 2014-04-15 12:55:07 +0200 | [diff] [blame] | 19 | |
| 20 | #define _CIF_MCCK_PENDING (1<<CIF_MCCK_PENDING) |
| 21 | #define _CIF_ASCE (1<<CIF_ASCE) |
Martin Schwidefsky | fe0f497 | 2014-09-30 17:37:52 +0200 | [diff] [blame] | 22 | #define _CIF_NOHZ_DELAY (1<<CIF_NOHZ_DELAY) |
Hendrik Brueckner | 9977e88 | 2015-06-10 12:53:42 +0200 | [diff] [blame] | 23 | #define _CIF_FPU (1<<CIF_FPU) |
Heiko Carstens | db7e007 | 2015-08-15 11:42:21 +0200 | [diff] [blame] | 24 | #define _CIF_IGNORE_IRQ (1<<CIF_IGNORE_IRQ) |
Martin Schwidefsky | d3a73ac | 2014-04-15 12:55:07 +0200 | [diff] [blame] | 25 | |
Heiko Carstens | eb608fb | 2012-09-05 13:26:11 +0200 | [diff] [blame] | 26 | #ifndef __ASSEMBLY__ |
| 27 | |
Heiko Carstens | edd5378 | 2008-12-25 13:39:16 +0100 | [diff] [blame] | 28 | #include <linux/linkage.h> |
David Howells | a0616cd | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 29 | #include <linux/irqflags.h> |
Heiko Carstens | e86a6ed | 2009-09-11 10:29:04 +0200 | [diff] [blame] | 30 | #include <asm/cpu.h> |
Christian Ehrhardt | 25097bf | 2009-04-14 15:36:16 +0200 | [diff] [blame] | 31 | #include <asm/page.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <asm/ptrace.h> |
Christian Ehrhardt | 25097bf | 2009-04-14 15:36:16 +0200 | [diff] [blame] | 33 | #include <asm/setup.h> |
Jan Glauber | e4b8b3f | 2012-07-31 10:52:05 +0200 | [diff] [blame] | 34 | #include <asm/runtime_instr.h> |
Hendrik Brueckner | 904818e | 2015-06-11 15:33:54 +0200 | [diff] [blame] | 35 | #include <asm/fpu-internal.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
Martin Schwidefsky | d3a73ac | 2014-04-15 12:55:07 +0200 | [diff] [blame] | 37 | static inline void set_cpu_flag(int flag) |
| 38 | { |
Heiko Carstens | ac25e79 | 2015-10-06 16:23:29 +0200 | [diff] [blame^] | 39 | S390_lowcore.cpu_flags |= (1UL << flag); |
Martin Schwidefsky | d3a73ac | 2014-04-15 12:55:07 +0200 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | static inline void clear_cpu_flag(int flag) |
| 43 | { |
Heiko Carstens | ac25e79 | 2015-10-06 16:23:29 +0200 | [diff] [blame^] | 44 | S390_lowcore.cpu_flags &= ~(1UL << flag); |
Martin Schwidefsky | d3a73ac | 2014-04-15 12:55:07 +0200 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | static inline int test_cpu_flag(int flag) |
| 48 | { |
Heiko Carstens | ac25e79 | 2015-10-06 16:23:29 +0200 | [diff] [blame^] | 49 | return !!(S390_lowcore.cpu_flags & (1UL << flag)); |
Martin Schwidefsky | d3a73ac | 2014-04-15 12:55:07 +0200 | [diff] [blame] | 50 | } |
| 51 | |
Martin Schwidefsky | fe0f497 | 2014-09-30 17:37:52 +0200 | [diff] [blame] | 52 | #define arch_needs_cpu() test_cpu_flag(CIF_NOHZ_DELAY) |
| 53 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | /* |
| 55 | * Default implementation of macro that returns current |
| 56 | * instruction pointer ("program counter"). |
| 57 | */ |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 58 | #define current_text_addr() ({ void *pc; asm("basr %0,0" : "=a" (pc)); pc; }) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
Heiko Carstens | e86a6ed | 2009-09-11 10:29:04 +0200 | [diff] [blame] | 60 | static inline void get_cpu_id(struct cpuid *ptr) |
Michael Holzheu | 72960a0 | 2007-02-21 10:55:18 +0100 | [diff] [blame] | 61 | { |
Martin Schwidefsky | 987bcda | 2010-02-26 22:37:31 +0100 | [diff] [blame] | 62 | asm volatile("stidp %0" : "=Q" (*ptr)); |
Michael Holzheu | 72960a0 | 2007-02-21 10:55:18 +0100 | [diff] [blame] | 63 | } |
| 64 | |
Martin Schwidefsky | 31ee4b2 | 2007-02-05 21:18:31 +0100 | [diff] [blame] | 65 | extern void s390_adjust_jiffies(void); |
Martin Schwidefsky | 638ad34 | 2011-10-30 15:17:13 +0100 | [diff] [blame] | 66 | extern const struct seq_operations cpuinfo_op; |
| 67 | extern int sysctl_ieee_emulation_warnings; |
Al Viro | 65f22a9 | 2012-09-06 15:48:11 -0400 | [diff] [blame] | 68 | extern void execve_tail(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | /* |
Martin Schwidefsky | f481bfa | 2009-03-18 13:27:36 +0100 | [diff] [blame] | 71 | * User space process size: 2GB for 31 bit, 4TB or 8PT for 64 bit. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
Martin Schwidefsky | f481bfa | 2009-03-18 13:27:36 +0100 | [diff] [blame] | 74 | #define TASK_SIZE_OF(tsk) ((tsk)->mm->context.asce_limit) |
Martin Schwidefsky | 5a216a2 | 2008-02-09 18:24:36 +0100 | [diff] [blame] | 75 | #define TASK_UNMAPPED_BASE (test_thread_flag(TIF_31BIT) ? \ |
| 76 | (1UL << 30) : (1UL << 41)) |
| 77 | #define TASK_SIZE TASK_SIZE_OF(current) |
Martin Schwidefsky | ee6ee55 | 2013-07-26 15:04:03 +0200 | [diff] [blame] | 78 | #define TASK_MAX_SIZE (1UL << 53) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | |
Martin Schwidefsky | 6252d70 | 2008-02-09 18:24:37 +0100 | [diff] [blame] | 80 | #define STACK_TOP (1UL << (test_thread_flag(TIF_31BIT) ? 31:42)) |
| 81 | #define STACK_TOP_MAX (1UL << 42) |
David Howells | 922a70d | 2008-02-08 04:19:26 -0800 | [diff] [blame] | 82 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | #define HAVE_ARCH_PICK_MMAP_LAYOUT |
| 84 | |
| 85 | typedef struct { |
| 86 | __u32 ar4; |
| 87 | } mm_segment_t; |
| 88 | |
| 89 | /* |
| 90 | * Thread structure |
| 91 | */ |
| 92 | struct thread_struct { |
Hendrik Brueckner | 904818e | 2015-06-11 15:33:54 +0200 | [diff] [blame] | 93 | struct fpu fpu; /* FP and VX register save area */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | unsigned int acrs[NUM_ACRS]; |
| 95 | unsigned long ksp; /* kernel stack pointer */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | mm_segment_t mm_segment; |
Martin Schwidefsky | e5992f2 | 2011-07-24 10:48:20 +0200 | [diff] [blame] | 97 | unsigned long gmap_addr; /* address of last gmap fault. */ |
Dominik Dingel | 24eb3a8 | 2013-06-17 16:25:18 +0200 | [diff] [blame] | 98 | unsigned int gmap_pfault; /* signal of a pending guest pfault */ |
Martin Schwidefsky | 5e9a269 | 2011-01-05 12:48:10 +0100 | [diff] [blame] | 99 | struct per_regs per_user; /* User specified PER registers */ |
| 100 | struct per_event per_event; /* Cause of the last PER trap */ |
Martin Schwidefsky | d35339a | 2012-07-31 11:03:04 +0200 | [diff] [blame] | 101 | unsigned long per_flags; /* Flags to control debug behavior */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | /* pfault_wait is used to block the process on a pfault event */ |
| 103 | unsigned long pfault_wait; |
Heiko Carstens | f2db2e6 | 2011-05-23 10:24:34 +0200 | [diff] [blame] | 104 | struct list_head list; |
Jan Glauber | e4b8b3f | 2012-07-31 10:52:05 +0200 | [diff] [blame] | 105 | /* cpu runtime instrumentation */ |
| 106 | struct runtime_instr_cb *ri_cb; |
| 107 | int ri_signum; |
Martin Schwidefsky | d35339a | 2012-07-31 11:03:04 +0200 | [diff] [blame] | 108 | unsigned char trap_tdb[256]; /* Transaction abort diagnose block */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | }; |
| 110 | |
Michael Mueller | 64597f9 | 2013-07-02 22:58:26 +0200 | [diff] [blame] | 111 | /* Flag to disable transactions. */ |
| 112 | #define PER_FLAG_NO_TE 1UL |
| 113 | /* Flag to enable random transaction aborts. */ |
| 114 | #define PER_FLAG_TE_ABORT_RAND 2UL |
| 115 | /* Flag to specify random transaction abort mode: |
| 116 | * - abort each transaction at a random instruction before TEND if set. |
| 117 | * - abort random transactions at a random instruction if cleared. |
| 118 | */ |
| 119 | #define PER_FLAG_TE_ABORT_RAND_TEND 4UL |
Martin Schwidefsky | d35339a | 2012-07-31 11:03:04 +0200 | [diff] [blame] | 120 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | typedef struct thread_struct thread_struct; |
| 122 | |
| 123 | /* |
| 124 | * Stack layout of a C stack frame. |
| 125 | */ |
| 126 | #ifndef __PACK_STACK |
| 127 | struct stack_frame { |
| 128 | unsigned long back_chain; |
| 129 | unsigned long empty1[5]; |
| 130 | unsigned long gprs[10]; |
| 131 | unsigned int empty2[8]; |
| 132 | }; |
| 133 | #else |
| 134 | struct stack_frame { |
| 135 | unsigned long empty1[5]; |
| 136 | unsigned int empty2[8]; |
| 137 | unsigned long gprs[10]; |
| 138 | unsigned long back_chain; |
| 139 | }; |
| 140 | #endif |
| 141 | |
| 142 | #define ARCH_MIN_TASKALIGN 8 |
| 143 | |
Hendrik Brueckner | 0ac2777 | 2015-09-29 17:53:22 +0200 | [diff] [blame] | 144 | extern __vector128 init_task_fpu_regs[__NUM_VXRS]; |
Martin Schwidefsky | 6f3fa3f | 2007-10-22 12:52:45 +0200 | [diff] [blame] | 145 | #define INIT_THREAD { \ |
| 146 | .ksp = sizeof(init_stack) + (unsigned long) &init_stack, \ |
Hendrik Brueckner | 0ac2777 | 2015-09-29 17:53:22 +0200 | [diff] [blame] | 147 | .fpu.regs = (void *)&init_task_fpu_regs, \ |
Martin Schwidefsky | 6f3fa3f | 2007-10-22 12:52:45 +0200 | [diff] [blame] | 148 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | |
| 150 | /* |
| 151 | * Do necessary setup to start up a new thread. |
| 152 | */ |
Martin Schwidefsky | b50511e | 2011-10-30 15:16:50 +0100 | [diff] [blame] | 153 | #define start_thread(regs, new_psw, new_stackp) do { \ |
Martin Schwidefsky | e258d71 | 2013-09-24 09:14:56 +0200 | [diff] [blame] | 154 | regs->psw.mask = PSW_USER_BITS | PSW_MASK_EA | PSW_MASK_BA; \ |
Martin Schwidefsky | b50511e | 2011-10-30 15:16:50 +0100 | [diff] [blame] | 155 | regs->psw.addr = new_psw | PSW_ADDR_AMODE; \ |
| 156 | regs->gprs[15] = new_stackp; \ |
Al Viro | 65f22a9 | 2012-09-06 15:48:11 -0400 | [diff] [blame] | 157 | execve_tail(); \ |
Martin Schwidefsky | 63506c4 | 2008-07-14 09:58:54 +0200 | [diff] [blame] | 158 | } while (0) |
| 159 | |
Martin Schwidefsky | b50511e | 2011-10-30 15:16:50 +0100 | [diff] [blame] | 160 | #define start_thread31(regs, new_psw, new_stackp) do { \ |
Martin Schwidefsky | e258d71 | 2013-09-24 09:14:56 +0200 | [diff] [blame] | 161 | regs->psw.mask = PSW_USER_BITS | PSW_MASK_BA; \ |
Martin Schwidefsky | b50511e | 2011-10-30 15:16:50 +0100 | [diff] [blame] | 162 | regs->psw.addr = new_psw | PSW_ADDR_AMODE; \ |
| 163 | regs->gprs[15] = new_stackp; \ |
| 164 | crst_table_downgrade(current->mm, 1UL << 31); \ |
Al Viro | 65f22a9 | 2012-09-06 15:48:11 -0400 | [diff] [blame] | 165 | execve_tail(); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | } while (0) |
| 167 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | /* Forward declaration, a strange C thing */ |
| 169 | struct task_struct; |
| 170 | struct mm_struct; |
Eric W. Biederman | df5f831 | 2008-02-08 04:18:33 -0800 | [diff] [blame] | 171 | struct seq_file; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | |
Heiko Carstens | 5a79859 | 2015-02-12 13:08:27 +0100 | [diff] [blame] | 173 | void show_cacheinfo(struct seq_file *m); |
Heiko Carstens | 6668022 | 2012-08-29 14:12:20 +0200 | [diff] [blame] | 174 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | /* Free all resources held by a thread. */ |
| 176 | extern void release_thread(struct task_struct *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | /* |
| 179 | * Return saved PC of a blocked thread. |
| 180 | */ |
| 181 | extern unsigned long thread_saved_pc(struct task_struct *t); |
| 182 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | unsigned long get_wchan(struct task_struct *p); |
Al Viro | c7584fb | 2006-01-12 01:05:49 -0800 | [diff] [blame] | 184 | #define task_pt_regs(tsk) ((struct pt_regs *) \ |
Al Viro | 30af712 | 2006-01-12 01:05:50 -0800 | [diff] [blame] | 185 | (task_stack_page(tsk) + THREAD_SIZE) - 1) |
Al Viro | c7584fb | 2006-01-12 01:05:49 -0800 | [diff] [blame] | 186 | #define KSTK_EIP(tsk) (task_pt_regs(tsk)->psw.addr) |
| 187 | #define KSTK_ESP(tsk) (task_pt_regs(tsk)->gprs[15]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | |
Heiko Carstens | 5ebf250 | 2013-10-16 09:58:01 +0200 | [diff] [blame] | 189 | /* Has task runtime instrumentation enabled ? */ |
| 190 | #define is_ri_task(tsk) (!!(tsk)->thread.ri_cb) |
| 191 | |
David Howells | a0616cd | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 192 | static inline unsigned short stap(void) |
| 193 | { |
| 194 | unsigned short cpu_address; |
| 195 | |
| 196 | asm volatile("stap %0" : "=m" (cpu_address)); |
| 197 | return cpu_address; |
| 198 | } |
| 199 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | /* |
| 201 | * Give up the time slice of the virtual PU. |
| 202 | */ |
Heiko Carstens | 4d92f50 | 2015-01-28 07:43:56 +0100 | [diff] [blame] | 203 | void cpu_relax(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | |
Davidlohr Bueso | 3a6bfbc | 2014-06-29 15:09:33 -0700 | [diff] [blame] | 205 | #define cpu_relax_lowlatency() barrier() |
Heiko Carstens | 083986e | 2013-09-28 11:23:59 +0200 | [diff] [blame] | 206 | |
Heiko Carstens | dc74d7f | 2007-06-19 13:10:06 +0200 | [diff] [blame] | 207 | static inline void psw_set_key(unsigned int key) |
| 208 | { |
| 209 | asm volatile("spka 0(%0)" : : "d" (key)); |
| 210 | } |
| 211 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | /* |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 213 | * Set PSW to specified value. |
| 214 | */ |
| 215 | static inline void __load_psw(psw_t psw) |
| 216 | { |
Martin Schwidefsky | 987bcda | 2010-02-26 22:37:31 +0100 | [diff] [blame] | 217 | asm volatile("lpswe %0" : : "Q" (psw) : "cc"); |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | * Set PSW mask to specified value, while leaving the |
| 222 | * PSW addr pointing to the next instruction. |
| 223 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | static inline void __load_psw_mask (unsigned long mask) |
| 225 | { |
| 226 | unsigned long addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | psw_t psw; |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 228 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | psw.mask = mask; |
| 230 | |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 231 | asm volatile( |
| 232 | " larl %0,1f\n" |
Martin Schwidefsky | 987bcda | 2010-02-26 22:37:31 +0100 | [diff] [blame] | 233 | " stg %0,%O1+8(%R1)\n" |
| 234 | " lpswe %1\n" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | "1:" |
Martin Schwidefsky | 987bcda | 2010-02-26 22:37:31 +0100 | [diff] [blame] | 236 | : "=&d" (addr), "=Q" (psw) : "Q" (psw) : "memory", "cc"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | } |
Martin Schwidefsky | ccf45ca | 2011-10-30 15:16:48 +0100 | [diff] [blame] | 238 | |
| 239 | /* |
Martin Schwidefsky | 22362a0 | 2015-07-08 10:20:04 +0200 | [diff] [blame] | 240 | * Extract current PSW mask |
| 241 | */ |
| 242 | static inline unsigned long __extract_psw(void) |
| 243 | { |
| 244 | unsigned int reg1, reg2; |
| 245 | |
| 246 | asm volatile("epsw %0,%1" : "=d" (reg1), "=a" (reg2)); |
| 247 | return (((unsigned long) reg1) << 32) | ((unsigned long) reg2); |
| 248 | } |
| 249 | |
| 250 | /* |
Martin Schwidefsky | ccf45ca | 2011-10-30 15:16:48 +0100 | [diff] [blame] | 251 | * Rewind PSW instruction address by specified number of bytes. |
| 252 | */ |
| 253 | static inline unsigned long __rewind_psw(psw_t psw, unsigned long ilc) |
| 254 | { |
Martin Schwidefsky | ccf45ca | 2011-10-30 15:16:48 +0100 | [diff] [blame] | 255 | unsigned long mask; |
| 256 | |
| 257 | mask = (psw.mask & PSW_MASK_EA) ? -1UL : |
| 258 | (psw.mask & PSW_MASK_BA) ? (1UL << 31) - 1 : |
| 259 | (1UL << 24) - 1; |
| 260 | return (psw.addr - ilc) & mask; |
Martin Schwidefsky | ccf45ca | 2011-10-30 15:16:48 +0100 | [diff] [blame] | 261 | } |
Martin Schwidefsky | b5f87f1 | 2014-10-01 10:57:57 +0200 | [diff] [blame] | 262 | |
| 263 | /* |
| 264 | * Function to stop a processor until the next interrupt occurs |
| 265 | */ |
| 266 | void enabled_wait(void); |
| 267 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | * Function to drop a processor into disabled wait state |
| 270 | */ |
Joe Perches | ff2d8b1 | 2012-01-12 17:17:21 -0800 | [diff] [blame] | 271 | static inline void __noreturn disabled_wait(unsigned long code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | unsigned long ctl_buf; |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 274 | psw_t dw_psw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | |
Martin Schwidefsky | b50511e | 2011-10-30 15:16:50 +0100 | [diff] [blame] | 276 | dw_psw.mask = PSW_MASK_BASE | PSW_MASK_WAIT | PSW_MASK_BA | PSW_MASK_EA; |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 277 | dw_psw.addr = code; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | /* |
| 279 | * Store status and then load disabled wait psw, |
| 280 | * the processor is dead afterwards |
| 281 | */ |
Martin Schwidefsky | 94c12cc | 2006-09-28 16:56:43 +0200 | [diff] [blame] | 282 | asm volatile( |
| 283 | " stctg 0,0,0(%2)\n" |
| 284 | " ni 4(%2),0xef\n" /* switch off protection */ |
| 285 | " lctlg 0,0,0(%2)\n" |
| 286 | " lghi 1,0x1000\n" |
| 287 | " stpt 0x328(1)\n" /* store timer */ |
| 288 | " stckc 0x330(1)\n" /* store clock comparator */ |
| 289 | " stpx 0x318(1)\n" /* store prefix register */ |
| 290 | " stam 0,15,0x340(1)\n"/* store access registers */ |
| 291 | " stfpc 0x31c(1)\n" /* store fpu control */ |
| 292 | " std 0,0x200(1)\n" /* store f0 */ |
| 293 | " std 1,0x208(1)\n" /* store f1 */ |
| 294 | " std 2,0x210(1)\n" /* store f2 */ |
| 295 | " std 3,0x218(1)\n" /* store f3 */ |
| 296 | " std 4,0x220(1)\n" /* store f4 */ |
| 297 | " std 5,0x228(1)\n" /* store f5 */ |
| 298 | " std 6,0x230(1)\n" /* store f6 */ |
| 299 | " std 7,0x238(1)\n" /* store f7 */ |
| 300 | " std 8,0x240(1)\n" /* store f8 */ |
| 301 | " std 9,0x248(1)\n" /* store f9 */ |
| 302 | " std 10,0x250(1)\n" /* store f10 */ |
| 303 | " std 11,0x258(1)\n" /* store f11 */ |
| 304 | " std 12,0x260(1)\n" /* store f12 */ |
| 305 | " std 13,0x268(1)\n" /* store f13 */ |
| 306 | " std 14,0x270(1)\n" /* store f14 */ |
| 307 | " std 15,0x278(1)\n" /* store f15 */ |
| 308 | " stmg 0,15,0x280(1)\n"/* store general registers */ |
| 309 | " stctg 0,15,0x380(1)\n"/* store control registers */ |
| 310 | " oi 0x384(1),0x10\n"/* fake protection bit */ |
| 311 | " lpswe 0(%1)" |
| 312 | : "=m" (ctl_buf) |
Heiko Carstens | bdd42b2 | 2009-09-22 22:58:47 +0200 | [diff] [blame] | 313 | : "a" (&dw_psw), "a" (&ctl_buf), "m" (dw_psw) : "cc", "0", "1"); |
Heiko Carstens | edd5378 | 2008-12-25 13:39:16 +0100 | [diff] [blame] | 314 | while (1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | /* |
David Howells | a0616cd | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 318 | * Use to set psw mask except for the first byte which |
| 319 | * won't be changed by this function. |
| 320 | */ |
| 321 | static inline void |
| 322 | __set_psw_mask(unsigned long mask) |
| 323 | { |
| 324 | __load_psw_mask(mask | (arch_local_save_flags() & ~(-1UL >> 8))); |
| 325 | } |
| 326 | |
| 327 | #define local_mcck_enable() \ |
Martin Schwidefsky | e258d71 | 2013-09-24 09:14:56 +0200 | [diff] [blame] | 328 | __set_psw_mask(PSW_KERNEL_BITS | PSW_MASK_DAT | PSW_MASK_MCHECK) |
David Howells | a0616cd | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 329 | #define local_mcck_disable() \ |
Martin Schwidefsky | e258d71 | 2013-09-24 09:14:56 +0200 | [diff] [blame] | 330 | __set_psw_mask(PSW_KERNEL_BITS | PSW_MASK_DAT) |
David Howells | a0616cd | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 331 | |
| 332 | /* |
Heiko Carstens | ab14de6 | 2007-02-05 21:18:37 +0100 | [diff] [blame] | 333 | * Basic Machine Check/Program Check Handler. |
| 334 | */ |
| 335 | |
| 336 | extern void s390_base_mcck_handler(void); |
| 337 | extern void s390_base_pgm_handler(void); |
| 338 | extern void s390_base_ext_handler(void); |
| 339 | |
| 340 | extern void (*s390_base_mcck_handler_fn)(void); |
| 341 | extern void (*s390_base_pgm_handler_fn)(void); |
| 342 | extern void (*s390_base_ext_handler_fn)(void); |
| 343 | |
Heiko Carstens | dfd54cb | 2006-09-25 23:31:33 -0700 | [diff] [blame] | 344 | #define ARCH_LOW_ADDRESS_LIMIT 0x7fffffffUL |
| 345 | |
Heiko Carstens | fbe7656 | 2012-06-05 09:59:52 +0200 | [diff] [blame] | 346 | extern int memcpy_real(void *, void *, size_t); |
| 347 | extern void memcpy_absolute(void *, void *, size_t); |
| 348 | |
| 349 | #define mem_assign_absolute(dest, val) { \ |
| 350 | __typeof__(dest) __tmp = (val); \ |
| 351 | \ |
| 352 | BUILD_BUG_ON(sizeof(__tmp) != sizeof(val)); \ |
| 353 | memcpy_absolute(&(dest), &__tmp, sizeof(__tmp)); \ |
| 354 | } |
| 355 | |
Heiko Carstens | eb608fb | 2012-09-05 13:26:11 +0200 | [diff] [blame] | 356 | #endif /* __ASSEMBLY__ */ |
| 357 | |
| 358 | #endif /* __ASM_S390_PROCESSOR_H */ |