~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/sparc/kernel/module.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/sparc/kernel/module.c (Version linux-6.12-rc7) and /arch/ppc/kernel/module.c (Version linux-5.4.285)


  1 // SPDX-License-Identifier: GPL-2.0                 1 
  2 /* Kernel module help for sparc64.                
  3  *                                                
  4  * Copyright (C) 2001 Rusty Russell.              
  5  * Copyright (C) 2002 David S. Miller.            
  6  */                                               
  7                                                   
  8 #include <linux/moduleloader.h>                   
  9 #include <linux/kernel.h>                         
 10 #include <linux/elf.h>                            
 11 #include <linux/vmalloc.h>                        
 12 #include <linux/fs.h>                             
 13 #include <linux/gfp.h>                            
 14 #include <linux/string.h>                         
 15 #include <linux/ctype.h>                          
 16 #include <linux/mm.h>                             
 17                                                   
 18 #include <asm/processor.h>                        
 19 #include <asm/spitfire.h>                         
 20 #include <asm/cacheflush.h>                       
 21                                                   
 22 #include "entry.h"                                
 23                                                   
 24 /* Make generic code ignore STT_REGISTER dummy    
 25 int module_frob_arch_sections(Elf_Ehdr *hdr,      
 26                               Elf_Shdr *sechdr    
 27                               char *secstrings    
 28                               struct module *m    
 29 {                                                 
 30         unsigned int symidx;                      
 31         Elf_Sym *sym;                             
 32         char *strtab;                             
 33         int i;                                    
 34                                                   
 35         for (symidx = 0; sechdrs[symidx].sh_ty    
 36                 if (symidx == hdr->e_shnum-1)     
 37                         printk("%s: no symtab     
 38                         return -ENOEXEC;          
 39                 }                                 
 40         }                                         
 41         sym = (Elf_Sym *)sechdrs[symidx].sh_ad    
 42         strtab = (char *)sechdrs[sechdrs[symid    
 43                                                   
 44         for (i = 1; i < sechdrs[symidx].sh_siz    
 45                 if (sym[i].st_shndx == SHN_UND    
 46                         if (ELF_ST_TYPE(sym[i]    
 47                                 sym[i].st_shnd    
 48                 }                                 
 49         }                                         
 50         return 0;                                 
 51 }                                                 
 52                                                   
 53 int apply_relocate_add(Elf_Shdr *sechdrs,         
 54                        const char *strtab,        
 55                        unsigned int symindex,     
 56                        unsigned int relsec,       
 57                        struct module *me)         
 58 {                                                 
 59         unsigned int i;                           
 60         Elf_Rela *rel = (void *)sechdrs[relsec    
 61         Elf_Sym *sym;                             
 62         u8 *location;                             
 63         u32 *loc32;                               
 64                                                   
 65         for (i = 0; i < sechdrs[relsec].sh_siz    
 66                 Elf_Addr v;                       
 67                                                   
 68                 /* This is where to make the c    
 69                 location = (u8 *)sechdrs[sechd    
 70                         + rel[i].r_offset;        
 71                 loc32 = (u32 *) location;         
 72                                                   
 73 #ifdef CONFIG_SPARC64                             
 74                 BUG_ON(((u64)location >> (u64)    
 75 #endif /* CONFIG_SPARC64 */                       
 76                                                   
 77                 /* This is the symbol it is re    
 78                    undefined symbols have been    
 79                 sym = (Elf_Sym *)sechdrs[symin    
 80                         + ELF_R_SYM(rel[i].r_i    
 81                 v = sym->st_value + rel[i].r_a    
 82                                                   
 83                 switch (ELF_R_TYPE(rel[i].r_in    
 84                 case R_SPARC_DISP32:              
 85                         v -= (Elf_Addr) locati    
 86                         *loc32 = v;               
 87                         break;                    
 88 #ifdef CONFIG_SPARC64                             
 89                 case R_SPARC_64:                  
 90                         location[0] = v >> 56;    
 91                         location[1] = v >> 48;    
 92                         location[2] = v >> 40;    
 93                         location[3] = v >> 32;    
 94                         location[4] = v >> 24;    
 95                         location[5] = v >> 16;    
 96                         location[6] = v >>  8;    
 97                         location[7] = v >>  0;    
 98                         break;                    
 99                                                   
100                 case R_SPARC_WDISP19:             
101                         v -= (Elf_Addr) locati    
102                         *loc32 = (*loc32 & ~0x    
103                                 ((v >> 2) & 0x    
104                         break;                    
105                                                   
106                 case R_SPARC_OLO10:               
107                         *loc32 = (*loc32 & ~0x    
108                                 (((v & 0x3ff)     
109                                   (ELF_R_TYPE(    
110                                  & 0x1fff);       
111                         break;                    
112 #endif /* CONFIG_SPARC64 */                       
113                                                   
114                 case R_SPARC_32:                  
115                 case R_SPARC_UA32:                
116                         location[0] = v >> 24;    
117                         location[1] = v >> 16;    
118                         location[2] = v >>  8;    
119                         location[3] = v >>  0;    
120                         break;                    
121                                                   
122                 case R_SPARC_WDISP30:             
123                         v -= (Elf_Addr) locati    
124                         *loc32 = (*loc32 & ~0x    
125                                 ((v >> 2) & 0x    
126                         break;                    
127                                                   
128                 case R_SPARC_WDISP22:             
129                         v -= (Elf_Addr) locati    
130                         *loc32 = (*loc32 & ~0x    
131                                 ((v >> 2) & 0x    
132                         break;                    
133                                                   
134                 case R_SPARC_LO10:                
135                         *loc32 = (*loc32 & ~0x    
136                         break;                    
137                                                   
138                 case R_SPARC_HI22:                
139                         *loc32 = (*loc32 & ~0x    
140                                 ((v >> 10) & 0    
141                         break;                    
142                                                   
143                 default:                          
144                         printk(KERN_ERR "modul    
145                                me->name,          
146                                (int) (ELF_R_TY    
147                         return -ENOEXEC;          
148                 }                                 
149         }                                         
150         return 0;                                 
151 }                                                 
152                                                   
153 #ifdef CONFIG_SPARC64                             
154 static void do_patch_sections(const Elf_Ehdr *    
155                               const Elf_Shdr *    
156 {                                                 
157         const Elf_Shdr *s, *sun4v_1insn = NULL    
158         char *secstrings = (void *)hdr + sechd    
159                                                   
160         for (s = sechdrs; s < sechdrs + hdr->e    
161                 if (!strcmp(".sun4v_1insn_patc    
162                         sun4v_1insn = s;          
163                 if (!strcmp(".sun4v_2insn_patc    
164                         sun4v_2insn = s;          
165         }                                         
166                                                   
167         if (sun4v_1insn && tlb_type == hypervi    
168                 void *p = (void *) sun4v_1insn    
169                 sun4v_patch_1insn_range(p, p +    
170         }                                         
171         if (sun4v_2insn && tlb_type == hypervi    
172                 void *p = (void *) sun4v_2insn    
173                 sun4v_patch_2insn_range(p, p +    
174         }                                         
175 }                                                 
176                                                   
177 int module_finalize(const Elf_Ehdr *hdr,          
178                     const Elf_Shdr *sechdrs,      
179                     struct module *me)            
180 {                                                 
181         do_patch_sections(hdr, sechdrs);          
182                                                   
183         /* Cheetah's I-cache is fully coherent    
184         if (tlb_type == spitfire) {               
185                 unsigned long va;                 
186                                                   
187                 flushw_all();                     
188                 for (va =  0; va < (PAGE_SIZE     
189                         spitfire_put_icache_ta    
190                 __asm__ __volatile__("flush %g    
191         }                                         
192                                                   
193         return 0;                                 
194 }                                                 
195 #endif /* CONFIG_SPARC64 */                       
196                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php