kdump patches for s390x/kvm
Alex, can you either Ack or Pull the following patches:
The following changes since commit 951fab990db05d47ab9da5e72521e406c73a3eb9:
target-mips: fix get_physical_address() #if 0 build error (2013-08-28 19:28:02 +0200)
are available in the git repository at:
git://github.com/borntraeger/qemu.git tags/kdump
for you to fetch changes up to 8f288cfca867ac708cc371192e80947a83663833:
s390: wire up nmi command to raise a RESTART interrupt on S390 (2013-08-29 14:09:58 +0200)
----------------------------------------------------------------
This is a set of patches dealing with kdump support for s390x/kvm. kdump on s390x uses subcode 1 of diagnose 0x308 to put the hardware in a defined state. This is different from a full reset, since it does not touch all CPU registers.
These patches define the cpu resets, the subsystem reset a load function and also wires up the "nmi" command to issue a RESTART interrupt as defined in the z/Architecture principles of operation.
This allows recent guest kernels with properly setup userspace to trigger kdump:
- via guest crash
- via nmi from the host
----------------------------------------------------------------
Christian Borntraeger (4):
s390: provide I/O subsystem reset
s390: provide a cpu load normal function s390/cpu: split CPU reset into architectured functions
s390: Implement load normal reset
Eugene (jno) Dvurechenski (2):
s390/kvm: basic implementation of diagnose 308 subcode 6
s390: wire up nmi command to raise a RESTART interrupt on S390
cpus.c | 14 ++++++++ hmp-commands.hx | 4 +-- hw/s390x/s390-virtio-ccw.c | 15 +++++++++ qmp-commands.hx | 2 +- target-s390x/cpu-qom.h | 6 ++++ target-s390x/cpu.c | 55 ++++++++++++++++++++++++++----- target-s390x/cpu.h | 17 ++++++++++ target-s390x/kvm.c | 81 ++++++++++++++++++++++++++++++++++++++++++++-- 8 files changed, 180 insertions(+), 14 deletions(-)
[Qemu-devel] [PULL 1/6] s390/kvm: basic implementation of diagnose 308 subcode 6
From: "Eugene (jno) Dvurechenski" <[email protected]>
Linux uses a check for subcode 6 to decide if other subcodes are available. Provide a minimal implementation.
--- target-s390x/kvm.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
target-s390x/kvm.c +46 -0
@@ -72,9 +72,12 @@#define PRIV_XSCH 0x76#define PRIV_SQBS 0x8a#define PRIV_EQBS 0x9c +#define DIAG_IPL 0x308#define DIAG_KVM_HYPERCALL 0x500#define DIAG_KVM_BREAKPOINT 0x501 +#define DIAG_IPL_RC_OK_NOT4CONF 0x0102 +#define ICPT_INSTRUCTION 0x04#define ICPT_WAITPSW 0x1c#define ICPT_SOFT_INTERCEPT 0x24
@@ -578,11 +581,54 @@ static int handle_hypercall(S390CPU *cpu, struct kvm_run *run)return 0 ; } +static int handle_diag308 (S390CPU *cpu,struct kvm_run *run) +{ +uint64_t r1, r3, addr, subcode; + +cpu_synchronize_state (CPU (cpu)); + +if (cpu->env.psw.mask &PSW_MASK_PSTATE ) { +enter_pgmcheck (cpu,PGM_PRIVILEGED ); +return 0 ; + } + + r1 = (run->s390_sieic.ipa &0x00f0 ) >>8 ; + r3 = run->s390_sieic.ipa &0x000f ; + addr = cpu->env.regs[r1]; + subcode = cpu->env.regs[r3]; + +if ((subcode & ~0x0ffffULL ) || (subcode >6 )) { +enter_pgmcheck (cpu,PGM_SPECIFICATION ); +return 0 ; + } + +switch (subcode) { +case 5 : +if ((r1 &1 ) || (addr &0x0fffULL )) { +enter_pgmcheck (cpu,PGM_SPECIFICATION ); +return 0 ; + } +return -1 ; +case 6 : +if ((r1 &1 ) || (addr &0x0fffULL )) { +enter_pgmcheck (cpu,PGM_SPECIFICATION ); +return 0 ; + } + cpu->env.regs[r1+1 ] =DIAG_IPL_RC_OK_NOT4CONF ; +return 0 ; +default : +return -1 ; + } +} +static int handle_diag (S390CPU *cpu,struct kvm_run *run,int ipb_code) {int r =0 ;switch (ipb_code) { +case DIAG_IPL : + r =handle_diag308 (cpu, run); +break ;case DIAG_KVM_HYPERCALL : r =handle_hypercall (cpu, run);break ;
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PULL 1/6] s390/kvm: basic implementation of diagnose 308 subcode 6
Quoted 30 lines · Christian Borntraeger
From: "Eugene (jno) Dvurechenski" <[email protected]>
Linux uses a check for subcode 6 to decide if other subcodes are available. Provide a minimal implementation.
Signed-off-by Eugene (jno) Dvurechenski <[email protected]>Reviewed-by Cornelia Huck <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>---
target-s390x/kvm.c| 46 ++++++++++++++++++++++++++++++++++++++++++++++1 file changed, 46 insertions(+)target-s390x/kvm.c +3
-0@@ -72,9 +72,12 @@#define PRIV_XSCH 0x76#define PRIV_SQBS 0x8a#define PRIV_EQBS 0x9c +#define DIAG_IPL 0x308#define DIAG_KVM_HYPERCALL 0x500#define DIAG_KVM_BREAKPOINT 0x501 +#define DIAG_IPL_RC_OK_NOT4CONF 0x0102 +#define ICPT_INSTRUCTION 0x04#define ICPT_WAITPSW 0x1c#define ICPT_SOFT_INTERCEPT 0x24
target-s390x/kvm.c static int handle_hypercall(S390CPU *cpu, struct kvm_run *run) · line 584
Quoted 4 lines
target-s390x/kvm.c +1
-0@@ -578,11 +581,54 @@ static int handle_hypercall(S390CPU *cpu, struct kvm_run *run)return 0 ; } +static int handle_diag308 (S390CPU *cpu,struct kvm_run *run)
Most of this code shouldn't live in kvm.c, but in a more universal helper.
Alex
Quoted 53 lines
target-s390x/kvm.c +42
-0+{ +uint64_t r1, r3, addr, subcode; + +cpu_synchronize_state (CPU (cpu)); + +if (cpu->env.psw.mask &PSW_MASK_PSTATE ) { +enter_pgmcheck (cpu,PGM_PRIVILEGED ); +return 0 ; + } + + r1 = (run->s390_sieic.ipa &0x00f0 ) >>8 ; + r3 = run->s390_sieic.ipa &0x000f ; + addr = cpu->env.regs[r1]; + subcode = cpu->env.regs[r3]; + +if ((subcode & ~0x0ffffULL ) || (subcode >6 )) { +enter_pgmcheck (cpu,PGM_SPECIFICATION ); +return 0 ; + } + +switch (subcode) { +case 5 : +if ((r1 &1 ) || (addr &0x0fffULL )) { +enter_pgmcheck (cpu,PGM_SPECIFICATION ); +return 0 ; + } +return -1 ; +case 6 : +if ((r1 &1 ) || (addr &0x0fffULL )) { +enter_pgmcheck (cpu,PGM_SPECIFICATION ); +return 0 ; + } + cpu->env.regs[r1+1 ] =DIAG_IPL_RC_OK_NOT4CONF ; +return 0 ; +default : +return -1 ; + } +} +static int handle_diag (S390CPU *cpu,struct kvm_run *run,int ipb_code) {int r =0 ;switch (ipb_code) { +case DIAG_IPL : + r =handle_diag308 (cpu, run); +break ;case DIAG_KVM_HYPERCALL : r =handle_hypercall (cpu, run);break ;Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 2/6] s390: provide I/O subsystem reset
In reply to Christian BorntraegerProvide a function that resets the I/O subsystem.
--- hw/s390x/s390-virtio-ccw.c | 15 +++++++++++++++ target-s390x/cpu.h | 1 + 2 files changed, 16 insertions(+)
hw/s390x/s390-virtio-ccw.c +15 -0
@@ -17,6 +17,21 @@#include "css.h" #include "virtio-ccw.h" +void io_subsystem_reset (void ) +{ +DeviceState *css, *sclp; + + css =DEVICE (object_resolve_path_type ("" ,"virtual-css-bridge" ,NULL )); +if (css) { +qdev_reset_all (css); + } + sclp =DEVICE (object_resolve_path_type ("" , +"s390-sclp-event-facility" ,NULL )); +if (sclp) { +qdev_reset_all (sclp); + } +} +static int virtio_ccw_hcall_notify (const uint64_t *args) {uint64_t subch_id = args[0 ];
target-s390x/cpu.h +1 -0
@@ -400,6 +400,7 @@ void cpu_unlock(void);typedef struct SubchDev SubchDev ;#ifndef CONFIG_USER_ONLY +extern void io_subsystem_reset (void );SubchDev *css_find_subch (uint8_t m,uint8_t cssid,uint8_t ssid,uint16_t schid);bool css_subch_visible (SubchDev *sch);
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 5/6] s390: Implement load normal reset
In reply to Christian Borntraegerkdump on s390 uses a load normal reset to bring the system in a defined state by doing a subsystem reset. The issuing CPUs will have an initial CPU reset, all other CPUs will have a CPU reset as defined in POP (no register content will change).
Implement this as architectured.
--- target-s390x/kvm.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
target-s390x/kvm.c +29 -0
@@ -33,6 +33,7 @@#include "sysemu/sysemu.h" #include "sysemu/kvm.h" #include "cpu.h" +#include "sysemu/cpus.h" #include "sysemu/device_tree.h" #include "qapi/qmp/qjson.h" #include "monitor/monitor.h"
@@ -581,6 +582,32 @@ static int handle_hypercall(S390CPU *cpu, struct kvm_run *run)return 0 ; } +static void cpu_reset_all (void ) +{ +CPUState *cpu; +S390CPUClass *scc; + +for (cpu = first_cpu; cpu; cpu = cpu->next_cpu) { + scc =S390_CPU_GET_CLASS (CPU (cpu)); + scc->cpu_reset (CPU (cpu)); + } +} + +static int load_normal_reset (S390CPU *cpu) +{ +S390CPUClass *scc =S390_CPU_GET_CLASS (cpu); + +pause_all_vcpus (); +cpu_synchronize_all_states (); +cpu_reset_all (); +io_subsystem_reset (); + scc->initial_cpu_reset (CPU (cpu)); + scc->load_normal (CPU (cpu)); +cpu_synchronize_all_post_reset (); +resume_all_vcpus (); +return 0 ; +} +static int handle_diag308 (S390CPU *cpu,struct kvm_run *run) {uint64_t r1, r3, addr, subcode;
@@ -603,6 +630,8 @@ static int handle_diag308(S390CPU *cpu, struct kvm_run *run) }switch (subcode) { +case 1 : +return load_normal_reset (cpu);case 5 :if ((r1 &1 ) || (addr &0x0fffULL )) {enter_pgmcheck (cpu,PGM_SPECIFICATION );
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 3/6] s390: provide a cpu load normal function
In reply to Christian BorntraegerSome code needs to perform an IPL-like bootup that mimics the ESA (31bit) restart. Provide a cpu class method that does so.
--- target-s390x/cpu-qom.h | 2 ++ target-s390x/cpu.c | 14 ++++++++++++++ target-s390x/cpu.h | 3 +++ 3 files changed, 19 insertions(+)
target-s390x/cpu-qom.h +2 -0
@@ -36,6 +36,7 @@* S390CPUClass: * @parent_realize: The parent class' realize handler. * @parent_reset: The parent class' reset handler. +* @load_normal: Performs a load normal. * * An S/390 CPU model. */
@@ -46,6 +47,7 @@ typedef struct S390CPUClass {DeviceRealize parent_realize;void (*parent_reset)(CPUState *cpu); +void (*load_normal)(CPUState *cpu); } S390CPUClass;/**
target-s390x/cpu.c +14 -0
@@ -65,6 +65,17 @@ static void s390_cpu_set_pc(CPUState *cs, vaddr value) cpu->env.psw.addr = value; } +#if !defined(CONFIG_USER_ONLY ) +/* S390CPUClass::load_normal() */ +static void s390_cpu_load_normal (CPUState *s) +{ +S390CPU *cpu =S390_CPU (s); + cpu->env.psw.addr =ldl_phys (4 ) &PSW_MASK_ESA_ADDR ; + cpu->env.psw.mask =PSW_MASK_32 |PSW_MASK_64 ; +s390_add_running_cpu (cpu); +} +#endif +/* CPUClass::reset() */ static void s390_cpu_reset (CPUState *s) {
@@ -169,6 +180,9 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) dc->realize = s390_cpu_realizefn; scc->parent_reset = cc->reset; +#if !defined(CONFIG_USER_ONLY ) + scc->load_normal = s390_cpu_load_normal; +#endif cc->reset = s390_cpu_reset; cc->do_interrupt = s390_cpu_do_interrupt;
target-s390x/cpu.h +3 -0
@@ -228,6 +228,8 @@ typedef struct CPUS390XState {#undef PSW_MASK_CC#undef PSW_MASK_PM#undef PSW_MASK_64 +#undef PSW_MASK_32 +#undef PSW_MASK_ESA_ADDR#define PSW_MASK_PER 0x4000000000000000ULL#define PSW_MASK_DAT 0x0400000000000000ULL
@@ -243,6 +245,7 @@ typedef struct CPUS390XState {#define PSW_MASK_PM 0x00000F0000000000ULL#define PSW_MASK_64 0x0000000100000000ULL#define PSW_MASK_32 0x0000000080000000ULL +#define PSW_MASK_ESA_ADDR 0x000000007fffffffULL#undef PSW_ASC_PRIMARY#undef PSW_ASC_ACCREG
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 4/6] s390/cpu: split CPU reset into architectured functions
In reply to Christian Borntraegers390 provides several CPU resets:
- CPU reset, clears interrupts, stop processing, clears TLB, but does not touch registers
- initial CPU reset, like CPU reset, but also clears PSW, prefix, FPC, timer and control registers. It does not touch gprs, fprs and acrs (!)
- Power on reset: the full monty
wire up CPUClass reset to the full monty, but provide the lesser resets as part of S390CPUClass.
--- target-s390x/cpu-qom.h | 4 ++++ target-s390x/cpu.c | 41 +++++++++++++++++++++++++++++++++-------- 2 files changed, 37 insertions(+), 8 deletions(-)
target-s390x/cpu-qom.h +4 -0
@@ -37,6 +37,8 @@* @parent_realize: The parent class' realize handler. * @parent_reset: The parent class' reset handler. * @load_normal: Performs a load normal. +* @cpu_reset: Performs a CPU reset. +* @initial_cpu_reset: Performs an initial CPU reset. * * An S/390 CPU model. */
@@ -48,6 +50,8 @@ typedef struct S390CPUClass {DeviceRealize parent_realize;void (*parent_reset)(CPUState *cpu);void (*load_normal)(CPUState *cpu); +void (*cpu_reset)(CPUState *cpu); +void (*initial_cpu_reset)(CPUState *cpu); } S390CPUClass;/**
target-s390x/cpu.c +33 -8
65 lines not on this page · raw message
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 6/6] s390: wire up nmi command to raise a RESTART interrupt on S390
In reply to Christian BorntraegerFrom: "Eugene (jno) Dvurechenski" <[email protected]>
There is the 'nmi' command that is used to trigger a guest dump via kdump feature on x86. s390 uses RESTART interrupt to trigger kdump.
So, this patch provides a mean to use 'nmi' command on s390 to raise RESTART interrupt.
The CPU to receive the RESTART interrupt is the "default" one.
There is an infrastructure to select the "default" CPU using 'cpu' command. The 'info cpus' command can be used to see which one is the "default".
In order to wire up the RESTART to 'nmi' command we had to:
1. implement the kvm_s390_cpu_restart function by exporting the existing code
2. implement s390_cpu_restart function as kvm-aware wrapper
3. modify the qmp_inject_nmi function to enable (for s390) the scan for "default" CPU and call s390_cpu_restart for it;
3. fix some messages.
--- cpus.c | 14 ++++++++++++++ hmp-commands.hx | 4 ++-- qmp-commands.hx | 2 +- target-s390x/cpu.h | 13 +++++++++++++ target-s390x/kvm.c | 6 +++--- 5 files changed, 33 insertions(+), 6 deletions(-)
cpus.c +14 -0
@@ -1401,6 +1401,20 @@ void qmp_inject_nmi(Error **errp) apic_deliver_nmi(env->apic_state); } } +#elif defined(TARGET_S390X) +CPUState *cs; +S390CPU *cpu; + +for (cs = first_cpu; cs !=NULL ; cs = cs->next_cpu) { + cpu =S390_CPU (cs); +if (cpu->env.cpu_num ==monitor_get_cpu_index ()) { +if (s390_cpu_restart (S390_CPU (cs)) ==-1 ) { +error_set (errp,QERR_UNSUPPORTED ); +return ; + } +break ; + } + }#else error_set (errp,QERR_UNSUPPORTED );#endif
hmp-commands.hx +2 -2
@@ -822,7 +822,7 @@ The values that can be specified here depend on the machine type, but are the same that can be specified in the @code{-boot} command line option. ETEXI -#if defined(TARGET_I386) +#if defined(TARGET_I386) || defined(TARGET_S390X) { .name = "nmi", .args_type = "",
@@ -834,7 +834,7 @@ ETEXI STEXI @item nmi @var{cpu} @findex nmi -Inject an NMI on the given CPU (x86 only). +Inject an NMI (x86) or RESTART (s390x) on the given CPU. ETEXI
qmp-commands.hx +1 -1
@@ -487,7 +487,7 @@ Example: <- { "return": {} } Note: inject-nmi fails when the guest doesn't support injecting. - Currently, only x86 guests do. + Currently, only x86 (NMI) and s390x (RESTART) guests do. EQMP
target-s390x/cpu.h +13 -0
@@ -1066,6 +1066,7 @@ void kvm_s390_enable_css_support(S390CPU *cpu);int kvm_s390_get_registers_partial (CPUState *cpu);int kvm_s390_assign_subch_ioeventfd (EventNotifier *notifier,uint32_t sch,int vq,bool assign); +int kvm_s390_cpu_restart (S390CPU *cpu);#else static inline void kvm_s390_io_interrupt(S390CPU *cpu, uint16_t subchannel_id,
@@ -1090,8 +1091,20 @@ static inline int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, {return -ENOSYS ; } +static inline int kvm_s390_cpu_restart (S390CPU *cpu) +{ +return -ENOSYS ; +}#endif +static inline int s390_cpu_restart (S390CPU *cpu) +{ +if (kvm_enabled ()) { +return kvm_s390_cpu_restart (cpu); + } +return -ENOSYS ; +} + static inline void s390_io_interrupt(S390CPU *cpu, uint16_t subchannel_id, uint16_t subchannel_nr,
target-s390x/kvm.c +3 -3
@@ -673,12 +673,12 @@ static int handle_diag(S390CPU *cpu, struct kvm_run *run, int ipb_code)return r; } -static int s390_cpu_restart (S390CPU *cpu) +int kvm_s390_cpu_restart (S390CPU *cpu) {kvm_s390_interrupt (cpu,KVM_S390_RESTART ,0 );s390_add_running_cpu (cpu);qemu_cpu_kick (CPU (cpu)); -DPRINTF ("DONE: SIGP cpu restart: %p\n" , &cpu->env); +DPRINTF ("DONE: KVM cpu restart: %p\n" , &cpu->env);return 0 ; }
@@ -747,7 +747,7 @@ static int handle_sigp(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1)switch (order_code) {case SIGP_RESTART : - r =s390_cpu_restart (target_cpu); + r =kvm_s390_cpu_restart (target_cpu);break ;case SIGP_STORE_STATUS_ADDR : r =s390_store_status (target_env, parameter);
Signature · 1 line
1.8.3.1
Alexander Graf
Acked-byQuoted 1 line · Christian Borntraeger
Alex, can you either Ack or Pull the following patches:
Patch 1 needs some rework.
Patches 2-6 are:
Alex
Quoted 48 lines
The following changes since commit
951fab990db05d47ab9da5e72521e406c73a3eb9:target-mips: fix
get_physical_address()#if 0 build error (2013-08-28 19:28:02 +0200)are available in the git repository at:
git://github.com/borntraeger/qemu.gittags/kdumpfor you to fetch changes up to
8f288cfca867ac708cc371192e80947a83663833:s390: wire up nmi command to raise a RESTART interrupt on S390 (2013-08-29 14:09:58 +0200)
----------------------------------------------------------------
This is a set of patches dealing with kdump support for s390x/kvm. kdump on s390x uses subcode 1 of diagnose0x308to put the hardware in a defined state. This is different from a full reset, since it does not touch all CPU registers.
These patches define the cpu resets, the subsystem reset a load function and also wires up the "nmi" command to issue a RESTART interrupt as defined in the z/Architecture principles of operation.This allows recent guest kernels with properly setup userspace to trigger kdump:
- via guest crash
- via nmi from the host----------------------------------------------------------------
Christian Borntraeger (4):
s390: provide I/O subsystem reset
s390: provide a cpu load normal function s390/cpu: split CPU reset into architectured functions
s390: Implement load normal resetEugene (jno) Dvurechenski (2):
s390/kvm: basic implementation of diagnose 308 subcode 6
s390: wire up nmi command to raise a RESTART interrupt on S390cpus.c | 14 ++++++++ hmp-commands.hx | 4 +-- hw/s390x/s390-virtio-ccw.c | 15 +++++++++ qmp-commands.hx | 2 +- target-s390x/cpu-qom.h | 6 ++++ target-s390x/cpu.c | 55 ++++++++++++++++++++++++++----- target-s390x/cpu.h | 17 ++++++++++ target-s390x/kvm.c | 81 ++++++++++++++++++++++++++++++++++++++++++++-- 8 files changed, 180 insertions(+), 14 deletions(-)