This is the same as the v3 posted except a re-base and a few extra signoffs

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQEcBAABAgAGBQJYeOOmAAoJEPvQ2wlanipE3ZUH/Rsfpl23kXCMmqoXEIhWXy+h
 yf8ARWCmpU6UKfwb+sH4vLegBfU56f62vVkGQ6oaaAbuyQ4SxCUlZGMO/rqY8/TE
 m57aM+VfEE+bIdinAtLjFM24EVp/exMfkeutK7ItzLv7GwlrBos0J5veyCuyJ15q
 pccV24jrpbJGilEeJ2GblKp3r2I3dInQGauOQhtoP3MNjHmYNSQD7noSbdN/JiTR
 9H2eV700pg3ZPaSfO+CTVQN+cHjK1FC6qLi6916YZY9llnSOnDAegBYgbwE1RIBw
 AULpWrezYveKy71eFhHVtGxnPeCJ8J4GVECMK0P0cdxzprIXFh1kZezyM4bxAGk=
 =sboI
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/stsquad/tags/pull-tcg-common-tlb-reset-20170113-r1' into staging

This is the same as the v3 posted except a re-base and a few extra signoffs

# gpg: Signature made Fri 13 Jan 2017 14:26:46 GMT
# gpg:                using RSA key 0xFBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>"
# Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* remotes/stsquad/tags/pull-tcg-common-tlb-reset-20170113-r1:
  cputlb: drop flush_global flag from tlb_flush
  cpu_common_reset: wrap TCG specific code in tcg_enabled()
  qom/cpu: move tlb_flush to cpu_common_reset

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2017-01-16 18:23:02 +00:00
commit a8c611e113
57 changed files with 151 additions and 148 deletions

View File

@ -60,24 +60,15 @@
/* statistics */ /* statistics */
int tlb_flush_count; int tlb_flush_count;
/* NOTE: /* This is OK because CPU architectures generally permit an
* If flush_global is true (the usual case), flush all tlb entries. * implementation to drop entries from the TLB at any time, so
* If flush_global is false, flush (at least) all tlb entries not * flushing more entries than required is only an efficiency issue,
* marked global. * not a correctness issue.
*
* Since QEMU doesn't currently implement a global/not-global flag
* for tlb entries, at the moment tlb_flush() will also flush all
* tlb entries in the flush_global == false case. This is OK because
* CPU architectures generally permit an implementation to drop
* entries from the TLB at any time, so flushing more entries than
* required is only an efficiency issue, not a correctness issue.
*/ */
void tlb_flush(CPUState *cpu, int flush_global) void tlb_flush(CPUState *cpu)
{ {
CPUArchState *env = cpu->env_ptr; CPUArchState *env = cpu->env_ptr;
tlb_debug("(%d)\n", flush_global);
memset(env->tlb_table, -1, sizeof(env->tlb_table)); memset(env->tlb_table, -1, sizeof(env->tlb_table));
memset(env->tlb_v_table, -1, sizeof(env->tlb_v_table)); memset(env->tlb_v_table, -1, sizeof(env->tlb_v_table));
memset(cpu->tb_jmp_cache, 0, sizeof(cpu->tb_jmp_cache)); memset(cpu->tb_jmp_cache, 0, sizeof(cpu->tb_jmp_cache));
@ -144,7 +135,7 @@ void tlb_flush_page(CPUState *cpu, target_ulong addr)
TARGET_FMT_lx "/" TARGET_FMT_lx ")\n", TARGET_FMT_lx "/" TARGET_FMT_lx ")\n",
env->tlb_flush_addr, env->tlb_flush_mask); env->tlb_flush_addr, env->tlb_flush_mask);
tlb_flush(cpu, 1); tlb_flush(cpu);
return; return;
} }

4
exec.c
View File

@ -544,7 +544,7 @@ static int cpu_common_post_load(void *opaque, int version_id)
/* 0x01 was CPU_INTERRUPT_EXIT. This line can be removed when the /* 0x01 was CPU_INTERRUPT_EXIT. This line can be removed when the
version_id is increased. */ version_id is increased. */
cpu->interrupt_request &= ~0x01; cpu->interrupt_request &= ~0x01;
tlb_flush(cpu, 1); tlb_flush(cpu);
return 0; return 0;
} }
@ -2426,7 +2426,7 @@ static void tcg_commit(MemoryListener *listener)
*/ */
d = atomic_rcu_read(&cpuas->as->dispatch); d = atomic_rcu_read(&cpuas->as->dispatch);
atomic_rcu_set(&cpuas->memory_dispatch, d); atomic_rcu_set(&cpuas->memory_dispatch, d);
tlb_flush(cpuas->cpu, 1); tlb_flush(cpuas->cpu);
} }
void address_space_init_dispatch(AddressSpace *as) void address_space_init_dispatch(AddressSpace *as)

View File

