Skip to content

Commit 4739f7d

Browse files
committed
MIPS: mm: Remove redundant get_new_mmu_context() cpu argument
get_new_mmu_context() accepts a cpu argument, but implicitly assumes that this is always equal to smp_processor_id() by operating on the local CPU's TLB & icache. Remove the cpu argument and have get_new_mmu_context() call smp_processor_id() instead. Signed-off-by: Paul Burton <paul.burton@mips.com> Cc: linux-mips@vger.kernel.org
1 parent 9a27324 commit 4739f7d

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

arch/mips/include/asm/mmu_context.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,13 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
100100

101101
/* Normal, classic MIPS get_new_mmu_context */
102102
static inline void
103-
get_new_mmu_context(struct mm_struct *mm, unsigned long cpu)
103+
get_new_mmu_context(struct mm_struct *mm)
104104
{
105-
u64 asid = asid_cache(cpu);
105+
unsigned int cpu;
106+
u64 asid;
107+
108+
cpu = smp_processor_id();
109+
asid = asid_cache(cpu);
106110

107111
if (!((asid += cpu_asid_inc()) & cpu_asid_mask(&cpu_data[cpu]))) {
108112
if (cpu_has_vtag_icache)
@@ -142,7 +146,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
142146
htw_stop();
143147
/* Check if our ASID is of an older version and thus invalid */
144148
if ((cpu_context(cpu, next) ^ asid_cache(cpu)) & asid_version_mask(cpu))
145-
get_new_mmu_context(next, cpu);
149+
get_new_mmu_context(next);
146150
write_c0_entryhi(cpu_asid(cpu, next));
147151
TLBMISS_HANDLER_SETUP_PGD(next->pgd);
148152

@@ -184,7 +188,7 @@ drop_mmu_context(struct mm_struct *mm)
184188

185189
cpu = smp_processor_id();
186190
if (cpumask_test_cpu(cpu, mm_cpumask(mm))) {
187-
get_new_mmu_context(mm, cpu);
191+
get_new_mmu_context(mm);
188192
write_c0_entryhi(cpu_asid(cpu, mm));
189193
} else {
190194
/* will get a new context next time */

arch/mips/kvm/emulate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ static void kvm_mips_change_entryhi(struct kvm_vcpu *vcpu,
10161016
*/
10171017
preempt_disable();
10181018
cpu = smp_processor_id();
1019-
get_new_mmu_context(kern_mm, cpu);
1019+
get_new_mmu_context(kern_mm);
10201020
for_each_possible_cpu(i)
10211021
if (i != cpu)
10221022
cpu_context(i, kern_mm) = 0;

arch/mips/kvm/trap_emul.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ static int kvm_trap_emul_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
10581058
mm = KVM_GUEST_KERNEL_MODE(vcpu) ? kern_mm : user_mm;
10591059
if ((cpu_context(cpu, mm) ^ asid_cache(cpu)) &
10601060
asid_version_mask(cpu))
1061-
get_new_mmu_context(mm, cpu);
1061+
get_new_mmu_context(mm);
10621062
write_c0_entryhi(cpu_asid(cpu, mm));
10631063
TLBMISS_HANDLER_SETUP_PGD(mm->pgd);
10641064
kvm_mips_suspend_mm(cpu);
@@ -1076,7 +1076,7 @@ static int kvm_trap_emul_vcpu_put(struct kvm_vcpu *vcpu, int cpu)
10761076
/* Restore normal Linux process memory map */
10771077
if (((cpu_context(cpu, current->mm) ^ asid_cache(cpu)) &
10781078
asid_version_mask(cpu)))
1079-
get_new_mmu_context(current->mm, cpu);
1079+
get_new_mmu_context(current->mm);
10801080
write_c0_entryhi(cpu_asid(cpu, current->mm));
10811081
TLBMISS_HANDLER_SETUP_PGD(current->mm->pgd);
10821082
kvm_mips_resume_mm(cpu);
@@ -1113,7 +1113,7 @@ static void kvm_trap_emul_check_requests(struct kvm_vcpu *vcpu, int cpu,
11131113
/* Generate new ASID for current mode */
11141114
if (reload_asid) {
11151115
mm = KVM_GUEST_KERNEL_MODE(vcpu) ? kern_mm : user_mm;
1116-
get_new_mmu_context(mm, cpu);
1116+
get_new_mmu_context(mm);
11171117
htw_stop();
11181118
write_c0_entryhi(cpu_asid(cpu, mm));
11191119
TLBMISS_HANDLER_SETUP_PGD(mm->pgd);
@@ -1230,7 +1230,7 @@ static void kvm_trap_emul_vcpu_reenter(struct kvm_run *run,
12301230
*/
12311231
if ((cpu_context(cpu, mm) ^ asid_cache(cpu)) &
12321232
asid_version_mask(cpu))
1233-
get_new_mmu_context(mm, cpu);
1233+
get_new_mmu_context(mm);
12341234
}
12351235

12361236
static int kvm_trap_emul_vcpu_run(struct kvm_run *run, struct kvm_vcpu *vcpu)
@@ -1268,7 +1268,7 @@ static int kvm_trap_emul_vcpu_run(struct kvm_run *run, struct kvm_vcpu *vcpu)
12681268
/* Restore normal Linux process memory map */
12691269
if (((cpu_context(cpu, current->mm) ^ asid_cache(cpu)) &
12701270
asid_version_mask(cpu)))
1271-
get_new_mmu_context(current->mm, cpu);
1271+
get_new_mmu_context(current->mm);
12721272
write_c0_entryhi(cpu_asid(cpu, current->mm));
12731273
TLBMISS_HANDLER_SETUP_PGD(current->mm->pgd);
12741274
kvm_mips_resume_mm(cpu);

arch/mips/kvm/vz.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2457,7 +2457,7 @@ static void kvm_vz_vcpu_load_tlb(struct kvm_vcpu *vcpu, int cpu)
24572457
if (cpumask_test_and_clear_cpu(cpu, &kvm->arch.asid_flush_mask)
24582458
|| (cpu_context(cpu, gpa_mm) ^ asid_cache(cpu)) &
24592459
asid_version_mask(cpu))
2460-
get_new_mmu_context(gpa_mm, cpu);
2460+
get_new_mmu_context(gpa_mm);
24612461
}
24622462
}
24632463

0 commit comments

Comments
 (0)