* [PATCH v3] target/arm/kvm: Retry KVM_CREATE_VM call if it fails EINTR
@ 2022-09-30 11:38 Peter Maydell
2022-09-30 12:28 ` Vitaly Chikunov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Peter Maydell @ 2022-09-30 11:38 UTC (permalink / raw)
To: qemu-arm, qemu-devel
Cc: Vitaly Chikunov, Marc Zyngier, Eric Auger, Paolo Bonzini
Occasionally the KVM_CREATE_VM ioctl can return EINTR, even though
there is no pending signal to be taken. In commit 94ccff13382055
we added a retry-on-EINTR loop to the KVM_CREATE_VM call in the
generic KVM code. Adopt the same approach for the use of the
ioctl in the Arm-specific KVM code (where we use it to create a
scratch VM for probing for various things).
For more information, see the mailing list thread:
https://lore.kernel.org/qemu-devel/8735e0s1zw.wl-maz@kernel.org/
Reported-by: Vitaly Chikunov <vt@altlinux.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
The view in the thread seems to be that this is a kernel bug (because
in QEMU's case there shouldn't be a signal to be delivered at this
point because of our signal handling strategy); so I've adopted the
same "just retry-on-EINTR for this specific ioctl" approach that
commit 94ccff13 did, rather than, for instance, something wider like
"make kvm_ioctl() and friends always retry on EINTR".
v2: correctly check for -1 and errno is EINTR...
v3: really correctly check errno. This time for sure!
---
target/arm/kvm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index e5c1bd50d29..1e4de9b42e3 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -79,7 +79,9 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try,
if (max_vm_pa_size < 0) {
max_vm_pa_size = 0;
}
- vmfd = ioctl(kvmfd, KVM_CREATE_VM, max_vm_pa_size);
+ do {
+ vmfd = ioctl(kvmfd, KVM_CREATE_VM, max_vm_pa_size);
+ } while (vmfd == -1 && errno == EINTR);
if (vmfd < 0) {
goto err;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3] target/arm/kvm: Retry KVM_CREATE_VM call if it fails EINTR
2022-09-30 11:38 [PATCH v3] target/arm/kvm: Retry KVM_CREATE_VM call if it fails EINTR Peter Maydell
@ 2022-09-30 12:28 ` Vitaly Chikunov
2022-09-30 12:31 ` Marc Zyngier
2022-09-30 12:59 ` Eric Auger
2 siblings, 0 replies; 4+ messages in thread
From: Vitaly Chikunov @ 2022-09-30 12:28 UTC (permalink / raw)
To: Peter Maydell
Cc: qemu-arm, qemu-devel, Marc Zyngier, Eric Auger, Paolo Bonzini
On Fri, Sep 30, 2022 at 12:38:24PM +0100, Peter Maydell wrote:
> Occasionally the KVM_CREATE_VM ioctl can return EINTR, even though
> there is no pending signal to be taken. In commit 94ccff13382055
> we added a retry-on-EINTR loop to the KVM_CREATE_VM call in the
> generic KVM code. Adopt the same approach for the use of the
> ioctl in the Arm-specific KVM code (where we use it to create a
> scratch VM for probing for various things).
>
> For more information, see the mailing list thread:
> https://lore.kernel.org/qemu-devel/8735e0s1zw.wl-maz@kernel.org/
>
> Reported-by: Vitaly Chikunov <vt@altlinux.org>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> The view in the thread seems to be that this is a kernel bug (because
> in QEMU's case there shouldn't be a signal to be delivered at this
> point because of our signal handling strategy); so I've adopted the
> same "just retry-on-EINTR for this specific ioctl" approach that
> commit 94ccff13 did, rather than, for instance, something wider like
> "make kvm_ioctl() and friends always retry on EINTR".
>
> v2: correctly check for -1 and errno is EINTR...
> v3: really correctly check errno. This time for sure!
> ---
> target/arm/kvm.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/target/arm/kvm.c b/target/arm/kvm.c
> index e5c1bd50d29..1e4de9b42e3 100644
> --- a/target/arm/kvm.c
> +++ b/target/arm/kvm.c
> @@ -79,7 +79,9 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try,
> if (max_vm_pa_size < 0) {
> max_vm_pa_size = 0;
> }
> - vmfd = ioctl(kvmfd, KVM_CREATE_VM, max_vm_pa_size);
> + do {
> + vmfd = ioctl(kvmfd, KVM_CREATE_VM, max_vm_pa_size);
> + } while (vmfd == -1 && errno == EINTR);
Reviewed-by: Vitaly Chikunov <vt@altlinux.org>
Thanks,
> if (vmfd < 0) {
> goto err;
> }
> --
> 2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] target/arm/kvm: Retry KVM_CREATE_VM call if it fails EINTR
2022-09-30 11:38 [PATCH v3] target/arm/kvm: Retry KVM_CREATE_VM call if it fails EINTR Peter Maydell
2022-09-30 12:28 ` Vitaly Chikunov
@ 2022-09-30 12:31 ` Marc Zyngier
2022-09-30 12:59 ` Eric Auger
2 siblings, 0 replies; 4+ messages in thread
From: Marc Zyngier @ 2022-09-30 12:31 UTC (permalink / raw)
To: Peter Maydell
Cc: qemu-arm, qemu-devel, Vitaly Chikunov, Eric Auger, Paolo Bonzini
On Fri, 30 Sep 2022 12:38:24 +0100,
Peter Maydell <peter.maydell@linaro.org> wrote:
>
> Occasionally the KVM_CREATE_VM ioctl can return EINTR, even though
> there is no pending signal to be taken. In commit 94ccff13382055
> we added a retry-on-EINTR loop to the KVM_CREATE_VM call in the
> generic KVM code. Adopt the same approach for the use of the
> ioctl in the Arm-specific KVM code (where we use it to create a
> scratch VM for probing for various things).
>
> For more information, see the mailing list thread:
> https://lore.kernel.org/qemu-devel/8735e0s1zw.wl-maz@kernel.org/
>
> Reported-by: Vitaly Chikunov <vt@altlinux.org>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> The view in the thread seems to be that this is a kernel bug (because
> in QEMU's case there shouldn't be a signal to be delivered at this
> point because of our signal handling strategy); so I've adopted the
> same "just retry-on-EINTR for this specific ioctl" approach that
> commit 94ccff13 did, rather than, for instance, something wider like
> "make kvm_ioctl() and friends always retry on EINTR".
>
> v2: correctly check for -1 and errno is EINTR...
> v3: really correctly check errno. This time for sure!
> ---
> target/arm/kvm.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Acked-by: Marc Zyngier <maz@kernel.org>
M.
--
Without deviation from the norm, progress is not possible.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] target/arm/kvm: Retry KVM_CREATE_VM call if it fails EINTR
2022-09-30 11:38 [PATCH v3] target/arm/kvm: Retry KVM_CREATE_VM call if it fails EINTR Peter Maydell
2022-09-30 12:28 ` Vitaly Chikunov
2022-09-30 12:31 ` Marc Zyngier
@ 2022-09-30 12:59 ` Eric Auger
2 siblings, 0 replies; 4+ messages in thread
From: Eric Auger @ 2022-09-30 12:59 UTC (permalink / raw)
To: Peter Maydell, qemu-arm, qemu-devel
Cc: Vitaly Chikunov, Marc Zyngier, Paolo Bonzini
Hi Peter,
On 9/30/22 13:38, Peter Maydell wrote:
> Occasionally the KVM_CREATE_VM ioctl can return EINTR, even though
> there is no pending signal to be taken. In commit 94ccff13382055
> we added a retry-on-EINTR loop to the KVM_CREATE_VM call in the
> generic KVM code. Adopt the same approach for the use of the
> ioctl in the Arm-specific KVM code (where we use it to create a
> scratch VM for probing for various things).
>
> For more information, see the mailing list thread:
> https://lore.kernel.org/qemu-devel/8735e0s1zw.wl-maz@kernel.org/
>
> Reported-by: Vitaly Chikunov <vt@altlinux.org>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> The view in the thread seems to be that this is a kernel bug (because
> in QEMU's case there shouldn't be a signal to be delivered at this
> point because of our signal handling strategy); so I've adopted the
> same "just retry-on-EINTR for this specific ioctl" approach that
> commit 94ccff13 did, rather than, for instance, something wider like
> "make kvm_ioctl() and friends always retry on EINTR".
>
> v2: correctly check for -1 and errno is EINTR...
> v3: really correctly check errno. This time for sure!
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Thanks
Eric
> ---
> target/arm/kvm.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/target/arm/kvm.c b/target/arm/kvm.c
> index e5c1bd50d29..1e4de9b42e3 100644
> --- a/target/arm/kvm.c
> +++ b/target/arm/kvm.c
> @@ -79,7 +79,9 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try,
> if (max_vm_pa_size < 0) {
> max_vm_pa_size = 0;
> }
> - vmfd = ioctl(kvmfd, KVM_CREATE_VM, max_vm_pa_size);
> + do {
> + vmfd = ioctl(kvmfd, KVM_CREATE_VM, max_vm_pa_size);
> + } while (vmfd == -1 && errno == EINTR);
> if (vmfd < 0) {
> goto err;
> }
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-30 13:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-30 11:38 [PATCH v3] target/arm/kvm: Retry KVM_CREATE_VM call if it fails EINTR Peter Maydell
2022-09-30 12:28 ` Vitaly Chikunov
2022-09-30 12:31 ` Marc Zyngier
2022-09-30 12:59 ` Eric Auger
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.