1*6b0ef279SArd Biesheuvel // SPDX-License-Identifier: GPL-2.0-only 2*6b0ef279SArd Biesheuvel // Copyright 2024 Google LLC 3*6b0ef279SArd Biesheuvel // Author: Ard Biesheuvel <ardb@google.com> 4*6b0ef279SArd Biesheuvel 5*6b0ef279SArd Biesheuvel #include <linux/types.h> 6*6b0ef279SArd Biesheuvel #include <asm/tlbflush.h> 7*6b0ef279SArd Biesheuvel 8*6b0ef279SArd Biesheuvel #ifdef CONFIG_CPU_TLB_V4WT 9*6b0ef279SArd Biesheuvel void v4_flush_user_tlb_range(unsigned long, unsigned long, struct vm_area_struct *); 10*6b0ef279SArd Biesheuvel void v4_flush_kern_tlb_range(unsigned long, unsigned long); 11*6b0ef279SArd Biesheuvel 12*6b0ef279SArd Biesheuvel struct cpu_tlb_fns v4_tlb_fns __initconst = { 13*6b0ef279SArd Biesheuvel .flush_user_range = v4_flush_user_tlb_range, 14*6b0ef279SArd Biesheuvel .flush_kern_range = v4_flush_kern_tlb_range, 15*6b0ef279SArd Biesheuvel .tlb_flags = v4_tlb_flags, 16*6b0ef279SArd Biesheuvel }; 17*6b0ef279SArd Biesheuvel #endif 18*6b0ef279SArd Biesheuvel 19*6b0ef279SArd Biesheuvel #ifdef CONFIG_CPU_TLB_V4WB 20*6b0ef279SArd Biesheuvel void v4wb_flush_user_tlb_range(unsigned long, unsigned long, struct vm_area_struct *); 21*6b0ef279SArd Biesheuvel void v4wb_flush_kern_tlb_range(unsigned long, unsigned long); 22*6b0ef279SArd Biesheuvel 23*6b0ef279SArd Biesheuvel struct cpu_tlb_fns v4wb_tlb_fns __initconst = { 24*6b0ef279SArd Biesheuvel .flush_user_range = v4wb_flush_user_tlb_range, 25*6b0ef279SArd Biesheuvel .flush_kern_range = v4wb_flush_kern_tlb_range, 26*6b0ef279SArd Biesheuvel .tlb_flags = v4wb_tlb_flags, 27*6b0ef279SArd Biesheuvel }; 28*6b0ef279SArd Biesheuvel #endif 29*6b0ef279SArd Biesheuvel 30*6b0ef279SArd Biesheuvel #if defined(CONFIG_CPU_TLB_V4WBI) || defined(CONFIG_CPU_TLB_FEROCEON) 31*6b0ef279SArd Biesheuvel void v4wbi_flush_user_tlb_range(unsigned long, unsigned long, struct vm_area_struct *); 32*6b0ef279SArd Biesheuvel void v4wbi_flush_kern_tlb_range(unsigned long, unsigned long); 33*6b0ef279SArd Biesheuvel 34*6b0ef279SArd Biesheuvel struct cpu_tlb_fns v4wbi_tlb_fns __initconst = { 35*6b0ef279SArd Biesheuvel .flush_user_range = v4wbi_flush_user_tlb_range, 36*6b0ef279SArd Biesheuvel .flush_kern_range = v4wbi_flush_kern_tlb_range, 37*6b0ef279SArd Biesheuvel .tlb_flags = v4wbi_tlb_flags, 38*6b0ef279SArd Biesheuvel }; 39*6b0ef279SArd Biesheuvel #endif 40*6b0ef279SArd Biesheuvel 41*6b0ef279SArd Biesheuvel #ifdef CONFIG_CPU_TLB_V6 42*6b0ef279SArd Biesheuvel void v6wbi_flush_user_tlb_range(unsigned long, unsigned long, struct vm_area_struct *); 43*6b0ef279SArd Biesheuvel void v6wbi_flush_kern_tlb_range(unsigned long, unsigned long); 44*6b0ef279SArd Biesheuvel 45*6b0ef279SArd Biesheuvel struct cpu_tlb_fns v6wbi_tlb_fns __initconst = { 46*6b0ef279SArd Biesheuvel .flush_user_range = v6wbi_flush_user_tlb_range, 47*6b0ef279SArd Biesheuvel .flush_kern_range = v6wbi_flush_kern_tlb_range, 48*6b0ef279SArd Biesheuvel .tlb_flags = v6wbi_tlb_flags, 49*6b0ef279SArd Biesheuvel }; 50*6b0ef279SArd Biesheuvel #endif 51*6b0ef279SArd Biesheuvel 52*6b0ef279SArd Biesheuvel #ifdef CONFIG_CPU_TLB_V7 53*6b0ef279SArd Biesheuvel void v7wbi_flush_user_tlb_range(unsigned long, unsigned long, struct vm_area_struct *); 54*6b0ef279SArd Biesheuvel void v7wbi_flush_kern_tlb_range(unsigned long, unsigned long); 55*6b0ef279SArd Biesheuvel 56*6b0ef279SArd Biesheuvel struct cpu_tlb_fns v7wbi_tlb_fns __initconst = { 57*6b0ef279SArd Biesheuvel .flush_user_range = v7wbi_flush_user_tlb_range, 58*6b0ef279SArd Biesheuvel .flush_kern_range = v7wbi_flush_kern_tlb_range, 59*6b0ef279SArd Biesheuvel .tlb_flags = IS_ENABLED(CONFIG_SMP) ? v7wbi_tlb_flags_smp 60*6b0ef279SArd Biesheuvel : v7wbi_tlb_flags_up, 61*6b0ef279SArd Biesheuvel }; 62*6b0ef279SArd Biesheuvel 63*6b0ef279SArd Biesheuvel #ifdef CONFIG_SMP_ON_UP 64*6b0ef279SArd Biesheuvel /* This will be run-time patched so the offset better be right */ 65*6b0ef279SArd Biesheuvel static_assert(offsetof(struct cpu_tlb_fns, tlb_flags) == 8); 66*6b0ef279SArd Biesheuvel 67*6b0ef279SArd Biesheuvel asm(" .pushsection \".alt.smp.init\", \"a\" \n" \ 68*6b0ef279SArd Biesheuvel " .align 2 \n" \ 69*6b0ef279SArd Biesheuvel " .long v7wbi_tlb_fns + 8 - . \n" \ 70*6b0ef279SArd Biesheuvel " .long " __stringify(v7wbi_tlb_flags_up) " \n" \ 71*6b0ef279SArd Biesheuvel " .popsection \n"); 72*6b0ef279SArd Biesheuvel #endif 73*6b0ef279SArd Biesheuvel #endif 74*6b0ef279SArd Biesheuvel 75*6b0ef279SArd Biesheuvel #ifdef CONFIG_CPU_TLB_FA 76*6b0ef279SArd Biesheuvel void fa_flush_user_tlb_range(unsigned long, unsigned long, struct vm_area_struct *); 77*6b0ef279SArd Biesheuvel void fa_flush_kern_tlb_range(unsigned long, unsigned long); 78*6b0ef279SArd Biesheuvel 79*6b0ef279SArd Biesheuvel struct cpu_tlb_fns fa_tlb_fns __initconst = { 80*6b0ef279SArd Biesheuvel .flush_user_range = fa_flush_user_tlb_range, 81*6b0ef279SArd Biesheuvel .flush_kern_range = fa_flush_kern_tlb_range, 82*6b0ef279SArd Biesheuvel .tlb_flags = fa_tlb_flags, 83*6b0ef279SArd Biesheuvel }; 84*6b0ef279SArd Biesheuvel #endif 85