target-ppc: Implement "compat" CPU option
This adds basic support for the "compat" CPU option. By specifying the compat property, the user can manually switch guest CPU mode from "raw" to "architected". This defines feature disable bits which are not used yet as, for example, PowerISA 2.07 says if 2.06 mode is selected, the TM bit does not matter - transactional memory (TM) will be disabled because 2.06 does not define it at all. The same is true for VSX and 2.05 mode. So just setting a mode must be ok. This does not change the existing behavior as the actual compatibility mode support is coming in next patches. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> [agraf: fix compilation on 32bit hosts] Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
parent
833d46685d
commit
6d9412ea81
|
@ -210,6 +210,14 @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu,
|
||||||
uint32_t gservers_prop[smt_threads * 2];
|
uint32_t gservers_prop[smt_threads * 2];
|
||||||
int index = ppc_get_vcpu_dt_id(cpu);
|
int index = ppc_get_vcpu_dt_id(cpu);
|
||||||
|
|
||||||
|
if (cpu->cpu_version) {
|
||||||
|
ret = fdt_setprop(fdt, offset, "cpu-version",
|
||||||
|
&cpu->cpu_version, sizeof(cpu->cpu_version));
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Build interrupt servers and gservers properties */
|
/* Build interrupt servers and gservers properties */
|
||||||
for (i = 0; i < smt_threads; i++) {
|
for (i = 0; i < smt_threads; i++) {
|
||||||
servers_prop[i] = cpu_to_be32(index + i);
|
servers_prop[i] = cpu_to_be32(index + i);
|
||||||
|
@ -1275,6 +1283,12 @@ static void ppc_spapr_init(MachineState *machine)
|
||||||
kvmppc_set_papr(cpu);
|
kvmppc_set_papr(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cpu->max_compat) {
|
||||||
|
if (ppc_set_compat(cpu, cpu->max_compat) < 0) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
xics_cpu_setup(spapr->icp, cpu);
|
xics_cpu_setup(spapr->icp, cpu);
|
||||||
|
|
||||||
qemu_register_reset(spapr_cpu_reset, cpu);
|
qemu_register_reset(spapr_cpu_reset, cpu);
|
||||||
|
|
|
@ -84,6 +84,7 @@ typedef struct PowerPCCPUClass {
|
||||||
* @env: #CPUPPCState
|
* @env: #CPUPPCState
|
||||||
* @cpu_dt_id: CPU index used in the device tree. KVM uses this index too
|
* @cpu_dt_id: CPU index used in the device tree. KVM uses this index too
|
||||||
* @max_compat: Maximal supported logical PVR from the command line
|
* @max_compat: Maximal supported logical PVR from the command line
|
||||||
|
* @cpu_version: Current logical PVR, zero if in "raw" mode
|
||||||
*
|
*
|
||||||
* A PowerPC CPU.
|
* A PowerPC CPU.
|
||||||
*/
|
*/
|
||||||
|
@ -95,6 +96,7 @@ struct PowerPCCPU {
|
||||||
CPUPPCState env;
|
CPUPPCState env;
|
||||||
int cpu_dt_id;
|
int cpu_dt_id;
|
||||||
uint32_t max_compat;
|
uint32_t max_compat;
|
||||||
|
uint32_t cpu_version;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline PowerPCCPU *ppc_env_get_cpu(CPUPPCState *env)
|
static inline PowerPCCPU *ppc_env_get_cpu(CPUPPCState *env)
|
||||||
|
|
|
@ -1122,6 +1122,7 @@ void ppc_store_sdr1 (CPUPPCState *env, target_ulong value);
|
||||||
void ppc_store_msr (CPUPPCState *env, target_ulong value);
|
void ppc_store_msr (CPUPPCState *env, target_ulong value);
|
||||||
|
|
||||||
void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf);
|
void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf);
|
||||||
|
int ppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version);
|
||||||
|
|
||||||
/* Time-base and decrementer management */
|
/* Time-base and decrementer management */
|
||||||
#ifndef NO_CPU_IO_DEFS
|
#ifndef NO_CPU_IO_DEFS
|
||||||
|
@ -1338,6 +1339,7 @@ static inline int cpu_mmu_index (CPUPPCState *env)
|
||||||
#define SPR_LPCR (0x13E)
|
#define SPR_LPCR (0x13E)
|
||||||
#define SPR_BOOKE_DVC2 (0x13F)
|
#define SPR_BOOKE_DVC2 (0x13F)
|
||||||
#define SPR_BOOKE_TSR (0x150)
|
#define SPR_BOOKE_TSR (0x150)
|
||||||
|
#define SPR_PCR (0x152)
|
||||||
#define SPR_BOOKE_TCR (0x154)
|
#define SPR_BOOKE_TCR (0x154)
|
||||||
#define SPR_BOOKE_TLB0PS (0x158)
|
#define SPR_BOOKE_TLB0PS (0x158)
|
||||||
#define SPR_BOOKE_TLB1PS (0x159)
|
#define SPR_BOOKE_TLB1PS (0x159)
|
||||||
|
@ -2061,6 +2063,15 @@ enum {
|
||||||
PPC_INTERRUPT_PERFM, /* Performance monitor interrupt */
|
PPC_INTERRUPT_PERFM, /* Performance monitor interrupt */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Processor Compatibility mask (PCR) */
|
||||||
|
enum {
|
||||||
|
PCR_COMPAT_2_05 = 1ull << (63-62),
|
||||||
|
PCR_COMPAT_2_06 = 1ull << (63-61),
|
||||||
|
PCR_VEC_DIS = 1ull << (63-0), /* Vec. disable (bit NA since POWER8) */
|
||||||
|
PCR_VSX_DIS = 1ull << (63-1), /* VSX disable (bit NA since POWER8) */
|
||||||
|
PCR_TM_DIS = 1ull << (63-2), /* Trans. memory disable (POWER8) */
|
||||||
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static inline target_ulong cpu_read_xer(CPUPPCState *env)
|
static inline target_ulong cpu_read_xer(CPUPPCState *env)
|
||||||
|
|
|
@ -7829,6 +7829,15 @@ static void init_proc_POWER7 (CPUPPCState *env)
|
||||||
/* Can't find information on what this should be on reset. This
|
/* Can't find information on what this should be on reset. This
|
||||||
* value is the one used by 74xx processors. */
|
* value is the one used by 74xx processors. */
|
||||||
vscr_init(env, 0x00010000);
|
vscr_init(env, 0x00010000);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Register PCR to report POWERPC_EXCP_PRIV_REG instead of
|
||||||
|
* POWERPC_EXCP_INVAL_SPR.
|
||||||
|
*/
|
||||||
|
spr_register(env, SPR_PCR, "PCR",
|
||||||
|
SPR_NOACCESS, SPR_NOACCESS,
|
||||||
|
SPR_NOACCESS, SPR_NOACCESS,
|
||||||
|
0x00000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)
|
POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)
|
||||||
|
@ -8909,6 +8918,31 @@ static void ppc_cpu_unrealizefn(DeviceState *dev, Error **errp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
CPUPPCState *env = &cpu->env;
|
||||||
|
|
||||||
|
cpu->cpu_version = cpu_version;
|
||||||
|
|
||||||
|
switch (cpu_version) {
|
||||||
|
case CPU_POWERPC_LOGICAL_2_05:
|
||||||
|
env->spr[SPR_PCR] = PCR_COMPAT_2_05;
|
||||||
|
break;
|
||||||
|
case CPU_POWERPC_LOGICAL_2_06:
|
||||||
|
env->spr[SPR_PCR] = PCR_COMPAT_2_06;
|
||||||
|
break;
|
||||||
|
case CPU_POWERPC_LOGICAL_2_06_PLUS:
|
||||||
|
env->spr[SPR_PCR] = PCR_COMPAT_2_06;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
env->spr[SPR_PCR] = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static gint ppc_cpu_compare_class_pvr(gconstpointer a, gconstpointer b)
|
static gint ppc_cpu_compare_class_pvr(gconstpointer a, gconstpointer b)
|
||||||
{
|
{
|
||||||
ObjectClass *oc = (ObjectClass *)a;
|
ObjectClass *oc = (ObjectClass *)a;
|
||||||
|
|
Loading…
Reference in a new issue