* [Qemu-devel] [PATCH] ppc/kvm: Use error_report() instead of cpu_abort() for user-triggerable errors
@ 2016-02-18 21:01 Thomas Huth
2016-02-19 0:16 ` David Gibson
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Huth @ 2016-02-18 21:01 UTC (permalink / raw)
To: qemu-ppc, david; +Cc: qemu-devel, agraf
Setting the KVM_CAP_PPC_PAPR capability can fail if either the KVM
kernel module does not support it, or if the specified vCPU type
is not a 64-bit Book3-S CPU type. For example, the user can trigger
it easily with "-M pseries -cpu G2leLS" when using the kvm-pr kernel
module. So the error should not be reported with cpu_abort() since
this function is rather meant for reporting programming errors than
reporting user-triggerable errors (it prints out all CPU registers
and then calls abort() to kills the program - two things that the
normal user does not expect here) . So let's use error_report() with
exit(1) here instead.
A similar problem exists in the code that sets the KVM_CAP_PPC_EPR
capability, so while we're at it, fix that, too.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
target-ppc/kvm.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 70ca296..762d6cf 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -23,6 +23,7 @@
#include <linux/kvm.h>
#include "qemu-common.h"
+#include "qemu/error-report.h"
#include "qemu/timer.h"
#include "sysemu/sysemu.h"
#include "sysemu/kvm.h"
@@ -1993,7 +1994,8 @@ void kvmppc_set_papr(PowerPCCPU *cpu)
ret = kvm_vcpu_enable_cap(cs, KVM_CAP_PPC_PAPR, 0);
if (ret) {
- cpu_abort(cs, "This KVM version does not support PAPR\n");
+ error_report("This vCPU type or KVM version does not support PAPR");
+ exit(1);
}
/* Update the capability flag so we sync the right information
@@ -2013,7 +2015,8 @@ void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy)
ret = kvm_vcpu_enable_cap(cs, KVM_CAP_PPC_EPR, 0, mpic_proxy);
if (ret && mpic_proxy) {
- cpu_abort(cs, "This KVM version does not support EPR\n");
+ error_report("This KVM version does not support EPR");
+ exit(1);
}
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] ppc/kvm: Use error_report() instead of cpu_abort() for user-triggerable errors
2016-02-18 21:01 [Qemu-devel] [PATCH] ppc/kvm: Use error_report() instead of cpu_abort() for user-triggerable errors Thomas Huth
@ 2016-02-19 0:16 ` David Gibson
0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2016-02-19 0:16 UTC (permalink / raw)
To: Thomas Huth; +Cc: qemu-ppc, qemu-devel, agraf
[-- Attachment #1: Type: text/plain, Size: 2344 bytes --]
On Thu, Feb 18, 2016 at 10:01:38PM +0100, Thomas Huth wrote:
> Setting the KVM_CAP_PPC_PAPR capability can fail if either the KVM
> kernel module does not support it, or if the specified vCPU type
> is not a 64-bit Book3-S CPU type. For example, the user can trigger
> it easily with "-M pseries -cpu G2leLS" when using the kvm-pr kernel
> module. So the error should not be reported with cpu_abort() since
> this function is rather meant for reporting programming errors than
> reporting user-triggerable errors (it prints out all CPU registers
> and then calls abort() to kills the program - two things that the
> normal user does not expect here) . So let's use error_report() with
> exit(1) here instead.
> A similar problem exists in the code that sets the KVM_CAP_PPC_EPR
> capability, so while we're at it, fix that, too.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
Applied to ppc-for-2.6, thanks.
> ---
> target-ppc/kvm.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
> index 70ca296..762d6cf 100644
> --- a/target-ppc/kvm.c
> +++ b/target-ppc/kvm.c
> @@ -23,6 +23,7 @@
> #include <linux/kvm.h>
>
> #include "qemu-common.h"
> +#include "qemu/error-report.h"
> #include "qemu/timer.h"
> #include "sysemu/sysemu.h"
> #include "sysemu/kvm.h"
> @@ -1993,7 +1994,8 @@ void kvmppc_set_papr(PowerPCCPU *cpu)
>
> ret = kvm_vcpu_enable_cap(cs, KVM_CAP_PPC_PAPR, 0);
> if (ret) {
> - cpu_abort(cs, "This KVM version does not support PAPR\n");
> + error_report("This vCPU type or KVM version does not support PAPR");
> + exit(1);
> }
>
> /* Update the capability flag so we sync the right information
> @@ -2013,7 +2015,8 @@ void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy)
>
> ret = kvm_vcpu_enable_cap(cs, KVM_CAP_PPC_EPR, 0, mpic_proxy);
> if (ret && mpic_proxy) {
> - cpu_abort(cs, "This KVM version does not support EPR\n");
> + error_report("This KVM version does not support EPR");
> + exit(1);
> }
> }
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-02-19 0:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-18 21:01 [Qemu-devel] [PATCH] ppc/kvm: Use error_report() instead of cpu_abort() for user-triggerable errors Thomas Huth
2016-02-19 0:16 ` David Gibson
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).