]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
MIPS: mm: Add set_cpu_context() for ASID assignments
authorPaul Burton <paul.burton@mips.com>
Sat, 2 Feb 2019 01:43:25 +0000 (01:43 +0000)
committerPaul Burton <paul.burton@mips.com>
Mon, 4 Feb 2019 18:56:33 +0000 (10:56 -0800)
When we gain MMID support we'll be storing MMIDs as atomic64_t values
and accessing them via atomic64_* functions. This necessitates that we
don't use cpu_context() as the left hand side of an assignment, ie. as a
modifiable lvalue. In preparation for this introduce a new
set_cpu_context() function & replace all assignments with cpu_context()
on their left hand side with an equivalent call to set_cpu_context().

To enforce that cpu_context() should not be used for assignments, we
rewrite it as a static inline function.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: linux-mips@vger.kernel.org
arch/mips/include/asm/mmu_context.h
arch/mips/kernel/smp.c
arch/mips/kvm/emulate.c
arch/mips/kvm/trap_emul.c
arch/mips/mm/context.c

index 336682fb48de089c27a9c5d1c2ec33a907ffd6e8..a0f29df8ced8c9c35886dcaf1281cb6db73f9b67 100644 (file)
@@ -88,7 +88,17 @@ static inline u64 asid_first_version(unsigned int cpu)
        return ~asid_version_mask(cpu) + 1;
 }
 
-#define cpu_context(cpu, mm)   ((mm)->context.asid[cpu])
+static inline u64 cpu_context(unsigned int cpu, const struct mm_struct *mm)
+{
+       return mm->context.asid[cpu];
+}
+
+static inline void set_cpu_context(unsigned int cpu,
+                                  struct mm_struct *mm, u64 ctx)
+{
+       mm->context.asid[cpu] = ctx;
+}
+
 #define asid_cache(cpu)                (cpu_data[cpu].asid_cache)
 #define cpu_asid(cpu, mm) \
        (cpu_context((cpu), (mm)) & cpu_asid_mask(&cpu_data[cpu]))
@@ -111,7 +121,7 @@ init_new_context(struct task_struct *tsk, struct mm_struct *mm)
        int i;
 
        for_each_possible_cpu(i)
-               cpu_context(i, mm) = 0;
+               set_cpu_context(i, mm, 0);
 
        mm->context.bd_emupage_allocmap = NULL;
        spin_lock_init(&mm->context.bd_emupage_lock);
@@ -175,7 +185,7 @@ drop_mmu_context(struct mm_struct *mm)
                htw_start();
        } else {
                /* will get a new context next time */
-               cpu_context(cpu, mm) = 0;
+               set_cpu_context(cpu, mm, 0);
        }
 
        local_irq_restore(flags);
index d7088ca31e43556b7370deb554406f685c68331a..f9dbd95e1d687dac1e27d11b9d62cf6c6fd346c5 100644 (file)
@@ -537,7 +537,7 @@ void flush_tlb_mm(struct mm_struct *mm)
 
                for_each_online_cpu(cpu) {
                        if (cpu != smp_processor_id() && cpu_context(cpu, mm))
-                               cpu_context(cpu, mm) = 0;
+                               set_cpu_context(cpu, mm, 0);
                }
        }
        drop_mmu_context(mm);
@@ -583,7 +583,7 @@ void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned l
                         * mm has been completely unused by that CPU.
                         */
                        if (cpu != smp_processor_id() && cpu_context(cpu, mm))
-                               cpu_context(cpu, mm) = !exec;
+                               set_cpu_context(cpu, mm, !exec);
                }
        }
        local_flush_tlb_range(vma, start, end);
@@ -635,7 +635,7 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
                         * by that CPU.
                         */
                        if (cpu != smp_processor_id() && cpu_context(cpu, vma->vm_mm))
-                               cpu_context(cpu, vma->vm_mm) = 1;
+                               set_cpu_context(cpu, vma->vm_mm, 1);
                }
        }
        local_flush_tlb_page(vma, page);
index ca83473724279a3aeeebc54d6c6dd6fac9a80122..0074427b04fbf8d3662ebed9985910827e477065 100644 (file)
@@ -1019,7 +1019,7 @@ static void kvm_mips_change_entryhi(struct kvm_vcpu *vcpu,
                get_new_mmu_context(kern_mm);
                for_each_possible_cpu(i)
                        if (i != cpu)
-                               cpu_context(i, kern_mm) = 0;
+                               set_cpu_context(i, kern_mm, 0);
                preempt_enable();
        }
        kvm_write_c0_guest_entryhi(cop0, entryhi);
@@ -1090,8 +1090,8 @@ static void kvm_mips_invalidate_guest_tlb(struct kvm_vcpu *vcpu,
                if (i == cpu)
                        continue;
                if (user)
-                       cpu_context(i, user_mm) = 0;
-               cpu_context(i, kern_mm) = 0;
+                       set_cpu_context(i, user_mm, 0);
+               set_cpu_context(i, kern_mm, 0);
        }
 
        preempt_enable();
index 22ffe72a9e4b463a57fa70ae7e1ed38de3f192c4..73daa6ad33afe41dd6fbe831f232ee421626a7ae 100644 (file)
@@ -1098,8 +1098,8 @@ static void kvm_trap_emul_check_requests(struct kvm_vcpu *vcpu, int cpu,
                kvm_mips_flush_gva_pt(kern_mm->pgd, KMF_GPA | KMF_KERN);
                kvm_mips_flush_gva_pt(user_mm->pgd, KMF_GPA | KMF_USER);
                for_each_possible_cpu(i) {
-                       cpu_context(i, kern_mm) = 0;
-                       cpu_context(i, user_mm) = 0;
+                       set_cpu_context(i, kern_mm, 0);
+                       set_cpu_context(i, user_mm, 0);
                }
 
                /* Generate new ASID for current mode */
@@ -1211,7 +1211,7 @@ static void kvm_trap_emul_vcpu_reenter(struct kvm_run *run,
                if (gasid != vcpu->arch.last_user_gasid) {
                        kvm_mips_flush_gva_pt(user_mm->pgd, KMF_USER);
                        for_each_possible_cpu(i)
-                               cpu_context(i, user_mm) = 0;
+                               set_cpu_context(i, user_mm, 0);
                        vcpu->arch.last_user_gasid = gasid;
                }
        }
index 4dd976acf41d1bc22d93fc85b084eccd497ada64..dcaceee179f7b3ff04be6e374ac413c25fdbe770 100644 (file)
@@ -15,7 +15,8 @@ void get_new_mmu_context(struct mm_struct *mm)
                local_flush_tlb_all();  /* start new asid cycle */
        }
 
-       cpu_context(cpu, mm) = asid_cache(cpu) = asid;
+       set_cpu_context(cpu, mm, asid);
+       asid_cache(cpu) = asid;
 }
 
 void check_mmu_context(struct mm_struct *mm)