Skip to content

Commit

Permalink
cputlb: Change tlb_flush_page() argument to CPUState
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Färber <[email protected]>
  • Loading branch information
afaerber committed Mar 13, 2014
1 parent 0063ebd commit 31b030d
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 70 deletions.
4 changes: 2 additions & 2 deletions cputlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ static inline void tlb_flush_entry(CPUTLBEntry *tlb_entry, target_ulong addr)
}
}

void tlb_flush_page(CPUArchState *env, target_ulong addr)
void tlb_flush_page(CPUState *cpu, target_ulong addr)
{
CPUState *cpu = ENV_GET_CPU(env);
CPUArchState *env = cpu->env_ptr;
int i;
int mmu_idx;

Expand Down
7 changes: 2 additions & 5 deletions exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,6 @@ int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len,
int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len,
int flags, CPUWatchpoint **watchpoint)
{
CPUArchState *env = cpu->env_ptr;
vaddr len_mask = ~(len - 1);
CPUWatchpoint *wp;

Expand All @@ -567,7 +566,7 @@ int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len,
QTAILQ_INSERT_TAIL(&cpu->watchpoints, wp, entry);
}

tlb_flush_page(env, addr);
tlb_flush_page(cpu, addr);

if (watchpoint)
*watchpoint = wp;
Expand All @@ -594,11 +593,9 @@ int cpu_watchpoint_remove(CPUState *cpu, vaddr addr, vaddr len,
/* Remove a specific watchpoint by reference. */
void cpu_watchpoint_remove_by_ref(CPUState *cpu, CPUWatchpoint *watchpoint)
{
CPUArchState *env = cpu->env_ptr;

QTAILQ_REMOVE(&cpu->watchpoints, watchpoint, entry);

tlb_flush_page(env, watchpoint->vaddr);
tlb_flush_page(cpu, watchpoint->vaddr);

g_free(watchpoint);
}
Expand Down
4 changes: 2 additions & 2 deletions include/exec/exec-all.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t end,
#if !defined(CONFIG_USER_ONLY)
void tcg_cpu_address_space_init(CPUState *cpu, AddressSpace *as);
/* cputlb.c */
void tlb_flush_page(CPUArchState *env, target_ulong addr);
void tlb_flush_page(CPUState *cpu, target_ulong addr);
void tlb_flush(CPUArchState *env, int flush_global);
void tlb_set_page(CPUArchState *env, target_ulong vaddr,
hwaddr paddr, int prot,
int mmu_idx, target_ulong size);
void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr);
#else
static inline void tlb_flush_page(CPUArchState *env, target_ulong addr)
static inline void tlb_flush_page(CPUState *cpu, target_ulong addr)
{
}

Expand Down
2 changes: 1 addition & 1 deletion target-alpha/sys_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void helper_tbia(CPUAlphaState *env)

void helper_tbis(CPUAlphaState *env, uint64_t p)
{
tlb_flush_page(env, p);
tlb_flush_page(CPU(alpha_env_get_cpu(env)), p);
}

void helper_tb_flush(CPUAlphaState *env)
Expand Down
14 changes: 10 additions & 4 deletions target-arm/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,9 @@ static void tlbimva_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
/* Invalidate single TLB entry by MVA and ASID (TLBIMVA) */
tlb_flush_page(env, value & TARGET_PAGE_MASK);
ARMCPU *cpu = arm_env_get_cpu(env);

tlb_flush_page(CPU(cpu), value & TARGET_PAGE_MASK);
}

static void tlbiasid_write(CPUARMState *env, const ARMCPRegInfo *ri,
Expand All @@ -356,7 +358,9 @@ static void tlbimvaa_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
/* Invalidate single entry by MVA, all ASIDs (TLBIMVAA) */
tlb_flush_page(env, value & TARGET_PAGE_MASK);
ARMCPU *cpu = arm_env_get_cpu(env);

tlb_flush_page(CPU(cpu), value & TARGET_PAGE_MASK);
}

static const ARMCPRegInfo cp_reginfo[] = {
Expand Down Expand Up @@ -1686,16 +1690,18 @@ static void tlbi_aa64_va_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
/* Invalidate by VA (AArch64 version) */
ARMCPU *cpu = arm_env_get_cpu(env);
uint64_t pageaddr = value << 12;
tlb_flush_page(env, pageaddr);
tlb_flush_page(CPU(cpu), pageaddr);
}

static void tlbi_aa64_vaa_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
/* Invalidate by VA, all ASIDs (AArch64 version) */
ARMCPU *cpu = arm_env_get_cpu(env);
uint64_t pageaddr = value << 12;
tlb_flush_page(env, pageaddr);
tlb_flush_page(CPU(cpu), pageaddr);
}

static void tlbi_aa64_asid_write(CPUARMState *env, const ARMCPRegInfo *ri,
Expand Down
3 changes: 2 additions & 1 deletion target-cris/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ static int cris_mmu_translate_page(struct cris_mmu_result *res,

void cris_mmu_flush_pid(CPUCRISState *env, uint32_t pid)
{
CRISCPU *cpu = cris_env_get_cpu(env);
target_ulong vaddr;
unsigned int idx;
uint32_t lo, hi;
Expand All @@ -315,7 +316,7 @@ void cris_mmu_flush_pid(CPUCRISState *env, uint32_t pid)
vaddr = tlb_vpn << TARGET_PAGE_BITS;
D_LOG("flush pid=%x vaddr=%x\n",
pid, vaddr);
tlb_flush_page(env, vaddr);
tlb_flush_page(CPU(cpu), vaddr);
}
}
}
Expand Down
12 changes: 9 additions & 3 deletions target-cris/op_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ void helper_tlb_flush_pid(CPUCRISState *env, uint32_t pid)
void helper_spc_write(CPUCRISState *env, uint32_t new_spc)
{
#if !defined(CONFIG_USER_ONLY)
tlb_flush_page(env, env->pregs[PR_SPC]);
tlb_flush_page(env, new_spc);
CRISCPU *cpu = cris_env_get_cpu(env);
CPUState *cs = CPU(cpu);

tlb_flush_page(cs, env->pregs[PR_SPC]);
tlb_flush_page(cs, new_spc);
#endif
}

Expand All @@ -114,6 +117,9 @@ void helper_dump(uint32_t a0, uint32_t a1, uint32_t a2)

void helper_movl_sreg_reg(CPUCRISState *env, uint32_t sreg, uint32_t reg)
{
#if !defined(CONFIG_USER_ONLY)
CRISCPU *cpu = cris_env_get_cpu(env);
#endif
uint32_t srs;
srs = env->pregs[PR_SRS];
srs &= 3;
Expand Down Expand Up @@ -155,7 +161,7 @@ void helper_movl_sreg_reg(CPUCRISState *env, uint32_t sreg, uint32_t reg)
D_LOG("tlb flush vaddr=%x v=%d pc=%x\n",
vaddr, tlb_v, env->pc);
if (tlb_v) {
tlb_flush_page(env, vaddr);
tlb_flush_page(CPU(cpu), vaddr);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion target-i386/misc_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ void helper_lmsw(CPUX86State *env, target_ulong t0)

void helper_invlpg(CPUX86State *env, target_ulong addr)
{
X86CPU *cpu = x86_env_get_cpu(env);

cpu_svm_check_intercept_param(env, SVM_EXIT_INVLPG, 0);
tlb_flush_page(env, addr);
tlb_flush_page(CPU(cpu), addr);
}

void helper_rdtsc(CPUX86State *env)
Expand Down
3 changes: 2 additions & 1 deletion target-i386/svm_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ void helper_skinit(CPUX86State *env)

void helper_invlpga(CPUX86State *env, int aflag)
{
X86CPU *cpu = x86_env_get_cpu(env);
target_ulong addr;

cpu_svm_check_intercept_param(env, SVM_EXIT_INVLPGA, 0);
Expand All @@ -481,7 +482,7 @@ void helper_invlpga(CPUX86State *env, int aflag)

/* XXX: could use the ASID to see if it is needed to do the
flush */
tlb_flush_page(env, addr);
tlb_flush_page(CPU(cpu), addr);
}

void helper_svm_check_intercept_param(CPUX86State *env, uint32_t type,
Expand Down
3 changes: 2 additions & 1 deletion target-microblaze/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ static unsigned int tlb_decode_size(unsigned int f)

static void mmu_flush_idx(CPUMBState *env, unsigned int idx)
{
CPUState *cs = CPU(mb_env_get_cpu(env));
struct microblaze_mmu *mmu = &env->mmu;
unsigned int tlb_size;
uint32_t tlb_tag, end, t;
Expand All @@ -47,7 +48,7 @@ static void mmu_flush_idx(CPUMBState *env, unsigned int idx)
end = tlb_tag + tlb_size;

while (tlb_tag < end) {
tlb_flush_page(env, tlb_tag);
tlb_flush_page(cs, tlb_tag);
tlb_tag += TARGET_PAGE_SIZE;
}
}
Expand Down
8 changes: 6 additions & 2 deletions target-mips/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,8 @@ void mips_cpu_do_interrupt(CPUState *cs)
#if !defined(CONFIG_USER_ONLY)
void r4k_invalidate_tlb (CPUMIPSState *env, int idx, int use_extra)
{
MIPSCPU *cpu = mips_env_get_cpu(env);
CPUState *cs;
r4k_tlb_t *tlb;
target_ulong addr;
target_ulong end;
Expand All @@ -678,6 +680,7 @@ void r4k_invalidate_tlb (CPUMIPSState *env, int idx, int use_extra)
/* 1k pages are not supported. */
mask = tlb->PageMask | ~(TARGET_PAGE_MASK << 1);
if (tlb->V0) {
cs = CPU(cpu);
addr = tlb->VPN & ~mask;
#if defined(TARGET_MIPS64)
if (addr >= (0xFFFFFFFF80000000ULL & env->SEGMask)) {
Expand All @@ -686,11 +689,12 @@ void r4k_invalidate_tlb (CPUMIPSState *env, int idx, int use_extra)
#endif
end = addr | (mask >> 1);
while (addr < end) {
tlb_flush_page (env, addr);
tlb_flush_page(cs, addr);
addr += TARGET_PAGE_SIZE;
}
}
if (tlb->V1) {
cs = CPU(cpu);
addr = (tlb->VPN & ~mask) | ((mask >> 1) + 1);
#if defined(TARGET_MIPS64)
if (addr >= (0xFFFFFFFF80000000ULL & env->SEGMask)) {
Expand All @@ -699,7 +703,7 @@ void r4k_invalidate_tlb (CPUMIPSState *env, int idx, int use_extra)
#endif
end = addr | mask;
while (addr - 1 < end) {
tlb_flush_page (env, addr);
tlb_flush_page(cs, addr);
addr += TARGET_PAGE_SIZE;
}
}
Expand Down
4 changes: 2 additions & 2 deletions target-openrisc/sys_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env,
case TO_SPR(1, 512) ... TO_SPR(1, 512+DTLB_SIZE-1): /* DTLBW0MR 0-127 */
idx = spr - TO_SPR(1, 512);
if (!(rb & 1)) {
tlb_flush_page(env, env->tlb->dtlb[0][idx].mr & TARGET_PAGE_MASK);
tlb_flush_page(cs, env->tlb->dtlb[0][idx].mr & TARGET_PAGE_MASK);
}
env->tlb->dtlb[0][idx].mr = rb;
break;
Expand All @@ -103,7 +103,7 @@ void HELPER(mtspr)(CPUOpenRISCState *env,
case TO_SPR(2, 512) ... TO_SPR(2, 512+ITLB_SIZE-1): /* ITLBW0MR 0-127 */
idx = spr - TO_SPR(2, 512);
if (!(rb & 1)) {
tlb_flush_page(env, env->tlb->itlb[0][idx].mr & TARGET_PAGE_MASK);
tlb_flush_page(cs, env->tlb->itlb[0][idx].mr & TARGET_PAGE_MASK);
}
env->tlb->itlb[0][idx].mr = rb;
break;
Expand Down
Loading

0 comments on commit 31b030d

Please sign in to comment.