Lines Matching +full:32 +full:- +full:bit
1 // SPDX-License-Identifier: GPL-2.0+
23 #include <asm/nospec-branch.h>
53 mod->state == MODULE_STATE_LIVE) in module_arch_freeing_init()
56 vfree(mod->arch.syminfo); in module_arch_freeing_init()
57 mod->arch.syminfo = NULL; in module_arch_freeing_init()
64 info = me->arch.syminfo + ELF_R_SYM (rela->r_info); in check_rela()
65 switch (ELF_R_TYPE (rela->r_info)) { in check_rela()
66 case R_390_GOT12: /* 12 bit GOT offset. */ in check_rela()
67 case R_390_GOT16: /* 16 bit GOT offset. */ in check_rela()
68 case R_390_GOT20: /* 20 bit GOT offset. */ in check_rela()
69 case R_390_GOT32: /* 32 bit GOT offset. */ in check_rela()
70 case R_390_GOT64: /* 64 bit GOT offset. */ in check_rela()
71 case R_390_GOTENT: /* 32 bit PC rel. to GOT entry shifted by 1. */ in check_rela()
72 case R_390_GOTPLT12: /* 12 bit offset to jump slot. */ in check_rela()
73 case R_390_GOTPLT16: /* 16 bit offset to jump slot. */ in check_rela()
74 case R_390_GOTPLT20: /* 20 bit offset to jump slot. */ in check_rela()
75 case R_390_GOTPLT32: /* 32 bit offset to jump slot. */ in check_rela()
76 case R_390_GOTPLT64: /* 64 bit offset to jump slot. */ in check_rela()
77 case R_390_GOTPLTENT: /* 32 bit rel. offset to jump slot >> 1. */ in check_rela()
78 if (info->got_offset == -1UL) { in check_rela()
79 info->got_offset = me->arch.got_size; in check_rela()
80 me->arch.got_size += sizeof(void*); in check_rela()
83 case R_390_PLT16DBL: /* 16 bit PC rel. PLT shifted by 1. */ in check_rela()
84 case R_390_PLT32DBL: /* 32 bit PC rel. PLT shifted by 1. */ in check_rela()
85 case R_390_PLT32: /* 32 bit PC relative PLT address. */ in check_rela()
86 case R_390_PLT64: /* 64 bit PC relative PLT address. */ in check_rela()
87 case R_390_PLTOFF16: /* 16 bit offset from GOT to PLT. */ in check_rela()
88 case R_390_PLTOFF32: /* 32 bit offset from GOT to PLT. */ in check_rela()
89 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */ in check_rela()
90 if (info->plt_offset == -1UL) { in check_rela()
91 info->plt_offset = me->arch.plt_size; in check_rela()
92 me->arch.plt_size += PLT_ENTRY_SIZE; in check_rela()
100 modules linked with -shared. */ in check_rela()
120 for (i = 0; i < hdr->e_shnum; i++) in module_frob_arch_sections()
127 printk(KERN_ERR "module %s: no symbol table\n", me->name); in module_frob_arch_sections()
128 return -ENOEXEC; in module_frob_arch_sections()
132 me->arch.nsyms = symtab->sh_size / sizeof(Elf_Sym); in module_frob_arch_sections()
133 me->arch.syminfo = vmalloc(array_size(sizeof(struct mod_arch_syminfo), in module_frob_arch_sections()
134 me->arch.nsyms)); in module_frob_arch_sections()
135 if (!me->arch.syminfo) in module_frob_arch_sections()
136 return -ENOMEM; in module_frob_arch_sections()
137 symbols = (void *) hdr + symtab->sh_offset; in module_frob_arch_sections()
138 strings = (void *) hdr + sechdrs[symtab->sh_link].sh_offset; in module_frob_arch_sections()
139 for (i = 0; i < me->arch.nsyms; i++) { in module_frob_arch_sections()
145 me->arch.syminfo[i].got_offset = -1UL; in module_frob_arch_sections()
146 me->arch.syminfo[i].plt_offset = -1UL; in module_frob_arch_sections()
147 me->arch.syminfo[i].got_initialized = 0; in module_frob_arch_sections()
148 me->arch.syminfo[i].plt_initialized = 0; in module_frob_arch_sections()
152 me->arch.got_size = me->arch.plt_size = 0; in module_frob_arch_sections()
153 for (i = 0; i < hdr->e_shnum; i++) { in module_frob_arch_sections()
164 me->core_layout.size = ALIGN(me->core_layout.size, 4); in module_frob_arch_sections()
165 me->arch.got_offset = me->core_layout.size; in module_frob_arch_sections()
166 me->core_layout.size += me->arch.got_size; in module_frob_arch_sections()
167 me->arch.plt_offset = me->core_layout.size; in module_frob_arch_sections()
168 if (me->arch.plt_size) { in module_frob_arch_sections()
170 me->arch.plt_size += PLT_ENTRY_SIZE; in module_frob_arch_sections()
171 me->core_layout.size += me->arch.plt_size; in module_frob_arch_sections()
182 if (val & ((1UL << shift) - 1)) in apply_rela_bits()
183 return -ENOEXEC; in apply_rela_bits()
186 min = -(1L << (bits - 1)); in apply_rela_bits()
187 max = (1L << (bits - 1)) - 1; in apply_rela_bits()
189 return -ENOEXEC; in apply_rela_bits()
192 umax = ((1UL << (bits - 1)) << 1) - 1; in apply_rela_bits()
194 return -ENOEXEC; in apply_rela_bits()
208 else if (bits == 32) in apply_rela_bits()
221 int rc = -ENOEXEC; in apply_rela()
224 loc = base + rela->r_offset; in apply_rela()
227 r_sym = ELF_R_SYM(rela->r_info); in apply_rela()
228 r_type = ELF_R_TYPE(rela->r_info); in apply_rela()
229 info = me->arch.syminfo + r_sym; in apply_rela()
236 case R_390_8: /* Direct 8 bit. */ in apply_rela()
237 case R_390_12: /* Direct 12 bit. */ in apply_rela()
238 case R_390_16: /* Direct 16 bit. */ in apply_rela()
239 case R_390_20: /* Direct 20 bit. */ in apply_rela()
240 case R_390_32: /* Direct 32 bit. */ in apply_rela()
241 case R_390_64: /* Direct 64 bit. */ in apply_rela()
242 val += rela->r_addend; in apply_rela()
252 rc = apply_rela_bits(loc, val, 0, 32, 0); in apply_rela()
256 case R_390_PC16: /* PC relative 16 bit. */ in apply_rela()
257 case R_390_PC16DBL: /* PC relative 16 bit shifted by 1. */ in apply_rela()
258 case R_390_PC32DBL: /* PC relative 32 bit shifted by 1. */ in apply_rela()
259 case R_390_PC32: /* PC relative 32 bit. */ in apply_rela()
260 case R_390_PC64: /* PC relative 64 bit. */ in apply_rela()
261 val += rela->r_addend - loc; in apply_rela()
267 rc = apply_rela_bits(loc, val, 1, 32, 1); in apply_rela()
269 rc = apply_rela_bits(loc, val, 1, 32, 0); in apply_rela()
273 case R_390_GOT12: /* 12 bit GOT offset. */ in apply_rela()
274 case R_390_GOT16: /* 16 bit GOT offset. */ in apply_rela()
275 case R_390_GOT20: /* 20 bit GOT offset. */ in apply_rela()
276 case R_390_GOT32: /* 32 bit GOT offset. */ in apply_rela()
277 case R_390_GOT64: /* 64 bit GOT offset. */ in apply_rela()
278 case R_390_GOTENT: /* 32 bit PC rel. to GOT entry shifted by 1. */ in apply_rela()
279 case R_390_GOTPLT12: /* 12 bit offset to jump slot. */ in apply_rela()
280 case R_390_GOTPLT20: /* 20 bit offset to jump slot. */ in apply_rela()
281 case R_390_GOTPLT16: /* 16 bit offset to jump slot. */ in apply_rela()
282 case R_390_GOTPLT32: /* 32 bit offset to jump slot. */ in apply_rela()
283 case R_390_GOTPLT64: /* 64 bit offset to jump slot. */ in apply_rela()
284 case R_390_GOTPLTENT: /* 32 bit rel. offset to jump slot >> 1. */ in apply_rela()
285 if (info->got_initialized == 0) { in apply_rela()
288 gotent = me->core_layout.base + me->arch.got_offset + in apply_rela()
289 info->got_offset; in apply_rela()
291 info->got_initialized = 1; in apply_rela()
293 val = info->got_offset + rela->r_addend; in apply_rela()
305 rc = apply_rela_bits(loc, val, 0, 32, 0); in apply_rela()
311 val += (Elf_Addr) me->core_layout.base - loc; in apply_rela()
312 rc = apply_rela_bits(loc, val, 1, 32, 1); in apply_rela()
315 case R_390_PLT16DBL: /* 16 bit PC rel. PLT shifted by 1. */ in apply_rela()
316 case R_390_PLT32DBL: /* 32 bit PC rel. PLT shifted by 1. */ in apply_rela()
317 case R_390_PLT32: /* 32 bit PC relative PLT address. */ in apply_rela()
318 case R_390_PLT64: /* 64 bit PC relative PLT address. */ in apply_rela()
319 case R_390_PLTOFF16: /* 16 bit offset from GOT to PLT. */ in apply_rela()
320 case R_390_PLTOFF32: /* 32 bit offset from GOT to PLT. */ in apply_rela()
321 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */ in apply_rela()
322 if (info->plt_initialized == 0) { in apply_rela()
324 ip = me->core_layout.base + me->arch.plt_offset + in apply_rela()
325 info->plt_offset; in apply_rela()
330 ij = me->core_layout.base + in apply_rela()
331 me->arch.plt_offset + in apply_rela()
332 me->arch.plt_size - PLT_ENTRY_SIZE; in apply_rela()
335 (((unsigned long) ij - 8 - in apply_rela()
340 ip[3] = (unsigned int) (val >> 32); in apply_rela()
342 info->plt_initialized = 1; in apply_rela()
347 val = me->arch.plt_offset - me->arch.got_offset + in apply_rela()
348 info->plt_offset + rela->r_addend; in apply_rela()
351 val - loc + 0xffffUL < 0x1ffffeUL) || in apply_rela()
353 val - loc + 0xffffffffULL < 0x1fffffffeULL))) in apply_rela()
354 val = (Elf_Addr) me->core_layout.base + in apply_rela()
355 me->arch.plt_offset + in apply_rela()
356 info->plt_offset; in apply_rela()
357 val += rela->r_addend - loc; in apply_rela()
364 rc = apply_rela_bits(loc, val, 1, 32, 1); in apply_rela()
367 rc = apply_rela_bits(loc, val, 0, 32, 0); in apply_rela()
372 case R_390_GOTOFF16: /* 16 bit offset to GOT. */ in apply_rela()
373 case R_390_GOTOFF32: /* 32 bit offset to GOT. */ in apply_rela()
374 case R_390_GOTOFF64: /* 64 bit offset to GOT. */ in apply_rela()
375 val = val + rela->r_addend - in apply_rela()
376 ((Elf_Addr) me->core_layout.base + me->arch.got_offset); in apply_rela()
380 rc = apply_rela_bits(loc, val, 0, 32, 0); in apply_rela()
384 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */ in apply_rela()
385 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */ in apply_rela()
386 val = (Elf_Addr) me->core_layout.base + me->arch.got_offset + in apply_rela()
387 rela->r_addend - loc; in apply_rela()
389 rc = apply_rela_bits(loc, val, 1, 32, 0); in apply_rela()
391 rc = apply_rela_bits(loc, val, 1, 32, 1); in apply_rela()
398 modules linked with -shared. */ in apply_rela()
399 return -ENOEXEC; in apply_rela()
402 me->name, r_type); in apply_rela()
403 return -ENOEXEC; in apply_rela()
408 me->name, strtab + symtab[r_sym].st_name, in apply_rela()
449 !nospec_disable && me->arch.plt_size) { in module_finalize()
452 ij = me->core_layout.base + me->arch.plt_offset + in module_finalize()
453 me->arch.plt_size - PLT_ENTRY_SIZE; in module_finalize()
465 secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; in module_finalize()
466 for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) { in module_finalize()
467 aseg = (void *) s->sh_addr; in module_finalize()
468 secname = secstrings + s->sh_name; in module_finalize()
472 apply_alternatives(aseg, aseg + s->sh_size); in module_finalize()
476 nospec_revert(aseg, aseg + s->sh_size); in module_finalize()
480 nospec_revert(aseg, aseg + s->sh_size); in module_finalize()