target/arm/kvm: Retry KVM_CREATE_VM call if it fails EINTR
PATCH v3 1/1 target/arm/kvm: Retry KVM_CREATE_VM call if it fails EINTR
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/[email protected]/
---
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(-)
target/arm/kvm.c +3 -1
@@ -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; }
Signature · 1 line
2.25.1
Quoted 31 lines · Peter Maydell
Occasionally the
KVM_CREATE_VMioctl can return EINTR, even though there is no pending signal to be taken. In commit94ccff13382055we added a retry-on-EINTR loop to theKVM_CREATE_VMcall 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/[email protected]/Reported-by Vitaly Chikunov <[email protected]>Signed-off-by Peter Maydell <[email protected]>---
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 commit94ccff13did, rather than, for instance, something wider like "makekvm_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(-)target/arm/kvm.c +0
-0
target/arm/kvm.c bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, · line 84
Quoted 7 lines
target/arm/kvm.c +3
-1@@ -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 );
Thanks,
Quoted 5 lines
target/arm/kvm.c +0
-0if (vmfd <0 ) { goto err; }Signature · 1 line
2.25.1
Quoted 21 lines · Peter Maydell
Occasionally the
KVM_CREATE_VMioctl can return EINTR, even though there is no pending signal to be taken. In commit94ccff13382055we added a retry-on-EINTR loop to theKVM_CREATE_VMcall 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/[email protected]/Reported-by Vitaly Chikunov <[email protected]>Signed-off-by Peter Maydell <[email protected]>---
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 commit94ccff13did, rather than, for instance, something wider like "makekvm_ioctl()and friends always retry on EINTR".
Quoted 5 lines
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(-)
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Hi Peter,
Quoted 20 lines · Peter Maydell
Occasionally the
KVM_CREATE_VMioctl can return EINTR, even though there is no pending signal to be taken. In commit94ccff13382055we added a retry-on-EINTR loop to theKVM_CREATE_VMcall 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/[email protected]/Reported-by Vitaly Chikunov <[email protected]>Signed-off-by Peter Maydell <[email protected]>---
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 commit94ccff13did, rather than, for instance, something wider like "makekvm_ioctl()and friends always retry on EINTR".
Quoted 2 lines
v2: correctly check for -1 and errno is EINTR...
v3: really correctly check errno. This time for sure!
Thanks
Eric
Quoted 19 lines
--- target/arm/kvm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)target/arm/kvm.c +3
-1@@ -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; }