Merge tag 'asm-generic-mmu-context-5.11' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 16 Dec 2020 07:58:04 +0000 (23:58 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 16 Dec 2020 07:58:04 +0000 (23:58 -0800)
Pull asm-generic mmu-context cleanup from Arnd Bergmann:
 "This is a cleanup series from Nicholas Piggin, preparing for later
  changes. The asm/mmu_context.h header are generalized and common code
  moved to asm-gneneric/mmu_context.h.

  This saves a bit of code and makes it easier to change in the future"

* tag 'asm-generic-mmu-context-5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic: (25 commits)
  h8300: Fix generic mmu_context build
  m68k: mmu_context: Fix Sun-3 build
  xtensa: use asm-generic/mmu_context.h for no-op implementations
  x86: use asm-generic/mmu_context.h for no-op implementations
  um: use asm-generic/mmu_context.h for no-op implementations
  sparc: use asm-generic/mmu_context.h for no-op implementations
  sh: use asm-generic/mmu_context.h for no-op implementations
  s390: use asm-generic/mmu_context.h for no-op implementations
  riscv: use asm-generic/mmu_context.h for no-op implementations
  powerpc: use asm-generic/mmu_context.h for no-op implementations
  parisc: use asm-generic/mmu_context.h for no-op implementations
  openrisc: use asm-generic/mmu_context.h for no-op implementations
  nios2: use asm-generic/mmu_context.h for no-op implementations
  nds32: use asm-generic/mmu_context.h for no-op implementations
  mips: use asm-generic/mmu_context.h for no-op implementations
  microblaze: use asm-generic/mmu_context.h for no-op implementations
  m68k: use asm-generic/mmu_context.h for no-op implementations
  ia64: use asm-generic/mmu_context.h for no-op implementations
  hexagon: use asm-generic/mmu_context.h for no-op implementations
  csky: use asm-generic/mmu_context.h for no-op implementations
  ...

1  2 
arch/arm64/include/asm/mmu_context.h
arch/s390/include/asm/mmu_context.h
arch/x86/include/asm/mmu_context.h

index 5c72c20bd300e1cc964f16a2e124a7f1e9b60d05,81189251db41115c4b7a1218239d3b796d393802..0b3079fd28ebe23b8a099d2d5ed017c85cfde60b
@@@ -36,11 -36,11 +36,11 @@@ static inline void contextidr_thread_sw
  }
  
  /*
 - * Set TTBR0 to empty_zero_page. No translations will be possible via TTBR0.
 + * Set TTBR0 to reserved_pg_dir. No translations will be possible via TTBR0.
   */
  static inline void cpu_set_reserved_ttbr0(void)
  {
 -      unsigned long ttbr = phys_to_ttbr(__pa_symbol(empty_zero_page));
 +      unsigned long ttbr = phys_to_ttbr(__pa_symbol(reserved_pg_dir));
  
        write_sysreg(ttbr, ttbr0_el1);
        isb();
@@@ -174,9 -174,9 +174,9 @@@ static inline void cpu_replace_ttbr1(pg
   * Setting a reserved TTBR0 or EPD0 would work, but it all gets ugly when you
   * take CPU migration into account.
   */
- #define destroy_context(mm)           do { } while(0)
  void check_and_switch_context(struct mm_struct *mm);
  
+ #define init_new_context(tsk, mm) init_new_context(tsk, mm)
  static inline int
  init_new_context(struct task_struct *tsk, struct mm_struct *mm)
  {
@@@ -195,7 -195,7 +195,7 @@@ static inline void update_saved_ttbr0(s
                return;
  
        if (mm == &init_mm)
 -              ttbr = __pa_symbol(empty_zero_page);
 +              ttbr = __pa_symbol(reserved_pg_dir);
        else
                ttbr = virt_to_phys(mm->pgd) | ASID(mm) << 48;
  
@@@ -208,6 -208,7 +208,7 @@@ static inline void update_saved_ttbr0(s
  }
  #endif
  
+ #define enter_lazy_tlb enter_lazy_tlb
  static inline void
  enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
  {
@@@ -248,15 -249,14 +249,14 @@@ switch_mm(struct mm_struct *prev, struc
        update_saved_ttbr0(tsk, next);
  }
  
- #define deactivate_mm(tsk,mm) do { } while (0)
- #define activate_mm(prev,next)        switch_mm(prev, next, current)
  void verify_cpu_asid_bits(void);
  void post_ttbr_update_workaround(void);
  
  unsigned long arm64_mm_context_get(struct mm_struct *mm);
  void arm64_mm_context_put(struct mm_struct *mm);
  
+ #include <asm-generic/mmu_context.h>
  #endif /* !__ASSEMBLY__ */
  
  #endif /* !__ASM_MMU_CONTEXT_H */
index 5dc49c467319f6f3b030d5b68c5f5fb801645f5c,66f9cf0a07e3cbfb9fced6ad5566b17e23c2d444..e7cffc7b5c2f65a95953570dadf988921c1fce7d
@@@ -15,6 -15,7 +15,7 @@@
  #include <asm/ctl_reg.h>
  #include <asm-generic/mm_hooks.h>
  
+ #define init_new_context init_new_context
  static inline int init_new_context(struct task_struct *tsk,
                                   struct mm_struct *mm)
  {
        return 0;
  }
  
- #define destroy_context(mm)             do { } while (0)
 -static inline void set_user_asce(struct mm_struct *mm)
 -{
 -      S390_lowcore.user_asce = mm->context.asce;
 -      __ctl_load(S390_lowcore.user_asce, 1, 1);
 -      clear_cpu_flag(CIF_ASCE_PRIMARY);
 -}
 -
 -static inline void clear_user_asce(void)
 -{
 -      S390_lowcore.user_asce = S390_lowcore.kernel_asce;
 -      __ctl_load(S390_lowcore.kernel_asce, 1, 1);
 -      set_cpu_flag(CIF_ASCE_PRIMARY);
 -}
 -
 -mm_segment_t enable_sacf_uaccess(void);
 -void disable_sacf_uaccess(mm_segment_t old_fs);
--
  static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
                             struct task_struct *tsk)
  {
        int cpu = smp_processor_id();
  
 -      S390_lowcore.user_asce = next->context.asce;
 +      if (next == &init_mm)
 +              S390_lowcore.user_asce = s390_invalid_asce;
 +      else
 +              S390_lowcore.user_asce = next->context.asce;
        cpumask_set_cpu(cpu, &next->context.cpu_attach_mask);
 -      /* Clear previous user-ASCE from CR1 and CR7 */
 -      if (!test_cpu_flag(CIF_ASCE_PRIMARY)) {
 -              __ctl_load(S390_lowcore.kernel_asce, 1, 1);
 -              set_cpu_flag(CIF_ASCE_PRIMARY);
 -      }
 -      if (test_cpu_flag(CIF_ASCE_SECONDARY)) {
 -              __ctl_load(S390_lowcore.vdso_asce, 7, 7);
 -              clear_cpu_flag(CIF_ASCE_SECONDARY);
 -      }
 +      /* Clear previous user-ASCE from CR7 */
 +      __ctl_load(s390_invalid_asce, 7, 7);
        if (prev != next)
                cpumask_clear_cpu(cpu, &prev->context.cpu_attach_mask);
  }
@@@ -101,18 -121,18 +100,18 @@@ static inline void finish_arch_post_loc
                __tlb_flush_mm_lazy(mm);
                preempt_enable();
        }
 -      set_fs(current->thread.mm_segment);
 +      __ctl_load(S390_lowcore.user_asce, 7, 7);
  }
  
- #define enter_lazy_tlb(mm,tsk)        do { } while (0)
- #define deactivate_mm(tsk,mm) do { } while (0)
+ #define activate_mm activate_mm
  static inline void activate_mm(struct mm_struct *prev,
                                 struct mm_struct *next)
  {
        switch_mm(prev, next, current);
        cpumask_set_cpu(smp_processor_id(), mm_cpumask(next));
 -      set_user_asce(next);
 +      __ctl_load(S390_lowcore.user_asce, 7, 7);
  }
  
+ #include <asm-generic/mmu_context.h>
  #endif /* __S390_MMU_CONTEXT_H */
index 054a791573231e242e6bf06b601420921a3d1a9a,36afcbea6a9f411f994b0269b6d5e7bc7a1b9ecb..27516046117a389a80b962579b8c42e6f17e67b9
@@@ -91,12 -91,14 +91,14 @@@ static inline void switch_ldt(struct mm
  }
  #endif
  
+ #define enter_lazy_tlb enter_lazy_tlb
  extern void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk);
  
  /*
   * Init a new mm.  Used on mm copies, like at fork()
   * and on mm's that are brand-new, like at execve().
   */
+ #define init_new_context init_new_context
  static inline int init_new_context(struct task_struct *tsk,
                                   struct mm_struct *mm)
  {
        init_new_context_ldt(mm);
        return 0;
  }
+ #define destroy_context destroy_context
  static inline void destroy_context(struct mm_struct *mm)
  {
        destroy_context_ldt(mm);
@@@ -177,7 -181,7 +181,7 @@@ static inline void arch_exit_mmap(struc
  static inline bool is_64bit_mm(struct mm_struct *mm)
  {
        return  !IS_ENABLED(CONFIG_IA32_EMULATION) ||
 -              !(mm->context.ia32_compat == TIF_IA32);
 +              !(mm->context.flags & MM_CONTEXT_UPROBE_IA32);
  }
  #else
  static inline bool is_64bit_mm(struct mm_struct *mm)
@@@ -214,4 -218,6 +218,6 @@@ static inline bool arch_vma_access_perm
  
  unsigned long __get_current_cr3_fast(void);
  
+ #include <asm-generic/mmu_context.h>
  #endif /* _ASM_X86_MMU_CONTEXT_H */