@ -417,7 +417,7 @@ static void sh7750_mem_writel(void *opaque, hwaddr addr,
case SH7750_PTEH_A7: case SH7750_PTEH_A7:
/* If asid changes, clear all registered tlb entries. */ /* If asid changes, clear all registered tlb entries. */
if ((s->cpu->env.pteh & 0xff) != (mem_value & 0xff)) { if ((s->cpu->env.pteh & 0xff) != (mem_value & 0xff)) {
tlb_flush(CPU(s->cpu), 1); tlb_flush(CPU(s->cpu));
} }
s->cpu->env.pteh = mem_value; s->cpu->env.pteh = mem_value;
return; return;

View File

@ -95,15 +95,13 @@ void tlb_flush_page(CPUState *cpu, target_ulong addr);
/** /**
* tlb_flush: * tlb_flush:
* @cpu: CPU whose TLB should be flushed * @cpu: CPU whose TLB should be flushed
* @flush_global: ignored
* *
* Flush the entire TLB for the specified CPU. * Flush the entire TLB for the specified CPU. Most CPU architectures
* The flush_global flag is in theory an indicator of whether the whole * allow the implementation to drop entries from the TLB at any time
* TLB should be flushed, or only those entries not marked global. * so this is generally safe. If more selective flushing is required
* In practice QEMU does not implement any global/not global flag for * use one of the other functions for efficiency.
* TLB entries, and the argument is ignored.
*/ */
void tlb_flush(CPUState *cpu, int flush_global); void tlb_flush(CPUState *cpu);
/** /**
* tlb_flush_page_by_mmuidx: * tlb_flush_page_by_mmuidx:
* @cpu: CPU whose TLB should be flushed * @cpu: CPU whose TLB should be flushed
@ -165,7 +163,7 @@ static inline void tlb_flush_page(CPUState *cpu, target_ulong addr)
{ {
} }
static inline void tlb_flush(CPUState *cpu, int flush_global) static inline void tlb_flush(CPUState *cpu)
{ {
} }

View File

@ -270,8 +270,14 @@ static void cpu_common_reset(CPUState *cpu)
cpu->exception_index = -1; cpu->exception_index = -1;
cpu->crash_occurred = false; cpu->crash_occurred = false;
for (i = 0; i < TB_JMP_CACHE_SIZE; ++i) { if (tcg_enabled()) {
atomic_set(&cpu->tb_jmp_cache[i], NULL); for (i = 0; i < TB_JMP_CACHE_SIZE; ++i) {
atomic_set(&cpu->tb_jmp_cache[i], NULL);
}
#ifdef CONFIG_SOFTMMU
tlb_flush(cpu, 0);
#endif
} }
} }

View File

@ -273,7 +273,7 @@ static void alpha_cpu_initfn(Object *obj)
CPUAlphaState *env = &cpu->env; CPUAlphaState *env = &cpu->env;
cs->env_ptr = env; cs->env_ptr = env;
tlb_flush(cs, 1); tlb_flush(cs);
alpha_translate_init(); alpha_translate_init();

View File

@ -44,7 +44,7 @@ uint64_t helper_load_pcc(CPUAlphaState *env)
#ifndef CONFIG_USER_ONLY #ifndef CONFIG_USER_ONLY
void helper_tbia(CPUAlphaState *env) void helper_tbia(CPUAlphaState *env)
{ {
tlb_flush(CPU(alpha_env_get_cpu(env)), 1); tlb_flush(CPU(alpha_env_get_cpu(env)));
} }
void helper_tbis(CPUAlphaState *env, uint64_t p) void helper_tbis(CPUAlphaState *env, uint64_t p)

View File

@ -122,7 +122,8 @@ static void arm_cpu_reset(CPUState *s)
acc->parent_reset(s); acc->parent_reset(s);
memset(env, 0, offsetof(CPUARMState, features)); memset(env, 0, offsetof(CPUARMState, end_reset_fields));
g_hash_table_foreach(cpu->cp_regs, cp_reg_reset, cpu); g_hash_table_foreach(cpu->cp_regs, cp_reg_reset, cpu);
g_hash_table_foreach(cpu->cp_regs, cp_reg_check_reset, cpu); g_hash_table_foreach(cpu->cp_regs, cp_reg_check_reset, cpu);
@ -226,8 +227,6 @@ static void arm_cpu_reset(CPUState *s)
&env->vfp.fp_status); &env->vfp.fp_status);
set_float_detect_tininess(float_tininess_before_rounding, set_float_detect_tininess(float_tininess_before_rounding,
&env->vfp.standard_fp_status); &env->vfp.standard_fp_status);
tlb_flush(s, 1);
#ifndef CONFIG_USER_ONLY #ifndef CONFIG_USER_ONLY
if (kvm_enabled()) { if (kvm_enabled()) {
kvm_arm_reset_vcpu(cpu); kvm_arm_reset_vcpu(cpu);

View File

@ -491,9 +491,12 @@ typedef struct CPUARMState {
struct CPUBreakpoint *cpu_breakpoint[16]; struct CPUBreakpoint *cpu_breakpoint[16];
struct CPUWatchpoint *cpu_watchpoint[16]; struct CPUWatchpoint *cpu_watchpoint[16];
/* Fields up to this point are cleared by a CPU reset */
struct {} end_reset_fields;
CPU_COMMON CPU_COMMON
/* These fields after the common ones so they are preserved on reset. */ /* Fields after CPU_COMMON are preserved across CPU reset. */
/* Internal CPU feature flags. */ /* Internal CPU feature flags. */
uint64_t features; uint64_t features;

View File

@ -464,7 +464,7 @@ static void dacr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
ARMCPU *cpu = arm_env_get_cpu(env); ARMCPU *cpu = arm_env_get_cpu(env);
raw_write(env, ri, value); raw_write(env, ri, value);
tlb_flush(CPU(cpu), 1); /* Flush TLB as domain not tracked in TLB */ tlb_flush(CPU(cpu)); /* Flush TLB as domain not tracked in TLB */
} }
static void fcse_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) static void fcse_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
@ -475,7 +475,7 @@ static void fcse_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
/* Unlike real hardware the qemu TLB uses virtual addresses, /* Unlike real hardware the qemu TLB uses virtual addresses,
* not modified virtual addresses, so this causes a TLB flush. * not modified virtual addresses, so this causes a TLB flush.
*/ */
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
raw_write(env, ri, value); raw_write(env, ri, value);
} }
} }
@ -491,7 +491,7 @@ static void contextidr_write(CPUARMState *env, const ARMCPRegInfo *ri,
* format) this register includes the ASID, so do a TLB flush. * format) this register includes the ASID, so do a TLB flush.
* For PMSA it is purely a process ID and no action is needed. * For PMSA it is purely a process ID and no action is needed.
*/ */
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
raw_write(env, ri, value); raw_write(env, ri, value);
} }
@ -502,7 +502,7 @@ static void tlbiall_write(CPUARMState *env, const ARMCPRegInfo *ri,
/* Invalidate all (TLBIALL) */ /* Invalidate all (TLBIALL) */
ARMCPU *cpu = arm_env_get_cpu(env); ARMCPU *cpu = arm_env_get_cpu(env);
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
static void tlbimva_write(CPUARMState *env, const ARMCPRegInfo *ri, static void tlbimva_write(CPUARMState *env, const ARMCPRegInfo *ri,
@ -520,7 +520,7 @@ static void tlbiasid_write(CPUARMState *env, const ARMCPRegInfo *ri,
/* Invalidate by ASID (TLBIASID) */ /* Invalidate by ASID (TLBIASID) */
ARMCPU *cpu = arm_env_get_cpu(env); ARMCPU *cpu = arm_env_get_cpu(env);
tlb_flush(CPU(cpu), value == 0); tlb_flush(CPU(cpu));
} }
static void tlbimvaa_write(CPUARMState *env, const ARMCPRegInfo *ri, static void tlbimvaa_write(CPUARMState *env, const ARMCPRegInfo *ri,
@ -539,7 +539,7 @@ static void tlbiall_is_write(CPUARMState *env, const ARMCPRegInfo *ri,
CPUState *other_cs; CPUState *other_cs;
CPU_FOREACH(other_cs) { CPU_FOREACH(other_cs) {
tlb_flush(other_cs, 1); tlb_flush(other_cs);
} }
} }
@ -549,7 +549,7 @@ static void tlbiasid_is_write(CPUARMState *env, const ARMCPRegInfo *ri,
CPUState *other_cs; CPUState *other_cs;
CPU_FOREACH(other_cs) { CPU_FOREACH(other_cs) {
tlb_flush(other_cs, value == 0); tlb_flush(other_cs);
} }
} }
@ -2304,7 +2304,7 @@ static void pmsav7_write(CPUARMState *env, const ARMCPRegInfo *ri,
} }
u32p += env->cp15.c6_rgnr; u32p += env->cp15.c6_rgnr;
tlb_flush(CPU(cpu), 1); /* Mappings may have changed - purge! */ tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */
*u32p = value; *u32p = value;
} }
@ -2449,7 +2449,7 @@ static void vmsa_ttbcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
/* With LPAE the TTBCR could result in a change of ASID /* With LPAE the TTBCR could result in a change of ASID
* via the TTBCR.A1 bit, so do a TLB flush. * via the TTBCR.A1 bit, so do a TLB flush.
*/ */
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
vmsa_ttbcr_raw_write(env, ri, value); vmsa_ttbcr_raw_write(env, ri, value);
} }
@ -2473,7 +2473,7 @@ static void vmsa_tcr_el1_write(CPUARMState *env, const ARMCPRegInfo *ri,
TCR *tcr = raw_ptr(env, ri); TCR *tcr = raw_ptr(env, ri);
/* For AArch64 the A1 bit could result in a change of ASID, so TLB flush. */ /* For AArch64 the A1 bit could result in a change of ASID, so TLB flush. */
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
tcr->raw_tcr = value; tcr->raw_tcr = value;
} }
@ -2486,7 +2486,7 @@ static void vmsa_ttbr_write(CPUARMState *env, const ARMCPRegInfo *ri,
if (cpreg_field_is_64bit(ri)) { if (cpreg_field_is_64bit(ri)) {
ARMCPU *cpu = arm_env_get_cpu(env); ARMCPU *cpu = arm_env_get_cpu(env);
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
raw_write(env, ri, value); raw_write(env, ri, value);
} }
@ -3154,7 +3154,7 @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri,
raw_write(env, ri, value); raw_write(env, ri, value);
/* ??? Lots of these bits are not implemented. */ /* ??? Lots of these bits are not implemented. */
/* This may enable/disable the MMU, so do a TLB flush. */ /* This may enable/disable the MMU, so do a TLB flush. */
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
static CPAccessResult fpexc32_access(CPUARMState *env, const ARMCPRegInfo *ri, static CPAccessResult fpexc32_access(CPUARMState *env, const ARMCPRegInfo *ri,
@ -3622,7 +3622,7 @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
* HCR_DC Disables stage1 and enables stage2 translation * HCR_DC Disables stage1 and enables stage2 translation
*/ */
if ((raw_read(env, ri) ^ value) & (HCR_VM | HCR_PTW | HCR_DC)) { if ((raw_read(env, ri) ^ value) & (HCR_VM | HCR_PTW | HCR_DC)) {
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
raw_write(env, ri, value); raw_write(env, ri, value);
} }

View File

@ -52,9 +52,8 @@ static void cris_cpu_reset(CPUState *s)
ccc->parent_reset(s); ccc->parent_reset(s);
vr = env->pregs[PR_VR]; vr = env->pregs[PR_VR];
memset(env, 0, offsetof(CPUCRISState, load_info)); memset(env, 0, offsetof(CPUCRISState, end_reset_fields));
env->pregs[PR_VR] = vr; env->pregs[PR_VR] = vr;
tlb_flush(s, 1);
#if defined(CONFIG_USER_ONLY) #if defined(CONFIG_USER_ONLY)
/* start in user mode with interrupts enabled. */ /* start in user mode with interrupts enabled. */

View File

@ -167,10 +167,13 @@ typedef struct CPUCRISState {
*/ */
TLBSet tlbsets[2][4][16]; TLBSet tlbsets[2][4][16];
CPU_COMMON /* Fields up to this point are cleared by a CPU reset */
struct {} end_reset_fields;
/* Members from load_info on are preserved across resets. */ CPU_COMMON
void *load_info;
/* Members from load_info on are preserved across resets. */
void *load_info;
} CPUCRISState; } CPUCRISState;
/** /**

View File

@ -2820,8 +2820,6 @@ static void x86_cpu_reset(CPUState *s)
memset(env, 0, offsetof(CPUX86State, end_reset_fields)); memset(env, 0, offsetof(CPUX86State, end_reset_fields));
tlb_flush(s, 1);
env->old_exception = -1; env->old_exception = -1;
/* init to reset state */ /* init to reset state */

View File

@ -1123,10 +1123,12 @@ typedef struct CPUX86State {
uint8_t nmi_injected; uint8_t nmi_injected;
uint8_t nmi_pending; uint8_t nmi_pending;
/* Fields up to this point are cleared by a CPU reset */
struct {} end_reset_fields;
CPU_COMMON CPU_COMMON
/* Fields from here on are preserved across CPU reset. */ /* Fields after CPU_COMMON are preserved across CPU reset. */
struct {} end_reset_fields;
/* processor features (e.g. for CPUID insn) */ /* processor features (e.g. for CPUID insn) */
/* Minimum level/xlevel/xlevel2, based on CPU model + features */ /* Minimum level/xlevel/xlevel2, based on CPU model + features */

View File

@ -1465,7 +1465,7 @@ void helper_xrstor(CPUX86State *env, target_ulong ptr, uint64_t rfbm)
} }
if (env->pkru != old_pkru) { if (env->pkru != old_pkru) {
CPUState *cs = CPU(x86_env_get_cpu(env)); CPUState *cs = CPU(x86_env_get_cpu(env));
tlb_flush(cs, 1); tlb_flush(cs);
} }
} }
} }

