s390: current patches
cover s390: current patches
Alex, this is our current patch queue for s390.
SCLP patches v2:
SCLP base support was changed to address your review comments and the signal quiesce support patch now uses a powerdown notifier.
sync regs v2:
Christian's sync regs patch now follows the level statement for KVM_PUT_FULL_STATE and _RESET_STATE and saves the sync_regs capability in a variable.
Christian Borntraeger (1):
s390: use sync regs for register transfer
Heinz Graalfs (4):
s390: sclp base support
s390: sclp event support
s390: sclp signal quiesce support
s390: sclp ascii console support
hw/s390-virtio.c | 2 + hw/s390x/Makefile.objs | 3 + hw/s390x/event-facility.c | 398 +++++++++++++++++++++++++++++++++++++++++++++ hw/s390x/event-facility.h | 96 +++++++++++ hw/s390x/sclp.c | 164 +++++++++++++++++++ hw/s390x/sclp.h | 118 ++++++++++++++ hw/s390x/sclpconsole.c | 306 ++++++++++++++++++++++++++++++++++ hw/s390x/sclpquiesce.c | 123 ++++++++++++++ target-s390x/cpu.h | 13 +- target-s390x/kvm.c | 124 +++++++++++--- target-s390x/misc_helper.c | 45 +---- 11 files changed, 1312 insertions(+), 80 deletions(-) create mode 100644 hw/s390x/event-facility.c create mode 100644 hw/s390x/event-facility.h create mode 100644 hw/s390x/sclp.c create mode 100644 hw/s390x/sclp.h create mode 100644 hw/s390x/sclpconsole.c create mode 100644 hw/s390x/sclpquiesce.c
Signature · 1 line
1.7.11.7
PATCH 1/5 s390: use sync regs for register transfer
From: Christian Borntraeger <[email protected]>
Newer kernels provide the guest registers in kvm_run. Lets use those if available (i.e. the capability is set). This avoids ioctls on cpu_synchronize_state making intercepts faster.
In addition, we have now the prefix register, the access registers the control registers up to date. This helps in certain cases, e.g. for resolving kernel module addresses with gdb on a guest.
On return, we update the registers according to the level statement, i.e. we put all registers for KVM_PUT_FULL_STATE and _RESET_STATE.
--- target-s390x/kvm.c | 119 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 99 insertions(+), 20 deletions(-)
target-s390x/kvm.c +99 -20
@@ -67,8 +67,11 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = { KVM_CAP_LAST_INFO }; +int cap_sync_regs; +int kvm_arch_init (KVMState *s) { + cap_sync_regs =kvm_check_extension (s,KVM_CAP_SYNC_REGS );return 0 ; }
@@ -88,49 +91,125 @@ void kvm_arch_reset_vcpu(CPUS390XState *env)/* FIXME: add code to reset vcpu. */ } +/* we want to have the prefix, the GPRS, the ACRS and the CRS up to date */ +#define QEMU_NEEDED_REGS (KVM_SYNC_PREFIX | KVM_SYNC_GPRS | \ + KVM_SYNC_ACRS | KVM_SYNC_CRS) + +/* But qemu only changes the GPRS */ +#define QEMU_DIRTY_REGS (KVM_SYNC_GPRS) +int kvm_arch_put_registers (CPUS390XState *env,int level) { +struct kvm_sregs sregs;struct kvm_regs regs;int ret;int i; - ret =kvm_vcpu_ioctl (env,KVM_GET_REGS , ®s); -if (ret <0 ) { -return ret; - } +/* always save the PSW and the GPRS*/ + env->kvm_run->psw_addr = env->psw.addr; + env->kvm_run->psw_mask = env->psw.mask; -for (i =0 ; i <16 ; i++) { - regs.gprs[i] = env->regs[i]; +if (cap_sync_regs && env->kvm_run->kvm_valid_regs &KVM_SYNC_GPRS ) { +for (i =0 ; i <16 ; i++) { + env->kvm_run->s.regs.gprs[i] = env->regs[i]; + env->kvm_run->kvm_dirty_regs |=KVM_SYNC_GPRS ; + } + }else { +for (i =0 ; i <16 ; i++) { + regs.gprs[i] = env->regs[i]; + } + ret =kvm_vcpu_ioctl (env,KVM_SET_REGS , ®s); +if (ret <0 ) { +return ret; + } } - ret =kvm_vcpu_ioctl (env,KVM_SET_REGS , ®s); -if (ret <0 ) { -return ret; +/* Do we need to save more than that? */ +if (level ==KVM_PUT_RUNTIME_STATE ) { +return 0 ; } - env->kvm_run->psw_addr = env->psw.addr; - env->kvm_run->psw_mask = env->psw.mask; +if (cap_sync_regs && + env->kvm_run->kvm_valid_regs &KVM_SYNC_ACRS && + env->kvm_run->kvm_valid_regs &KVM_SYNC_CRS ) { +for (i =0 ; i <16 ; i++) { + env->kvm_run->s.regs.acrs[i] = env->aregs[i]; + env->kvm_run->s.regs.crs[i] = env->cregs[i]; + } + env->kvm_run->kvm_dirty_regs |=KVM_SYNC_ACRS ; + env->kvm_run->kvm_dirty_regs |=KVM_SYNC_CRS ; + }else { +for (i =0 ; i <16 ; i++) { + sregs.acrs[i] = env->aregs[i]; + sregs.crs[i] = env->cregs[i]; + } + ret =kvm_vcpu_ioctl (env,KVM_SET_SREGS , &sregs); +if (ret <0 ) { +return ret; + } + } -return ret; +/* Finally the prefix */ +if (cap_sync_regs && env->kvm_run->kvm_valid_regs &KVM_SYNC_PREFIX ) { + env->kvm_run->s.regs.prefix = env->psa; + env->kvm_run->kvm_dirty_regs |=KVM_SYNC_PREFIX ; + }else { +/* prefix is only supported via sync regs */ + } +return 0 ; }int kvm_arch_get_registers (CPUS390XState *env) { -int ret; +struct kvm_sregs sregs;struct kvm_regs regs; +int ret;int i; - ret =kvm_vcpu_ioctl (env,KVM_GET_REGS , ®s); -if (ret <0 ) { -return ret; +/* get the PSW */ + env->psw.addr = env->kvm_run->psw_addr; + env->psw.mask = env->kvm_run->psw_mask; + +/* the GPRS */ +if (cap_sync_regs && env->kvm_run->kvm_valid_regs &KVM_SYNC_GPRS ) { +for (i =0 ; i <16 ; i++) { + env->regs[i] = env->kvm_run->s.regs.gprs[i]; + } + }else { + ret =kvm_vcpu_ioctl (env,KVM_GET_REGS , ®s); +if (ret <0 ) { +return ret; + } +for (i =0 ; i <16 ; i++) { + env->regs[i] = regs.gprs[i]; + } } -for (i =0 ; i <16 ; i++) { - env->regs[i] = regs.gprs[i]; +/* The ACRS and CRS */ +if (cap_sync_regs && + env->kvm_run->kvm_valid_regs &KVM_SYNC_ACRS && + env->kvm_run->kvm_valid_regs &KVM_SYNC_CRS ) { +for (i =0 ; i <16 ; i++) { + env->aregs[i] = env->kvm_run->s.regs.acrs[i]; + env->cregs[i] = env->kvm_run->s.regs.crs[i]; + } + }else { + ret =kvm_vcpu_ioctl (env,KVM_GET_SREGS , &sregs); +if (ret <0 ) { +return ret; + } +for (i =0 ; i <16 ; i++) { + env->aregs[i] = sregs.acrs[i]; + env->cregs[i] = sregs.crs[i]; + } } - env->psw.addr = env->kvm_run->psw_addr; - env->psw.mask = env->kvm_run->psw_mask; +/* Finally the prefix */ +if (cap_sync_regs && env->kvm_run->kvm_valid_regs &KVM_SYNC_PREFIX ) { + env->psa = env->kvm_run->s.regs.prefix; + }else { +/* no prefix without sync regs */ + }return 0 ; }
Signature · 1 line
1.7.11.7
Re: [Qemu-devel] [PATCH 1/5] s390: use sync regs for register transfer
Quoted 24 lines · Jens Freimann
From: Christian Borntraeger <[email protected]>
Newer kernels provide the guest registers in
kvm_run. Lets use those if available (i.e. the capability is set). This avoids ioctls oncpu_synchronize_statemaking intercepts faster.In addition, we have now the prefix register, the access registers the control registers up to date. This helps in certain cases, e.g. for resolving kernel module addresses with gdb on a guest.
On return, we update the registers according to the level statement, i.e. we put all registers for
KVM_PUT_FULL_STATEand_RESET_STATE.Signed-off-by Christian Borntraeger <[email protected]>Signed-off-by Jens Freimann <[email protected]>--- target-s390x/kvm.c | 119 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 99 insertions(+), 20 deletions(-)target-s390x/kvm.c +0
-0
target-s390x/kvm.c const KVMCapabilityInfo kvm_arch_required_capabilities[] = { · line 70
Quoted 4 lines
target-s390x/kvm.c +1
-0@@ -67,8 +67,11 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = { KVM_CAP_LAST_INFO }; +int cap_sync_regs;
static
Quoted 157 lines
target-s390x/kvm.c +98
-21+int kvm_arch_init (KVMState *s) { + cap_sync_regs =kvm_check_extension (s,KVM_CAP_SYNC_REGS );return 0 ; }@@ -88,49 +91,125 @@ void kvm_arch_reset_vcpu(CPUS390XState *env)/* FIXME: add code to reset vcpu. */ } +/* we want to have the prefix, the GPRS, the ACRS and the CRS up to date */ +#define QEMU_NEEDED_REGS (KVM_SYNC_PREFIX | KVM_SYNC_GPRS | \ + KVM_SYNC_ACRS | KVM_SYNC_CRS) + +/* But qemu only changes the GPRS */ +#define QEMU_DIRTY_REGS (KVM_SYNC_GPRS) +int kvm_arch_put_registers (CPUS390XState *env,int level) { +struct kvm_sregs sregs;struct kvm_regs regs;int ret;int i; - ret =kvm_vcpu_ioctl (env,KVM_GET_REGS , ®s); -if (ret <0 ) { -return ret; - } +/* always save the PSW and the GPRS*/ + env->kvm_run->psw_addr = env->psw.addr; + env->kvm_run->psw_mask = env->psw.mask; -for (i =0 ; i <16 ; i++) { - regs.gprs[i] = env->regs[i]; +if (cap_sync_regs && env->kvm_run->kvm_valid_regs &KVM_SYNC_GPRS ) { +for (i =0 ; i <16 ; i++) { + env->kvm_run->s.regs.gprs[i] = env->regs[i]; + env->kvm_run->kvm_dirty_regs |=KVM_SYNC_GPRS ; + } + }else { +for (i =0 ; i <16 ; i++) { + regs.gprs[i] = env->regs[i]; + } + ret =kvm_vcpu_ioctl (env,KVM_SET_REGS , ®s); +if (ret <0 ) { +return ret; + } } - ret =kvm_vcpu_ioctl (env,KVM_SET_REGS , ®s); -if (ret <0 ) { -return ret; +/* Do we need to save more than that? */ +if (level ==KVM_PUT_RUNTIME_STATE ) { +return 0 ; } - env->kvm_run->psw_addr = env->psw.addr; - env->kvm_run->psw_mask = env->psw.mask; +if (cap_sync_regs && + env->kvm_run->kvm_valid_regs &KVM_SYNC_ACRS && + env->kvm_run->kvm_valid_regs &KVM_SYNC_CRS ) { +for (i =0 ; i <16 ; i++) { + env->kvm_run->s.regs.acrs[i] = env->aregs[i]; + env->kvm_run->s.regs.crs[i] = env->cregs[i]; + } + env->kvm_run->kvm_dirty_regs |=KVM_SYNC_ACRS ; + env->kvm_run->kvm_dirty_regs |=KVM_SYNC_CRS ; + }else { +for (i =0 ; i <16 ; i++) { + sregs.acrs[i] = env->aregs[i]; + sregs.crs[i] = env->cregs[i]; + } + ret =kvm_vcpu_ioctl (env,KVM_SET_SREGS , &sregs); +if (ret <0 ) { +return ret; + } + } -return ret; +/* Finally the prefix */ +if (cap_sync_regs && env->kvm_run->kvm_valid_regs &KVM_SYNC_PREFIX ) { + env->kvm_run->s.regs.prefix = env->psa; + env->kvm_run->kvm_dirty_regs |=KVM_SYNC_PREFIX ; + }else { +/* prefix is only supported via sync regs */ + } +return 0 ; }int kvm_arch_get_registers (CPUS390XState *env) { -int ret; +struct kvm_sregs sregs;struct kvm_regs regs; +int ret;int i; - ret =kvm_vcpu_ioctl (env,KVM_GET_REGS , ®s); -if (ret <0 ) { -return ret; +/* get the PSW */ + env->psw.addr = env->kvm_run->psw_addr; + env->psw.mask = env->kvm_run->psw_mask; + +/* the GPRS */ +if (cap_sync_regs && env->kvm_run->kvm_valid_regs &KVM_SYNC_GPRS ) { +for (i =0 ; i <16 ; i++) { + env->regs[i] = env->kvm_run->s.regs.gprs[i]; + } + }else { + ret =kvm_vcpu_ioctl (env,KVM_GET_REGS , ®s); +if (ret <0 ) { +return ret; + } +for (i =0 ; i <16 ; i++) { + env->regs[i] = regs.gprs[i]; + } } -for (i =0 ; i <16 ; i++) { - env->regs[i] = regs.gprs[i]; +/* The ACRS and CRS */ +if (cap_sync_regs && + env->kvm_run->kvm_valid_regs &KVM_SYNC_ACRS && + env->kvm_run->kvm_valid_regs &KVM_SYNC_CRS ) { +for (i =0 ; i <16 ; i++) { + env->aregs[i] = env->kvm_run->s.regs.acrs[i]; + env->cregs[i] = env->kvm_run->s.regs.crs[i]; + } + }else { + ret =kvm_vcpu_ioctl (env,KVM_GET_SREGS , &sregs); +if (ret <0 ) { +return ret; + } +for (i =0 ; i <16 ; i++) { + env->aregs[i] = sregs.acrs[i]; + env->cregs[i] = sregs.crs[i]; + } } - env->psw.addr = env->kvm_run->psw_addr; - env->psw.mask = env->kvm_run->psw_mask; +/* Finally the prefix */ +if (cap_sync_regs && env->kvm_run->kvm_valid_regs &KVM_SYNC_PREFIX ) { + env->psa = env->kvm_run->s.regs.prefix; + }else { +/* no prefix without sync regs */ + }return 0 ; } --1.7.11.7
PATCH 1/1 s390: use sync regs for register transfer
From: Christian Borntraeger <[email protected]>
Newer kernels provide the guest registers in kvm_run. Lets use those if available (i.e. the capability is set). This avoids ioctls on cpu_synchronize_state making intercepts faster.
In addition, we have now the prefix register, the access registers the control registers up to date. This helps in certain cases, e.g. for resolving kernel module addresses with gdb on a guest.
On return, we update the registers according to the level statement, i.e. we put all registers for KVM_PUT_FULL_STATE and _RESET_STATE.
--- target-s390x/kvm.c | 119 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 99 insertions(+), 20 deletions(-)
target-s390x/kvm.c +99 -20
@@ -67,8 +67,11 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = { KVM_CAP_LAST_INFO }; +static int cap_sync_regs; +int kvm_arch_init (KVMState *s) { + cap_sync_regs =kvm_check_extension (s,KVM_CAP_SYNC_REGS );return 0 ; }
@@ -88,49 +91,125 @@ void kvm_arch_reset_vcpu(CPUS390XState *env)/* FIXME: add code to reset vcpu. */ } +/* we want to have the prefix, the GPRS, the ACRS and the CRS up to date */ +#define QEMU_NEEDED_REGS (KVM_SYNC_PREFIX | KVM_SYNC_GPRS | \ + KVM_SYNC_ACRS | KVM_SYNC_CRS) + +/* But qemu only changes the GPRS */ +#define QEMU_DIRTY_REGS (KVM_SYNC_GPRS) +int kvm_arch_put_registers (CPUS390XState *env,int level) { +struct kvm_sregs sregs;struct kvm_regs regs;int ret;int i; - ret =kvm_vcpu_ioctl (env,KVM_GET_REGS , ®s); -if (ret <0 ) { -return ret; - } +/* always save the PSW and the GPRS*/ + env->kvm_run->psw_addr = env->psw.addr; + env->kvm_run->psw_mask = env->psw.mask; -for (i =0 ; i <16 ; i++) { - regs.gprs[i] = env->regs[i]; +if (cap_sync_regs && env->kvm_run->kvm_valid_regs &KVM_SYNC_GPRS ) { +for (i =0 ; i <16 ; i++) { + env->kvm_run->s.regs.gprs[i] = env->regs[i]; + env->kvm_run->kvm_dirty_regs |=KVM_SYNC_GPRS ; + } + }else { +for (i =0 ; i <16 ; i++) { + regs.gprs[i] = env->regs[i]; + } + ret =kvm_vcpu_ioctl (env,KVM_SET_REGS , ®s); +if (ret <0 ) { +return ret; + } } - ret =kvm_vcpu_ioctl (env,KVM_SET_REGS , ®s); -if (ret <0 ) { -return ret; +/* Do we need to save more than that? */ +if (level ==KVM_PUT_RUNTIME_STATE ) { +return 0 ; } - env->kvm_run->psw_addr = env->psw.addr; - env->kvm_run->psw_mask = env->psw.mask; +if (cap_sync_regs && + env->kvm_run->kvm_valid_regs &KVM_SYNC_ACRS && + env->kvm_run->kvm_valid_regs &KVM_SYNC_CRS ) { +for (i =0 ; i <16 ; i++) { + env->kvm_run->s.regs.acrs[i] = env->aregs[i]; + env->kvm_run->s.regs.crs[i] = env->cregs[i]; + } + env->kvm_run->kvm_dirty_regs |=KVM_SYNC_ACRS ; + env->kvm_run->kvm_dirty_regs |=KVM_SYNC_CRS ; + }else { +for (i =0 ; i <16 ; i++) { + sregs.acrs[i] = env->aregs[i]; + sregs.crs[i] = env->cregs[i]; + } + ret =kvm_vcpu_ioctl (env,KVM_SET_SREGS , &sregs); +if (ret <0 ) { +return ret; + } + } -return ret; +/* Finally the prefix */ +if (cap_sync_regs && env->kvm_run->kvm_valid_regs &KVM_SYNC_PREFIX ) { + env->kvm_run->s.regs.prefix = env->psa; + env->kvm_run->kvm_dirty_regs |=KVM_SYNC_PREFIX ; + }else { +/* prefix is only supported via sync regs */ + } +return 0 ; }int kvm_arch_get_registers (CPUS390XState *env) { -int ret; +struct kvm_sregs sregs;struct kvm_regs regs; +int ret;int i; - ret =kvm_vcpu_ioctl (env,KVM_GET_REGS , ®s); -if (ret <0 ) { -return ret; +/* get the PSW */ + env->psw.addr = env->kvm_run->psw_addr; + env->psw.mask = env->kvm_run->psw_mask; + +/* the GPRS */ +if (cap_sync_regs && env->kvm_run->kvm_valid_regs &KVM_SYNC_GPRS ) { +for (i =0 ; i <16 ; i++) { + env->regs[i] = env->kvm_run->s.regs.gprs[i]; + } + }else { + ret =kvm_vcpu_ioctl (env,KVM_GET_REGS , ®s); +if (ret <0 ) { +return ret; + } +for (i =0 ; i <16 ; i++) { + env->regs[i] = regs.gprs[i]; + } } -for (i =0 ; i <16 ; i++) { - env->regs[i] = regs.gprs[i]; +/* The ACRS and CRS */ +if (cap_sync_regs && + env->kvm_run->kvm_valid_regs &KVM_SYNC_ACRS && + env->kvm_run->kvm_valid_regs &KVM_SYNC_CRS ) { +for (i =0 ; i <16 ; i++) { + env->aregs[i] = env->kvm_run->s.regs.acrs[i]; + env->cregs[i] = env->kvm_run->s.regs.crs[i]; + } + }else { + ret =kvm_vcpu_ioctl (env,KVM_GET_SREGS , &sregs); +if (ret <0 ) { +return ret; + } +for (i =0 ; i <16 ; i++) { + env->aregs[i] = sregs.acrs[i]; + env->cregs[i] = sregs.crs[i]; + } } - env->psw.addr = env->kvm_run->psw_addr; - env->psw.mask = env->kvm_run->psw_mask; +/* Finally the prefix */ +if (cap_sync_regs && env->kvm_run->kvm_valid_regs &KVM_SYNC_PREFIX ) { + env->psa = env->kvm_run->s.regs.prefix; + }else { +/* no prefix without sync regs */ + }return 0 ; }
Signature · 1 line
1.7.11.7
PATCH 2/5 s390: sclp base support
In reply to Jens FreimannFrom: Heinz Graalfs <[email protected]>
This adds a more generic infrastructure for handling Service-Call requests on s390. Currently we only support a small subset of Read SCP Info directly in target-s390x. This patch provides the base infrastructure for supporting more commands and moves Read SCP Info.
In the future we could add additional commands for hotplug, call home and event handling.
--- hw/s390x/Makefile.objs | 1 + hw/s390x/sclp.c | 119 +++++++++++++++++++++++++++++++++++++++++++++ hw/s390x/sclp.h | 76 +++++++++++++++++++++++++++++ target-s390x/cpu.h | 13 +---- target-s390x/kvm.c | 5 +- target-s390x/misc_helper.c | 45 +---------------- 6 files changed, 199 insertions(+), 60 deletions(-) create mode 100644 hw/s390x/sclp.c create mode 100644 hw/s390x/sclp.h
hw/s390x/Makefile.objs +1 -0
@@ -1,3 +1,4 @@ obj-y = s390-virtio-bus.o s390-virtio.o obj-y := $(addprefix ../,$(obj-y)) +obj-y += sclp.o
hw/s390x/sclp.c new file +119 -0
119 lines not on this page · raw message
hw/s390x/sclp.h new file +76 -0
76 lines not on this page · raw message
target-s390x/cpu.h +1 -12
@@ -596,17 +596,6 @@ static inline const char *cc_name(int cc_op)return cc_names[cc_op]; } -/* SCLP PV interface defines */ -#define SCLP_CMDW_READ_SCP_INFO 0x00020001 -#define SCLP_CMDW_READ_SCP_INFO_FORCED 0x00120001 - -#define SCP_LENGTH 0x00 -#define SCP_FUNCTION_CODE 0x02 -#define SCP_CONTROL_MASK 0x03 -#define SCP_RESPONSE_CODE 0x06 -#define SCP_MEM_CODE 0x08 -#define SCP_INCREMENT 0x0a - typedef struct LowCore { /* prefix area: defined by architecture */
@@ -955,7 +944,7 @@ static inline void ebcdic_put(uint8_t *p, const char *ascii, int len)void load_psw (CPUS390XState *env,uint64_t mask,uint64_t addr);int mmu_translate (CPUS390XState *env,target_ulong vaddr,int rw,uint64_t asc,target_ulong *raddr,int *flags); -int sclp_service_call (CPUS390XState *env,uint32_t sccb,uint64_t code); +int sclp_service_call (uint32_t sccb,uint64_t code);uint32_t calc_cc (CPUS390XState *env,uint32_t cc_op,uint64_t src,uint64_t dst,uint64_t vr);
target-s390x/kvm.c +1 -4
@@ -60,9 +60,6 @@#define SIGP_STORE_STATUS_ADDR 0x0e#define SIGP_SET_ARCH 0x12 -#define SCLP_CMDW_READ_SCP_INFO 0x00020001 -#define SCLP_CMDW_READ_SCP_INFO_FORCED 0x00120001 -const KVMCapabilityInfo kvm_arch_required_capabilities[] = {KVM_CAP_LAST_INFO };
@@ -351,7 +348,7 @@ static int kvm_sclp_service_call(CPUS390XState *env, struct kvm_run *run, sccb = env->regs[ipbh0 &0xf ]; code = env->regs[(ipbh0 &0xf0 ) >>4 ]; - r =sclp_service_call (env, sccb, code); + r =sclp_service_call (sccb, code);if (r <0 ) {enter_pgmcheck (env, -r); }
target-s390x/misc_helper.c +1 -44
56 lines not on this page · raw message
Signature · 1 line
1.7.11.7
PATCH 3/5 s390: sclp event support
In reply to Jens FreimannFrom: Heinz Graalfs <[email protected]>
Several SCLP features are considered to be events. Those events don't provide SCLP commands on their own, instead they are all based on Read Event Data, Write Event Data, Write Event Mask and the service interrupt. Follow-on patches will provide SCLP's Signal Quiesce (via system_powerdown) and the ASCII console.
Further down the road the sclp line mode console and configuration change events (e.g. cpu hotplug) can be implemented.
--- hw/s390-virtio.c | 2 + hw/s390x/Makefile.objs | 1 + hw/s390x/event-facility.c | 391 ++++++++++++++++++++++++++++++++++++++++++++++ hw/s390x/event-facility.h | 96 ++++++++++++ hw/s390x/sclp.c | 49 +++++- hw/s390x/sclp.h | 42 +++++ 6 files changed, 579 insertions(+), 2 deletions(-) create mode 100644 hw/s390x/event-facility.c create mode 100644 hw/s390x/event-facility.h
hw/s390-virtio.c +2 -0
@@ -32,6 +32,7 @@#include "exec-memory.h" #include "hw/s390-virtio-bus.h" +#include "hw/s390x/sclp.h" //#define DEBUG_S390
@@ -183,6 +184,7 @@ static void s390_init(ram_addr_t my_ram_size,/* get a BUS */ s390_bus =s390_virtio_bus_init (&my_ram_size); +s390_sclp_init ();/* allocate RAM */ memory_region_init_ram (ram,"s390.ram" , my_ram_size);
hw/s390x/Makefile.objs +1 -0
@@ -2,3 +2,4 @@ obj-y = s390-virtio-bus.o s390-virtio.o obj-y := $(addprefix ../,$(obj-y)) obj-y += sclp.o +obj-y += event-facility.o
hw/s390x/event-facility.c new file +391 -0
391 lines not on this page · raw message
hw/s390x/event-facility.h new file +96 -0
96 lines not on this page · raw message
hw/s390x/sclp.c +47 -2
77 lines not on this page · raw message
hw/s390x/sclp.h +42 -0
71 lines not on this page · raw message
Signature · 1 line
1.7.11.7
PATCH 4/5 s390: sclp signal quiesce support
In reply to Jens FreimannFrom: Heinz Graalfs <[email protected]>
This implements the sclp signal quiesce event via the SCLP Event Facility.
This allows to gracefully shutdown a guest by using system_powerdown notifiers. It creates a service interrupt that will trigger a Read Event Data command from the guest. This code will then add an event that is interpreted by linux guests as ctrl-alt-del.
--- hw/s390x/Makefile.objs | 1 + hw/s390x/event-facility.c | 7 +++ hw/s390x/sclpquiesce.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 hw/s390x/sclpquiesce.c
hw/s390x/Makefile.objs +1 -0
@@ -3,3 +3,4 @@ obj-y = s390-virtio-bus.o s390-virtio.o obj-y := $(addprefix ../,$(obj-y)) obj-y += sclp.o obj-y += event-facility.o +obj-y += sclpquiesce.o
hw/s390x/event-facility.c +7 -0
@@ -315,6 +315,7 @@ static void command_handler(SCLPEventFacility *ef, SCCB *sccb, uint64_t code)static int init_event_facility (S390SCLPDevice *sdev) {SCLPEventFacility *event_facility; +DeviceState *quiesce; event_facility =g_malloc0 (sizeof (SCLPEventFacility)); sdev->ef = event_facility;
@@ -327,6 +328,12 @@ static int init_event_facility(S390SCLPDevice *sdev) event_facility->sbus.qbus.allow_hotplug =0 ; event_facility->qdev = (DeviceState *) sdev; + quiesce =qdev_create (&event_facility->sbus.qbus,"sclpquiesce" ); +if (!quiesce) { +return -1 ; + } +qdev_init_nofail (quiesce); +return 0 ; }
hw/s390x/sclpquiesce.c new file +123 -0
123 lines not on this page · raw message
Signature · 1 line
1.7.11.7
Re: [Qemu-devel] [PATCH 4/5] s390: sclp signal quiesce support
Quoted 8 lines · Jens Freimann
From: Heinz Graalfs <[email protected]>
This implements the sclp signal quiesce event via the SCLP Event Facility.
This allows to gracefully shutdown a guest by usingsystem_powerdownnotifiers. It creates a service interrupt that will trigger a Read Event Data command from the guest. This code will then add an event that is interpreted by linux guests as ctrl-alt-del.
Doesn't ctrl-alt-del usually reboot the machine, not shut it down?
Alex
Quoted 177 lines
Signed-off-by Heinz Graalfs <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>Signed-off-by Jens Freimann <[email protected]>---
hw/s390x/Makefile.objs | 1 + hw/s390x/event-facility.c | 7 +++ hw/s390x/sclpquiesce.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+)create mode 100644
hw/s390x/sclpquiesce.chw/s390x/Makefile.objs +0
-0@@ -3,3 +3,4 @@ obj-y = s390-virtio-bus.o s390-virtio.o obj-y := $(addprefix ../,$(obj-y))obj-y += sclp.o
obj-y += event-facility.ohw/s390x/Makefile.objs +1
-0+obj-y += sclpquiesce.ohw/s390x/event-facility.c +7
-0@@ -315,6 +315,7 @@ static void command_handler(SCLPEventFacility *ef, SCCB *sccb, uint64_t code)static int init_event_facility (S390SCLPDevice *sdev) {SCLPEventFacility *event_facility; +DeviceState *quiesce; event_facility =g_malloc0 (sizeof (SCLPEventFacility)); sdev->ef = event_facility;@@ -327,6 +328,12 @@ static int init_event_facility(S390SCLPDevice *sdev) event_facility->sbus.qbus.allow_hotplug =0 ; event_facility->qdev = (DeviceState *) sdev; + quiesce =qdev_create (&event_facility->sbus.qbus,"sclpquiesce" ); +if (!quiesce) { +return -1 ; + } +qdev_init_nofail (quiesce); +return 0 ; }hw/s390x/sclpquiesce.c new file +123
-0@@ -0,0 +1,123 @@ +/* +* SCLP event type +* Signal Quiesce - trigger system powerdown request +* +* Copyright IBM, Corp. 2012 +* +* Authors: +* Heinz Graalfs <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or (at your +* option) any later version. See the COPYING file in the top-level directory. +* +*/ +#include <hw/qdev.h> +#include "sysemu.h" +#include "sclp.h" +#include "event-facility.h" + +typedef struct SignalQuiesce { +EventBufferHeader ebh; +uint16_t timeout; +uint8_t unit; +} QEMU_PACKED SignalQuiesce; + +static int event_type (void ) +{ +return SCLP_EVENT_SIGNAL_QUIESCE ; +} + +static unsigned int send_mask (void ) +{ +return SCLP_EVENT_MASK_SIGNAL_QUIESCE ; +} + +static unsigned int receive_mask (void ) +{ +return 0 ; +} + +static int read_event_data (SCLPEvent *event,EventBufferHeader *evt_buf_hdr, +int *slen) +{ +SignalQuiesce *sq = (SignalQuiesce *) evt_buf_hdr; + +if (*slen <sizeof (SignalQuiesce)) { +return 0 ; + } + +if (!event->event_pending) { +return 0 ; + } + event->event_pending = false; + + sq->ebh.length =cpu_to_be16 (sizeof (SignalQuiesce)); + sq->ebh.type =SCLP_EVENT_SIGNAL_QUIESCE ; + sq->ebh.flags |=SCLP_EVENT_BUFFER_ACCEPTED ; +/* +* system_powerdown does not have a timeout. Fortunately the +* timeout value is currently ignored by Linux, anyway +*/ + sq->timeout =cpu_to_be16 (0 ); + sq->unit =cpu_to_be16 (0 ); + *slen -=sizeof (SignalQuiesce); + +return 1 ; +} + +typedef struct QuiesceNotifier QuiesceNotifier ; + +static struct QuiesceNotifier { +Notifier notifier; +SCLPEvent *event; +} qn; + +static void quiesce_powerdown_req (Notifier *n,void *opaque) +{ +QuiesceNotifier *qn =container_of (n, QuiesceNotifier, notifier); +SCLPEvent *event = qn->event; + + event->event_pending = true; +/* trigger SCLP read operation */ +sclp_service_interrupt (0 ); +} + +static int quiesce_init (SCLPEvent *event) +{ + event->event_type =SCLP_EVENT_SIGNAL_QUIESCE ; + + qn.notifier.notify = quiesce_powerdown_req; + qn.event = event; + +qemu_register_powerdown_notifier (&qn.notifier); + +return 0 ; +} + +static void quiesce_class_init (ObjectClass *klass,void *data) +{ +SCLPEventClass *k =SCLP_EVENT_CLASS (klass); + + k->init = quiesce_init; + + k->get_send_mask = send_mask; + k->get_receive_mask = receive_mask; + k->event_type = event_type; + k->read_event_data = read_event_data; + k->write_event_data =NULL ; +} + +static TypeInfo sclp_quiesce_info = { + .name ="sclpquiesce" , + .parent =TYPE_SCLP_EVENT , + .instance_size =sizeof (SCLPEvent), + .class_init = quiesce_class_init, + .class_size =sizeof (SCLPEventClass), +}; + +static void register_types (void ) +{ +type_register_static (&sclp_quiesce_info); +} + +type_init (register_types)Signature · 1 line
1.7.11.7
Re: [Qemu-devel] [PATCH 4/5] s390: sclp signal quiesce support
Quoted 5 lines · Alexander Graf
Quoted 2 lines · Jens Freimann
From: Heinz Graalfs <[email protected]>
Quoted 8 lines
Quoted 6 lines
This implements the sclp signal quiesce event via the SCLP Event Facility.
This allows to gracefully shutdown a guest by usingsystem_powerdownnotifiers. It creates a service interrupt that will trigger a Read Event Data command from the guest. This code will then add an event that is interpreted by linux guests as ctrl-alt-del.Doesn't ctrl-alt-del usually reboot the machine, not shut it down?
On my 390 systems it seems to shutdown, at least that happens on lpar and z/VM as well as under KVM.
PATCH 5/5 s390: sclp ascii console support
In reply to Jens FreimannFrom: Heinz Graalfs <[email protected]>
This code adds console support by implementing SCLP's ASCII Console Data event. This is the same console as LPARs ASCII console or z/VMs sysascii.
The console can be specified manually with something like
-chardev stdio,id=charconsole0 -device sclpconsole,chardev=charconsole0,id=console0
Newer kernels will autodetect that console and prefer that over virtio console.
When data is received from the character layer it creates a service interrupt to trigger a Read Event Data command from the guest that will pick up the received character byte-stream.
When characters are echo'ed by the linux guest a Write Event Data occurs which is forwarded by the Event Facility to the console that supports a corresponding mask value.
Console resizing is not supported.
The character layer byte-stream is buffered using a fixed size iov buffer.
--- hw/s390x/Makefile.objs | 2 +- hw/s390x/sclpconsole.c | 306 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 307 insertions(+), 1 deletion(-) create mode 100644 hw/s390x/sclpconsole.c
hw/s390x/Makefile.objs +1 -1
@@ -3,4 +3,4 @@ obj-y = s390-virtio-bus.o s390-virtio.o obj-y := $(addprefix ../,$(obj-y)) obj-y += sclp.o obj-y += event-facility.o -obj-y += sclpquiesce.o +obj-y += sclpquiesce.o sclpconsole.o
hw/s390x/sclpconsole.c new file +306 -0
306 lines not on this page · raw message
Signature · 1 line
1.7.11.7