MIPS: mm: Remove redundant get_new_mmu_context() cpu argument
authorPaul Burton <paul.burton@mips.com>
Sat, 2 Feb 2019 01:43:17 +0000 (01:43 +0000)
committerPaul Burton <paul.burton@mips.com>
Mon, 4 Feb 2019 18:56:14 +0000 (10:56 -0800)
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
arch/mips/include/asm/mmu_context.h
arch/mips/kvm/emulate.c
arch/mips/kvm/trap_emul.c
arch/mips/kvm/vz.c

index dc45690cbbf5560021a7643253568d9ba826db02..0d050d781737d33c56c918cb41038372a20843ef 100644 (file)
@@ -100,9 +100,13 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
 
 /* Normal, classic MIPS get_new_mmu_context */
 static inline void
-get_new_mmu_context(struct mm_struct *mm, unsigned long cpu)
+get_new_mmu_context(struct mm_struct *mm)
 {
-       u64 asid = asid_cache(cpu);
+       unsigned int cpu;
+       u64 asid;
+
+       cpu = smp_processor_id();
+       asid = asid_cache(cpu);
 
        if (!((asid += cpu_asid_inc()) & cpu_asid_mask(&cpu_data[cpu]))) {
                if (cpu_has_vtag_icache)
@@ -142,7 +146,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
        htw_stop();
        /* Check if our ASID is of an older version and thus invalid */
        if ((cpu_context(cpu, next) ^ asid_cache(cpu)) & asid_version_mask(cpu))
-               get_new_mmu_context(next, cpu);
+               get_new_mmu_context(next);
        write_c0_entryhi(cpu_asid(cpu, next));
        TLBMISS_HANDLER_SETUP_PGD(next->pgd);
 
@@ -184,7 +188,7 @@ drop_mmu_context(struct mm_struct *mm)
 
        cpu = smp_processor_id();
        if (cpumask_test_cpu(cpu, mm_cpumask(mm)))  {
-               get_new_mmu_context(mm, cpu);
+               get_new_mmu_context(mm);
                write_c0_entryhi(cpu_asid(cpu, mm));
        } else {
                /* will get a new context next time */
index ec9ed23bca7fdeea33f0e66dc0dd1a86c655f64e..ca83473724279a3aeeebc54d6c6dd6fac9a80122 100644 (file)
@@ -1016,7 +1016,7 @@ static void kvm_mips_change_entryhi(struct kvm_vcpu *vcpu,
                 */
                preempt_disable();
                cpu = smp_processor_id();
-               get_new_mmu_context(kern_mm, cpu);
+               get_new_mmu_context(kern_mm);
                for_each_possible_cpu(i)
                        if (i != cpu)
                                cpu_context(i, kern_mm) = 0;
index 6a0d7040d8820c695ac926b02e849e9074bc54c0..503c2fb7e4da9f0f6e1c56124e45199ff99d332c 100644 (file)
@@ -1058,7 +1058,7 @@ static int kvm_trap_emul_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
                mm = KVM_GUEST_KERNEL_MODE(vcpu) ? kern_mm : user_mm;
                if ((cpu_context(cpu, mm) ^ asid_cache(cpu)) &
                    asid_version_mask(cpu))
-                       get_new_mmu_context(mm, cpu);
+                       get_new_mmu_context(mm);
                write_c0_entryhi(cpu_asid(cpu, mm));
                TLBMISS_HANDLER_SETUP_PGD(mm->pgd);
                kvm_mips_suspend_mm(cpu);
@@ -1076,7 +1076,7 @@ static int kvm_trap_emul_vcpu_put(struct kvm_vcpu *vcpu, int cpu)
                /* Restore normal Linux process memory map */
                if (((cpu_context(cpu, current->mm) ^ asid_cache(cpu)) &
                     asid_version_mask(cpu)))
-                       get_new_mmu_context(current->mm, cpu);
+                       get_new_mmu_context(current->mm);
                write_c0_entryhi(cpu_asid(cpu, current->mm));
                TLBMISS_HANDLER_SETUP_PGD(current->mm->pgd);
                kvm_mips_resume_mm(cpu);
@@ -1113,7 +1113,7 @@ static void kvm_trap_emul_check_requests(struct kvm_vcpu *vcpu, int cpu,
                /* Generate new ASID for current mode */
                if (reload_asid) {
                        mm = KVM_GUEST_KERNEL_MODE(vcpu) ? kern_mm : user_mm;
-                       get_new_mmu_context(mm, cpu);
+                       get_new_mmu_context(mm);
                        htw_stop();
                        write_c0_entryhi(cpu_asid(cpu, mm));
                        TLBMISS_HANDLER_SETUP_PGD(mm->pgd);
@@ -1230,7 +1230,7 @@ static void kvm_trap_emul_vcpu_reenter(struct kvm_run *run,
         */
        if ((cpu_context(cpu, mm) ^ asid_cache(cpu)) &
            asid_version_mask(cpu))
-               get_new_mmu_context(mm, cpu);
+               get_new_mmu_context(mm);
 }
 
 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)
        /* Restore normal Linux process memory map */
        if (((cpu_context(cpu, current->mm) ^ asid_cache(cpu)) &
             asid_version_mask(cpu)))
-               get_new_mmu_context(current->mm, cpu);
+               get_new_mmu_context(current->mm);
        write_c0_entryhi(cpu_asid(cpu, current->mm));
        TLBMISS_HANDLER_SETUP_PGD(current->mm->pgd);
        kvm_mips_resume_mm(cpu);
index 74805035edc892f42f23ff1584f1fb9b6ef79777..d98c12a22eacc7a694bb9947b5e57431ab57369a 100644 (file)
@@ -2457,7 +2457,7 @@ static void kvm_vz_vcpu_load_tlb(struct kvm_vcpu *vcpu, int cpu)
                if (cpumask_test_and_clear_cpu(cpu, &kvm->arch.asid_flush_mask)
                    || (cpu_context(cpu, gpa_mm) ^ asid_cache(cpu)) &
                                                asid_version_mask(cpu))
-                       get_new_mmu_context(gpa_mm, cpu);
+                       get_new_mmu_context(gpa_mm);
        }
 }