The opcode decode tables aren't really part of the CPUPPCState but an
internal implementation detail for the translator. This can cause
problems with memcpy in cpu_copy as any table created during
ppc_cpu_realize get written over causing a memory leak. To avoid this
move the tables into PowerPCCPU which is better suited to hold
internal implementation details.
- /* Those resources are used only during code translation */
- /* opcode handlers */
- opc_handler_t *opcodes[PPC_CPU_OPCODES_LEN];
-
/* Those resources are used only in QEMU core */
target_ulong hflags; /* hflags is a MSR & HFLAGS_MASK */
target_ulong hflags_nmsr; /* specific hflags, not coming from MSR */
@@ -1191,6 +1187,10 @@ struct PowerPCCPU {
int32_t node_id; /* NUMA node this CPU belongs to */
PPCHash64Options *hash64_opts;
+ /* Those resources are used only during code translation */
+ /* opcode handlers */
+ opc_handler_t *opcodes[PPC_CPU_OPCODES_LEN];
+
/* Fields related to migration compatibility hacks */
bool pre_2_8_migration;
target_ulong mig_msr_mask;
diff --git a/target/ppc/translate.c b/target/ppc/translate.c
index 4a5de280365..c0faab8a824 100644
--- a/target/ppc/translate.c
+++ b/target/ppc/translate.c
@@ -7857,6 +7857,7 @@ static bool ppc_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cs,
static void ppc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
{
DisasContext *ctx = container_of(dcbase, DisasContext, base);
+ PowerPCCPU *cpu = POWERPC_CPU(cs);
CPUPPCState *env = cs->env_ptr;
opc_handler_t **table, *handler;
The opcode decode tables aren't really part of the CPUPPCState but an
internal implementation detail for the translator. This can cause
problems with memcpy in cpu_copy as any table created during
ppc_cpu_realize get written over causing a memory leak. To avoid this
move the tables into PowerPCCPU which is better suited to hold
internal implementation details.
Attempts to fix: https:/ /bugs.launchpad .net/qemu/ +bug/1836558 ppc/translate. c | 3 ++- ppc/translate_ init.inc. c | 16 +++++++---------
Cc: <email address hidden>
Signed-off-by: Alex Bennée <email address hidden>
---
target/ppc/cpu.h | 8 ++++----
target/
target/
3 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h .10e34b69b75 100644
index c9beba2a5c0.
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -1104,10 +1104,6 @@ struct CPUPPCState {
bool resume_as_sreset;
#endif
- /* Those resources are used only during code translation */ PPC_CPU_ OPCODES_ LEN]; ptions *hash64_opts;
- /* opcode handlers */
- opc_handler_t *opcodes[
-
/* Those resources are used only in QEMU core */
target_ulong hflags; /* hflags is a MSR & HFLAGS_MASK */
target_ulong hflags_nmsr; /* specific hflags, not coming from MSR */
@@ -1191,6 +1187,10 @@ struct PowerPCCPU {
int32_t node_id; /* NUMA node this CPU belongs to */
PPCHash64O
+ /* Those resources are used only during code translation */ PPC_CPU_ OPCODES_ LEN]; ppc/translate. c b/target/ ppc/translate. c .c0faab8a824 100644 ppc/translate. c ppc/translate. c breakpoint_ check(DisasCont extBase *dcbase, CPUState *cs, translate_ insn(DisasConte xtBase *dcbase, CPUState *cs) of(dcbase, DisasContext, base);
+ /* opcode handlers */
+ opc_handler_t *opcodes[
+
/* Fields related to migration compatibility hacks */
bool pre_2_8_migration;
target_ulong mig_msr_mask;
diff --git a/target/
index 4a5de280365.
--- a/target/
+++ b/target/
@@ -7857,6 +7857,7 @@ static bool ppc_tr_
static void ppc_tr_
{
DisasContext *ctx = container_
+ PowerPCCPU *cpu = POWERPC_CPU(cs);
CPUPPCState *env = cs->env_ptr;
opc_handler_t **table, *handler;
@@ -7874,7 +7875,7 @@ static void ppc_tr_ translate_ insn(DisasConte xtBase *dcbase, CPUState *cs)
opc3(ctx- >opcode) , opc4(ctx->opcode),
ctx->le_ mode ? "little" : "big"); >base.pc_ next += 4; ctx->opcode) ]; opcode( handler) ) { ppc/translate_ init.inc. c b/target/ ppc/translate_ init.inc. c .9cd2033bb92 100644 ppc/translate_ init.inc. c ppc/translate_ init.inc. c tables( opc_handler_ t **ppc_opcodes) ppc_opcodes( PowerPCCPU *cpu, Error **errp) Class *pcc = POWERPC_ CPU_GET_ CLASS(cpu) ;
ctx-
- table = env->opcodes;
+ table = cpu->opcodes;
handler = table[opc1(
if (is_indirect_
table = ind_table(handler);
diff --git a/target/
index 86fc8f2e316.
--- a/target/
+++ b/target/
@@ -9440,14 +9440,13 @@ static void fix_opcode_
static void create_
{
PowerPCCPU
- CPUPPCState *env = &cpu->env;
opcode_t *opc;
- fill_new_ table(env- >opcodes, PPC_CPU_ OPCODES_ LEN); table(cpu- >opcodes, PPC_CPU_ OPCODES_ LEN); ARRAY_SIZE( opcodes) ]; opc++) { >handler. type & pcc->insns_flags) != 0) ||
( (opc->handler. type2 & pcc->insns_flags2) != 0)) { insn(env- >opcodes, opc) < 0) { insn(cpu- >opcodes, opc) < 0) {
error_ setg(errp, "ERROR initializing PowerPC instruction "
"0x%02x 0x%02x 0x%02x", opc->opc1, opc->opc2,
opc->opc3) ; ppc_opcodes( PowerPCCPU *cpu, Error **errp) tables( env->opcodes) ; tables( cpu->opcodes) ; stdout) ; stderr) ; unrealize( DeviceState *dev, Error **errp) Class *pcc = POWERPC_ CPU_GET_ CLASS(cpu) ; unrealize( DeviceState *dev, Error **errp)
+ fill_new_
for (opc = opcodes; opc < &opcodes[
if (((opc-
- if (register_
+ if (register_
@@ -9455,7 +9454,7 @@ static void create_
}
}
}
- fix_opcode_
+ fix_opcode_
fflush(
fflush(
}
@@ -10023,7 +10022,6 @@ static void ppc_cpu_
{
PowerPCCPU *cpu = POWERPC_CPU(dev);
PowerPCCPU
- CPUPPCState *env = &cpu->env;
Error *local_err = NULL;
opc_handler_t **table, **table_2;
int i, j, k;
@@ -10035,11 +10033,11 @@ static void ppc_cpu_
}
for (i = 0; i < PPC_CPU_ OPCODES_ LEN; i++) {
continue; opcode( env->opcodes[ i])) { env->opcodes[ i]); opcode( cpu->opcodes[ i])) { cpu->opcodes[ i]); INDIRECT_ OPCODES_ LEN; j++) {
continue; unrealize( DeviceState *dev, Error **errp)
~PPC_ INDIRECT) ); (opc_handler_ t *)((uintptr_ t)env-> opcodes[ i] & (opc_handler_ t *)((uintptr_ t)cpu-> opcodes[ i] &
~PPC_ INDIRECT) );
- if (env->opcodes[i] == &invalid_handler) {
+ if (cpu->opcodes[i] == &invalid_handler) {
}
- if (is_indirect_
- table = ind_table(
+ if (is_indirect_
+ table = ind_table(
for (j = 0; j < PPC_CPU_
if (table[j] == &invalid_handler) {
@@ -10057,7 +10055,7 @@ static void ppc_cpu_
}
}
- g_free(
+ g_free(
}
}
--
2.20.1