* [Qemu-devel] [PULL 1/6] s390/kvm: basic implementation of diagnose 308 subcode 6
2013-08-29 21:10 [Qemu-devel] [PULL 0/6] kdump patches for s390x/kvm Christian Borntraeger
@ 2013-08-29 21:10 ` Christian Borntraeger
2013-08-29 22:14 ` Alexander Graf
2013-08-29 21:10 ` [Qemu-devel] [PULL 2/6] s390: provide I/O subsystem reset Christian Borntraeger
` (5 subsequent siblings)
6 siblings, 1 reply; 9+ messages in thread
From: Christian Borntraeger @ 2013-08-29 21:10 UTC (permalink / raw)
To: Alexander Graf
Cc: qemu-devel, Christian Borntraeger, Jens Freimann, Cornelia Huck,
Eugene (jno) Dvurechenski, Andreas Färber
From: "Eugene (jno) Dvurechenski" <jno@linux.vnet.ibm.com>
Linux uses a check for subcode 6 to decide if other subcodes are
available. Provide a minimal implementation.
Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
target-s390x/kvm.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 26d18e3..9d3d201 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -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;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PULL 1/6] s390/kvm: basic implementation of diagnose 308 subcode 6
2013-08-29 21:10 ` [Qemu-devel] [PULL 1/6] s390/kvm: basic implementation of diagnose 308 subcode 6 Christian Borntraeger
@ 2013-08-29 22:14 ` Alexander Graf
0 siblings, 0 replies; 9+ messages in thread
From: Alexander Graf @ 2013-08-29 22:14 UTC (permalink / raw)
To: Christian Borntraeger
Cc: Cornelia Huck, Eugene (jno) Dvurechenski, Jens Freimann,
Andreas Färber, qemu-devel
On 29.08.2013, at 23:10, Christian Borntraeger wrote:
> From: "Eugene (jno) Dvurechenski" <jno@linux.vnet.ibm.com>
>
> Linux uses a check for subcode 6 to decide if other subcodes are
> available. Provide a minimal implementation.
>
> Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com>
> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
> target-s390x/kvm.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 46 insertions(+)
>
> diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
> index 26d18e3..9d3d201 100644
> --- a/target-s390x/kvm.c
> +++ b/target-s390x/kvm.c
> @@ -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)
Most of this code shouldn't live in kvm.c, but in a more universal helper.
Alex
> +{
> + 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;
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] [PULL 2/6] s390: provide I/O subsystem reset
2013-08-29 21:10 [Qemu-devel] [PULL 0/6] kdump patches for s390x/kvm Christian Borntraeger
2013-08-29 21:10 ` [Qemu-devel] [PULL 1/6] s390/kvm: basic implementation of diagnose 308 subcode 6 Christian Borntraeger
@ 2013-08-29 21:10 ` Christian Borntraeger
2013-08-29 21:10 ` [Qemu-devel] [PULL 3/6] s390: provide a cpu load normal function Christian Borntraeger
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Christian Borntraeger @ 2013-08-29 21:10 UTC (permalink / raw)
To: Alexander Graf
Cc: Cornelia Huck, Christian Borntraeger, Jens Freimann,
Andreas Färber, qemu-devel
Provide a function that resets the I/O subsystem.
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
hw/s390x/s390-virtio-ccw.c | 15 +++++++++++++++
target-s390x/cpu.h | 1 +
2 files changed, 16 insertions(+)
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index aebbbf1..8fd46a9 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -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];
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 65bef86..1c8e2c2 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -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);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PULL 3/6] s390: provide a cpu load normal function
2013-08-29 21:10 [Qemu-devel] [PULL 0/6] kdump patches for s390x/kvm Christian Borntraeger
2013-08-29 21:10 ` [Qemu-devel] [PULL 1/6] s390/kvm: basic implementation of diagnose 308 subcode 6 Christian Borntraeger
2013-08-29 21:10 ` [Qemu-devel] [PULL 2/6] s390: provide I/O subsystem reset Christian Borntraeger
@ 2013-08-29 21:10 ` Christian Borntraeger
2013-08-29 21:10 ` [Qemu-devel] [PULL 4/6] s390/cpu: split CPU reset into architectured functions Christian Borntraeger
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Christian Borntraeger @ 2013-08-29 21:10 UTC (permalink / raw)
To: Alexander Graf
Cc: Cornelia Huck, Christian Borntraeger, Jens Freimann,
Andreas Färber, qemu-devel
Some code needs to perform an IPL-like bootup that mimics the
ESA (31bit) restart. Provide a cpu class method that does so.
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
target-s390x/cpu-qom.h | 2 ++
target-s390x/cpu.c | 14 ++++++++++++++
target-s390x/cpu.h | 3 +++
3 files changed, 19 insertions(+)
diff --git a/target-s390x/cpu-qom.h b/target-s390x/cpu-qom.h
index cbe2341..2dc1750 100644
--- a/target-s390x/cpu-qom.h
+++ b/target-s390x/cpu-qom.h
@@ -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;
/**
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 5cc9938..69f5e10 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -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;
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 1c8e2c2..7ba4da2 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -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
--
1.8.3.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PULL 4/6] s390/cpu: split CPU reset into architectured functions
2013-08-29 21:10 [Qemu-devel] [PULL 0/6] kdump patches for s390x/kvm Christian Borntraeger
` (2 preceding siblings ...)
2013-08-29 21:10 ` [Qemu-devel] [PULL 3/6] s390: provide a cpu load normal function Christian Borntraeger
@ 2013-08-29 21:10 ` Christian Borntraeger
2013-08-29 21:10 ` [Qemu-devel] [PULL 5/6] s390: Implement load normal reset Christian Borntraeger
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Christian Borntraeger @ 2013-08-29 21:10 UTC (permalink / raw)
To: Alexander Graf
Cc: Cornelia Huck, Christian Borntraeger, Jens Freimann,
Andreas Färber, qemu-devel
s390 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.
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
target-s390x/cpu-qom.h | 4 ++++
target-s390x/cpu.c | 41 +++++++++++++++++++++++++++++++++--------
2 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/target-s390x/cpu-qom.h b/target-s390x/cpu-qom.h
index 2dc1750..ac0460e 100644
--- a/target-s390x/cpu-qom.h
+++ b/target-s390x/cpu-qom.h
@@ -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;
/**
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 69f5e10..b0af043 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -76,7 +76,7 @@ static void s390_cpu_load_normal(CPUState *s)
}
#endif
-/* CPUClass::reset() */
+/* S390CPUClass::cpu_reset() */
static void s390_cpu_reset(CPUState *s)
{
S390CPU *cpu = S390_CPU(s);
@@ -87,11 +87,6 @@ static void s390_cpu_reset(CPUState *s)
scc->parent_reset(s);
- memset(env, 0, offsetof(CPUS390XState, breakpoints));
-
- /* architectured initial values for CR 0 and 14 */
- env->cregs[0] = CR0_RESET;
- env->cregs[14] = CR14_RESET;
/* set halted to 1 to make sure we can add the cpu in
* s390_ipl_cpu code, where CPUState::halted is set back to 0
* after incrementing the cpu counter */
@@ -110,6 +105,35 @@ static void s390_cpu_machine_reset_cb(void *opaque)
}
#endif
+/* S390CPUClass::initial_reset() */
+static void s390_cpu_initial_reset(CPUState *s)
+{
+ S390CPU *cpu = S390_CPU(s);
+ CPUS390XState *env = &cpu->env;
+
+ s390_cpu_reset(s);
+ /* initial reset does not touch regs,fregs and aregs */
+ memset(&env->fpc, 0, offsetof(CPUS390XState, breakpoints) -
+ offsetof(CPUS390XState, fpc));
+
+ /* architectured initial values for CR 0 and 14 */
+ env->cregs[0] = CR0_RESET;
+ env->cregs[14] = CR14_RESET;
+}
+
+/* CPUClass:reset() */
+static void s390_cpu_full_reset(CPUState *s)
+{
+ S390CPU *cpu = S390_CPU(s);
+ CPUS390XState *env = &cpu->env;
+
+ s390_cpu_initial_reset(s);
+ /* also reset regs,aregs and fregs */
+ memset(env, 0, offsetof(CPUS390XState, fpc));
+}
+
+
+
static void s390_cpu_realizefn(DeviceState *dev, Error **errp)
{
CPUState *cs = CPU(dev);
@@ -183,8 +207,9 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)
#if !defined(CONFIG_USER_ONLY)
scc->load_normal = s390_cpu_load_normal;
#endif
- cc->reset = s390_cpu_reset;
-
+ scc->cpu_reset = s390_cpu_reset;
+ scc->initial_cpu_reset = s390_cpu_initial_reset;
+ cc->reset = s390_cpu_full_reset;
cc->do_interrupt = s390_cpu_do_interrupt;
cc->dump_state = s390_cpu_dump_state;
cc->set_pc = s390_cpu_set_pc;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PULL 5/6] s390: Implement load normal reset
2013-08-29 21:10 [Qemu-devel] [PULL 0/6] kdump patches for s390x/kvm Christian Borntraeger
` (3 preceding siblings ...)
2013-08-29 21:10 ` [Qemu-devel] [PULL 4/6] s390/cpu: split CPU reset into architectured functions Christian Borntraeger
@ 2013-08-29 21:10 ` Christian Borntraeger
2013-08-29 21:10 ` [Qemu-devel] [PULL 6/6] s390: wire up nmi command to raise a RESTART interrupt on S390 Christian Borntraeger
2013-08-29 22:33 ` [Qemu-devel] [PULL 0/6] kdump patches for s390x/kvm Alexander Graf
6 siblings, 0 replies; 9+ messages in thread
From: Christian Borntraeger @ 2013-08-29 21:10 UTC (permalink / raw)
To: Alexander Graf
Cc: Cornelia Huck, Christian Borntraeger, Jens Freimann,
Andreas Färber, qemu-devel
kdump 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.
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
target-s390x/kvm.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 9d3d201..8a32af0 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -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);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PULL 6/6] s390: wire up nmi command to raise a RESTART interrupt on S390
2013-08-29 21:10 [Qemu-devel] [PULL 0/6] kdump patches for s390x/kvm Christian Borntraeger
` (4 preceding siblings ...)
2013-08-29 21:10 ` [Qemu-devel] [PULL 5/6] s390: Implement load normal reset Christian Borntraeger
@ 2013-08-29 21:10 ` Christian Borntraeger
2013-08-29 22:33 ` [Qemu-devel] [PULL 0/6] kdump patches for s390x/kvm Alexander Graf
6 siblings, 0 replies; 9+ messages in thread
From: Christian Borntraeger @ 2013-08-29 21:10 UTC (permalink / raw)
To: Alexander Graf
Cc: qemu-devel, Christian Borntraeger, Jens Freimann, Cornelia Huck,
Eugene (jno) Dvurechenski, Andreas Färber
From: "Eugene (jno) Dvurechenski" <jno@linux.vnet.ibm.com>
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.
Signed-off-by: Eugene (jno) Dvurechenski <jno@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
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(-)
diff --git a/cpus.c b/cpus.c
index b9e5685..d74cc11 100644
--- a/cpus.c
+++ b/cpus.c
@@ -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
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 8c6b91a..628807f 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -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
diff --git a/qmp-commands.hx b/qmp-commands.hx
index cf47e3f..bb09e72 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -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
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 7ba4da2..a09515e 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -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,
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 8a32af0..212a0a4 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -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);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PULL 0/6] kdump patches for s390x/kvm
2013-08-29 21:10 [Qemu-devel] [PULL 0/6] kdump patches for s390x/kvm Christian Borntraeger
` (5 preceding siblings ...)
2013-08-29 21:10 ` [Qemu-devel] [PULL 6/6] s390: wire up nmi command to raise a RESTART interrupt on S390 Christian Borntraeger
@ 2013-08-29 22:33 ` Alexander Graf
6 siblings, 0 replies; 9+ messages in thread
From: Alexander Graf @ 2013-08-29 22:33 UTC (permalink / raw)
To: Christian Borntraeger
Cc: Cornelia Huck, Jens Freimann, Andreas Färber, qemu-devel
On 29.08.2013, at 23:10, Christian Borntraeger wrote:
> Alex, can you either Ack or Pull the following patches:
Patch 1 needs some rework.
Patches 2-6 are:
Acked-by: Alexander Graf <agraf@suse.de>
Alex
>
> 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(-)
>
^ permalink raw reply [flat|nested] 9+ messages in thread