spapr: support CPU hotplug
PATCH 1/1 spapr: support CPU hotplug
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.
--- hw/ppc/spapr_rtas.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
hw/ppc/spapr_rtas.c +14 -0
@@ -202,6 +202,19 @@ 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); +CPUPPCState *env = &cpu->env; + + cs->halted =1 ; + env->msr =0 ; + cs->exit_request =1 ; +} + static struct rtas_call { const char *name; spapr_rtas_fn fn;
@@ -322,6 +335,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)
Signature · 1 line
1.8.4.rc4
Quoted 19 lines · Alexey Kardashevskiy
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 <[email protected]>---
hw/ppc/spapr_rtas.c| 14 ++++++++++++++1 file changed, 14 insertions(+)hw/ppc/spapr_rtas.c +0
-0@@ -202,6 +202,19 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPREnvironment *spapr,rtas_st (rets,0 ,-3 ); }
hw/ppc/spapr_rtas.c static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPREnvironment *spapr, · line 214
Quoted 10 lines
hw/ppc/spapr_rtas.c +10
-0+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); +CPUPPCState *env = &cpu->env; + + cs->halted =1 ; + env->msr =0 ;
So this is here to make sure we don't accidentally get out of halted state by an interrupt on that vcpu. Could you please somehow make that part obvious? Either by adding a comment or by only explicitly masking DEC and EE and a comment :).
hw/ppc/spapr_rtas.c static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPREnvironment *spapr, · line 215
Quoted 1 line
hw/ppc/spapr_rtas.c +1
-0+ cs->exit_request =1 ;
This should probably be qemu_cpu_kick_self().
Alex
Quoted 35 lines · Alexander Graf
Quoted 19 lines · Alexey Kardashevskiy
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 <[email protected]>---
hw/ppc/spapr_rtas.c| 14 ++++++++++++++1 file changed, 14 insertions(+)hw/ppc/spapr_rtas.c +0
-0@@ -202,6 +202,19 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPREnvironment *spapr,rtas_st (rets,0 ,-3 ); }hw/ppc/spapr_rtas.c static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPREnvironment *spapr, · line 214
Quoted 10 lines
hw/ppc/spapr_rtas.c +10
-0+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); +CPUPPCState *env = &cpu->env; + + cs->halted =1 ; + env->msr =0 ;So this is here to make sure we don't accidentally get out of halted state by an interrupt on that vcpu. Could you please somehow make that part obvious? Either by adding a comment or by only explicitly masking DEC and EE and a comment :).
Quoted 3 lines
hw/ppc/spapr_rtas.c static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPREnvironment *spapr, · line 215
Quoted 1 line
hw/ppc/spapr_rtas.c +1
-0+ cs->exit_request =1 ;This should probably be
qemu_cpu_kick_self().
Uh, no, I don't think so. This is there purely to make sure we exit the inner loop, and actually test cpu_can_run() which will test halted. AFAICT qemu_cpu_kick_self() won't do anything similar.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 36 lines · David Gibson
Quoted 35 lines · Alexander Graf
Quoted 19 lines · Alexey Kardashevskiy
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 <[email protected]>---
hw/ppc/spapr_rtas.c| 14 ++++++++++++++1 file changed, 14 insertions(+)hw/ppc/spapr_rtas.c +0
-0@@ -202,6 +202,19 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPREnvironment *spapr,rtas_st (rets,0 ,-3 ); }hw/ppc/spapr_rtas.c static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPREnvironment *spapr, · line 214
Quoted 10 lines
hw/ppc/spapr_rtas.c +10
-0+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); +CPUPPCState *env = &cpu->env; + + cs->halted =1 ; + env->msr =0 ;So this is here to make sure we don't accidentally get out of halted state by an interrupt on that vcpu. Could you please somehow make that part obvious? Either by adding a comment or by only explicitly masking DEC and EE and a comment :).
Quoted 7 lines
Quoted 3 lines
hw/ppc/spapr_rtas.c static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPREnvironment *spapr, · line 215
Quoted 1 line
hw/ppc/spapr_rtas.c +1
-0+ cs->exit_request =1 ;This should probably be
qemu_cpu_kick_self().Uh, no, I don't think so. This is there purely to make sure we exit the inner loop, and actually test
cpu_can_run()which will test halted. AFAICTqemu_cpu_kick_self()won't do anything similar.
rtas_stop_self() eventually returns to kvm_cpu_exec() which calls qemu_cpu_kick_self() and resets cs->exit_request before return so I do not really see the difference in behaviour. And actually both ways CPU stops in exactly the same way. What do I miss?
Signature · 1 line
Alexey
Il 27/08/2013 08:37, Alexey Kardashevskiy ha scritto:
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
So this is here to make sure we don't accidentally get out of halted state by an interrupt on that vcpu. Could you please somehow make that part obvious? Either by adding a comment or by only explicitly masking DEC and EE and a comment :).
Quoted 1 line
+
cs->exit_request= 1;This should probably be
qemu_cpu_kick_self().
Quoted 8 lines
Quoted 3 lines
Uh, no, I don't think so. This is there purely to make sure we exit the inner loop, and actually test
cpu_can_run()which will test halted. AFAICTqemu_cpu_kick_self()won't do anything similar.
rtas_stop_self()eventually returns tokvm_cpu_exec()which callsqemu_cpu_kick_self()and resetscs->exit_requestbefore return so I do not really see the difference in behaviour. And actually both ways CPU stops in exactly the same way. What do I miss?
What about TCG?
Paolo
Quoted 11 lines · Paolo Bonzini
Il 27/08/2013 08:37, Alexey Kardashevskiy ha scritto:
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
So this is here to make sure we don't accidentally get out of halted state by an interrupt on that vcpu. Could you please somehow make that part obvious? Either by adding a comment or by only explicitly masking DEC and EE and a comment :).
Quoted 1 line
+
cs->exit_request= 1;This should probably be
qemu_cpu_kick_self().Uh, no, I don't think so. This is there purely to make sure we exit the inner loop, and actually test
cpu_can_run()which will test halted. AFAICTqemu_cpu_kick_self()won't do anything similar.
Quoted 6 lines
Quoted 4 lines
rtas_stop_self()eventually returns tokvm_cpu_exec()which callsqemu_cpu_kick_self()and resetscs->exit_requestbefore return so I do not really see the difference in behaviour. And actually both ways CPU stops in exactly the same way. What do I miss?What about TCG?
Oh. Right. TCG :(
qemu_cpu_kick_self() crashes the guest and cs->exit_request works fine.
Why? Both should work? What is the expected behavior here? Thanks.
Signature · 1 line
Alexey
Quoted 17 lines · Alexey Kardashevskiy
Quoted 16 lines · Paolo Bonzini
Il 27/08/2013 08:37, Alexey Kardashevskiy ha scritto:
Quoted 14 lines
Quoted 9 lines
Quoted 5 lines
So this is here to make sure we don't accidentally get out of halted state by an interrupt on that vcpu. Could you please somehow make that part obvious? Either by adding a comment or by only explicitly masking DEC and EE and a comment :).
Quoted 1 line
+
cs->exit_request= 1;This should probably be
qemu_cpu_kick_self().Uh, no, I don't think so. This is there purely to make sure we exit the inner loop, and actually test
cpu_can_run()which will test halted. AFAICTqemu_cpu_kick_self()won't do anything similar.
rtas_stop_self()eventually returns tokvm_cpu_exec()which callsqemu_cpu_kick_self()and resetscs->exit_requestbefore return so I do not really see the difference in behaviour. And actually both ways CPU stops in exactly the same way. What do I miss?
Quoted 7 lines
Quoted 1 line
What about TCG?
Oh. Right. TCG :(
qemu_cpu_kick_self()crashes the guest andcs->exit_requestworks fine.Why? Both should work? What is the expected behavior here? Thanks.
Hrm. To me exit_request always was an internal piece of state that the inner loop uses to find out whether to exit, but not something we should randomly set from a device (and hypercalls / rtas calls are very similar to devices). So I would like to not have any code in hw/ that modifies it.
However, we need the functionality of breaking out of the main loop, I agree.
Maybe what you are really looking for is cpu_interrupt(CPU_INTERRUPT_HALT). That sets halted = 1 and exits the main loop, because it's an interrupt.
Alex
Quoted 28 lines · Alexander Graf
Quoted 17 lines · Alexey Kardashevskiy
Quoted 16 lines · Paolo Bonzini
Il 27/08/2013 08:37, Alexey Kardashevskiy ha scritto:
Quoted 14 lines
Quoted 9 lines
Quoted 5 lines
So this is here to make sure we don't accidentally get out of halted state by an interrupt on that vcpu. Could you please somehow make that part obvious? Either by adding a comment or by only explicitly masking DEC and EE and a comment :).
Quoted 1 line
+
cs->exit_request= 1;This should probably be
qemu_cpu_kick_self().Uh, no, I don't think so. This is there purely to make sure we exit the inner loop, and actually test
cpu_can_run()which will test halted. AFAICTqemu_cpu_kick_self()won't do anything similar.
rtas_stop_self()eventually returns tokvm_cpu_exec()which callsqemu_cpu_kick_self()and resetscs->exit_requestbefore return so I do not really see the difference in behaviour. And actually both ways CPU stops in exactly the same way. What do I miss?Quoted 7 lines
Quoted 1 line
What about TCG?
Oh. Right. TCG :(
qemu_cpu_kick_self()crashes the guest andcs->exit_requestworks fine.Why? Both should work? What is the expected behavior here? Thanks.
Quoted 7 lines
Hrm. To me
exit_requestalways was an internal piece of state that the inner loop uses to find out whether to exit, but not something we should randomly set from a device (and hypercalls / rtas calls are very similar to devices). So I would like to not have any code in hw/ that modifies it.However, we need the functionality of breaking out of the main loop, I agree.
Maybe what you are really looking for is
cpu_interrupt(CPU_INTERRUPT_HALT). That sets halted = 1 and exits the main loop, because it's an interrupt.
cpu_interrupt(CPU_INTERRUPT_HALT) works fine for TCG but does not for KVM (the rtas call returns to the guest and it reports BUG).
Signature · 1 line
Alexey
Quoted 31 lines · Alexey Kardashevskiy
Quoted 30 lines · Alexander Graf
Quoted 17 lines · Alexey Kardashevskiy
Quoted 16 lines · Paolo Bonzini
Il 27/08/2013 08:37, Alexey Kardashevskiy ha scritto:
Quoted 14 lines
Quoted 9 lines
Quoted 5 lines
So this is here to make sure we don't accidentally get out of halted state by an interrupt on that vcpu. Could you please somehow make that part obvious? Either by adding a comment or by only explicitly masking DEC and EE and a comment :).
Quoted 1 line
+
cs->exit_request= 1;This should probably be
qemu_cpu_kick_self().Uh, no, I don't think so. This is there purely to make sure we exit the inner loop, and actually test
cpu_can_run()which will test halted. AFAICTqemu_cpu_kick_self()won't do anything similar.
rtas_stop_self()eventually returns tokvm_cpu_exec()which callsqemu_cpu_kick_self()and resetscs->exit_requestbefore return so I do not really see the difference in behaviour. And actually both ways CPU stops in exactly the same way. What do I miss?Quoted 7 lines
Quoted 1 line
What about TCG?
Oh. Right. TCG :(
qemu_cpu_kick_self()crashes the guest andcs->exit_requestworks fine.Why? Both should work? What is the expected behavior here? Thanks.
Hrm. To me
exit_requestalways was an internal piece of state that the inner loop uses to find out whether to exit, but not something we should randomly set from a device (and hypercalls / rtas calls are very similar to devices). So I would like to not have any code in hw/ that modifies it.
Quoted 8 lines
Quoted 5 lines
However, we need the functionality of breaking out of the main loop, I agree.
Maybe what you are really looking for is
cpu_interrupt(CPU_INTERRUPT_HALT). That sets halted = 1 and exits the main loop, because it's an interrupt.
cpu_interrupt(CPU_INTERRUPT_HALT)works fine for TCG but does not for KVM (the rtas call returns to the guest and it reports BUG).
How about cpu_exit()? That looks exactly like what we need.
Alex