View File

@ -586,7 +586,7 @@ void x86_cpu_set_a20(X86CPU *cpu, int a20_state)
/* when a20 is changed, all the MMU mappings are invalid, so /* when a20 is changed, all the MMU mappings are invalid, so
we must flush everything */ we must flush everything */
tlb_flush(cs, 1); tlb_flush(cs);
env->a20_mask = ~(1 << 20) | (a20_state << 20); env->a20_mask = ~(1 << 20) | (a20_state << 20);
} }
} }
@ -599,7 +599,7 @@ void cpu_x86_update_cr0(CPUX86State *env, uint32_t new_cr0)
qemu_log_mask(CPU_LOG_MMU, "CR0 update: CR0=0x%08x\n", new_cr0); qemu_log_mask(CPU_LOG_MMU, "CR0 update: CR0=0x%08x\n", new_cr0);
if ((new_cr0 & (CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK)) != if ((new_cr0 & (CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK)) !=
(env->cr[0] & (CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK))) { (env->cr[0] & (CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK))) {
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
#ifdef TARGET_X86_64 #ifdef TARGET_X86_64
@ -641,7 +641,7 @@ void cpu_x86_update_cr3(CPUX86State *env, target_ulong new_cr3)
if (env->cr[0] & CR0_PG_MASK) { if (env->cr[0] & CR0_PG_MASK) {
qemu_log_mask(CPU_LOG_MMU, qemu_log_mask(CPU_LOG_MMU,
"CR3 update: CR3=" TARGET_FMT_lx "\n", new_cr3); "CR3 update: CR3=" TARGET_FMT_lx "\n", new_cr3);
tlb_flush(CPU(cpu), 0); tlb_flush(CPU(cpu));
} }
} }
@ -656,7 +656,7 @@ void cpu_x86_update_cr4(CPUX86State *env, uint32_t new_cr4)
if ((new_cr4 ^ env->cr[4]) & if ((new_cr4 ^ env->cr[4]) &
(CR4_PGE_MASK | CR4_PAE_MASK | CR4_PSE_MASK | (CR4_PGE_MASK | CR4_PAE_MASK | CR4_PSE_MASK |
CR4_SMEP_MASK | CR4_SMAP_MASK | CR4_LA57_MASK)) { CR4_SMEP_MASK | CR4_SMAP_MASK | CR4_LA57_MASK)) {
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
/* Clear bits we're going to recompute. */ /* Clear bits we're going to recompute. */

View File

@ -387,7 +387,7 @@ static int cpu_post_load(void *opaque, int version_id)
env->dr[7] = dr7 & ~(DR7_GLOBAL_BP_MASK | DR7_LOCAL_BP_MASK); env->dr[7] = dr7 & ~(DR7_GLOBAL_BP_MASK | DR7_LOCAL_BP_MASK);
cpu_x86_update_dr7(env, dr7); cpu_x86_update_dr7(env, dr7);
} }
tlb_flush(cs, 1); tlb_flush(cs);
if (tcg_enabled()) { if (tcg_enabled()) {
cpu_smm_update(cpu); cpu_smm_update(cpu);

View File

@ -635,5 +635,5 @@ void helper_wrpkru(CPUX86State *env, uint32_t ecx, uint64_t val)
} }
env->pkru = val; env->pkru = val;
tlb_flush(cs, 1); tlb_flush(cs);
} }

