Kernel KVM virtualization development
 help / color / mirror / Atom feed
* [PATCH] PPC: KVM: fix VCPU run for HV KVM
@ 2014-01-10  7:21 Alexey Kardashevskiy
  2014-01-12 15:44 ` Alexander Graf
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Kardashevskiy @ 2014-01-10  7:21 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Alexey Kardashevskiy, Paul Mackerras, Alexander Graf, kvm-ppc,
	kvm, linux-kernel, Michael S. Tsirkin

When write to MMIO happens and there is an ioeventfd for that and
is handled successfully, ioeventfd_write() returns 0 (success) and
kvmppc_handle_store() returns EMULATE_DONE. Then kvmppc_emulate_mmio()
converts EMULATE_DONE to RESUME_GUEST_NV and this broke from the loop.

This adds handling of RESUME_GUEST_NV in kvmppc_vcpu_run_hv().

Cc: Michael S. Tsirkin <mst@redhat.com>
Suggested-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---

This definitely needs a better commit message. Please, help.
ps. it seems like ioeventfd never worked on ppc64. hm.

---
 arch/powerpc/kvm/book3s_hv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 072287f..24f363f 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -1569,7 +1569,7 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu)
 				vcpu->arch.fault_dar, vcpu->arch.fault_dsisr);
 			srcu_read_unlock(&vcpu->kvm->srcu, srcu_idx);
 		}
-	} while (r == RESUME_GUEST);
+	} while ((r == RESUME_GUEST_NV) || (r == RESUME_GUEST));
 
  out:
 	vcpu->arch.state = KVMPPC_VCPU_NOTREADY;
-- 
1.8.4.rc4


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

* Re: [PATCH] PPC: KVM: fix VCPU run for HV KVM
  2014-01-10  7:21 [PATCH] PPC: KVM: fix VCPU run for HV KVM Alexey Kardashevskiy
@ 2014-01-12 15:44 ` Alexander Graf
  2014-02-04  8:03   ` Alexey Kardashevskiy
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Graf @ 2014-01-12 15:44 UTC (permalink / raw)
  To: Alexey Kardashevskiy
  Cc: linuxppc-dev, Paul Mackerras, kvm-ppc,
	kvm@vger.kernel.org mailing list,
	linux-kernel@vger.kernel.org list, Michael S. Tsirkin


On 10.01.2014, at 08:21, Alexey Kardashevskiy <aik@ozlabs.ru> wrote:

> When write to MMIO happens and there is an ioeventfd for that and
> is handled successfully, ioeventfd_write() returns 0 (success) and
> kvmppc_handle_store() returns EMULATE_DONE. Then kvmppc_emulate_mmio()
> converts EMULATE_DONE to RESUME_GUEST_NV and this broke from the loop.
> 
> This adds handling of RESUME_GUEST_NV in kvmppc_vcpu_run_hv().
> 
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Suggested-by: Paul Mackerras <paulus@samba.org>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
> 
> This definitely needs a better commit message. Please, help.
> ps. it seems like ioeventfd never worked on ppc64. hm.
> 
> ---
> arch/powerpc/kvm/book3s_hv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 072287f..24f363f 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -1569,7 +1569,7 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu)
> 				vcpu->arch.fault_dar, vcpu->arch.fault_dsisr);
> 			srcu_read_unlock(&vcpu->kvm->srcu, srcu_idx);
> 		}
> -	} while (r == RESUME_GUEST);
> +	} while ((r == RESUME_GUEST_NV) || (r == RESUME_GUEST));

How about

  while(!(r & RESUME_FLAG_HOST));

That should cover all RESUME_GUEST_XXX cases just fine. Apart from that I agree that we should check for ! FLAG_HOST bit rather than the actual RESUME_GUEST value in all case where we check for it (read: please update all places).


Alex

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

* Re: [PATCH] PPC: KVM: fix VCPU run for HV KVM
  2014-01-12 15:44 ` Alexander Graf
@ 2014-02-04  8:03   ` Alexey Kardashevskiy
  2014-02-04  8:09     ` Alexander Graf
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Kardashevskiy @ 2014-02-04  8:03 UTC (permalink / raw)
  To: Alexander Graf
  Cc: linuxppc-dev, Paul Mackerras, kvm-ppc,
	kvm@vger.kernel.org mailing list,
	linux-kernel@vger.kernel.org list

On 01/13/2014 02:44 AM, Alexander Graf wrote:
> 
> On 10.01.2014, at 08:21, Alexey Kardashevskiy <aik@ozlabs.ru> wrote:
> 
>> When write to MMIO happens and there is an ioeventfd for that and
>> is handled successfully, ioeventfd_write() returns 0 (success) and
>> kvmppc_handle_store() returns EMULATE_DONE. Then kvmppc_emulate_mmio()
>> converts EMULATE_DONE to RESUME_GUEST_NV and this broke from the loop.
>>
>> This adds handling of RESUME_GUEST_NV in kvmppc_vcpu_run_hv().
>>
>> Cc: Michael S. Tsirkin <mst@redhat.com>
>> Suggested-by: Paul Mackerras <paulus@samba.org>
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>> ---
>>
>> This definitely needs a better commit message. Please, help.
>> ps. it seems like ioeventfd never worked on ppc64. hm.
>>
>> ---
>> arch/powerpc/kvm/book3s_hv.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
>> index 072287f..24f363f 100644
>> --- a/arch/powerpc/kvm/book3s_hv.c
>> +++ b/arch/powerpc/kvm/book3s_hv.c
>> @@ -1569,7 +1569,7 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu)
>> 				vcpu->arch.fault_dar, vcpu->arch.fault_dsisr);
>> 			srcu_read_unlock(&vcpu->kvm->srcu, srcu_idx);
>> 		}
>> -	} while (r == RESUME_GUEST);
>> +	} while ((r == RESUME_GUEST_NV) || (r == RESUME_GUEST));
> 
> How about
> 
>   while(!(r & RESUME_FLAG_HOST));


