Commit a9ae32c3 authored by Heiko Carstens's avatar Heiko Carstens Committed by Martin Schwidefsky

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: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 524b24ad
#ifndef __S390_ASM_SIGP_H
#define __S390_ASM_SIGP_H
/* SIGP order codes */
#define SIGP_SENSE 1
#define SIGP_EXTERNAL_CALL 2
#define SIGP_EMERGENCY_SIGNAL 3
#define SIGP_STOP 5
#define SIGP_RESTART 6
#define SIGP_STOP_AND_STORE_STATUS 9
#define SIGP_INITIAL_CPU_RESET 11
#define SIGP_SET_PREFIX 13
#define SIGP_STORE_STATUS_AT_ADDRESS 14
#define SIGP_SET_ARCHITECTURE 18
#define SIGP_SENSE_RUNNING 21
/* SIGP condition codes */
#define SIGP_CC_ORDER_CODE_ACCEPTED 0
#define SIGP_CC_STATUS_STORED 1
#define SIGP_CC_BUSY 2
#define SIGP_CC_NOT_OPERATIONAL 3
/* SIGP cpu status bits */
#define SIGP_STATUS_CHECK_STOP 0x00000010UL
#define SIGP_STATUS_STOPPED 0x00000040UL
#define SIGP_STATUS_INVALID_PARAMETER 0x00000100UL
#define SIGP_STATUS_INCORRECT_STATE 0x00000200UL
#define SIGP_STATUS_NOT_RUNNING 0x00000400UL
#endif /* __S390_ASM_SIGP_H */
...@@ -44,33 +44,9 @@ ...@@ -44,33 +44,9 @@
#include <asm/vdso.h> #include <asm/vdso.h>
#include <asm/debug.h> #include <asm/debug.h>
#include <asm/os_info.h> #include <asm/os_info.h>
#include <asm/sigp.h>
#include "entry.h" #include "entry.h"
enum {
sigp_sense = 1,
sigp_external_call = 2,
sigp_emergency_signal = 3,
sigp_start = 4,
sigp_stop = 5,
sigp_restart = 6,
sigp_stop_and_store_status = 9,
sigp_initial_cpu_reset = 11,
sigp_cpu_reset = 12,
sigp_set_prefix = 13,
sigp_store_status_at_address = 14,
sigp_store_extended_status_at_address = 15,
sigp_set_architecture = 18,
sigp_conditional_emergency_signal = 19,
sigp_sense_running = 21,
};
enum {
sigp_order_code_accepted = 0,
sigp_status_stored = 1,
sigp_busy = 2,
sigp_not_operational = 3,
};
enum { enum {
ec_schedule = 0, ec_schedule = 0,
ec_call_function, ec_call_function,
...@@ -124,7 +100,7 @@ static inline int __pcpu_sigp_relax(u16 addr, u8 order, u32 parm, u32 *status) ...@@ -124,7 +100,7 @@ static inline int __pcpu_sigp_relax(u16 addr, u8 order, u32 parm, u32 *status)
while (1) { while (1) {
cc = __pcpu_sigp(addr, order, parm, status); cc = __pcpu_sigp(addr, order, parm, status);
if (cc != sigp_busy) if (cc != SIGP_CC_BUSY)
return cc; return cc;
cpu_relax(); cpu_relax();
} }
...@@ -136,7 +112,7 @@ static int pcpu_sigp_retry(struct pcpu *pcpu, u8 order, u32 parm) ...@@ -136,7 +112,7 @@ static int pcpu_sigp_retry(struct pcpu *pcpu, u8 order, u32 parm)
for (retry = 0; ; retry++) { for (retry = 0; ; retry++) {
cc = __pcpu_sigp(pcpu->address, order, parm, &pcpu->status); cc = __pcpu_sigp(pcpu->address, order, parm, &pcpu->status);
if (cc != sigp_busy) if (cc != SIGP_CC_BUSY)
break; break;
if (retry >= 3) if (retry >= 3)
udelay(10); udelay(10);
...@@ -146,8 +122,8 @@ static int pcpu_sigp_retry(struct pcpu *pcpu, u8 order, u32 parm) ...@@ -146,8 +122,8 @@ static int pcpu_sigp_retry(struct pcpu *pcpu, u8 order, u32 parm)
static inline int pcpu_stopped(struct pcpu *pcpu) static inline int pcpu_stopped(struct pcpu *pcpu)
{ {
if (__pcpu_sigp(pcpu->address, sigp_sense, if (__pcpu_sigp(pcpu->address, SIGP_SENSE,
0, &pcpu->status) != sigp_status_stored) 0, &pcpu->status) != SIGP_CC_STATUS_STORED)
return 0; return 0;
/* Check for stopped and check stop state */ /* Check for stopped and check stop state */
return !!(pcpu->status & 0x50); return !!(pcpu->status & 0x50);
...@@ -155,8 +131,8 @@ static inline int pcpu_stopped(struct pcpu *pcpu) ...@@ -155,8 +131,8 @@ static inline int pcpu_stopped(struct pcpu *pcpu)
static inline int pcpu_running(struct pcpu *pcpu) static inline int pcpu_running(struct pcpu *pcpu)
{ {
if (__pcpu_sigp(pcpu->address, sigp_sense_running, if (__pcpu_sigp(pcpu->address, SIGP_SENSE_RUNNING,
0, &pcpu->status) != sigp_status_stored) 0, &pcpu->status) != SIGP_CC_STATUS_STORED)
return 1; return 1;
/* Status stored condition code is equivalent to cpu not running. */ /* Status stored condition code is equivalent to cpu not running. */
return 0; return 0;
...@@ -181,7 +157,7 @@ static void pcpu_ec_call(struct pcpu *pcpu, int ec_bit) ...@@ -181,7 +157,7 @@ static void pcpu_ec_call(struct pcpu *pcpu, int ec_bit)
set_bit(ec_bit, &pcpu->ec_mask); set_bit(ec_bit, &pcpu->ec_mask);
order = pcpu_running(pcpu) ? order = pcpu_running(pcpu) ?
sigp_external_call : sigp_emergency_signal; SIGP_EXTERNAL_CALL : SIGP_EMERGENCY_SIGNAL;
pcpu_sigp_retry(pcpu, order, 0); pcpu_sigp_retry(pcpu, order, 0);
} }
...@@ -214,7 +190,7 @@ static int __cpuinit pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu) ...@@ -214,7 +190,7 @@ static int __cpuinit pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu)
goto out; goto out;
#endif #endif
lowcore_ptr[cpu] = lc; lowcore_ptr[cpu] = lc;
pcpu_sigp_retry(pcpu, sigp_set_prefix, (u32)(unsigned long) lc); pcpu_sigp_retry(pcpu, SIGP_SET_PREFIX, (u32)(unsigned long) lc);
return 0; return 0;
out: out:
if (pcpu != &pcpu_devices[0]) { if (pcpu != &pcpu_devices[0]) {
...@@ -229,7 +205,7 @@ static int __cpuinit pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu) ...@@ -229,7 +205,7 @@ static int __cpuinit pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu)
static void pcpu_free_lowcore(struct pcpu *pcpu) static void pcpu_free_lowcore(struct pcpu *pcpu)
{ {
pcpu_sigp_retry(pcpu, sigp_set_prefix, 0); pcpu_sigp_retry(pcpu, SIGP_SET_PREFIX, 0);
lowcore_ptr[pcpu - pcpu_devices] = NULL; lowcore_ptr[pcpu - pcpu_devices] = NULL;
#ifndef CONFIG_64BIT #ifndef CONFIG_64BIT
if (MACHINE_HAS_IEEE) { if (MACHINE_HAS_IEEE) {
...@@ -288,7 +264,7 @@ static void pcpu_start_fn(struct pcpu *pcpu, void (*func)(void *), void *data) ...@@ -288,7 +264,7 @@ static void pcpu_start_fn(struct pcpu *pcpu, void (*func)(void *), void *data)
lc->restart_fn = (unsigned long) func; lc->restart_fn = (unsigned long) func;
lc->restart_data = (unsigned long) data; lc->restart_data = (unsigned long) data;
lc->restart_source = -1UL; lc->restart_source = -1UL;
pcpu_sigp_retry(pcpu, sigp_restart, 0); pcpu_sigp_retry(pcpu, SIGP_RESTART, 0);
} }
/* /*
...@@ -309,7 +285,7 @@ static void pcpu_delegate(struct pcpu *pcpu, void (*func)(void *), ...@@ -309,7 +285,7 @@ static void pcpu_delegate(struct pcpu *pcpu, void (*func)(void *),
if (pcpu->address == restart.source) if (pcpu->address == restart.source)
func(data); /* should not return */ func(data); /* should not return */
/* Stop target cpu (if func returns this stops the current cpu). */ /* Stop target cpu (if func returns this stops the current cpu). */
pcpu_sigp_retry(pcpu, sigp_stop, 0); pcpu_sigp_retry(pcpu, SIGP_STOP, 0);
/* Restart func on the target cpu and stop the current cpu. */ /* Restart func on the target cpu and stop the current cpu. */
memcpy_absolute(&lc->restart_stack, &restart, sizeof(restart)); memcpy_absolute(&lc->restart_stack, &restart, sizeof(restart));
asm volatile( asm volatile(
...@@ -388,8 +364,8 @@ void smp_emergency_stop(cpumask_t *cpumask) ...@@ -388,8 +364,8 @@ void smp_emergency_stop(cpumask_t *cpumask)
for_each_cpu(cpu, cpumask) { for_each_cpu(cpu, cpumask) {
struct pcpu *pcpu = pcpu_devices + cpu; struct pcpu *pcpu = pcpu_devices + cpu;
set_bit(ec_stop_cpu, &pcpu->ec_mask); set_bit(ec_stop_cpu, &pcpu->ec_mask);
while (__pcpu_sigp(pcpu->address, sigp_emergency_signal, while (__pcpu_sigp(pcpu->address, SIGP_EMERGENCY_SIGNAL,
0, NULL) == sigp_busy && 0, NULL) == SIGP_CC_BUSY &&
get_clock() < end) get_clock() < end)
cpu_relax(); cpu_relax();
} }
...@@ -425,7 +401,7 @@ void smp_send_stop(void) ...@@ -425,7 +401,7 @@ void smp_send_stop(void)
/* stop all processors */ /* stop all processors */
for_each_cpu(cpu, &cpumask) { for_each_cpu(cpu, &cpumask) {
struct pcpu *pcpu = pcpu_devices + cpu; struct pcpu *pcpu = pcpu_devices + cpu;
pcpu_sigp_retry(pcpu, sigp_stop, 0); pcpu_sigp_retry(pcpu, SIGP_STOP, 0);
while (!pcpu_stopped(pcpu)) while (!pcpu_stopped(pcpu))
cpu_relax(); cpu_relax();
} }
...@@ -436,7 +412,7 @@ void smp_send_stop(void) ...@@ -436,7 +412,7 @@ void smp_send_stop(void)
*/ */
void smp_stop_cpu(void) void smp_stop_cpu(void)
{ {
pcpu_sigp_retry(pcpu_devices + smp_processor_id(), sigp_stop, 0); pcpu_sigp_retry(pcpu_devices + smp_processor_id(), SIGP_STOP, 0);
for (;;) ; for (;;) ;
} }
...@@ -590,7 +566,7 @@ static void __init smp_get_save_area(int cpu, u16 address) ...@@ -590,7 +566,7 @@ static void __init smp_get_save_area(int cpu, u16 address)
} }
#endif #endif
/* Get the registers of a non-boot cpu. */ /* Get the registers of a non-boot cpu. */
__pcpu_sigp_relax(address, sigp_stop_and_store_status, 0, NULL); __pcpu_sigp_relax(address, SIGP_STOP_AND_STORE_STATUS, 0, NULL);
memcpy_real(save_area, lc + SAVE_AREA_BASE, sizeof(*save_area)); memcpy_real(save_area, lc + SAVE_AREA_BASE, sizeof(*save_area));
} }
...@@ -599,8 +575,8 @@ int smp_store_status(int cpu) ...@@ -599,8 +575,8 @@ int smp_store_status(int cpu)
struct pcpu *pcpu; struct pcpu *pcpu;
pcpu = pcpu_devices + cpu; pcpu = pcpu_devices + cpu;
if (__pcpu_sigp_relax(pcpu->address, sigp_stop_and_store_status, if (__pcpu_sigp_relax(pcpu->address, SIGP_STOP_AND_STORE_STATUS,
0, NULL) != sigp_order_code_accepted) 0, NULL) != SIGP_CC_ORDER_CODE_ACCEPTED)
return -EIO; return -EIO;
return 0; return 0;
} }
...@@ -621,8 +597,8 @@ static struct sclp_cpu_info *smp_get_cpu_info(void) ...@@ -621,8 +597,8 @@ static struct sclp_cpu_info *smp_get_cpu_info(void)
if (info && (use_sigp_detection || sclp_get_cpu_info(info))) { if (info && (use_sigp_detection || sclp_get_cpu_info(info))) {
use_sigp_detection = 1; use_sigp_detection = 1;
for (address = 0; address <= MAX_CPU_ADDRESS; address++) { for (address = 0; address <= MAX_CPU_ADDRESS; address++) {
if (__pcpu_sigp_relax(address, sigp_sense, 0, NULL) == if (__pcpu_sigp_relax(address, SIGP_SENSE, 0, NULL) ==
sigp_not_operational) SIGP_CC_NOT_OPERATIONAL)
continue; continue;
info->cpu[info->configured].address = address; info->cpu[info->configured].address = address;
info->configured++; info->configured++;
...@@ -734,8 +710,8 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle) ...@@ -734,8 +710,8 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
pcpu = pcpu_devices + cpu; pcpu = pcpu_devices + cpu;
if (pcpu->state != CPU_STATE_CONFIGURED) if (pcpu->state != CPU_STATE_CONFIGURED)
return -EIO; return -EIO;
if (pcpu_sigp_retry(pcpu, sigp_initial_cpu_reset, 0) != if (pcpu_sigp_retry(pcpu, SIGP_INITIAL_CPU_RESET, 0) !=
sigp_order_code_accepted) SIGP_CC_ORDER_CODE_ACCEPTED)
return -EIO; return -EIO;
rc = pcpu_alloc_lowcore(pcpu, cpu); rc = pcpu_alloc_lowcore(pcpu, cpu);
...@@ -795,7 +771,7 @@ void __cpu_die(unsigned int cpu) ...@@ -795,7 +771,7 @@ void __cpu_die(unsigned int cpu)
void __noreturn cpu_die(void) void __noreturn cpu_die(void)
{ {
idle_task_exit(); idle_task_exit();
pcpu_sigp_retry(pcpu_devices + smp_processor_id(), sigp_stop, 0); pcpu_sigp_retry(pcpu_devices + smp_processor_id(), SIGP_STOP, 0);
for (;;) ; for (;;) ;
} }
......
...@@ -15,38 +15,10 @@ ...@@ -15,38 +15,10 @@
#include <linux/kvm.h> #include <linux/kvm.h>
#include <linux/kvm_host.h> #include <linux/kvm_host.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <asm/sigp.h>
#include "gaccess.h" #include "gaccess.h"
#include "kvm-s390.h" #include "kvm-s390.h"
/* sigp order codes */
#define SIGP_SENSE 0x01
#define SIGP_EXTERNAL_CALL 0x02
#define SIGP_EMERGENCY 0x03
#define SIGP_START 0x04
#define SIGP_STOP 0x05
#define SIGP_RESTART 0x06
#define SIGP_STOP_STORE_STATUS 0x09
#define SIGP_INITIAL_CPU_RESET 0x0b
#define SIGP_CPU_RESET 0x0c
#define SIGP_SET_PREFIX 0x0d
#define SIGP_STORE_STATUS_ADDR 0x0e
#define SIGP_SET_ARCH 0x12
#define SIGP_SENSE_RUNNING 0x15
/* cpu status bits */
#define SIGP_STAT_EQUIPMENT_CHECK 0x80000000UL
#define SIGP_STAT_NOT_RUNNING 0x00000400UL
#define SIGP_STAT_INCORRECT_STATE 0x00000200UL
#define SIGP_STAT_INVALID_PARAMETER 0x00000100UL
#define SIGP_STAT_EXT_CALL_PENDING 0x00000080UL
#define SIGP_STAT_STOPPED 0x00000040UL
#define SIGP_STAT_OPERATOR_INTERV 0x00000020UL
#define SIGP_STAT_CHECK_STOP 0x00000010UL
#define SIGP_STAT_INOPERATIVE 0x00000004UL
#define SIGP_STAT_INVALID_ORDER 0x00000002UL
#define SIGP_STAT_RECEIVER_CHECK 0x00000001UL
static int __sigp_sense(struct kvm_vcpu *vcpu, u16 cpu_addr, static int __sigp_sense(struct kvm_vcpu *vcpu, u16 cpu_addr,
u64 *reg) u64 *reg)
{ {
...@@ -65,7 +37,7 @@ static int __sigp_sense(struct kvm_vcpu *vcpu, u16 cpu_addr, ...@@ -65,7 +37,7 @@ static int __sigp_sense(struct kvm_vcpu *vcpu, u16 cpu_addr,
rc = 1; /* status stored */ rc = 1; /* status stored */
} else { } else {
*reg &= 0xffffffff00000000UL; *reg &= 0xffffffff00000000UL;
*reg |= SIGP_STAT_STOPPED; *reg |= SIGP_STATUS_STOPPED;
rc = 1; /* status stored */ rc = 1; /* status stored */
} }
spin_unlock(&fi->lock); spin_unlock(&fi->lock);
...@@ -235,7 +207,7 @@ static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address, ...@@ -235,7 +207,7 @@ static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address,
address = address & 0x7fffe000u; address = address & 0x7fffe000u;
if (copy_from_guest_absolute(vcpu, &tmp, address, 1) || if (copy_from_guest_absolute(vcpu, &tmp, address, 1) ||
copy_from_guest_absolute(vcpu, &tmp, address + PAGE_SIZE, 1)) { copy_from_guest_absolute(vcpu, &tmp, address + PAGE_SIZE, 1)) {
*reg |= SIGP_STAT_INVALID_PARAMETER; *reg |= SIGP_STATUS_INVALID_PARAMETER;
return 1; /* invalid parameter */ return 1; /* invalid parameter */
} }
...@@ -249,7 +221,7 @@ static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address, ...@@ -249,7 +221,7 @@ static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address,
if (li == NULL) { if (li == NULL) {
rc = 1; /* incorrect state */ rc = 1; /* incorrect state */
*reg &= SIGP_STAT_INCORRECT_STATE; *reg &= SIGP_STATUS_INCORRECT_STATE;
kfree(inti); kfree(inti);
goto out_fi; goto out_fi;
} }
...@@ -258,7 +230,7 @@ static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address, ...@@ -258,7 +230,7 @@ static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address,
/* cpu must be in stopped state */ /* cpu must be in stopped state */
if (!(atomic_read(li->cpuflags) & CPUSTAT_STOPPED)) { if (!(atomic_read(li->cpuflags) & CPUSTAT_STOPPED)) {
rc = 1; /* incorrect state */ rc = 1; /* incorrect state */
*reg &= SIGP_STAT_INCORRECT_STATE; *reg &= SIGP_STATUS_INCORRECT_STATE;
kfree(inti); kfree(inti);
goto out_li; goto out_li;
} }
...@@ -300,7 +272,7 @@ static int __sigp_sense_running(struct kvm_vcpu *vcpu, u16 cpu_addr, ...@@ -300,7 +272,7 @@ static int __sigp_sense_running(struct kvm_vcpu *vcpu, u16 cpu_addr,
} else { } else {
/* not running */ /* not running */
*reg &= 0xffffffff00000000UL; *reg &= 0xffffffff00000000UL;
*reg |= SIGP_STAT_NOT_RUNNING; *reg |= SIGP_STATUS_NOT_RUNNING;
rc = 0; rc = 0;
} }
} }
...@@ -375,7 +347,7 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu) ...@@ -375,7 +347,7 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu)
vcpu->stat.instruction_sigp_external_call++; vcpu->stat.instruction_sigp_external_call++;
rc = __sigp_external_call(vcpu, cpu_addr); rc = __sigp_external_call(vcpu, cpu_addr);
break; break;
case SIGP_EMERGENCY: case SIGP_EMERGENCY_SIGNAL:
vcpu->stat.instruction_sigp_emergency++; vcpu->stat.instruction_sigp_emergency++;
rc = __sigp_emergency(vcpu, cpu_addr); rc = __sigp_emergency(vcpu, cpu_addr);
break; break;
...@@ -383,12 +355,12 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu) ...@@ -383,12 +355,12 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu)
vcpu->stat.instruction_sigp_stop++; vcpu->stat.instruction_sigp_stop++;
rc = __sigp_stop(vcpu, cpu_addr, ACTION_STOP_ON_STOP); rc = __sigp_stop(vcpu, cpu_addr, ACTION_STOP_ON_STOP);
break; break;
case SIGP_STOP_STORE_STATUS: case SIGP_STOP_AND_STORE_STATUS:
vcpu->stat.instruction_sigp_stop++; vcpu->stat.instruction_sigp_stop++;
rc = __sigp_stop(vcpu, cpu_addr, ACTION_STORE_ON_STOP | rc = __sigp_stop(vcpu, cpu_addr, ACTION_STORE_ON_STOP |
ACTION_STOP_ON_STOP); ACTION_STOP_ON_STOP);
break; break;
case SIGP_SET_ARCH: case SIGP_SET_ARCHITECTURE:
vcpu->stat.instruction_sigp_arch++; vcpu->stat.instruction_sigp_arch++;
rc = __sigp_set_arch(vcpu, parameter); rc = __sigp_set_arch(vcpu, parameter);
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment