From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEy9z-0003nC-Bu for qemu-devel@nongnu.org; Thu, 29 Aug 2013 05:05:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VEy9r-0001Bj-I8 for qemu-devel@nongnu.org; Thu, 29 Aug 2013 05:04:59 -0400 Received: from mail-pb0-f52.google.com ([209.85.160.52]:57700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEy9r-0001BT-At for qemu-devel@nongnu.org; Thu, 29 Aug 2013 05:04:51 -0400 Received: by mail-pb0-f52.google.com with SMTP id wz12so176032pbc.11 for ; Thu, 29 Aug 2013 02:04:50 -0700 (PDT) Message-ID: <521F0EAB.8040704@ozlabs.ru> Date: Thu, 29 Aug 2013 19:04:43 +1000 From: Alexey Kardashevskiy MIME-Version: 1.0 References: <1377682371-12586-1-git-send-email-aik@ozlabs.ru> <20130828114203.GB2944@voom.redhat.com> In-Reply-To: <20130828114203.GB2944@voom.redhat.com> Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] spapr: add "stop-self" RTAS call required to support hot CPU unplug List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, Paolo Bonzini , Paul Mackerras On 08/28/2013 09:42 PM, David Gibson wrote: > On Wed, Aug 28, 2013 at 07:32:51PM +1000, Alexey Kardashevskiy wrote: >> PAPR+ requires two RTAS calls to be supported by the hypervisor in >> order to allow hotplugging VCPUs from the guest. The "start-cpu" RTAS >> call was already there but "stop-self" was not. >> >> This adds the "stop-self" RTAS call. >> >> Signed-off-by: Alexey Kardashevskiy >> --- >> Changes: >> v2: >> * exit_request flag change replaced with more correct cpu_exit() call >> * fixed commit message, "spapr: support CPU hotplug" >> --- >> hw/ppc/spapr_rtas.c | 12 ++++++++++++ >> 1 file changed, 12 insertions(+) >> >> diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c >> index 394ce05..b906294 100644 >> --- a/hw/ppc/spapr_rtas.c >> +++ b/hw/ppc/spapr_rtas.c >> @@ -202,6 +202,17 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPREnvironment *spapr, >> rtas_st(rets, 0, -3); >> } >> >> +static void rtas_stop_self(PowerPCCPU *cpu, sPAPREnvironment *spapr, >> + uint32_t token, uint32_t nargs, >> + target_ulong args, >> + uint32_t nret, target_ulong rets) >> +{ >> + CPUState *cs = CPU(cpu); >> + >> + cs->halted = 1; > > Uh.. I think you still need the msr = 0, or an interrupt could wake > the cpu up again. Tried with KVM and TCG - nothing wakes up the stopped CPU :-/ After a CPU stopped, the guest calls H_CPPR and disables interrupts on the specific CPU (or "server") on the XICS level. And decrementer interrupt does not wake up the CPU. What is strange is that with TCG (but not with KVM) I see a warning from the guest at WARN_ON(get_preferred_offline_state(cpu) != CPU_STATE_OFFLINE); (pseries_mach_cpu_die() function) but only when I stop a CPU (any!) first time in the guest. Specifically, I can do "echo 0 > ...cpuX/online" and "echo 1 > ...cpuX/online" many times during the same boot but only the first stop at all generates a warning (the state is 2 which is CPU_STATE_ONLINE). >> + cpu_exit(cs); >> +} >> + >> static struct rtas_call { >> const char *name; >> spapr_rtas_fn fn; >> @@ -322,6 +333,7 @@ static void core_rtas_register_types(void) >> spapr_rtas_register("query-cpu-stopped-state", >> rtas_query_cpu_stopped_state); >> spapr_rtas_register("start-cpu", rtas_start_cpu); >> + spapr_rtas_register("stop-self", rtas_stop_self); >> } >> >> type_init(core_rtas_register_types) > -- Alexey