Rather "while(!(r & RESUME_FLAG_HOST) && (r > 0));" and still not obvious
that this is really better.

Paul agrees with the original patch (and made a better commit message for
our internal tree) but I just cannot make him reply in this thread, keep
constantly asking him but to no avail :)


> That should cover all RESUME_GUEST_XXX cases just fine. Apart from that
> I agree that we should check for ! FLAG_HOST bit rather than the actual
> RESUME_GUEST value in all case where we check for it (read: please
> update all places).

There are 3 places remotely similar to this and none of them requires a fix
like above.



-- 
Alexey

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

* Re: [PATCH] PPC: KVM: fix VCPU run for HV KVM
  2014-02-04  8:03   ` Alexey Kardashevskiy
@ 2014-02-04  8:09     ` Alexander Graf
  0 siblings, 0 replies; 4+ messages in thread
From: Alexander Graf @ 2014-02-04  8:09 UTC (permalink / raw)
  To: Alexey Kardashevskiy
  Cc: linuxppc-dev, Paul Mackerras, kvm-ppc,
	kvm@vger.kernel.org mailing list,
	linux-kernel@vger.kernel.org list


On 04.02.2014, at 09:03, Alexey Kardashevskiy <aik@ozlabs.ru> wrote:

> On 01/13/2014 02:44 AM, Alexander Graf wrote:
>> 
>> On 10.01.2014, at 08:21, Alexey Kardashevskiy <aik@ozlabs.ru> wrote:
>> 
>>> When write to MMIO happens and there is an ioeventfd for that and
>>> is handled successfully, ioeventfd_write() returns 0 (success) and
>>> kvmppc_handle_store() returns EMULATE_DONE. Then kvmppc_emulate_mmio()
>>> converts EMULATE_DONE to RESUME_GUEST_NV and this broke from the loop.
>>> 
>>> This adds handling of RESUME_GUEST_NV in kvmppc_vcpu_run_hv().
>>> 
>>> Cc: Michael S. Tsirkin <mst@redhat.com>
>>> Suggested-by: Paul Mackerras <paulus@samba.org>
>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>>> ---
>>> 
>>> This definitely needs a better commit message. Please, help.
>>> ps. it seems like ioeventfd never worked on ppc64. hm.
>>> 
>>> ---
>>> arch/powerpc/kvm/book3s_hv.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>> 
>>> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
>>> index 072287f..24f363f 100644
>>> --- a/arch/powerpc/kvm/book3s_hv.c
>>> +++ b/arch/powerpc/kvm/book3s_hv.c
>>> @@ -1569,7 +1569,7 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu)
>>> 				vcpu->arch.fault_dar, vcpu->arch.fault_dsisr);
>>> 			srcu_read_unlock(&vcpu->kvm->srcu, srcu_idx);
>>> 		}
>>> -	} while (r == RESUME_GUEST);
>>> +	} while ((r == RESUME_GUEST_NV) || (r == RESUME_GUEST));
>> 
>> How about
>> 
>>  while(!(r & RESUME_FLAG_HOST));
> 
> 
> Rather "while(!(r & RESUME_FLAG_HOST) && (r > 0));" and still not obvious
> that this is really better.
> 
> Paul agrees with the original patch (and made a better commit message for
> our internal tree) but I just cannot make him reply in this thread, keep
> constantly asking him but to no avail :)
> 
> 
>> That should cover all RESUME_GUEST_XXX cases just fine. Apart from that
>> I agree that we should check for ! FLAG_HOST bit rather than the actual
>> RESUME_GUEST value in all case where we check for it (read: please
>> update all places).
> 
> There are 3 places remotely similar to this and none of them requires a fix
> like above.

Not today. Then someone goes in and realizes that CEDE advanced version 8 should clear r15 at which point you have to set RESUME_GUEST_NV and are in the same mess again. Let's just always treat RESUME_GUEST_NV and RESUME_GUEST as identical when checking for it.

If you like, add a small helper like

static inline bool is_resume_guest(int r) {
  return (r == RESUME_GUEST || r == RESUME_GUEST_NV);
}

in a header and use that one instead. That way we're guaranteed to be consistent.


Alex

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

end of thread, other threads:[~2014-02-04  8:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-10  7:21 [PATCH] PPC: KVM: fix VCPU run for HV KVM Alexey Kardashevskiy
2014-01-12 15:44 ` Alexander Graf
2014-02-04  8:03   ` Alexey Kardashevskiy
2014-02-04  8:09     ` Alexander Graf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox