aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2012-06-26 10:06:37 -0400
committerMarcelo Tosatti <mtosatti@redhat.com>2012-07-03 13:55:33 -0400
commit9b747530d928800c9eb7f0c131dffd2cc868c475 (patch)
tree12ba4acabb160112ad9e159200f7745b8225fd6a /arch/s390
parent9d04edd23e6ab368d25ca0adde6f1676185d49f8 (diff)
s390/smp/kvm: unifiy sigp definitions
The smp and the kvm code have different defines for the sigp order codes. Let's just have a single place where these are defined. Also move the sigp condition code and sigp cpu status bits to the new sigp.h header file. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/s390')
-rw-r--r--arch/s390/include/asm/sigp.h31
-rw-r--r--arch/s390/kernel/smp.c72
-rw-r--r--arch/s390/kvm/sigp.c46
3 files changed, 64 insertions, 85 deletions
diff --git a/arch/s390/include/asm/sigp.h b/arch/s390/include/asm/sigp.h
new file mode 100644
index 000000000000..7306270b5b84
--- /dev/null
+++ b/arch/s390/include/asm/sigp.h
@@ -0,0 +1,31 @@
1#ifndef __S390_ASM_SIGP_H
2#define __S390_ASM_SIGP_H
3
4/* SIGP order codes */
5#define SIGP_SENSE 1
6#define SIGP_EXTERNAL_CALL 2
7#define SIGP_EMERGENCY_SIGNAL 3
8#define SIGP_STOP 5
9#define SIGP_RESTART 6
10#define SIGP_STOP_AND_STORE_STATUS 9
11#define SIGP_INITIAL_CPU_RESET 11
12#define SIGP_SET_PREFIX 13
13#define SIGP_STORE_STATUS_AT_ADDRESS 14
14#define SIGP_SET_ARCHITECTURE 18
15#define SIGP_SENSE_RUNNING 21
16
17/* SIGP condition codes */
18#define SIGP_CC_ORDER_CODE_ACCEPTED 0
19#define SIGP_CC_STATUS_STORED 1
20#define SIGP_CC_BUSY 2
21#define SIGP_CC_NOT_OPERATIONAL 3
22
23/* SIGP cpu status bits */
24
25#define SIGP_STATUS_CHECK_STOP 0x00000010UL
26#define SIGP_STATUS_STOPPED 0x00000040UL
27#define SIGP_STATUS_INVALID_PARAMETER 0x00000100UL
28#define SIGP_STATUS_INCORRECT_STATE 0x00000200UL
29#define SIGP_STATUS_NOT_RUNNING 0x00000400UL
30
31#endif /* __S390_ASM_SIGP_H */
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index c78074c6cc1d..6e4047e4b498 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -44,34 +44,10 @@
44#include <asm/vdso.h> 44#include <asm/vdso.h>
45#include <asm/debug.h> 45#include <asm/debug.h>
46#include <asm/os_info.h> 46#include <asm/os_info.h>
47#include <asm/sigp.h>
47#include "entry.h" 48#include "entry.h"
48 49
49enum { 50enum {
50 sigp_sense = 1,
51 sigp_external_call = 2,
52 sigp_emergency_signal = 3,
53 sigp_start = 4,
54 sigp_stop = 5,
55 sigp_restart = 6,
56 sigp_stop_and_store_status = 9,
57 sigp_initial_cpu_reset = 11,
58 sigp_cpu_reset = 12,
59 sigp_set_prefix = 13,
60 sigp_store_status_at_address = 14,
61 sigp_store_extended_status_at_address = 15,
62 sigp_set_architecture = 18,
63 sigp_conditional_emergency_signal = 19,
64 sigp_sense_running = 21,
65};
66
67enum {
68 sigp_order_code_accepted = 0,
69 sigp_status_stored = 1,
70 sigp_busy = 2,
71 sigp_not_operational = 3,
72};
73
74enum {
75 ec_schedule = 0, 51 ec_schedule = 0,
76 ec_call_function, 52 ec_call_function,
77 ec_call_function_single, 53 ec_call_function_single,
@@ -124,7 +100,7 @@ static inline int __pcpu_sigp_relax(u16 addr, u8 order, u32 parm, u32 *status)
124 100
125 while (1) { 101 while (1) {
126 cc = __pcpu_sigp(addr, order, parm, status); 102 cc = __pcpu_sigp(addr, order, parm, status);
127 if (cc != sigp_busy) 103 if (cc != SIGP_CC_BUSY)
128 return cc; 104 return cc;
129 cpu_relax(); 105 cpu_relax();
130 } 106 }
@@ -136,7 +112,7 @@ static int pcpu_sigp_retry(struct pcpu *pcpu, u8 order, u32 parm)
136 112
137 for (retry = 0; ; retry++) { 113 for (retry = 0; ; retry++) {
138 cc = __pcpu_sigp(pcpu->address, order, parm, &pcpu->status); 114 cc = __pcpu_sigp(pcpu->address, order, parm, &pcpu->status);
139 if (cc != sigp_busy) 115 if (cc != SIGP_CC_BUSY)
140 break; 116 break;
141 if (retry >= 3) 117 if (retry >= 3)
142 udelay(10); 118 udelay(10);
@@ -146,8 +122,8 @@ static int pcpu_sigp_retry(struct pcpu *pcpu, u8 order, u32 parm)
146 122
147static inline int pcpu_stopped(struct pcpu *pcpu) 123static inline int pcpu_stopped(struct pcpu *pcpu)
148{ 124{
149 if (__pcpu_sigp(pcpu->address, sigp_sense, 125 if (__pcpu_sigp(pcpu->address, SIGP_SENSE,
150 0, &pcpu->status) != sigp_status_stored) 126 0, &pcpu->status) != SIGP_CC_STATUS_STORED)
151 return 0; 127 return 0;
152 /* Check for stopped and check stop state */ 128 /* Check for stopped and check stop state */
153 return !!(pcpu->status & 0x50); 129 return !!(pcpu->status & 0x50);
@@ -155,8 +131,8 @@ static inline int pcpu_stopped(struct pcpu *pcpu)
155 131
156static inline int pcpu_running(struct pcpu *pcpu) 132static inline int pcpu_running(struct pcpu *pcpu)
157{ 133{
158 if (__pcpu_sigp(pcpu->address, sigp_sense_running, 134 if (__pcpu_sigp(pcpu->address, SIGP_SENSE_RUNNING,
159 0, &pcpu->status) != sigp_status_stored) 135 0, &pcpu->status) != SIGP_CC_STATUS_STORED)
160 return 1; 136 return 1;
161 /* Status stored condition code is equivalent to cpu not running. */ 137 /* Status stored condition code is equivalent to cpu not running. */
162 return 0; 138 return 0;
@@ -181,7 +157,7 @@ static void pcpu_ec_call(struct pcpu *pcpu, int ec_bit)
181 157
182 set_bit(ec_bit, &pcpu->ec_mask); 158 set_bit(ec_bit, &pcpu->ec_mask);
183 order = pcpu_running(pcpu) ? 159 order = pcpu_running(pcpu) ?
184 sigp_external_call : sigp_emergency_signal; 160 SIGP_EXTERNAL_CALL : SIGP_EMERGENCY_SIGNAL;
185 pcpu_sigp_retry(pcpu, order, 0); 161 pcpu_sigp_retry(pcpu, order, 0);
186} 162}
187 163
@@ -214,7 +190,7 @@ static int __cpuinit pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu)
214 goto out; 190 goto out;
215#endif 191#endif
216 lowcore_ptr[cpu] = lc; 192 lowcore_ptr[cpu] = lc;
217 pcpu_sigp_retry(pcpu, sigp_set_prefix, (u32)(unsigned long) lc); 193 pcpu_sigp_retry(pcpu, SIGP_SET_PREFIX, (u32)(unsigned long) lc);
218 return 0; 194 return 0;
219out: 195out:
220 if (pcpu != &pcpu_devices[0]) { 196 if (pcpu != &pcpu_devices[0]) {
@@ -229,7 +205,7 @@ out:
229 205
230static void pcpu_free_lowcore(struct pcpu *pcpu) 206static void pcpu_free_lowcore(struct pcpu *pcpu)
231{ 207{
232 pcpu_sigp_retry(pcpu, sigp_set_prefix, 0); 208 pcpu_sigp_retry(pcpu, SIGP_SET_PREFIX, 0);
233 lowcore_ptr[pcpu - pcpu_devices] = NULL; 209 lowcore_ptr[pcpu - pcpu_devices] = NULL;
234#ifndef CONFIG_64BIT 210#ifndef CONFIG_64BIT
235 if (MACHINE_HAS_IEEE) { 211 if (MACHINE_HAS_IEEE) {
@@ -288,7 +264,7 @@ static void pcpu_start_fn(struct pcpu *pcpu, void (*func)(void *), void *data)
288 lc->restart_fn = (unsigned long) func; 264 lc->restart_fn = (unsigned long) func;
289 lc->restart_data = (unsigned long) data; 265 lc->restart_data = (unsigned long) data;
290 lc->restart_source = -1UL; 266 lc->restart_source = -1UL;
291 pcpu_sigp_retry(pcpu, sigp_restart, 0); 267 pcpu_sigp_retry(pcpu, SIGP_RESTART, 0);
292} 268}
293 269
294/* 270/*
@@ -309,7 +285,7 @@ static void pcpu_delegate(struct pcpu *pcpu, void (*func)(void *),
309 if (pcpu->address == restart.source) 285 if (pcpu->address == restart.source)
310 func(data); /* should not return */ 286 func(data); /* should not return */
311 /* Stop target cpu (if func returns this stops the current cpu). */ 287 /* Stop target cpu (if func returns this stops the current cpu). */
312 pcpu_sigp_retry(pcpu, sigp_stop, 0); 288 pcpu_sigp_retry(pcpu, SIGP_STOP, 0);
313 /* Restart func on the target cpu and stop the current cpu. */ 289 /* Restart func on the target cpu and stop the current cpu. */
314 memcpy_absolute(&lc->restart_stack, &restart, sizeof(restart)); 290 memcpy_absolute(&lc->restart_stack, &restart, sizeof(restart));
315 asm volatile( 291 asm volatile(
@@ -388,8 +364,8 @@ void smp_emergency_stop(cpumask_t *cpumask)
388 for_each_cpu(cpu, cpumask) { 364 for_each_cpu(cpu, cpumask) {
389 struct pcpu *pcpu = pcpu_devices + cpu; 365 struct pcpu *pcpu = pcpu_devices + cpu;
390 set_bit(ec_stop_cpu, &pcpu->ec_mask); 366 set_bit(ec_stop_cpu, &pcpu->ec_mask);
391 while (__pcpu_sigp(pcpu->address, sigp_emergency_signal, 367 while (__pcpu_sigp(pcpu->address, SIGP_EMERGENCY_SIGNAL,
392 0, NULL) == sigp_busy && 368 0, NULL) == SIGP_CC_BUSY &&
393 get_clock() < end) 369 get_clock() < end)
394 cpu_relax(); 370 cpu_relax();
395 } 371 }
@@ -425,7 +401,7 @@ void smp_send_stop(void)
425 /* stop all processors */ 401 /* stop all processors */
426 for_each_cpu(cpu, &cpumask) { 402 for_each_cpu(cpu, &cpumask) {
427 struct pcpu *pcpu = pcpu_devices + cpu; 403 struct pcpu *pcpu = pcpu_devices + cpu;
428 pcpu_sigp_retry(pcpu, sigp_stop, 0); 404 pcpu_sigp_retry(pcpu, SIGP_STOP, 0);
429 while (!pcpu_stopped(pcpu)) 405 while (!pcpu_stopped(pcpu))
430 cpu_relax(); 406 cpu_relax();
431 } 407 }
@@ -436,7 +412,7 @@ void smp_send_stop(void)
436 */ 412 */
437void smp_stop_cpu(void) 413void smp_stop_cpu(void)
438{ 414{
439 pcpu_sigp_retry(pcpu_devices + smp_processor_id(), sigp_stop, 0); 415 pcpu_sigp_retry(pcpu_devices + smp_processor_id(), SIGP_STOP, 0);
440 for (;;) ; 416 for (;;) ;
441} 417}
442 418
@@ -590,7 +566,7 @@ static void __init smp_get_save_area(int cpu, u16 address)
590 } 566 }
591#endif 567#endif
592 /* Get the registers of a non-boot cpu. */ 568 /* Get the registers of a non-boot cpu. */
593 __pcpu_sigp_relax(address, sigp_stop_and_store_status, 0, NULL); 569 __pcpu_sigp_relax(address, SIGP_STOP_AND_STORE_STATUS, 0, NULL);
594 memcpy_real(save_area, lc + SAVE_AREA_BASE, sizeof(*save_area)); 570 memcpy_real(save_area, lc + SAVE_AREA_BASE, sizeof(*save_area));
595} 571}
596 572
@@ -599,8 +575,8 @@ int smp_store_status(int cpu)
599 struct pcpu *pcpu; 575 struct pcpu *pcpu;
600 576
601 pcpu = pcpu_devices + cpu; 577 pcpu = pcpu_devices + cpu;
602 if (__pcpu_sigp_relax(pcpu->address, sigp_stop_and_store_status, 578 if (__pcpu_sigp_relax(pcpu->address, SIGP_STOP_AND_STORE_STATUS,
603 0, NULL) != sigp_order_code_accepted) 579 0, NULL) != SIGP_CC_ORDER_CODE_ACCEPTED)
604 return -EIO; 580 return -EIO;
605 return 0; 581 return 0;
606} 582}
@@ -621,8 +597,8 @@ static struct sclp_cpu_info *smp_get_cpu_info(void)
621 if (info && (use_sigp_detection || sclp_get_cpu_info(info))) { 597 if (info && (use_sigp_detection || sclp_get_cpu_info(info))) {
622 use_sigp_detection = 1; 598 use_sigp_detection = 1;
623 for (address = 0; address <= MAX_CPU_ADDRESS; address++) { 599 for (address = 0; address <= MAX_CPU_ADDRESS; address++) {
624 if (__pcpu_sigp_relax(address, sigp_sense, 0, NULL) == 600 if (__pcpu_sigp_relax(address, SIGP_SENSE, 0, NULL) ==
625 sigp_not_operational) 601 SIGP_CC_NOT_OPERATIONAL)
626 continue; 602 continue;
627 info->cpu[info->configured].address = address; 603 info->cpu[info->configured].address = address;
628 info->configured++; 604 info->configured++;
@@ -734,8 +710,8 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
734 pcpu = pcpu_devices + cpu; 710 pcpu = pcpu_devices + cpu;
735 if (pcpu->state != CPU_STATE_CONFIGURED) 711 if (pcpu->state != CPU_STATE_CONFIGURED)
736 return -EIO; 712 return -EIO;
737 if (pcpu_sigp_retry(pcpu, sigp_initial_cpu_reset, 0) != 713 if (pcpu_sigp_retry(pcpu, SIGP_INITIAL_CPU_RESET, 0) !=
738 sigp_order_code_accepted) 714 SIGP_CC_ORDER_CODE_ACCEPTED)
739 return -EIO; 715 return -EIO;
740 716
741 rc = pcpu_alloc_lowcore(pcpu, cpu); 717 rc = pcpu_alloc_lowcore(pcpu, cpu);
@@ -795,7 +771,7 @@ void __cpu_die(unsigned int cpu)
795void __noreturn cpu_die(void) 771void __noreturn cpu_die(void)
796{ 772{
797 idle_task_exit(); 773 idle_task_exit();
798 pcpu_sigp_retry(pcpu_devices + smp_processor_id(), sigp_stop, 0); 774 pcpu_sigp_retry(pcpu_devices + smp_processor_id(), SIGP_STOP, 0);
799 for (;;) ; 775 for (;;) ;
800} 776}
801 777
diff --git a/arch/s390/kvm/sigp.c b/arch/s390/kvm/sigp.c
index 0ad4cf238391..fda1d64f15ee 100644
--- a/arch/s390/kvm/sigp.c
+++ b/arch/s390/kvm/sigp.c
@@ -15,38 +15,10 @@
15#include <linux/kvm.h> 15#include <linux/kvm.h>
16#include <linux/kvm_host.h> 16#include <linux/kvm_host.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <asm/sigp.h>
18#include "gaccess.h" 19#include "gaccess.h"
19#include "kvm-s390.h" 20#include "kvm-s390.h"
20 21
21/* sigp order codes */
22#define SIGP_SENSE 0x01
23#define SIGP_EXTERNAL_CALL 0x02
24#define SIGP_EMERGENCY 0x03
25#define SIGP_START 0x04
26#define SIGP_STOP 0x05
27#define SIGP_RESTART 0x06
28#define SIGP_STOP_STORE_STATUS 0x09
29#define SIGP_INITIAL_CPU_RESET 0x0b
30#define SIGP_CPU_RESET 0x0c
31#define SIGP_SET_PREFIX 0x0d
32#define SIGP_STORE_STATUS_ADDR 0x0e
33#define SIGP_SET_ARCH 0x12
34#define SIGP_SENSE_RUNNING 0x15
35
36/* cpu status bits */
37#define SIGP_STAT_EQUIPMENT_CHECK 0x80000000UL
38#define SIGP_STAT_NOT_RUNNING 0x00000400UL
39#define SIGP_STAT_INCORRECT_STATE 0x00000200UL
40#define SIGP_STAT_INVALID_PARAMETER 0x00000100UL
41#define SIGP_STAT_EXT_CALL_PENDING 0x00000080UL
42#define SIGP_STAT_STOPPED 0x00000040UL
43#define SIGP_STAT_OPERATOR_INTERV 0x00000020UL
44#define SIGP_STAT_CHECK_STOP 0x00000010UL
45#define SIGP_STAT_INOPERATIVE 0x00000004UL
46#define SIGP_STAT_INVALID_ORDER 0x00000002UL
47#define SIGP_STAT_RECEIVER_CHECK 0x00000001UL
48
49
50static int __sigp_sense(struct kvm_vcpu *vcpu, u16 cpu_addr, 22static int __sigp_sense(struct kvm_vcpu *vcpu, u16 cpu_addr,
51 u64 *reg) 23 u64 *reg)
52{ 24{
@@ -65,7 +37,7 @@ static int __sigp_sense(struct kvm_vcpu *vcpu, u16 cpu_addr,
65 rc = 1; /* status stored */ 37 rc = 1; /* status stored */
66 } else { 38 } else {
67 *reg &= 0xffffffff00000000UL; 39 *reg &= 0xffffffff00000000UL;
68 *reg |= SIGP_STAT_STOPPED; 40 *reg |= SIGP_STATUS_STOPPED;
69 rc = 1; /* status stored */ 41 rc = 1; /* status stored */
70 } 42 }
71 spin_unlock(&fi->lock); 43 spin_unlock(&fi->lock);
@@ -235,7 +207,7 @@ static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address,
235 address = address & 0x7fffe000u; 207 address = address & 0x7fffe000u;
236 if (copy_from_guest_absolute(vcpu, &tmp, address, 1) || 208 if (copy_from_guest_absolute(vcpu, &tmp, address, 1) ||
237 copy_from_guest_absolute(vcpu, &tmp, address + PAGE_SIZE, 1)) { 209 copy_from_guest_absolute(vcpu, &tmp, address + PAGE_SIZE, 1)) {
238 *reg |= SIGP_STAT_INVALID_PARAMETER; 210 *reg |= SIGP_STATUS_INVALID_PARAMETER;
239 return 1; /* invalid parameter */ 211 return 1; /* invalid parameter */
240 } 212 }
241 213
@@ -249,7 +221,7 @@ static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address,
249 221
250 if (li == NULL) { 222 if (li == NULL) {
251 rc = 1; /* incorrect state */ 223 rc = 1; /* incorrect state */
252 *reg &= SIGP_STAT_INCORRECT_STATE; 224 *reg &= SIGP_STATUS_INCORRECT_STATE;
253 kfree(inti); 225 kfree(inti);
254 goto out_fi; 226 goto out_fi;
255 } 227 }
@@ -258,7 +230,7 @@ static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address,
258 /* cpu must be in stopped state */ 230 /* cpu must be in stopped state */
259 if (!(atomic_read(li->cpuflags) & CPUSTAT_STOPPED)) { 231 if (!(atomic_read(li->cpuflags) & CPUSTAT_STOPPED)) {
260 rc = 1; /* incorrect state */ 232 rc = 1; /* incorrect state */
261 *reg &= SIGP_STAT_INCORRECT_STATE; 233 *reg &= SIGP_STATUS_INCORRECT_STATE;
262 kfree(inti); 234 kfree(inti);
263 goto out_li; 235 goto out_li;
264 } 236 }
@@ -300,7 +272,7 @@ static int __sigp_sense_running(struct kvm_vcpu *vcpu, u16 cpu_addr,
300 } else { 272 } else {
301 /* not running */ 273 /* not running */
302 *reg &= 0xffffffff00000000UL; 274 *reg &= 0xffffffff00000000UL;
303 *reg |= SIGP_STAT_NOT_RUNNING; 275 *reg |= SIGP_STATUS_NOT_RUNNING;
304 rc = 0; 276 rc = 0;
305 } 277 }
306 } 278 }
@@ -375,7 +347,7 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu)
375 vcpu->stat.instruction_sigp_external_call++; 347 vcpu->stat.instruction_sigp_external_call++;
376 rc = __sigp_external_call(vcpu, cpu_addr); 348 rc = __sigp_external_call(vcpu, cpu_addr);
377 break; 349 break;
378 case SIGP_EMERGENCY: 350 case SIGP_EMERGENCY_SIGNAL:
379 vcpu->stat.instruction_sigp_emergency++; 351 vcpu->stat.instruction_sigp_emergency++;
380 rc = __sigp_emergency(vcpu, cpu_addr); 352 rc = __sigp_emergency(vcpu, cpu_addr);
381 break; 353 break;
@@ -383,12 +355,12 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu)
383 vcpu->stat.instruction_sigp_stop++; 355 vcpu->stat.instruction_sigp_stop++;
384 rc = __sigp_stop(vcpu, cpu_addr, ACTION_STOP_ON_STOP); 356 rc = __sigp_stop(vcpu, cpu_addr, ACTION_STOP_ON_STOP);
385 break; 357 break;
386 case SIGP_STOP_STORE_STATUS: 358 case SIGP_STOP_AND_STORE_STATUS:
387 vcpu->stat.instruction_sigp_stop++; 359 vcpu->stat.instruction_sigp_stop++;
388 rc = __sigp_stop(vcpu, cpu_addr, ACTION_STORE_ON_STOP | 360 rc = __sigp_stop(vcpu, cpu_addr, ACTION_STORE_ON_STOP |
389 ACTION_STOP_ON_STOP); 361 ACTION_STOP_ON_STOP);
390 break; 362 break;
391 case SIGP_SET_ARCH: 363 case SIGP_SET_ARCHITECTURE:
392 vcpu->stat.instruction_sigp_arch++; 364 vcpu->stat.instruction_sigp_arch++;
393 rc = __sigp_set_arch(vcpu, parameter); 365 rc = __sigp_set_arch(vcpu, parameter);
394 break; 366 break;