View File

@ -289,7 +289,7 @@ void helper_vmrun(CPUX86State *env, int aflag, int next_eip_addend)
break; break;
case TLB_CONTROL_FLUSH_ALL_ASID: case TLB_CONTROL_FLUSH_ALL_ASID:
/* FIXME: this is not 100% correct but should work for now */ /* FIXME: this is not 100% correct but should work for now */
tlb_flush(cs, 1); tlb_flush(cs);
break; break;
} }

View File

@ -128,10 +128,9 @@ static void lm32_cpu_reset(CPUState *s)
lcc->parent_reset(s); lcc->parent_reset(s);
/* reset cpu state */ /* reset cpu state */
memset(env, 0, offsetof(CPULM32State, eba)); memset(env, 0, offsetof(CPULM32State, end_reset_fields));
lm32_cpu_init_cfg_reg(cpu); lm32_cpu_init_cfg_reg(cpu);
tlb_flush(s, 1);
} }
static void lm32_cpu_disas_set_info(CPUState *cpu, disassemble_info *info) static void lm32_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)

View File

@ -165,6 +165,9 @@ struct CPULM32State {
struct CPUBreakpoint *cpu_breakpoint[4]; struct CPUBreakpoint *cpu_breakpoint[4];
struct CPUWatchpoint *cpu_watchpoint[4]; struct CPUWatchpoint *cpu_watchpoint[4];
/* Fields up to this point are cleared by a CPU reset */
struct {} end_reset_fields;
CPU_COMMON CPU_COMMON
/* Fields from here on are preserved across CPU reset. */ /* Fields from here on are preserved across CPU reset. */

View File

@ -52,7 +52,7 @@ static void m68k_cpu_reset(CPUState *s)
mcc->parent_reset(s); mcc->parent_reset(s);
memset(env, 0, offsetof(CPUM68KState, features)); memset(env, 0, offsetof(CPUM68KState, end_reset_fields));
#if !defined(CONFIG_USER_ONLY) #if !defined(CONFIG_USER_ONLY)
env->sr = 0x2700; env->sr = 0x2700;
#endif #endif
@ -61,7 +61,6 @@ static void m68k_cpu_reset(CPUState *s)
cpu_m68k_set_ccr(env, 0); cpu_m68k_set_ccr(env, 0);
/* TODO: We should set PC from the interrupt vector. */ /* TODO: We should set PC from the interrupt vector. */
env->pc = 0; env->pc = 0;
tlb_flush(s, 1);
} }
static void m68k_cpu_disas_set_info(CPUState *s, disassemble_info *info) static void m68k_cpu_disas_set_info(CPUState *s, disassemble_info *info)

View File

@ -112,6 +112,9 @@ typedef struct CPUM68KState {
uint32_t qregs[MAX_QREGS]; uint32_t qregs[MAX_QREGS];
/* Fields up to this point are cleared by a CPU reset */
struct {} end_reset_fields;
CPU_COMMON CPU_COMMON
/* Fields from here on are preserved across CPU reset. */ /* Fields from here on are preserved across CPU reset. */

View File

@ -103,9 +103,8 @@ static void mb_cpu_reset(CPUState *s)
mcc->parent_reset(s); mcc->parent_reset(s);
memset(env, 0, offsetof(CPUMBState, pvr)); memset(env, 0, offsetof(CPUMBState, end_reset_fields));
env->res_addr = RES_ADDR_NONE; env->res_addr = RES_ADDR_NONE;
tlb_flush(s, 1);
/* Disable stack protector. */ /* Disable stack protector. */
env->shr = ~0; env->shr = ~0;

View File

@ -267,6 +267,9 @@ struct CPUMBState {
struct microblaze_mmu mmu; struct microblaze_mmu mmu;
#endif #endif
/* Fields up to this point are cleared by a CPU reset */
struct {} end_reset_fields;
CPU_COMMON CPU_COMMON
/* These fields are preserved on reset. */ /* These fields are preserved on reset. */

View File

@ -255,7 +255,7 @@ void mmu_write(CPUMBState *env, uint32_t rn, uint32_t v)
/* Changes to the zone protection reg flush the QEMU TLB. /* Changes to the zone protection reg flush the QEMU TLB.
Fortunately, these are very uncommon. */ Fortunately, these are very uncommon. */
if (v != env->mmu.regs[rn]) { if (v != env->mmu.regs[rn]) {
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
env->mmu.regs[rn] = v; env->mmu.regs[rn] = v;
break; break;

View File

@ -100,8 +100,7 @@ static void mips_cpu_reset(CPUState *s)
mcc->parent_reset(s); mcc->parent_reset(s);
memset(env, 0, offsetof(CPUMIPSState, mvp)); memset(env, 0, offsetof(CPUMIPSState, end_reset_fields));
tlb_flush(s, 1);
cpu_state_reset(env); cpu_state_reset(env);

View File

@ -607,6 +607,9 @@ struct CPUMIPSState {
uint32_t CP0_TCStatus_rw_bitmask; /* Read/write bits in CP0_TCStatus */ uint32_t CP0_TCStatus_rw_bitmask; /* Read/write bits in CP0_TCStatus */
int insn_flags; /* Supported instruction set */ int insn_flags; /* Supported instruction set */
/* Fields up to this point are cleared by a CPU reset */
struct {} end_reset_fields;
CPU_COMMON CPU_COMMON
/* Fields from here on are preserved across CPU reset. */ /* Fields from here on are preserved across CPU reset. */
@ -1051,7 +1054,7 @@ static inline void compute_hflags(CPUMIPSState *env)
} }
} }
void cpu_mips_tlb_flush(CPUMIPSState *env, int flush_global); void cpu_mips_tlb_flush(CPUMIPSState *env);
void sync_c0_status(CPUMIPSState *env, CPUMIPSState *cpu, int tc); void sync_c0_status(CPUMIPSState *env, CPUMIPSState *cpu, int tc);
void cpu_mips_store_status(CPUMIPSState *env, target_ulong val); void cpu_mips_store_status(CPUMIPSState *env, target_ulong val);
void cpu_mips_store_cause(CPUMIPSState *env, target_ulong val); void cpu_mips_store_cause(CPUMIPSState *env, target_ulong val);

View File

@ -223,12 +223,12 @@ static int get_physical_address (CPUMIPSState *env, hwaddr *physical,
return ret; return ret;
} }
void cpu_mips_tlb_flush(CPUMIPSState *env, int flush_global) void cpu_mips_tlb_flush(CPUMIPSState *env)
{ {
MIPSCPU *cpu = mips_env_get_cpu(env); MIPSCPU *cpu = mips_env_get_cpu(env);
/* Flush qemu's TLB and discard all shadowed entries. */ /* Flush qemu's TLB and discard all shadowed entries. */
tlb_flush(CPU(cpu), flush_global); tlb_flush(CPU(cpu));
env->tlb->tlb_in_use = env->tlb->nb_tlb; env->tlb->tlb_in_use = env->tlb->nb_tlb;
} }
@ -290,7 +290,7 @@ void cpu_mips_store_status(CPUMIPSState *env, target_ulong val)
#if defined(TARGET_MIPS64) #if defined(TARGET_MIPS64)
if ((env->CP0_Status ^ old) & (old & (7 << CP0St_UX))) { if ((env->CP0_Status ^ old) & (old & (7 << CP0St_UX))) {
/* Access to at least one of the 64-bit segments has been disabled */ /* Access to at least one of the 64-bit segments has been disabled */
cpu_mips_tlb_flush(env, 1); cpu_mips_tlb_flush(env);
} }
#endif #endif
if (env->CP0_Config3 & (1 << CP0C3_MT)) { if (env->CP0_Config3 & (1 << CP0C3_MT)) {

View File

@ -1409,7 +1409,7 @@ void helper_mtc0_entryhi(CPUMIPSState *env, target_ulong arg1)
/* If the ASID changes, flush qemu's TLB. */ /* If the ASID changes, flush qemu's TLB. */
if ((old & env->CP0_EntryHi_ASID_mask) != if ((old & env->CP0_EntryHi_ASID_mask) !=
(val & env->CP0_EntryHi_ASID_mask)) { (val & env->CP0_EntryHi_ASID_mask)) {
cpu_mips_tlb_flush(env, 1); cpu_mips_tlb_flush(env);
} }
} }
@ -1999,7 +1999,7 @@ void r4k_helper_tlbinv(CPUMIPSState *env)
tlb->EHINV = 1; tlb->EHINV = 1;
} }
} }
cpu_mips_tlb_flush(env, 1); cpu_mips_tlb_flush(env);
} }
void r4k_helper_tlbinvf(CPUMIPSState *env) void r4k_helper_tlbinvf(CPUMIPSState *env)
@ -2009,7 +2009,7 @@ void r4k_helper_tlbinvf(CPUMIPSState *env)
for (idx = 0; idx < env->tlb->nb_tlb; idx++) { for (idx = 0; idx < env->tlb->nb_tlb; idx++) {
env->tlb->mmu.r4k.tlb[idx].EHINV = 1; env->tlb->mmu.r4k.tlb[idx].EHINV = 1;
} }
cpu_mips_tlb_flush(env, 1); cpu_mips_tlb_flush(env);
} }
void r4k_helper_tlbwi(CPUMIPSState *env) void r4k_helper_tlbwi(CPUMIPSState *env)
@ -2123,7 +2123,7 @@ void r4k_helper_tlbr(CPUMIPSState *env)
/* If this will change the current ASID, flush qemu's TLB. */ /* If this will change the current ASID, flush qemu's TLB. */
if (ASID != tlb->ASID) if (ASID != tlb->ASID)
cpu_mips_tlb_flush (env, 1); cpu_mips_tlb_flush(env);
r4k_mips_tlb_flush_extra(env, env->tlb->nb_tlb); r4k_mips_tlb_flush_extra(env, env->tlb->nb_tlb);

View File

@ -45,10 +45,8 @@ static void moxie_cpu_reset(CPUState *s)
mcc->parent_reset(s); mcc->parent_reset(s);
memset(env, 0, sizeof(CPUMoxieState)); memset(env, 0, offsetof(CPUMoxieState, end_reset_fields));
env->pc = 0x1000; env->pc = 0x1000;
tlb_flush(s, 1);
} }
static void moxie_cpu_disas_set_info(CPUState *cpu, disassemble_info *info) static void moxie_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)

View File

@ -56,6 +56,9 @@ typedef struct CPUMoxieState {
void *irq[8]; void *irq[8];
/* Fields up to this point are cleared by a CPU reset */
struct {} end_reset_fields;
CPU_COMMON CPU_COMMON
} CPUMoxieState; } CPUMoxieState;

View File

@ -44,14 +44,7 @@ static void openrisc_cpu_reset(CPUState *s)
occ->parent_reset(s); occ->parent_reset(s);
#ifndef CONFIG_USER_ONLY memset(&cpu->env, 0, offsetof(CPUOpenRISCState, end_reset_fields));
memset(&cpu->env, 0, offsetof(CPUOpenRISCState, tlb));
#else
memset(&cpu->env, 0, offsetof(CPUOpenRISCState, irq));
#endif
tlb_flush(s, 1);
/*tb_flush(&cpu->env); FIXME: Do we need it? */
cpu->env.pc = 0x100; cpu->env.pc = 0x100;
cpu->env.sr = SR_FO | SR_SM; cpu->env.sr = SR_FO | SR_SM;

View File

@ -300,6 +300,9 @@ typedef struct CPUOpenRISCState {
in solt so far. */ in solt so far. */
uint32_t btaken; /* the SR_F bit */ uint32_t btaken; /* the SR_F bit */
/* Fields up to this point are cleared by a CPU reset */
struct {} end_reset_fields;
CPU_COMMON CPU_COMMON
/* Fields from here on are preserved across CPU reset. */ /* Fields from here on are preserved across CPU reset. */

View File

@ -45,7 +45,7 @@ void openrisc_cpu_do_interrupt(CPUState *cs)
/* For machine-state changed between user-mode and supervisor mode, /* For machine-state changed between user-mode and supervisor mode,
we need flush TLB when we enter&exit EXCP. */ we need flush TLB when we enter&exit EXCP. */
tlb_flush(cs, 1); tlb_flush(cs);
env->esr = env->sr; env->esr = env->sr;
env->sr &= ~SR_DME; env->sr &= ~SR_DME;

View File

@ -53,7 +53,7 @@ void HELPER(rfe)(CPUOpenRISCState *env)
} }
if (need_flush_tlb) { if (need_flush_tlb) {
tlb_flush(cs, 1); tlb_flush(cs);
} }
#endif #endif
cs->interrupt_request |= CPU_INTERRUPT_EXITTB; cs->interrupt_request |= CPU_INTERRUPT_EXITTB;

View File

@ -47,7 +47,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env,
case TO_SPR(0, 17): /* SR */ case TO_SPR(0, 17): /* SR */
if ((env->sr & (SR_IME | SR_DME | SR_SM)) ^ if ((env->sr & (SR_IME | SR_DME | SR_SM)) ^
(rb & (SR_IME | SR_DME | SR_SM))) { (rb & (SR_IME | SR_DME | SR_SM))) {
tlb_flush(cs, 1); tlb_flush(cs);
} }
env->sr = rb; env->sr = rb;
env->sr |= SR_FO; /* FO is const equal to 1 */ env->sr |= SR_FO; /* FO is const equal to 1 */

View File

