* [Qemu-devel] [PATCH] target-arm: Check error conditions on kvm_arm_reset_vcpu
@ 2014-12-03 20:17 Christoffer Dall
2014-12-04 19:13 ` Peter Maydell
0 siblings, 1 reply; 3+ messages in thread
From: Christoffer Dall @ 2014-12-03 20:17 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>
---
target-arm/kvm32.c | 13 +++++++++++--
target-arm/kvm64.c | 8 +++++++-
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/target-arm/kvm32.c b/target-arm/kvm32.c
index 5ec4eb1..1fd0e83 100644
--- a/target-arm/kvm32.c
+++ b/target-arm/kvm32.c
@@ -511,9 +511,18 @@ int kvm_arch_get_registers(CPUState *cs)
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();
+ }
}
diff --git a/target-arm/kvm64.c b/target-arm/kvm64.c
index c615286..101354a 100644
--- a/target-arm/kvm64.c
+++ b/target-arm/kvm64.c
@@ -263,8 +263,14 @@ int kvm_arch_get_registers(CPUState *cs)
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));
+ ret = kvm_arm_vcpu_init(CPU(cpu));
+ if (ret < 0) {
+ fprintf(stderr, "kvm_arm_vcpu_init failed: %s\n", strerror(ret));
+ abort();
+ }
}
--
2.1.2.330.g565301e.dirty
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] target-arm: Check error conditions on kvm_arm_reset_vcpu
2014-12-03 20:17 [Qemu-devel] [PATCH] target-arm: Check error conditions on kvm_arm_reset_vcpu Christoffer Dall
@ 2014-12-04 19:13 ` Peter Maydell
2014-12-04 21:26 ` Christoffer Dall
0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2014-12-04 19:13 UTC (permalink / raw)
To: Christoffer Dall; +Cc: QEMU Developers, kvmarm@lists.cs.columbia.edu
On 3 December 2014 at 20:17, 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.
I like this patch, but it is going to conflict with a patch I'm
nearly done testing and plan to send tomorrow that unifies the
sysreg handling for 32 and 64 bit KVM/ARM. Part of what that
involves is using a single kvm_arm_reset_vcpu() in kvm.c rather
than different 32 and 64 bit versions. So you should probably
respin this patch on top of that one.
> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
> ---
> target-arm/kvm32.c | 13 +++++++++++--
> target-arm/kvm64.c | 8 +++++++-
> 2 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/target-arm/kvm32.c b/target-arm/kvm32.c
> index 5ec4eb1..1fd0e83 100644
> --- a/target-arm/kvm32.c
> +++ b/target-arm/kvm32.c
> @@ -511,9 +511,18 @@ int kvm_arch_get_registers(CPUState *cs)
>
> 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));
Shouldn't this be strerror(-ret) ?
thanks
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] target-arm: Check error conditions on kvm_arm_reset_vcpu
2014-12-04 19:13 ` Peter Maydell
@ 2014-12-04 21:26 ` Christoffer Dall
0 siblings, 0 replies; 3+ messages in thread
From: Christoffer Dall @ 2014-12-04 21:26 UTC (permalink / raw)
To: Peter Maydell; +Cc: QEMU Developers, kvmarm@lists.cs.columbia.edu
On Thu, Dec 4, 2014 at 8:13 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 3 December 2014 at 20:17, 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.
>
> I like this patch, but it is going to conflict with a patch I'm
> nearly done testing and plan to send tomorrow that unifies the
> sysreg handling for 32 and 64 bit KVM/ARM. Part of what that
> involves is using a single kvm_arm_reset_vcpu() in kvm.c rather
> than different 32 and 64 bit versions. So you should probably
> respin this patch on top of that one.
>
ok, will do, or you can squash this into yours, as you like.
>> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
>> ---
>> target-arm/kvm32.c | 13 +++++++++++--
>> target-arm/kvm64.c | 8 +++++++-
>> 2 files changed, 18 insertions(+), 3 deletions(-)
>>
>> diff --git a/target-arm/kvm32.c b/target-arm/kvm32.c
>> index 5ec4eb1..1fd0e83 100644
>> --- a/target-arm/kvm32.c
>> +++ b/target-arm/kvm32.c
>> @@ -511,9 +511,18 @@ int kvm_arch_get_registers(CPUState *cs)
>>
>> 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));
>
> Shouldn't this be strerror(-ret) ?
>
ah right, the init call returns a negative errno, but strerror expects
the positive one.
-Christoffer
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-12-04 21:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-03 20:17 [Qemu-devel] [PATCH] target-arm: Check error conditions on kvm_arm_reset_vcpu Christoffer Dall
2014-12-04 19:13 ` Peter Maydell
2014-12-04 21:26 ` Christoffer Dall
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).