Make s390x skey work
This commit is contained in:
@ -137,6 +137,8 @@ static void s390_cpu_initfn(struct uc_struct *uc, CPUState *obj)
|
||||
// cpu->env.cpu_timer =
|
||||
// timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_cpu_timer, cpu);
|
||||
s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu);
|
||||
|
||||
cpu->env.uc = uc;
|
||||
}
|
||||
|
||||
static unsigned s390_count_running_cpus(void)
|
||||
@ -255,6 +257,13 @@ S390CPU *cpu_s390_init(struct uc_struct *uc, const char *cpu_model)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (uc->cpu_model == INT_MAX) {
|
||||
uc->cpu_model = 36; // qemu-s390x-cpu
|
||||
} else if (uc->cpu_model >= 38) {
|
||||
free(cpu);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cs = (CPUState *)cpu;
|
||||
cc = (CPUClass *)&cpu->cc;
|
||||
cs->cc = cc;
|
||||
@ -267,29 +276,18 @@ S390CPU *cpu_s390_init(struct uc_struct *uc, const char *cpu_model)
|
||||
/* init CPUClass */
|
||||
s390_cpu_class_init(uc, cc);
|
||||
|
||||
// init skeys
|
||||
s390_skeys_init(uc);
|
||||
|
||||
// init s390 models
|
||||
s390_init_cpu_model(uc, uc->cpu_model);
|
||||
|
||||
/* init CPUState */
|
||||
cpu_common_initfn(uc, cs);
|
||||
|
||||
/* init CPU */
|
||||
s390_cpu_initfn(uc, cs);
|
||||
|
||||
/* init specific CPU model */
|
||||
/*
|
||||
for (i = 0; i < ARRAY_SIZE(cpu_models); i++) {
|
||||
if (strcmp(cpu_model, cpu_models[i].name) == 0) {
|
||||
cpu_models[i].initfn(cs);
|
||||
|
||||
if (arm_cpus[i].class_init) {
|
||||
arm_cpus[i].class_init(uc, cc, uc);
|
||||
}
|
||||
if (arm_cpus[i].initfn) {
|
||||
arm_cpus[i].initfn(uc, cs);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/* realize CPU */
|
||||
s390_cpu_realizefn(uc, cs);
|
||||
|
||||
|
@ -166,6 +166,7 @@ struct S390CPU {
|
||||
// unicorn
|
||||
struct S390CPUClass cc;
|
||||
struct S390SKeysClass skey;
|
||||
struct QEMUS390SKeysState ss;
|
||||
};
|
||||
|
||||
|
||||
|
@ -409,7 +409,7 @@ static void s390_max_cpu_model_initfn(CPUState *obj)
|
||||
memcpy(cpu->model, max_model, sizeof(*cpu->model));
|
||||
}
|
||||
|
||||
static void s390_cpu_model_finalize(CPUState *obj)
|
||||
void s390_cpu_model_finalize(CPUState *obj)
|
||||
{
|
||||
S390CPU *cpu = S390_CPU(obj);
|
||||
|
||||
@ -424,7 +424,7 @@ static void s390_base_cpu_model_class_init(struct uc_struct *uc, CPUClass *oc, v
|
||||
/* all base models are migration safe */
|
||||
xcc->cpu_def = (const S390CPUDef *) data;
|
||||
xcc->is_static = true;
|
||||
//xcc->desc = xcc->cpu_def->desc;
|
||||
// xcc->desc = xcc->cpu_def->desc;
|
||||
}
|
||||
|
||||
static void s390_cpu_model_class_init(struct uc_struct *uc, CPUClass *oc, void *data)
|
||||
@ -433,7 +433,8 @@ static void s390_cpu_model_class_init(struct uc_struct *uc, CPUClass *oc, void *
|
||||
|
||||
/* model that can change between QEMU versions */
|
||||
xcc->cpu_def = (const S390CPUDef *) data;
|
||||
//xcc->desc = xcc->cpu_def->desc;
|
||||
// xcc->is_migration_safe = true;
|
||||
// xcc->desc = xcc->cpu_def->desc;
|
||||
}
|
||||
|
||||
static void s390_qemu_cpu_model_class_init(struct uc_struct *uc, CPUClass *oc, void *data)
|
||||
@ -524,9 +525,8 @@ static void init_ignored_base_feat(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void register_types(void)
|
||||
void s390_init_cpu_model(uc_engine *uc, uc_cpu_s390x cpu_model)
|
||||
{
|
||||
#if 0
|
||||
static const S390FeatInit qemu_latest_init = { S390_FEAT_LIST_QEMU_LATEST };
|
||||
int i;
|
||||
|
||||
@ -547,33 +547,16 @@ static void register_types(void)
|
||||
s390_set_qemu_cpu_model(QEMU_MAX_CPU_TYPE, QEMU_MAX_CPU_GEN,
|
||||
QEMU_MAX_CPU_EC_GA, qemu_latest_init);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(s390_cpu_defs); i++) {
|
||||
char *base_name = s390_base_cpu_type_name(s390_cpu_defs[i].name);
|
||||
TypeInfo ti_base = {
|
||||
.name = base_name,
|
||||
.parent = TYPE_S390_CPU,
|
||||
.instance_init = s390_cpu_model_initfn,
|
||||
.instance_finalize = s390_cpu_model_finalize,
|
||||
.class_init = s390_base_cpu_model_class_init,
|
||||
.class_data = (void *) &s390_cpu_defs[i],
|
||||
};
|
||||
char *name = s390_cpu_type_name(s390_cpu_defs[i].name);
|
||||
TypeInfo ti = {
|
||||
.name = name,
|
||||
.parent = TYPE_S390_CPU,
|
||||
.instance_init = s390_cpu_model_initfn,
|
||||
.instance_finalize = s390_cpu_model_finalize,
|
||||
.class_init = s390_cpu_model_class_init,
|
||||
.class_data = (void *) &s390_cpu_defs[i],
|
||||
};
|
||||
|
||||
type_register_static(&ti_base);
|
||||
type_register_static(&ti);
|
||||
g_free(base_name);
|
||||
g_free(name);
|
||||
if (cpu_model < ARRAY_SIZE(s390_cpu_defs)) {
|
||||
s390_base_cpu_model_class_init(uc, uc->cpu->cc, (void *) &s390_cpu_defs[cpu_model]);
|
||||
s390_cpu_model_class_init(uc, uc->cpu->cc, (void *) &s390_cpu_defs[cpu_model]);
|
||||
s390_cpu_model_initfn(uc->cpu);
|
||||
} else if (cpu_model == UC_CPU_S390X_MAX) {
|
||||
s390_max_cpu_model_class_init(uc, uc->cpu->cc, NULL);
|
||||
s390_max_cpu_model_initfn(uc->cpu);
|
||||
} else if (cpu_model == UC_CPU_S390X_QEMU) {
|
||||
s390_qemu_cpu_model_class_init(uc, uc->cpu->cc, NULL);
|
||||
s390_qemu_cpu_model_initfn(uc->cpu);
|
||||
}
|
||||
|
||||
type_register_static(&qemu_s390_cpu_type_info);
|
||||
type_register_static(&max_s390_cpu_type_info);
|
||||
#endif
|
||||
}
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include "cpu_features.h"
|
||||
#include "gen-features.h"
|
||||
#include "hw/core/cpu.h"
|
||||
#include "unicorn/s390x.h"
|
||||
#include "uc_priv.h"
|
||||
|
||||
/* static CPU definition */
|
||||
struct S390CPUDef {
|
||||
@ -106,4 +108,8 @@ static inline uint64_t s390_cpuid_from_cpu_model(const S390CPUModel *model)
|
||||
S390CPUDef const *s390_find_cpu_def(uint16_t type, uint8_t gen, uint8_t ec_ga,
|
||||
S390FeatBitmap features);
|
||||
|
||||
void s390_init_cpu_model(uc_engine *uc, uc_cpu_s390x cpu_model);
|
||||
|
||||
void s390_cpu_model_finalize(CPUState *obj);
|
||||
|
||||
#endif /* TARGET_S390X_CPU_MODELS_H */
|
||||
|
@ -282,7 +282,7 @@ static int mmu_translate_asce(CPUS390XState *env, target_ulong vaddr,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mmu_handle_skey(target_ulong addr, int rw, int *flags)
|
||||
static void mmu_handle_skey(uc_engine *uc, target_ulong addr, int rw, int *flags)
|
||||
{
|
||||
static S390SKeysClass *skeyclass;
|
||||
static S390SKeysState *ss;
|
||||
@ -296,8 +296,8 @@ static void mmu_handle_skey(target_ulong addr, int rw, int *flags)
|
||||
#endif
|
||||
|
||||
if (unlikely(!ss)) {
|
||||
// ss = s390_get_skeys_device();
|
||||
// skeyclass = S390_SKEYS_GET_CLASS(ss);
|
||||
ss = s390_get_skeys_device(uc);
|
||||
skeyclass = S390_SKEYS_GET_CLASS(ss);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -437,7 +437,7 @@ nodat:
|
||||
/* Convert real address -> absolute address */
|
||||
*raddr = mmu_real2abs(env, *raddr);
|
||||
|
||||
mmu_handle_skey(*raddr, rw, flags);
|
||||
mmu_handle_skey(env->uc, *raddr, rw, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -549,6 +549,6 @@ int mmu_translate_real(CPUS390XState *env, target_ulong raddr, int rw,
|
||||
|
||||
*addr = mmu_real2abs(env, raddr & TARGET_PAGE_MASK);
|
||||
|
||||
mmu_handle_skey(*addr, rw, flags);
|
||||
mmu_handle_skey(env->uc, *addr, rw, flags);
|
||||
return 0;
|
||||
}
|
||||
|
@ -33,6 +33,13 @@ static void s390_release(void *ctx)
|
||||
g_free(fast->table);
|
||||
}
|
||||
#endif
|
||||
TCGContext *tcg_ctx = (TCGContext *)ctx;
|
||||
S390CPU *cpu = (S390CPU *)tcg_ctx->uc->cpu;
|
||||
|
||||
release_common(ctx);
|
||||
|
||||
s390_cpu_model_finalize(cpu);
|
||||
// TODO: Anymore to free?
|
||||
}
|
||||
|
||||
void s390_reg_reset(struct uc_struct *uc)
|
||||
|
Reference in New Issue
Block a user