All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] target-arm: Check error conditions on kvm_arm_reset_vcpu
@ 2014-12-08 11:53 Christoffer Dall
  2014-12-08 11:55 ` Peter Maydell
  2014-12-08 11:58 ` Christoffer Dall
  0 siblings, 2 replies; 4+ messages in thread
From: Christoffer Dall @ 2014-12-08 11:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: kvmarm, Christoffer Dall

When resetting a VCPU we currently call both kvm_arm_vcpu_init() and
write_kvmstate_to_list(), both of which can fail, but we never check the
return value.

The only choice here is to print an error an exit if the calls fail.

Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
Changes [v1 -> v2]:
 - Rebased onto Peter Maydell's "support migration/save/load on AArch64 CPUs"
   series.

 target-arm/kvm.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/target-arm/kvm.c b/target-arm/kvm.c
index 191e759..4d81f3d 100644
--- a/target-arm/kvm.c
+++ b/target-arm/kvm.c
@@ -442,11 +442,20 @@ bool write_list_to_kvmstate(ARMCPU *cpu)
 
 void kvm_arm_reset_vcpu(ARMCPU *cpu)
 {
+    int ret;
+
     /* Re-init VCPU so that all registers are set to
      * their respective reset values.
      */
-    kvm_arm_vcpu_init(CPU(cpu));
-    write_kvmstate_to_list(cpu);
+    ret = kvm_arm_vcpu_init(CPU(cpu));
+    if (ret < 0) {
+        fprintf(stderr, "kvm_arm_vcpu_init failed: %s\n", strerror(-ret));
+        abort();
+    }
+    if (!write_kvmstate_to_list(cpu)) {
+        fprintf(stderr, "write_kvmstate_to_list failed\n");
+        abort();
+    }
 }
 
 void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run)
-- 
2.1.2.330.g565301e.dirty

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

* Re: [Qemu-devel] [PATCH v2] target-arm: Check error conditions on kvm_arm_reset_vcpu
  2014-12-08 11:53 [Qemu-devel] [PATCH v2] target-arm: Check error conditions on kvm_arm_reset_vcpu Christoffer Dall
@ 2014-12-08 11:55 ` Peter Maydell
  2014-12-08 11:58 ` Christoffer Dall
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2014-12-08 11:55 UTC (permalink / raw)
  To: Christoffer Dall; +Cc: QEMU Developers, kvmarm@lists.cs.columbia.edu

On 8 December 2014 at 11:53, Christoffer Dall
<christoffer.dall@linaro.org> wrote:
> When resetting a VCPU we currently call both kvm_arm_vcpu_init() and
> write_kvmstate_to_list(), both of which can fail, but we never check the
> return value.
>
> The only choice here is to print an error an exit if the calls fail.
>
> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM

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

* Re: [Qemu-devel] [PATCH v2] target-arm: Check error conditions on kvm_arm_reset_vcpu
  2014-12-08 11:53 [Qemu-devel] [PATCH v2] target-arm: Check error conditions on kvm_arm_reset_vcpu Christoffer Dall
  2014-12-08 11:55 ` Peter Maydell
@ 2014-12-08 11:58 ` Christoffer Dall
  2014-12-08 11:59   ` Peter Maydell
  1 sibling, 1 reply; 4+ messages in thread
From: Christoffer Dall @ 2014-12-08 11:58 UTC (permalink / raw)
  To: qemu-devel; +Cc: kvmarm

On Mon, Dec 08, 2014 at 12:53:50PM +0100, Christoffer Dall wrote:
> When resetting a VCPU we currently call both kvm_arm_vcpu_init() and
> write_kvmstate_to_list(), both of which can fail, but we never check the
> return value.
> 
> The only choice here is to print an error an exit if the calls fail.
> 
> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
> ---
> Changes [v1 -> v2]:
>  - Rebased onto Peter Maydell's "support migration/save/load on AArch64 CPUs"
>    series.

Forgot to mention that I also changed strerror(ret) to strerror(-ret).

-Christoffer

> 
>  target-arm/kvm.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/target-arm/kvm.c b/target-arm/kvm.c
> index 191e759..4d81f3d 100644
> --- a/target-arm/kvm.c
> +++ b/target-arm/kvm.c
> @@ -442,11 +442,20 @@ bool write_list_to_kvmstate(ARMCPU *cpu)
>  
>  void kvm_arm_reset_vcpu(ARMCPU *cpu)
>  {
> +    int ret;
> +
>      /* Re-init VCPU so that all registers are set to
>       * their respective reset values.
>       */
> -    kvm_arm_vcpu_init(CPU(cpu));
> -    write_kvmstate_to_list(cpu);
> +    ret = kvm_arm_vcpu_init(CPU(cpu));
> +    if (ret < 0) {
> +        fprintf(stderr, "kvm_arm_vcpu_init failed: %s\n", strerror(-ret));
> +        abort();
> +    }
> +    if (!write_kvmstate_to_list(cpu)) {
> +        fprintf(stderr, "write_kvmstate_to_list failed\n");
> +        abort();
> +    }
>  }
>  
>  void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run)
> -- 
> 2.1.2.330.g565301e.dirty
> 

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

* Re: [Qemu-devel] [PATCH v2] target-arm: Check error conditions on kvm_arm_reset_vcpu
  2014-12-08 11:58 ` Christoffer Dall
@ 2014-12-08 11:59   ` Peter Maydell
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2014-12-08 11:59 UTC (permalink / raw)
  To: Christoffer Dall; +Cc: QEMU Developers, kvmarm@lists.cs.columbia.edu

On 8 December 2014 at 11:58, Christoffer Dall
<christoffer.dall@linaro.org> wrote:
> On Mon, Dec 08, 2014 at 12:53:50PM +0100, Christoffer Dall wrote:
>> When resetting a VCPU we currently call both kvm_arm_vcpu_init() and
>> write_kvmstate_to_list(), both of which can fail, but we never check the
>> return value.
>>
>> The only choice here is to print an error an exit if the calls fail.
>>
>> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
>> ---
>> Changes [v1 -> v2]:
>>  - Rebased onto Peter Maydell's "support migration/save/load on AArch64 CPUs"
>>    series.
>
> Forgot to mention that I also changed strerror(ret) to strerror(-ret).

That's ok, I forgot to check that you had when I reviewed this :-)

-- PMM

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

end of thread, other threads:[~2014-12-08 12:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-08 11:53 [Qemu-devel] [PATCH v2] target-arm: Check error conditions on kvm_arm_reset_vcpu Christoffer Dall
2014-12-08 11:55 ` Peter Maydell
2014-12-08 11:58 ` Christoffer Dall
2014-12-08 11:59   ` Peter Maydell

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.