@ -161,7 +161,7 @@ static inline void check_tlb_flush(CPUPPCState *env, bool global)
{ {
CPUState *cs = CPU(ppc_env_get_cpu(env)); CPUState *cs = CPU(ppc_env_get_cpu(env));
if (env->tlb_need_flush & TLB_NEED_LOCAL_FLUSH) { if (env->tlb_need_flush & TLB_NEED_LOCAL_FLUSH) {
tlb_flush(cs, 1); tlb_flush(cs);
env->tlb_need_flush &= ~TLB_NEED_LOCAL_FLUSH; env->tlb_need_flush &= ~TLB_NEED_LOCAL_FLUSH;
} }
@ -176,7 +176,7 @@ static inline void check_tlb_flush(CPUPPCState *env, bool global)
CPUPPCState *other_env = &cpu->env; CPUPPCState *other_env = &cpu->env;
other_env->tlb_need_flush &= ~TLB_NEED_LOCAL_FLUSH; other_env->tlb_need_flush &= ~TLB_NEED_LOCAL_FLUSH;
tlb_flush(other_cs, 1); tlb_flush(other_cs);
} }
} }
env->tlb_need_flush &= ~TLB_NEED_GLOBAL_FLUSH; env->tlb_need_flush &= ~TLB_NEED_GLOBAL_FLUSH;

View File

@ -85,7 +85,7 @@ void helper_store_sdr1(CPUPPCState *env, target_ulong val)
if (!env->external_htab) { if (!env->external_htab) {
if (env->spr[SPR_SDR1] != val) { if (env->spr[SPR_SDR1] != val) {
ppc_store_sdr1(env, val); ppc_store_sdr1(env, val);
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
} }
} }
@ -114,7 +114,7 @@ void helper_store_403_pbr(CPUPPCState *env, uint32_t num, target_ulong value)
if (likely(env->pb[num] != value)) { if (likely(env->pb[num] != value)) {
env->pb[num] = value; env->pb[num] = value;
/* Should be optimized */ /* Should be optimized */
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
} }

View File

@ -248,7 +248,7 @@ static inline void ppc6xx_tlb_invalidate_all(CPUPPCState *env)
tlb = &env->tlb.tlb6[nr]; tlb = &env->tlb.tlb6[nr];
pte_invalidate(&tlb->pte0); pte_invalidate(&tlb->pte0);
} }
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
static inline void ppc6xx_tlb_invalidate_virt2(CPUPPCState *env, static inline void ppc6xx_tlb_invalidate_virt2(CPUPPCState *env,
@ -661,7 +661,7 @@ static inline void ppc4xx_tlb_invalidate_all(CPUPPCState *env)
tlb = &env->tlb.tlbe[i]; tlb = &env->tlb.tlbe[i];
tlb->prot &= ~PAGE_VALID; tlb->prot &= ~PAGE_VALID;
} }
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
static int mmu40x_get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx, static int mmu40x_get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx,
@ -863,7 +863,7 @@ static void booke206_flush_tlb(CPUPPCState *env, int flags,
tlb += booke206_tlb_size(env, i); tlb += booke206_tlb_size(env, i);
} }
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
static hwaddr booke206_tlb_to_page_size(CPUPPCState *env, static hwaddr booke206_tlb_to_page_size(CPUPPCState *env,
@ -1769,7 +1769,7 @@ void helper_store_ibatu(CPUPPCState *env, uint32_t nr, target_ulong value)
#if !defined(FLUSH_ALL_TLBS) #if !defined(FLUSH_ALL_TLBS)
do_invalidate_BAT(env, env->IBAT[0][nr], mask); do_invalidate_BAT(env, env->IBAT[0][nr], mask);
#else #else
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
#endif #endif
} }
} }
@ -1804,7 +1804,7 @@ void helper_store_dbatu(CPUPPCState *env, uint32_t nr, target_ulong value)
#if !defined(FLUSH_ALL_TLBS) #if !defined(FLUSH_ALL_TLBS)
do_invalidate_BAT(env, env->DBAT[0][nr], mask); do_invalidate_BAT(env, env->DBAT[0][nr], mask);
#else #else
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
#endif #endif
} }
} }
@ -1852,7 +1852,7 @@ void helper_store_601_batu(CPUPPCState *env, uint32_t nr, target_ulong value)
} }
#if defined(FLUSH_ALL_TLBS) #if defined(FLUSH_ALL_TLBS)
if (do_inval) { if (do_inval) {
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
#endif #endif
} }
@ -1892,7 +1892,7 @@ void helper_store_601_batl(CPUPPCState *env, uint32_t nr, target_ulong value)
env->DBAT[1][nr] = value; env->DBAT[1][nr] = value;
#if defined(FLUSH_ALL_TLBS) #if defined(FLUSH_ALL_TLBS)
if (do_inval) { if (do_inval) {
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
#endif #endif
} }
@ -1921,7 +1921,7 @@ void ppc_tlb_invalidate_all(CPUPPCState *env)
cpu_abort(CPU(cpu), "MPC8xx MMU model is not implemented\n"); cpu_abort(CPU(cpu), "MPC8xx MMU model is not implemented\n");
break; break;
case POWERPC_MMU_BOOKE: case POWERPC_MMU_BOOKE:
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
break; break;
case POWERPC_MMU_BOOKE206: case POWERPC_MMU_BOOKE206:
booke206_flush_tlb(env, -1, 0); booke206_flush_tlb(env, -1, 0);
@ -1937,7 +1937,7 @@ void ppc_tlb_invalidate_all(CPUPPCState *env)
case POWERPC_MMU_2_07a: case POWERPC_MMU_2_07a:
#endif /* defined(TARGET_PPC64) */ #endif /* defined(TARGET_PPC64) */
env->tlb_need_flush = 0; env->tlb_need_flush = 0;
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
break; break;
default: default:
/* XXX: TODO */ /* XXX: TODO */
@ -2433,13 +2433,13 @@ void helper_440_tlbwe(CPUPPCState *env, uint32_t word, target_ulong entry,
} }
tlb->PID = env->spr[SPR_440_MMUCR] & 0x000000FF; tlb->PID = env->spr[SPR_440_MMUCR] & 0x000000FF;
if (do_flush_tlbs) { if (do_flush_tlbs) {
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
break; break;
case 1: case 1:
RPN = value & 0xFFFFFC0F; RPN = value & 0xFFFFFC0F;
if ((tlb->prot & PAGE_VALID) && tlb->RPN != RPN) { if ((tlb->prot & PAGE_VALID) && tlb->RPN != RPN) {
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
tlb->RPN = RPN; tlb->RPN = RPN;
break; break;
@ -2555,7 +2555,7 @@ void helper_booke_setpid(CPUPPCState *env, uint32_t pidn, target_ulong pid)
env->spr[pidn] = pid; env->spr[pidn] = pid;
/* changing PIDs mean we're in a different address space now */ /* changing PIDs mean we're in a different address space now */
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
void helper_booke206_tlbwe(CPUPPCState *env) void helper_booke206_tlbwe(CPUPPCState *env)
@ -2650,7 +2650,7 @@ void helper_booke206_tlbwe(CPUPPCState *env)
if (booke206_tlb_to_page_size(env, tlb) == TARGET_PAGE_SIZE) { if (booke206_tlb_to_page_size(env, tlb) == TARGET_PAGE_SIZE) {
tlb_flush_page(CPU(cpu), tlb->mas2 & MAS2_EPN_MASK); tlb_flush_page(CPU(cpu), tlb->mas2 & MAS2_EPN_MASK);
} else { } else {
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
} }
@ -2775,7 +2775,7 @@ void helper_booke206_tlbivax(CPUPPCState *env, target_ulong address)
/* flush TLB1 entries */ /* flush TLB1 entries */
booke206_invalidate_ea_tlb(env, 1, address); booke206_invalidate_ea_tlb(env, 1, address);
CPU_FOREACH(cs) { CPU_FOREACH(cs) {
tlb_flush(cs, 1); tlb_flush(cs);
} }
} else { } else {
/* flush TLB0 entries */ /* flush TLB0 entries */
@ -2811,7 +2811,7 @@ void helper_booke206_tlbilx1(CPUPPCState *env, target_ulong address)
} }
tlb += booke206_tlb_size(env, i); tlb += booke206_tlb_size(env, i);
} }
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
void helper_booke206_tlbilx3(CPUPPCState *env, target_ulong address) void helper_booke206_tlbilx3(CPUPPCState *env, target_ulong address)
@ -2852,7 +2852,7 @@ void helper_booke206_tlbilx3(CPUPPCState *env, target_ulong address)
tlb->mas1 &= ~MAS1_VALID; tlb->mas1 &= ~MAS1_VALID;
} }
} }
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
void helper_booke206_tlbflush(CPUPPCState *env, target_ulong type) void helper_booke206_tlbflush(CPUPPCState *env, target_ulong type)

