[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 31/42] spapr: Implement ibm,suspend-me
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 31/42] spapr: Implement ibm,suspend-me |
Date: |
Wed, 21 Aug 2019 17:25:31 +1000 |
From: Nicholas Piggin <address@hidden>
This has been useful to modify and test the Linux pseries suspend
code but it requires modification to the guest to call it (due to
being gated by other unimplemented features). It is not otherwise
used by Linux yet, but work is slowly progressing there.
This allows a (lightly modified) guest kernel to suspend with
`echo mem > /sys/power/state` and be resumed with system_wakeup
monitor command.
Signed-off-by: Nicholas Piggin <address@hidden>
Message-Id: <address@hidden>
Acked-by: Paolo Bonzini <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/spapr.c | 7 +++++++
hw/ppc/spapr_rtas.c | 32 ++++++++++++++++++++++++++++++++
include/hw/ppc/spapr.h | 3 ++-
3 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 56b33571c5..51e1cb0d46 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3083,6 +3083,13 @@ static void spapr_machine_init(MachineState *machine)
qemu_register_boot_set(spapr_boot_set, spapr);
+ /*
+ * Nothing needs to be done to resume a suspended guest because
+ * suspending does not change the machine state, so no need for
+ * a ->wakeup method.
+ */
+ qemu_register_wakeup_support();
+
if (kvm_enabled()) {
/* to stop and start vmclock */
qemu_add_vm_change_state_handler(cpu_ppc_clock_vm_state_change,
diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
index d3f9a69a51..526b489297 100644
--- a/hw/ppc/spapr_rtas.c
+++ b/hw/ppc/spapr_rtas.c
@@ -217,6 +217,36 @@ static void rtas_stop_self(PowerPCCPU *cpu,
SpaprMachineState *spapr,
qemu_cpu_kick(cs);
}
+static void rtas_ibm_suspend_me(PowerPCCPU *cpu, SpaprMachineState *spapr,
+ uint32_t token, uint32_t nargs,
+ target_ulong args,
+ uint32_t nret, target_ulong rets)
+{
+ CPUState *cs;
+
+ if (nargs != 0 || nret != 1) {
+ rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
+ return;
+ }
+
+ CPU_FOREACH(cs) {
+ PowerPCCPU *c = POWERPC_CPU(cs);
+ CPUPPCState *e = &c->env;
+ if (c == cpu) {
+ continue;
+ }
+
+ /* See h_join */
+ if (!cs->halted || (e->msr & (1ULL << MSR_EE))) {
+ rtas_st(rets, 0, H_MULTI_THREADS_ACTIVE);
+ return;
+ }
+ }
+
+ qemu_system_suspend_request();
+ rtas_st(rets, 0, RTAS_OUT_SUCCESS);
+}
+
static inline int sysparm_st(target_ulong addr, target_ulong len,
const void *val, uint16_t vallen)
{
@@ -484,6 +514,8 @@ static void core_rtas_register_types(void)
rtas_query_cpu_stopped_state);
spapr_rtas_register(RTAS_START_CPU, "start-cpu", rtas_start_cpu);
spapr_rtas_register(RTAS_STOP_SELF, "stop-self", rtas_stop_self);
+ spapr_rtas_register(RTAS_IBM_SUSPEND_ME, "ibm,suspend-me",
+ rtas_ibm_suspend_me);
spapr_rtas_register(RTAS_IBM_GET_SYSTEM_PARAMETER,
"ibm,get-system-parameter",
rtas_ibm_get_system_parameter);
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index c79bc6a123..fa7c380edb 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -642,8 +642,9 @@ target_ulong spapr_hypercall(PowerPCCPU *cpu, target_ulong
opcode,
#define RTAS_IBM_CREATE_PE_DMA_WINDOW (RTAS_TOKEN_BASE + 0x27)
#define RTAS_IBM_REMOVE_PE_DMA_WINDOW (RTAS_TOKEN_BASE + 0x28)
#define RTAS_IBM_RESET_PE_DMA_WINDOW (RTAS_TOKEN_BASE + 0x29)
+#define RTAS_IBM_SUSPEND_ME (RTAS_TOKEN_BASE + 0x2A)
-#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x2A)
+#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x2B)
/* RTAS ibm,get-system-parameter token values */
#define RTAS_SYSPARM_SPLPAR_CHARACTERISTICS 20
--
2.21.0
- [Qemu-ppc] [PULL 38/42] target/ppc: Add Directed Privileged Door-bell Exception State (DPDES) SPR, (continued)
- [Qemu-ppc] [PULL 38/42] target/ppc: Add Directed Privileged Door-bell Exception State (DPDES) SPR, David Gibson, 2019/08/21
- [Qemu-ppc] [PULL 21/42] pseries: Update SLOF firmware image, David Gibson, 2019/08/21
- [Qemu-ppc] [PULL 27/42] ppc/xive: Provide silent escalation support, David Gibson, 2019/08/21
- [Qemu-ppc] [PULL 30/42] i386: use machine class ->wakeup method, David Gibson, 2019/08/21
- [Qemu-ppc] [PULL 22/42] ppc/xive: use an abstract type for XiveNotifier, David Gibson, 2019/08/21
- [Qemu-ppc] [PULL 24/42] ppc/xive: Provide backlog support, David Gibson, 2019/08/21
- [Qemu-ppc] [PULL 32/42] ppc: remove idle_timer logic, David Gibson, 2019/08/21
- [Qemu-ppc] [PULL 40/42] ppc: conform to processor User's Manual for xscvdpspn, David Gibson, 2019/08/21
- [Qemu-ppc] [PULL 41/42] ppc: Fix emulated INFINITY and NAN conversions, David Gibson, 2019/08/21
- [Qemu-ppc] [PULL 42/42] ppc: Fix emulated single to double denormalized conversions, David Gibson, 2019/08/21
- [Qemu-ppc] [PULL 31/42] spapr: Implement ibm,suspend-me,
David Gibson <=
- [Qemu-ppc] [PULL 39/42] ppc: Add support for 'mffsl' instruction, David Gibson, 2019/08/21
- Re: [Qemu-ppc] [Qemu-devel] [PULL 00/42] ppc-for-4.2 queue 20190821, no-reply, 2019/08/21
- Re: [Qemu-ppc] [PULL 00/42] ppc-for-4.2 queue 20190821, Peter Maydell, 2019/08/21