[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 13/30] s390x/kvm: factor out storing of CPU statu
From: |
David Hildenbrand |
Subject: |
[Qemu-devel] [PATCH v2 13/30] s390x/kvm: factor out storing of CPU status |
Date: |
Thu, 28 Sep 2017 22:36:51 +0200 |
Factor it out into s390_store_status(), to be used also by TCG later on.
Signed-off-by: David Hildenbrand <address@hidden>
---
target/s390x/helper.c | 60 ++++++++++++++++++++++++++++++++++++++++++
target/s390x/internal.h | 2 ++
target/s390x/kvm.c | 69 +++----------------------------------------------
3 files changed, 65 insertions(+), 66 deletions(-)
diff --git a/target/s390x/helper.c b/target/s390x/helper.c
index baa18777f1..4c11822074 100644
--- a/target/s390x/helper.c
+++ b/target/s390x/helper.c
@@ -245,6 +245,66 @@ void s390_cpu_recompute_watchpoints(CPUState *cs)
}
}
+struct sigp_save_area {
+ uint64_t fprs[16]; /* 0x0000 */
+ uint64_t grs[16]; /* 0x0080 */
+ PSW psw; /* 0x0100 */
+ uint8_t pad_0x0110[0x0118 - 0x0110]; /* 0x0110 */
+ uint32_t prefix; /* 0x0118 */
+ uint32_t fpc; /* 0x011c */
+ uint8_t pad_0x0120[0x0124 - 0x0120]; /* 0x0120 */
+ uint32_t todpr; /* 0x0124 */
+ uint64_t cputm; /* 0x0128 */
+ uint64_t ckc; /* 0x0130 */
+ uint8_t pad_0x0138[0x0140 - 0x0138]; /* 0x0138 */
+ uint32_t ars[16]; /* 0x0140 */
+ uint64_t crs[16]; /* 0x0384 */
+};
+QEMU_BUILD_BUG_ON(sizeof(struct sigp_save_area) != 512);
+
+int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch)
+{
+ static const uint8_t ar_id = 1;
+ struct sigp_save_area *sa;
+ hwaddr len = sizeof(*sa);
+ int i;
+
+ sa = cpu_physical_memory_map(addr, &len, 1);
+ if (!sa) {
+ return -EFAULT;
+ }
+ if (len != sizeof(*sa)) {
+ cpu_physical_memory_unmap(sa, len, 1, 0);
+ return -EFAULT;
+ }
+
+ if (store_arch) {
+ cpu_physical_memory_write(offsetof(LowCore, ar_access_id), &ar_id, 1);
+ }
+ for (i = 0; i < 16; ++i) {
+ sa->fprs[i] = cpu_to_be64(get_freg(&cpu->env, i)->ll);
+ }
+ for (i = 0; i < 16; ++i) {
+ sa->grs[i] = cpu_to_be64(cpu->env.regs[i]);
+ }
+ sa->psw.addr = cpu_to_be64(cpu->env.psw.addr);
+ sa->psw.mask = cpu_to_be64(get_psw_mask(&cpu->env));
+ sa->prefix = cpu_to_be32(cpu->env.psa);
+ sa->fpc = cpu_to_be32(cpu->env.fpc);
+ sa->todpr = cpu_to_be32(cpu->env.todpr);
+ sa->cputm = cpu_to_be64(cpu->env.cputm);
+ sa->ckc = cpu_to_be64(cpu->env.ckc >> 8);
+ for (i = 0; i < 16; ++i) {
+ sa->ars[i] = cpu_to_be32(cpu->env.aregs[i]);
+ }
+ for (i = 0; i < 16; ++i) {
+ sa->ars[i] = cpu_to_be64(cpu->env.cregs[i]);
+ }
+
+ cpu_physical_memory_unmap(sa, len, 1, len);
+
+ return 0;
+}
#endif /* CONFIG_USER_ONLY */
void s390_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
diff --git a/target/s390x/internal.h b/target/s390x/internal.h
index 0ac026d30f..a301237c17 100644
--- a/target/s390x/internal.h
+++ b/target/s390x/internal.h
@@ -353,6 +353,8 @@ void s390x_tod_timer(void *opaque);
void s390x_cpu_timer(void *opaque);
void do_restart_interrupt(CPUS390XState *env);
void s390_handle_wait(S390CPU *cpu);
+#define S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_area)
+int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch);
#ifndef CONFIG_USER_ONLY
LowCore *cpu_map_lowcore(CPUS390XState *env);
void cpu_unmap_lowcore(LowCore *lowcore);
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
index 7f2623f679..c7d0145fa9 100644
--- a/target/s390x/kvm.c
+++ b/target/s390x/kvm.c
@@ -1547,68 +1547,6 @@ static int do_store_adtl_status(S390CPU *cpu, hwaddr
addr, hwaddr len)
return 0;
}
-struct sigp_save_area {
- uint64_t fprs[16]; /* 0x0000 */
- uint64_t grs[16]; /* 0x0080 */
- PSW psw; /* 0x0100 */
- uint8_t pad_0x0110[0x0118 - 0x0110]; /* 0x0110 */
- uint32_t prefix; /* 0x0118 */
- uint32_t fpc; /* 0x011c */
- uint8_t pad_0x0120[0x0124 - 0x0120]; /* 0x0120 */
- uint32_t todpr; /* 0x0124 */
- uint64_t cputm; /* 0x0128 */
- uint64_t ckc; /* 0x0130 */
- uint8_t pad_0x0138[0x0140 - 0x0138]; /* 0x0138 */
- uint32_t ars[16]; /* 0x0140 */
- uint64_t crs[16]; /* 0x0384 */
-};
-QEMU_BUILD_BUG_ON(sizeof(struct sigp_save_area) != 512);
-
-#define KVM_S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_area)
-static int kvm_s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch)
-{
- static const uint8_t ar_id = 1;
- struct sigp_save_area *sa;
- hwaddr len = sizeof(*sa);
- int i;
-
- sa = cpu_physical_memory_map(addr, &len, 1);
- if (!sa) {
- return -EFAULT;
- }
- if (len != sizeof(*sa)) {
- cpu_physical_memory_unmap(sa, len, 1, 0);
- return -EFAULT;
- }
-
- if (store_arch) {
- cpu_physical_memory_write(offsetof(LowCore, ar_access_id), &ar_id, 1);
- }
- for (i = 0; i < 16; ++i) {
- sa->fprs[i] = cpu_to_be64(get_freg(&cpu->env, i)->ll);
- }
- for (i = 0; i < 16; ++i) {
- sa->grs[i] = cpu_to_be64(cpu->env.regs[i]);
- }
- sa->psw.addr = cpu_to_be64(cpu->env.psw.addr);
- sa->psw.mask = cpu_to_be64(get_psw_mask(&cpu->env));
- sa->prefix = cpu_to_be32(cpu->env.psa);
- sa->fpc = cpu_to_be32(cpu->env.fpc);
- sa->todpr = cpu_to_be32(cpu->env.todpr);
- sa->cputm = cpu_to_be64(cpu->env.cputm);
- sa->ckc = cpu_to_be64(cpu->env.ckc >> 8);
- for (i = 0; i < 16; ++i) {
- sa->ars[i] = cpu_to_be32(cpu->env.aregs[i]);
- }
- for (i = 0; i < 16; ++i) {
- sa->ars[i] = cpu_to_be64(cpu->env.cregs[i]);
- }
-
- cpu_physical_memory_unmap(sa, len, 1, len);
-
- return 0;
-}
-
static void sigp_stop_and_store_status(CPUState *cs, run_on_cpu_data arg)
{
S390CPU *cpu = S390_CPU(cs);
@@ -1628,7 +1566,7 @@ static void sigp_stop_and_store_status(CPUState *cs,
run_on_cpu_data arg)
case CPU_STATE_STOPPED:
/* already stopped, just store the status */
cpu_synchronize_state(cs);
- kvm_s390_store_status(cpu, KVM_S390_STORE_STATUS_DEF_ADDR, true);
+ s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true);
break;
}
si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
@@ -1648,7 +1586,7 @@ static void sigp_store_status_at_address(CPUState *cs,
run_on_cpu_data arg)
cpu_synchronize_state(cs);
- if (kvm_s390_store_status(cpu, address, false)) {
+ if (s390_store_status(cpu, address, false)) {
set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER);
return;
}
@@ -2030,8 +1968,7 @@ static int handle_intercept(S390CPU *cpu)
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
}
if (cpu->env.sigp_order == SIGP_STOP_STORE_STATUS) {
- kvm_s390_store_status(cpu, KVM_S390_STORE_STATUS_DEF_ADDR,
- true);
+ s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true);
}
cpu->env.sigp_order = 0;
r = EXCP_HALTED;
--
2.13.5
- [Qemu-devel] [PATCH v2 03/30] s390x/tcg: injection of emergency signals and external calls, (continued)
- [Qemu-devel] [PATCH v2 03/30] s390x/tcg: injection of emergency signals and external calls, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 04/30] s390x/tcg: rework checking for deliverable interrupts, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 05/30] s390x/tcg: take care of external interrupt subclasses, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 06/30] s390x/tcg: STOPPED cpus can never wake up, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 07/30] s390x/tcg: a CPU cannot switch state due to an interrupt, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 08/30] target/s390x: factor out handling of WAIT PSW into s390_handle_wait(), David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 09/30] s390x/tcg: handle WAIT PSWs during interrupt injection, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 10/30] target/s390x: interpret PSW_MASK_WAIT only for TCG, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 11/30] s390x/kvm: pass ipb directly into handle_sigp(), David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 12/30] s390x/kvm: generalize SIGP stop and restart interrupt injection, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 13/30] s390x/kvm: factor out storing of CPU status,
David Hildenbrand <=
- [Qemu-devel] [PATCH v2 14/30] s390x/kvm: factor out storing of adtl CPU status, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 15/30] s390x/kvm: drop two debug prints, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 16/30] s390x/kvm: factor out SIGP code into sigp.c, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 17/30] MAINTAINERS: use s390 KVM maintainers for target/s390x/sigp.c, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 18/30] s390x/kvm: factor out actual handling of STOP interrupts, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 20/30] s390x/tcg: implement SIGP SENSE, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 19/30] s390x/tcg: implement SIGP SENSE RUNNING STATUS, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 21/30] s390x/tcg: implement SIGP EXTERNAL CALL, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 22/30] s390x/tcg: implement SIGP EMERGENCY SIGNAL, David Hildenbrand, 2017/09/28
- [Qemu-devel] [PATCH v2 23/30] s390x/tcg: implement SIGP CONDITIONAL EMERGENCY SIGNAL, David Hildenbrand, 2017/09/28