View File

@ -10416,9 +10416,6 @@ static void ppc_cpu_reset(CPUState *s)
} }
env->spr[i] = spr->default_value; env->spr[i] = spr->default_value;
} }
/* Flush all TLBs */
tlb_flush(s, 1);
} }
#ifndef CONFIG_USER_ONLY #ifndef CONFIG_USER_ONLY

View File

@ -82,7 +82,6 @@ static void s390_cpu_reset(CPUState *s)
scc->parent_reset(s); scc->parent_reset(s);
cpu->env.sigp_order = 0; cpu->env.sigp_order = 0;
s390_cpu_set_state(CPU_STATE_STOPPED, cpu); s390_cpu_set_state(CPU_STATE_STOPPED, cpu);
tlb_flush(s, 1);
} }
/* S390CPUClass::initial_reset() */ /* S390CPUClass::initial_reset() */
@ -94,7 +93,7 @@ static void s390_cpu_initial_reset(CPUState *s)
s390_cpu_reset(s); s390_cpu_reset(s);
/* initial reset does not touch regs,fregs and aregs */ /* initial reset does not touch regs,fregs and aregs */
memset(&env->fpc, 0, offsetof(CPUS390XState, cpu_num) - memset(&env->fpc, 0, offsetof(CPUS390XState, end_reset_fields) -
offsetof(CPUS390XState, fpc)); offsetof(CPUS390XState, fpc));
/* architectured initial values for CR 0 and 14 */ /* architectured initial values for CR 0 and 14 */
@ -118,7 +117,6 @@ static void s390_cpu_initial_reset(CPUState *s)
if (kvm_enabled()) { if (kvm_enabled()) {
kvm_s390_reset_vcpu(cpu); kvm_s390_reset_vcpu(cpu);
} }
tlb_flush(s, 1);
} }
/* CPUClass:reset() */ /* CPUClass:reset() */
@ -133,7 +131,7 @@ static void s390_cpu_full_reset(CPUState *s)
cpu->env.sigp_order = 0; cpu->env.sigp_order = 0;
s390_cpu_set_state(CPU_STATE_STOPPED, cpu); s390_cpu_set_state(CPU_STATE_STOPPED, cpu);
memset(env, 0, offsetof(CPUS390XState, cpu_num)); memset(env, 0, offsetof(CPUS390XState, end_reset_fields));
/* architectured initial values for CR 0 and 14 */ /* architectured initial values for CR 0 and 14 */
env->cregs[0] = CR0_RESET; env->cregs[0] = CR0_RESET;
@ -156,7 +154,6 @@ static void s390_cpu_full_reset(CPUState *s)
if (kvm_enabled()) { if (kvm_enabled()) {
kvm_s390_reset_vcpu(cpu); kvm_s390_reset_vcpu(cpu);
} }
tlb_flush(s, 1);
} }
#if !defined(CONFIG_USER_ONLY) #if !defined(CONFIG_USER_ONLY)

View File

