* [Qemu-devel] [PATCH v1 for-2.12] s390x/kvm: call cpu_synchronize_state() on every kvm_arch_handle_exit()
@ 2018-04-06 9:35 David Hildenbrand
2018-04-06 9:40 ` Thomas Huth
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: David Hildenbrand @ 2018-04-06 9:35 UTC (permalink / raw)
To: qemu-s390x
Cc: qemu-devel, Richard Henderson, Alexander Graf, Cornelia Huck,
Christian Borntraeger, Thomas Huth, David Hildenbrand
Manually having to use cpu_synchronize_state() is error prone. And as
Christian Borntraeger discovered, e.g. handle_diag() is currently
missing a cpu_synchronize_state(), as decode_basedisp_s() uses a
general purpose register value internally.
So let's do an overall cpu_synchronize_state(), which fixes at least the
one mentioned BUG. We will clean up the superfluous cpu_synchronize_state()
calls later.
We now also call it (although maybe not neded) for
- KVM_EXIT_S390_RESET -> s390_reipl_request()
- KVM_EXIT_DEBUG -> kvm_arch_handle_debug_exit()
- unmanagable/unimplemented intercepts
- ICPT_CPU_STOP -> do_stop_interrupt() -> cpu gets halted
- Scenarios where we inject an operation exception
- handle_stsi()
I don't think any of these are performance critical. Especially as we
have all information directly contained in kvm_run, there are no
additional IOCTLs to issue on modern kernels.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
target/s390x/kvm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
index f570896dc1..fb59d92def 100644
--- a/target/s390x/kvm.c
+++ b/target/s390x/kvm.c
@@ -1778,6 +1778,8 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
qemu_mutex_lock_iothread();
+ cpu_synchronize_state(cs);
+
switch (run->exit_reason) {
case KVM_EXIT_S390_SIEIC:
ret = handle_intercept(cpu);
--
2.14.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v1 for-2.12] s390x/kvm: call cpu_synchronize_state() on every kvm_arch_handle_exit()
2018-04-06 9:35 [Qemu-devel] [PATCH v1 for-2.12] s390x/kvm: call cpu_synchronize_state() on every kvm_arch_handle_exit() David Hildenbrand
@ 2018-04-06 9:40 ` Thomas Huth
2018-04-06 9:46 ` David Hildenbrand
2018-04-06 10:10 ` Christian Borntraeger
2018-04-06 10:58 ` Cornelia Huck
2 siblings, 1 reply; 6+ messages in thread
From: Thomas Huth @ 2018-04-06 9:40 UTC (permalink / raw)
To: David Hildenbrand, qemu-s390x
Cc: qemu-devel, Richard Henderson, Alexander Graf, Cornelia Huck,
Christian Borntraeger
On 06.04.2018 11:35, David Hildenbrand wrote:
> Manually having to use cpu_synchronize_state() is error prone. And as
> Christian Borntraeger discovered, e.g. handle_diag() is currently
> missing a cpu_synchronize_state(), as decode_basedisp_s() uses a
> general purpose register value internally.
>
> So let's do an overall cpu_synchronize_state(), which fixes at least the
> one mentioned BUG. We will clean up the superfluous cpu_synchronize_state()
> calls later.
>
> We now also call it (although maybe not neded) for
> - KVM_EXIT_S390_RESET -> s390_reipl_request()
> - KVM_EXIT_DEBUG -> kvm_arch_handle_debug_exit()
> - unmanagable/unimplemented intercepts
> - ICPT_CPU_STOP -> do_stop_interrupt() -> cpu gets halted
> - Scenarios where we inject an operation exception
> - handle_stsi()
>
> I don't think any of these are performance critical. Especially as we
> have all information directly contained in kvm_run, there are no
> additional IOCTLs to issue on modern kernels.
>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
> target/s390x/kvm.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
> index f570896dc1..fb59d92def 100644
> --- a/target/s390x/kvm.c
> +++ b/target/s390x/kvm.c
> @@ -1778,6 +1778,8 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
>
> qemu_mutex_lock_iothread();
>
> + cpu_synchronize_state(cs);
Since we're in kvm.c here, maybe rather call kvm_cpu_synchronize_state()
directly to avoid the wrapper function?
Thomas
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v1 for-2.12] s390x/kvm: call cpu_synchronize_state() on every kvm_arch_handle_exit()
2018-04-06 9:40 ` Thomas Huth
@ 2018-04-06 9:46 ` David Hildenbrand
2018-04-06 9:48 ` Cornelia Huck
0 siblings, 1 reply; 6+ messages in thread
From: David Hildenbrand @ 2018-04-06 9:46 UTC (permalink / raw)
To: Thomas Huth, qemu-s390x
Cc: qemu-devel, Richard Henderson, Alexander Graf, Cornelia Huck,
Christian Borntraeger
On 06.04.2018 11:40, Thomas Huth wrote:
> On 06.04.2018 11:35, David Hildenbrand wrote:
>> Manually having to use cpu_synchronize_state() is error prone. And as
>> Christian Borntraeger discovered, e.g. handle_diag() is currently
>> missing a cpu_synchronize_state(), as decode_basedisp_s() uses a
>> general purpose register value internally.
>>
>> So let's do an overall cpu_synchronize_state(), which fixes at least the
>> one mentioned BUG. We will clean up the superfluous cpu_synchronize_state()
>> calls later.
>>
>> We now also call it (although maybe not neded) for
>> - KVM_EXIT_S390_RESET -> s390_reipl_request()
>> - KVM_EXIT_DEBUG -> kvm_arch_handle_debug_exit()
>> - unmanagable/unimplemented intercepts
>> - ICPT_CPU_STOP -> do_stop_interrupt() -> cpu gets halted
>> - Scenarios where we inject an operation exception
>> - handle_stsi()
>>
>> I don't think any of these are performance critical. Especially as we
>> have all information directly contained in kvm_run, there are no
>> additional IOCTLs to issue on modern kernels.
>>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>> ---
>> target/s390x/kvm.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
>> index f570896dc1..fb59d92def 100644
>> --- a/target/s390x/kvm.c
>> +++ b/target/s390x/kvm.c
>> @@ -1778,6 +1778,8 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
>>
>> qemu_mutex_lock_iothread();
>>
>> + cpu_synchronize_state(cs);
>
> Since we're in kvm.c here, maybe rather call kvm_cpu_synchronize_state()
> directly to avoid the wrapper function?
>
> Thomas
>
No strong opinion. I can see that kvm_cpu_synchronize_state()
- is not used in target/s390x/kvm.c yet
- is very rarely used in kvm code in general
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v1 for-2.12] s390x/kvm: call cpu_synchronize_state() on every kvm_arch_handle_exit()
2018-04-06 9:46 ` David Hildenbrand
@ 2018-04-06 9:48 ` Cornelia Huck
0 siblings, 0 replies; 6+ messages in thread
From: Cornelia Huck @ 2018-04-06 9:48 UTC (permalink / raw)
To: David Hildenbrand
Cc: Thomas Huth, qemu-s390x, qemu-devel, Richard Henderson,
Alexander Graf, Christian Borntraeger
On Fri, 6 Apr 2018 11:46:22 +0200
David Hildenbrand <david@redhat.com> wrote:
> On 06.04.2018 11:40, Thomas Huth wrote:
> > On 06.04.2018 11:35, David Hildenbrand wrote:
> >> Manually having to use cpu_synchronize_state() is error prone. And as
> >> Christian Borntraeger discovered, e.g. handle_diag() is currently
> >> missing a cpu_synchronize_state(), as decode_basedisp_s() uses a
> >> general purpose register value internally.
> >>
> >> So let's do an overall cpu_synchronize_state(), which fixes at least the
> >> one mentioned BUG. We will clean up the superfluous cpu_synchronize_state()
> >> calls later.
> >>
> >> We now also call it (although maybe not neded) for
> >> - KVM_EXIT_S390_RESET -> s390_reipl_request()
> >> - KVM_EXIT_DEBUG -> kvm_arch_handle_debug_exit()
> >> - unmanagable/unimplemented intercepts
> >> - ICPT_CPU_STOP -> do_stop_interrupt() -> cpu gets halted
> >> - Scenarios where we inject an operation exception
> >> - handle_stsi()
> >>
> >> I don't think any of these are performance critical. Especially as we
> >> have all information directly contained in kvm_run, there are no
> >> additional IOCTLs to issue on modern kernels.
> >>
> >> Signed-off-by: David Hildenbrand <david@redhat.com>
> >> ---
> >> target/s390x/kvm.c | 2 ++
> >> 1 file changed, 2 insertions(+)
> >>
> >> diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
> >> index f570896dc1..fb59d92def 100644
> >> --- a/target/s390x/kvm.c
> >> +++ b/target/s390x/kvm.c
> >> @@ -1778,6 +1778,8 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
> >>
> >> qemu_mutex_lock_iothread();
> >>
> >> + cpu_synchronize_state(cs);
> >
> > Since we're in kvm.c here, maybe rather call kvm_cpu_synchronize_state()
> > directly to avoid the wrapper function?
> >
> > Thomas
> >
>
> No strong opinion. I can see that kvm_cpu_synchronize_state()
> - is not used in target/s390x/kvm.c yet
> - is very rarely used in kvm code in general
>
Let's just go with this one for 2.12? If we want to switch to the kvm_*
variant, we can still do it for 2.13.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v1 for-2.12] s390x/kvm: call cpu_synchronize_state() on every kvm_arch_handle_exit()
2018-04-06 9:35 [Qemu-devel] [PATCH v1 for-2.12] s390x/kvm: call cpu_synchronize_state() on every kvm_arch_handle_exit() David Hildenbrand
2018-04-06 9:40 ` Thomas Huth
@ 2018-04-06 10:10 ` Christian Borntraeger
2018-04-06 10:58 ` Cornelia Huck
2 siblings, 0 replies; 6+ messages in thread
From: Christian Borntraeger @ 2018-04-06 10:10 UTC (permalink / raw)
To: David Hildenbrand, qemu-s390x
Cc: qemu-devel, Richard Henderson, Alexander Graf, Cornelia Huck,
Thomas Huth
On 04/06/2018 11:35 AM, David Hildenbrand wrote:
> Manually having to use cpu_synchronize_state() is error prone. And as
> Christian Borntraeger discovered, e.g. handle_diag() is currently
> missing a cpu_synchronize_state(), as decode_basedisp_s() uses a
> general purpose register value internally.
>
> So let's do an overall cpu_synchronize_state(), which fixes at least the
> one mentioned BUG. We will clean up the superfluous cpu_synchronize_state()
> calls later.
>
> We now also call it (although maybe not neded) for
> - KVM_EXIT_S390_RESET -> s390_reipl_request()
> - KVM_EXIT_DEBUG -> kvm_arch_handle_debug_exit()
> - unmanagable/unimplemented intercepts
> - ICPT_CPU_STOP -> do_stop_interrupt() -> cpu gets halted
> - Scenarios where we inject an operation exception
> - handle_stsi()
>
> I don't think any of these are performance critical. Especially as we
> have all information directly contained in kvm_run, there are no
> additional IOCTLs to issue on modern kernels.
>
> Signed-off-by: David Hildenbrand <david@redhat.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
ok for 2.12.
> ---
> target/s390x/kvm.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
> index f570896dc1..fb59d92def 100644
> --- a/target/s390x/kvm.c
> +++ b/target/s390x/kvm.c
> @@ -1778,6 +1778,8 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
>
> qemu_mutex_lock_iothread();
>
> + cpu_synchronize_state(cs);
> +
> switch (run->exit_reason) {
> case KVM_EXIT_S390_SIEIC:
> ret = handle_intercept(cpu);
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v1 for-2.12] s390x/kvm: call cpu_synchronize_state() on every kvm_arch_handle_exit()
2018-04-06 9:35 [Qemu-devel] [PATCH v1 for-2.12] s390x/kvm: call cpu_synchronize_state() on every kvm_arch_handle_exit() David Hildenbrand
2018-04-06 9:40 ` Thomas Huth
2018-04-06 10:10 ` Christian Borntraeger
@ 2018-04-06 10:58 ` Cornelia Huck
2 siblings, 0 replies; 6+ messages in thread
From: Cornelia Huck @ 2018-04-06 10:58 UTC (permalink / raw)
To: David Hildenbrand
Cc: qemu-s390x, qemu-devel, Richard Henderson, Alexander Graf,
Christian Borntraeger, Thomas Huth
On Fri, 6 Apr 2018 11:35:52 +0200
David Hildenbrand <david@redhat.com> wrote:
> Manually having to use cpu_synchronize_state() is error prone. And as
> Christian Borntraeger discovered, e.g. handle_diag() is currently
> missing a cpu_synchronize_state(), as decode_basedisp_s() uses a
> general purpose register value internally.
>
> So let's do an overall cpu_synchronize_state(), which fixes at least the
> one mentioned BUG. We will clean up the superfluous cpu_synchronize_state()
> calls later.
>
> We now also call it (although maybe not neded) for
> - KVM_EXIT_S390_RESET -> s390_reipl_request()
> - KVM_EXIT_DEBUG -> kvm_arch_handle_debug_exit()
> - unmanagable/unimplemented intercepts
> - ICPT_CPU_STOP -> do_stop_interrupt() -> cpu gets halted
> - Scenarios where we inject an operation exception
> - handle_stsi()
>
> I don't think any of these are performance critical. Especially as we
> have all information directly contained in kvm_run, there are no
> additional IOCTLs to issue on modern kernels.
>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
> target/s390x/kvm.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
> index f570896dc1..fb59d92def 100644
> --- a/target/s390x/kvm.c
> +++ b/target/s390x/kvm.c
> @@ -1778,6 +1778,8 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
>
> qemu_mutex_lock_iothread();
>
> + cpu_synchronize_state(cs);
> +
> switch (run->exit_reason) {
> case KVM_EXIT_S390_SIEIC:
> ret = handle_intercept(cpu);
Thanks, queued to s390-fixes.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-04-06 10:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-06 9:35 [Qemu-devel] [PATCH v1 for-2.12] s390x/kvm: call cpu_synchronize_state() on every kvm_arch_handle_exit() David Hildenbrand
2018-04-06 9:40 ` Thomas Huth
2018-04-06 9:46 ` David Hildenbrand
2018-04-06 9:48 ` Cornelia Huck
2018-04-06 10:10 ` Christian Borntraeger
2018-04-06 10:58 ` Cornelia Huck
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).