[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 04/23] s390: Fix error handling and condition code o
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 04/23] s390: Fix error handling and condition code of service call |
Date: |
Tue, 21 Aug 2012 12:05:38 -0500 |
From: Christian Borntraeger <address@hidden>
Invalid sccb addresses will cause specification or addressing exception.
Lets add those checks. Furthermore, the good case (cc=0) was incorrect
for KVM, we did not set the CC at all. We now use return codes < 0
as program checks and return codes > 0 as condition code values.
Signed-off-by: Christian Borntraeger <address@hidden>
Signed-off-by: Alexander Graf <address@hidden>
(cherry picked from commit 9abf567d95a4e840df868ca993219175fbef8c22)
Signed-off-by: Michael Roth <address@hidden>
---
target-s390x/kvm.c | 5 +++--
target-s390x/op_helper.c | 27 ++++++++++++++++++---------
2 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 90aad61..e4e6f15 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -238,9 +238,10 @@ static int kvm_sclp_service_call(CPUS390XState *env,
struct kvm_run *run,
code = env->regs[(ipbh0 & 0xf0) >> 4];
r = sclp_service_call(env, sccb, code);
- if (r) {
- setcc(env, 3);
+ if (r < 0) {
+ enter_pgmcheck(env, -r);
}
+ setcc(env, r);
return 0;
}
diff --git a/target-s390x/op_helper.c b/target-s390x/op_helper.c
index 7b72473..91dd8dc 100644
--- a/target-s390x/op_helper.c
+++ b/target-s390x/op_helper.c
@@ -19,6 +19,8 @@
*/
#include "cpu.h"
+#include "memory.h"
+#include "cputlb.h"
#include "dyngen-exec.h"
#include "host-utils.h"
#include "helper.h"
@@ -2366,6 +2368,9 @@ static void ext_interrupt(CPUS390XState *env, int type,
uint32_t param,
cpu_inject_ext(env, type, param, param64);
}
+/*
+ * ret < 0 indicates program check, ret = 0,1,2,3 -> cc
+ */
int sclp_service_call(CPUS390XState *env, uint32_t sccb, uint64_t code)
{
int r = 0;
@@ -2375,10 +2380,12 @@ int sclp_service_call(CPUS390XState *env, uint32_t
sccb, uint64_t code)
printf("sclp(0x%x, 0x%" PRIx64 ")\n", sccb, code);
#endif
+ /* basic checks */
+ if (!memory_region_is_ram(phys_page_find(sccb >> TARGET_PAGE_BITS)->mr)) {
+ return -PGM_ADDRESSING;
+ }
if (sccb & ~0x7ffffff8ul) {
- fprintf(stderr, "KVM: invalid sccb address 0x%x\n", sccb);
- r = -1;
- goto out;
+ return -PGM_SPECIFICATION;
}
switch(code) {
@@ -2405,22 +2412,24 @@ int sclp_service_call(CPUS390XState *env, uint32_t
sccb, uint64_t code)
#ifdef DEBUG_HELPER
printf("KVM: invalid sclp call 0x%x / 0x%" PRIx64 "x\n", sccb,
code);
#endif
- r = -1;
+ r = 3;
break;
}
-out:
return r;
}
/* SCLP service call */
uint32_t HELPER(servc)(uint32_t r1, uint64_t r2)
{
- if (sclp_service_call(env, r1, r2)) {
- return 3;
- }
+ int r;
- return 0;
+ r = sclp_service_call(env, r1, r2);
+ if (r < 0) {
+ program_interrupt(env, -r, 4);
+ return 0;
+ }
+ return r;
}
/* DIAG */
--
1.7.9.5
- [Qemu-devel] [stable-1.1] Patch Round-up for stable 1.1.2, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 02/23] configure: Don't override user's --cpu on MacOS and Solaris, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 03/23] ppc: Fix bug in handling of PAPR hypercall exits, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 05/23] kvmvapic: Disable if there is insufficient memory, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 04/23] s390: Fix error handling and condition code of service call,
Michael Roth <=
- [Qemu-devel] [PATCH 01/23] qtest: fix infinite loop when QEMU aborts abruptly, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 07/23] virtio-blk: fix use-after-free while handling scsi commands, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 08/23] ehci: fix reset, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 06/23] qdev: fix use-after-free in the error path of qdev_init_nofail, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 13/23] usb-ehci: Fix an assert whenever isoc transfers are used, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 11/23] usb: restore USBDevice->attached on vmload, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 10/23] uhci: fix uhci_async_cancel_all, Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 14/23] qlist: add qlist_size(), Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 09/23] ehci: don't flush cache on doorbell rings., Michael Roth, 2012/08/21
- [Qemu-devel] [PATCH 12/23] usb-redir: Correctly handle the usb_redir_babble usbredir status, Michael Roth, 2012/08/21