@ -139,9 +139,10 @@ typedef struct CPUS390XState {
uint8_t riccb[64]; uint8_t riccb[64];
CPU_COMMON /* Fields up to this point are cleared by a CPU reset */
struct {} end_reset_fields;
/* reset does memset(0) up to here */ CPU_COMMON
uint32_t cpu_num; uint32_t cpu_num;
uint32_t machine_type; uint32_t machine_type;

View File

@ -199,7 +199,7 @@ static int cpu_write_c_reg(CPUS390XState *env, uint8_t *mem_buf, int n)
case S390_C0_REGNUM ... S390_C15_REGNUM: case S390_C0_REGNUM ... S390_C15_REGNUM:
env->cregs[n] = ldtul_p(mem_buf); env->cregs[n] = ldtul_p(mem_buf);
if (tcg_enabled()) { if (tcg_enabled()) {
tlb_flush(ENV_GET_CPU(env), 1); tlb_flush(ENV_GET_CPU(env));
} }
cpu_synchronize_post_init(ENV_GET_CPU(env)); cpu_synchronize_post_init(ENV_GET_CPU(env));
return 8; return 8;

View File

@ -872,7 +872,7 @@ void HELPER(lctlg)(CPUS390XState *env, uint32_t r1, uint64_t a2, uint32_t r3)
s390_cpu_recompute_watchpoints(CPU(cpu)); s390_cpu_recompute_watchpoints(CPU(cpu));
} }
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
void HELPER(lctl)(CPUS390XState *env, uint32_t r1, uint64_t a2, uint32_t r3) void HELPER(lctl)(CPUS390XState *env, uint32_t r1, uint64_t a2, uint32_t r3)
@ -900,7 +900,7 @@ void HELPER(lctl)(CPUS390XState *env, uint32_t r1, uint64_t a2, uint32_t r3)
s390_cpu_recompute_watchpoints(CPU(cpu)); s390_cpu_recompute_watchpoints(CPU(cpu));
} }
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
void HELPER(stctg)(CPUS390XState *env, uint32_t r1, uint64_t a2, uint32_t r3) void HELPER(stctg)(CPUS390XState *env, uint32_t r1, uint64_t a2, uint32_t r3)
@ -1036,7 +1036,7 @@ uint32_t HELPER(csp)(CPUS390XState *env, uint32_t r1, uint64_t r2)
cpu_stl_data(env, a2, env->regs[(r1 + 1) & 15]); cpu_stl_data(env, a2, env->regs[(r1 + 1) & 15]);
if (r2 & 0x3) { if (r2 & 0x3) {
/* flush TLB / ALB */ /* flush TLB / ALB */
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
cc = 0; cc = 0;
} else { } else {
@ -1121,7 +1121,7 @@ void HELPER(ptlb)(CPUS390XState *env)
{ {
S390CPU *cpu = s390_env_get_cpu(env); S390CPU *cpu = s390_env_get_cpu(env);
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
/* load using real address */ /* load using real address */

View File

@ -56,8 +56,7 @@ static void superh_cpu_reset(CPUState *s)
scc->parent_reset(s); scc->parent_reset(s);
memset(env, 0, offsetof(CPUSH4State, id)); memset(env, 0, offsetof(CPUSH4State, end_reset_fields));
tlb_flush(s, 1);
env->pc = 0xA0000000; env->pc = 0xA0000000;
#if defined(CONFIG_USER_ONLY) #if defined(CONFIG_USER_ONLY)

View File

@ -175,6 +175,9 @@ typedef struct CPUSH4State {
uint32_t ldst; uint32_t ldst;
/* Fields up to this point are cleared by a CPU reset */
struct {} end_reset_fields;
CPU_COMMON CPU_COMMON
/* Fields from here on are preserved over CPU reset. */ /* Fields from here on are preserved over CPU reset. */

View File

@ -583,7 +583,7 @@ void cpu_load_tlb(CPUSH4State * env)
entry->v = 0; entry->v = 0;
} }
tlb_flush(CPU(sh_env_get_cpu(s)), 1); tlb_flush(CPU(sh_env_get_cpu(s)));
} }
uint32_t cpu_sh4_read_mmaped_itlb_addr(CPUSH4State *s, uint32_t cpu_sh4_read_mmaped_itlb_addr(CPUSH4State *s,

View File

@ -36,8 +36,7 @@ static void sparc_cpu_reset(CPUState *s)
scc->parent_reset(s); scc->parent_reset(s);
memset(env, 0, offsetof(CPUSPARCState, version)); memset(env, 0, offsetof(CPUSPARCState, end_reset_fields));
tlb_flush(s, 1);
env->cwp = 0; env->cwp = 0;
#ifndef TARGET_SPARC64 #ifndef TARGET_SPARC64
env->wim = 1; env->wim = 1;

View File

@ -419,6 +419,9 @@ struct CPUSPARCState {
/* NOTE: we allow 8 more registers to handle wrapping */ /* NOTE: we allow 8 more registers to handle wrapping */
target_ulong regbase[MAX_NWINDOWS * 16 + 8]; target_ulong regbase[MAX_NWINDOWS * 16 + 8];
/* Fields up to this point are cleared by a CPU reset */
struct {} end_reset_fields;
CPU_COMMON CPU_COMMON
/* Fields from here on are preserved across CPU reset. */ /* Fields from here on are preserved across CPU reset. */

View File

@ -816,7 +816,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val,
case 2: /* flush region (16M) */ case 2: /* flush region (16M) */
case 3: /* flush context (4G) */ case 3: /* flush context (4G) */
case 4: /* flush entire */ case 4: /* flush entire */
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
break; break;
default: default:
break; break;
@ -841,7 +841,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val,
are invalid in normal mode. */ are invalid in normal mode. */
if ((oldreg ^ env->mmuregs[reg]) if ((oldreg ^ env->mmuregs[reg])
& (MMU_NF | env->def->mmu_bm)) { & (MMU_NF | env->def->mmu_bm)) {
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
break; break;
case 1: /* Context Table Pointer Register */ case 1: /* Context Table Pointer Register */
@ -852,7 +852,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val,
if (oldreg != env->mmuregs[reg]) { if (oldreg != env->mmuregs[reg]) {
/* we flush when the MMU context changes because /* we flush when the MMU context changes because
QEMU has no MMU context support */ QEMU has no MMU context support */
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
break; break;
case 3: /* Synchronous Fault Status Register with Clear */ case 3: /* Synchronous Fault Status Register with Clear */
@ -1509,13 +1509,13 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val,
env->dmmu.mmu_primary_context = val; env->dmmu.mmu_primary_context = val;
/* can be optimized to only flush MMU_USER_IDX /* can be optimized to only flush MMU_USER_IDX
and MMU_KERNEL_IDX entries */ and MMU_KERNEL_IDX entries */
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
break; break;
case 2: /* Secondary context */ case 2: /* Secondary context */
env->dmmu.mmu_secondary_context = val; env->dmmu.mmu_secondary_context = val;
/* can be optimized to only flush MMU_USER_SECONDARY_IDX /* can be optimized to only flush MMU_USER_SECONDARY_IDX
and MMU_KERNEL_SECONDARY_IDX entries */ and MMU_KERNEL_SECONDARY_IDX entries */
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
break; break;
case 5: /* TSB access */ case 5: /* TSB access */
DPRINTF_MMU("dmmu TSB write: 0x%016" PRIx64 " -> 0x%016" DPRINTF_MMU("dmmu TSB write: 0x%016" PRIx64 " -> 0x%016"
@ -1654,7 +1654,7 @@ void sparc_cpu_unassigned_access(CPUState *cs, hwaddr addr,
/* flush neverland mappings created during no-fault mode, /* flush neverland mappings created during no-fault mode,
so the sequential MMU faults report proper fault types */ so the sequential MMU faults report proper fault types */
if (env->mmuregs[0] & MMU_NF) { if (env->mmuregs[0] & MMU_NF) {
tlb_flush(cs, 1); tlb_flush(cs);
} }
} }
#else #else

View File

@ -84,8 +84,7 @@ static void tilegx_cpu_reset(CPUState *s)
tcc->parent_reset(s); tcc->parent_reset(s);
memset(env, 0, sizeof(CPUTLGState)); memset(env, 0, offsetof(CPUTLGState, end_reset_fields));
tlb_flush(s, 1);
} }
static void tilegx_cpu_realizefn(DeviceState *dev, Error **errp) static void tilegx_cpu_realizefn(DeviceState *dev, Error **errp)

View File

@ -97,6 +97,9 @@ typedef struct CPUTLGState {
uint32_t sigcode; /* Signal code */ uint32_t sigcode; /* Signal code */
#endif #endif
/* Fields up to this point are cleared by a CPU reset */
struct {} end_reset_fields;
CPU_COMMON CPU_COMMON
} CPUTLGState; } CPUTLGState;

View File

@ -53,8 +53,6 @@ static void tricore_cpu_reset(CPUState *s)
tcc->parent_reset(s); tcc->parent_reset(s);
tlb_flush(s, 1);
cpu_state_reset(env); cpu_state_reset(env);
} }

View File

@ -133,7 +133,7 @@ static void uc32_cpu_initfn(Object *obj)
env->regs[31] = 0x03000000; env->regs[31] = 0x03000000;
#endif #endif
tlb_flush(cs, 1); tlb_flush(cs);
if (tcg_enabled() && !inited) { if (tcg_enabled() && !inited) {
inited = true; inited = true;

View File

@ -106,7 +106,7 @@ void helper_cp0_set(CPUUniCore32State *env, uint32_t val, uint32_t creg,
case 6: case 6:
if ((cop <= 6) && (cop >= 2)) { if ((cop <= 6) && (cop >= 2)) {
/* invalid all tlb */ /* invalid all tlb */
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
return; return;
} }
break; break;

View File

@ -479,7 +479,7 @@ void HELPER(wsr_rasid)(CPUXtensaState *env, uint32_t v)
v = (v & 0xffffff00) | 0x1; v = (v & 0xffffff00) | 0x1;
if (v != env->sregs[RASID]) { if (v != env->sregs[RASID]) {
env->sregs[RASID] = v; env->sregs[RASID] = v;
tlb_flush(CPU(cpu), 1); tlb_flush(CPU(cpu));
} }
} }