/* Default case, create a single watchpoint. */ cpu_watchpoint_insert(cs, env->cregs[10], env->cregs[11] - env->cregs[10] + 1, wp_flags, NULL); } } 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->crs[i] = cpu_to_be64(cpu->env.cregs[i]); } cpu_physical_memory_unmap(sa, len, 1, len); return 0; } #define ADTL_GS_OFFSET 1024 /* offset of GS data in adtl save area */ #define ADTL_GS_MIN_SIZE 2048 /* minimal size of adtl save area for GS */ int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len) { hwaddr save = len; void *mem; mem = cpu_physical_memory_map(addr, &save, 1); if (!mem) { return -EFAULT; } if (save != len) { cpu_physical_memory_unmap(mem, len, 1, 0); return -EFAULT; } /* FIXME: as soon as TCG supports these features, convert cpu->be */ if (s390_has_feat(S390_FEAT_VECTOR)) { memcpy(mem, &cpu->env.vregs, 512); } if (s390_has_feat(S390_FEAT_GUARDED_STORAGE) && len >= ADTL_GS_MIN_SIZE) { memcpy(mem + ADTL_GS_OFFSET, &cpu->env.gscb, 32); } cpu_physical_memory_unmap(mem, len, 1, len); return 0; }
/* Default case, create a single watchpoint. */ cpu_watchpoint_insert(cs, env->cregs[10], env->cregs[11] - env->cregs[10] + 1, wp_flags, NULL); } } typedef struct SigpSaveArea { 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 */ } SigpSaveArea; QEMU_BUILD_BUG_ON(sizeof(SigpSaveArea) != 512); int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch) { static const uint8_t ar_id = 1; SigpSaveArea *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->crs[i] = cpu_to_be64(cpu->env.cregs[i]); } cpu_physical_memory_unmap(sa, len, 1, len); return 0; } typedef struct SigpAdtlSaveArea { uint64_t vregs[32][2]; /* 0x0000 */ uint8_t pad_0x0200[0x0400 - 0x0200]; /* 0x0200 */ uint64_t gscb[4]; /* 0x0400 */ uint8_t pad_0x0420[0x1000 - 0x0420]; /* 0x0420 */ } SigpAdtlSaveArea; QEMU_BUILD_BUG_ON(sizeof(SigpAdtlSaveArea) != 4096); #define ADTL_GS_MIN_SIZE 2048 /* minimal size of adtl save area for GS */ int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len) { SigpAdtlSaveArea *sa; hwaddr save = len; int i; sa = cpu_physical_memory_map(addr, &save, 1); if (!sa) { return -EFAULT; } if (save != len) { cpu_physical_memory_unmap(sa, len, 1, 0); return -EFAULT; } if (s390_has_feat(S390_FEAT_VECTOR)) { for (i = 0; i < 32; i++) { sa->vregs[i][0] = cpu_to_be64(cpu->env.vregs[i][0].ll); sa->vregs[i][1] = cpu_to_be64(cpu->env.vregs[i][1].ll); } } if (s390_has_feat(S390_FEAT_GUARDED_STORAGE) && len >= ADTL_GS_MIN_SIZE) { for (i = 0; i < 4; i++) { sa->gscb[i] = cpu_to_be64(cpu->env.gscb[i]); } } cpu_physical_memory_unmap(sa, len, 1, len); return 0; }
void s390_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, int flags) { S390CPU *cpu = S390_CPU(cs); CPUS390XState *env = &cpu->env; int i; if (env->cc_op > 3) { cpu_fprintf(f, "PSW=mask %016" PRIx64 " addr %016" PRIx64 " cc %15s\n", env->psw.mask, env->psw.addr, cc_name(env->cc_op)); } else { cpu_fprintf(f, "PSW=mask %016" PRIx64 " addr %016" PRIx64 " cc %02x\n", env->psw.mask, env->psw.addr, env->cc_op); } for (i = 0; i < 16; i++) { cpu_fprintf(f, "R%02d=%016" PRIx64, i, env->regs[i]); if ((i % 4) == 3) { cpu_fprintf(f, "\n"); } else { cpu_fprintf(f, " "); } } if (flags & CPU_DUMP_FPU) { if (s390_has_feat(S390_FEAT_VECTOR)) { for (i = 0; i < 32; i++) { cpu_fprintf(f, "V%02d=%016" PRIx64 "%016" PRIx64 "%c", i, env->vregs[i][0].ll, env->vregs[i][1].ll, i % 2 ? '\n' : ' '); } } else { for (i = 0; i < 16; i++) { cpu_fprintf(f, "F%02d=%016" PRIx64 "%c", i, get_freg(env, i)->ll, (i % 4) == 3 ? '\n' : ' '); } } } #ifndef CONFIG_USER_ONLY for (i = 0; i < 16; i++) { cpu_fprintf(f, "C%02d=%016" PRIx64, i, env->cregs[i]); if ((i % 4) == 3) { cpu_fprintf(f, "\n"); } else { cpu_fprintf(f, " "); } } #endif #ifdef DEBUG_INLINE_BRANCHES for (i = 0; i < CC_OP_MAX; i++) { cpu_fprintf(f, " %15s = %10ld\t%10ld\n", cc_name(i), inline_branch_miss[i], inline_branch_hit[i]); } #endif cpu_fprintf(f, "\n"); }
static bool vregs_needed(void *opaque) { return s390_has_feat(S390_FEAT_VECTOR); }
static bool gscb_needed(void *opaque) { return s390_has_feat(S390_FEAT_GUARDED_STORAGE); }
static bool riccb_needed(void *opaque) { return s390_has_feat(S390_FEAT_RUNTIME_INSTRUMENTATION); }
static bool bpbc_needed(void *opaque) { return s390_has_feat(S390_FEAT_BPB); }