qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] spapr: fix H_SET_MODE to sync LPCR with KVM
@ 2014-01-17  6:13 Alexey Kardashevskiy
  2014-01-20 14:41 ` Alexander Graf
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Kardashevskiy @ 2014-01-17  6:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alexey Kardashevskiy, qemu-ppc, Alexander Graf

The kvm_cpu_exec() only puts registers to KVM if the @kvm_vcpu_dirty flag
has been set.

This adds registers sync which also sets @kvm_vcpu_dirty so we store new
LPCR to KVM before continuing with the KVM_RUN ioctl.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 hw/ppc/spapr_hcall.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index f755a53..b61d744 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -682,6 +682,7 @@ static target_ulong h_set_mode(PowerPCCPU *cpu, sPAPREnvironment *spapr,
             CPU_FOREACH(cs) {
                 PowerPCCPU *cp = POWERPC_CPU(cs);
                 CPUPPCState *env = &cp->env;
+                kvm_cpu_synchronize_state(cs);
                 env->spr[SPR_LPCR] &= ~LPCR_ILE;
             }
             ret = H_SUCCESS;
@@ -691,6 +692,7 @@ static target_ulong h_set_mode(PowerPCCPU *cpu, sPAPREnvironment *spapr,
             CPU_FOREACH(cs) {
                 PowerPCCPU *cp = POWERPC_CPU(cs);
                 CPUPPCState *env = &cp->env;
+                kvm_cpu_synchronize_state(cs);
                 env->spr[SPR_LPCR] |= LPCR_ILE;
             }
             ret = H_SUCCESS;
-- 
1.8.4.rc4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] spapr: fix H_SET_MODE to sync LPCR with KVM
  2014-01-17  6:13 [Qemu-devel] [PATCH] spapr: fix H_SET_MODE to sync LPCR with KVM Alexey Kardashevskiy
@ 2014-01-20 14:41 ` Alexander Graf
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Graf @ 2014-01-20 14:41 UTC (permalink / raw)
  To: Alexey Kardashevskiy; +Cc: qemu-ppc, QEMU Developers


On 17.01.2014, at 07:13, Alexey Kardashevskiy <aik@ozlabs.ru> wrote:

> The kvm_cpu_exec() only puts registers to KVM if the @kvm_vcpu_dirty flag
> has been set.
> 
> This adds registers sync which also sets @kvm_vcpu_dirty so we store new
> LPCR to KVM before continuing with the KVM_RUN ioctl.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
> hw/ppc/spapr_hcall.c | 2 ++
> 1 file changed, 2 insertions(+)
> 
> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
> index f755a53..b61d744 100644
> --- a/hw/ppc/spapr_hcall.c
> +++ b/hw/ppc/spapr_hcall.c
> @@ -682,6 +682,7 @@ static target_ulong h_set_mode(PowerPCCPU *cpu, sPAPREnvironment *spapr,
>             CPU_FOREACH(cs) {
>                 PowerPCCPU *cp = POWERPC_CPU(cs);
>                 CPUPPCState *env = &cp->env;
> +                kvm_cpu_synchronize_state(cs);

This should be cpu_synchronize_state(). But even then I'm not 100% sure we're not racy. What guarantees that the other vcpu doesn't go back into the guest before we fiddle with its LPCR?

We might have to put the LPCR fiddling and synchronization into a single function we call through run_on_cpu().


Alex

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-01-20 14:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-17  6:13 [Qemu-devel] [PATCH] spapr: fix H_SET_MODE to sync LPCR with KVM Alexey Kardashevskiy
2014-01-20 14:41 ` Alexander Graf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).