Skip to content

Commit e04c16c

Browse files
authored
Fixes for PPC64 CPU emulation (#2308)
* Fix setting PPC64 CPU model manually The default POWER10 1.0 was pointing to the correct place in the array, but for manually set indices we still need to append the same offset in order to set the correct CPU. * Actually set MSR.HV correctly on reset Without this, PPC64 models with the HV bit do not work. hreg_store_msr cannot set MSR.HV to 1 even if alter_hv = 1, it just takes the value from the environment unless alter_hv = 1 *AND* MSR.HV was already set. if (!alter_hv || !(env->msr & MSR_HVB)) { value &= ~MSR_HVB; value |= env->msr & MSR_HVB; }
1 parent 5133d0d commit e04c16c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

qemu/target/ppc/translate_init.inc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10123,6 +10123,7 @@ static void ppc_cpu_reset(CPUState *dev)
1012310123
}
1012410124
#endif
1012510125

10126+
env->msr |= MSR_HVB; // alter_hv only does anything if MSR_HVB is already set
1012610127
hreg_store_msr(env, msr, 1);
1012710128

1012810129
env->nip = env->hreset_vector | env->excp_prefix;
@@ -11011,11 +11012,12 @@ PowerPCCPU *cpu_ppc_init(struct uc_struct *uc)
1101111012
memset(cpu, 0, sizeof(*cpu));
1101211013
#ifdef TARGET_PPC64
1101311014
if (uc->cpu_model == INT_MAX) {
11014-
uc->cpu_model = UC_CPU_PPC64_POWER10_V1_0 + UC_CPU_PPC32_7457A_V1_2 + 1; // power10_v1.0
11015+
uc->cpu_model = UC_CPU_PPC64_POWER10_V1_0; // power10_v1.0
1101511016
} else if (uc->cpu_model + UC_CPU_PPC32_7457A_V1_2 + 1 >= ARRAY_SIZE(ppc_cpus)) {
1101611017
free(cpu);
1101711018
return NULL;
1101811019
}
11020+
uc->cpu_model += UC_CPU_PPC32_7457A_V1_2 + 1; // PPC64 models come after PPC32
1101911021
#else
1102011022
if (uc->cpu_model == INT_MAX) {
1102111023
uc->cpu_model = UC_CPU_PPC32_7457A_V1_2; // 7457a_v1.2

0 commit comments

Comments
 (0)