| target/linux/cobalt/patches/001-no_module_reloc.patch |
| 1 | | +++ b/arch/mips/Makefile |
| 2 | | @@ -83,7 +83,7 @@ all-$(CONFIG_BOOT_ELF64) := $(vmlinux-64 |
| 1 | diff -urN linux-2.6.30.10/arch/mips/Makefile linux-2.6.30.10.new//arch/mips/Makefile |
| 2 | --- linux-2.6.30.10/arch/mips/Makefile 2010-01-29 16:12:01.000000000 +0100 |
| 3 | @@ -83,7 +83,7 @@ |
| 3 | 4 | cflags-y += -G 0 -mno-abicalls -fno-pic -pipe |
| 4 | 5 | cflags-y += -msoft-float |
| 5 | 6 | LDFLAGS_vmlinux += -G 0 -static -n -nostdlib |
| ... | ... | |
| 9 | 10 | |
| 10 | 11 | cflags-y += -ffreestanding |
| 11 | 12 | |
| 12 | | +++ b/arch/mips/include/asm/module.h |
| 13 | | @@ -9,11 +9,6 @@ struct mod_arch_specific { |
| 13 | diff -urN linux-2.6.30.10/arch/mips/include/asm/module.h linux-2.6.30.10.new//arch/mips/include/asm/module.h |
| 14 | --- linux-2.6.30.10/arch/mips/include/asm/module.h 2010-01-29 16:12:01.000000000 +0100 |
| 15 | @@ -9,11 +9,6 @@ |
| 14 | 16 | struct list_head dbe_list; |
| 15 | 17 | const struct exception_table_entry *dbe_start; |
| 16 | 18 | const struct exception_table_entry *dbe_end; |
| 17 | 19 | - |
| 18 | | - void *plt_tbl; |
| 19 | | - unsigned int core_plt_offset; |
| 20 | | - unsigned int core_plt_size; |
| 21 | | - unsigned int init_plt_offset; |
| 20 | - void *phys_plt_tbl; |
| 21 | - void *virt_plt_tbl; |
| 22 | - unsigned int phys_plt_offset; |
| 23 | - unsigned int virt_plt_offset; |
| 22 | 24 | }; |
| 23 | 25 | |
| 24 | 26 | typedef uint8_t Elf64_Byte; /* Type for a 8-bit quantity. */ |
| 25 | | +++ b/arch/mips/kernel/module.c |
| 26 | | @@ -43,116 +43,6 @@ static struct mips_hi16 *mips_hi16_list; |
| 27 | diff -urN linux-2.6.30.10/arch/mips/kernel/module.c linux-2.6.30.10.new//arch/mips/kernel/module.c |
| 28 | --- linux-2.6.30.10/arch/mips/kernel/module.c 2010-01-29 16:12:01.000000000 +0100 |
| 29 | @@ -43,116 +43,6 @@ |
| 27 | 30 | static LIST_HEAD(dbe_list); |
| 28 | 31 | static DEFINE_SPINLOCK(dbe_lock); |
| 29 | 32 | |
| ... | ... | |
| 142 | 145 | void *module_alloc(unsigned long size) |
| 143 | 146 | { |
| 144 | 147 | #ifdef MODULE_START |
| 145 | | @@ -168,45 +58,16 @@ void *module_alloc(unsigned long size) |
| 148 | @@ -168,101 +58,23 @@ |
| 146 | 149 | |
| 147 | 150 | return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL); |
| 148 | 151 | #else |
| ... | ... | |
| 190 | 193 | /* FIXME: If module_region == mod->init_region, trim exception |
| 191 | 194 | table entries. */ |
| 192 | 195 | } |
| 193 | | @@ -214,24 +75,6 @@ void module_free(struct module *mod, voi |
| 196 | |
| 197 | -static void *__module_alloc(int size, bool phys) |
| 198 | -{ |
| 199 | - void *ptr; |
| 200 | - |
| 201 | - if (phys) |
| 202 | - ptr = kmalloc(size, GFP_KERNEL); |
| 203 | - else |
| 204 | - ptr = vmalloc(size); |
| 205 | - return ptr; |
| 206 | -} |
| 207 | - |
| 208 | -static void __module_free(void *ptr) |
| 209 | -{ |
| 210 | - if (is_phys_addr(ptr)) |
| 211 | - kfree(ptr); |
| 212 | - else |
| 213 | - vfree(ptr); |
| 214 | -} |
| 215 | - |
| 194 | 216 | int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, |
| 195 | 217 | char *secstrings, struct module *mod) |
| 196 | 218 | { |
| ... | ... | |
| 205 | 227 | - core_size = get_plt_size(hdr, sechdrs, secstrings, symindex, false); |
| 206 | 228 | - init_size = get_plt_size(hdr, sechdrs, secstrings, symindex, true); |
| 207 | 229 | - |
| 208 | | - mod->arch.core_plt_offset = 0; |
| 209 | | - mod->arch.core_plt_size = core_size; |
| 210 | | - mod->arch.init_plt_offset = core_size; |
| 211 | | - mod->arch.plt_tbl = kmalloc(core_size + init_size, GFP_KERNEL); |
| 212 | | - if (!mod->arch.plt_tbl) |
| 230 | - mod->arch.phys_plt_offset = 0; |
| 231 | - mod->arch.virt_plt_offset = 0; |
| 232 | - mod->arch.phys_plt_tbl = NULL; |
| 233 | - mod->arch.virt_plt_tbl = NULL; |
| 234 | - |
| 235 | - if ((core_size + init_size) == 0) |
| 236 | - return 0; |
| 237 | - |
| 238 | - mod->arch.phys_plt_tbl = __module_alloc(core_size + init_size, 1); |
| 239 | - if (!mod->arch.phys_plt_tbl) |
| 213 | 240 | - return -ENOMEM; |
| 214 | 241 | - |
| 242 | - mod->arch.virt_plt_tbl = __module_alloc(core_size + init_size, 0); |
| 243 | - if (!mod->arch.virt_plt_tbl) { |
| 244 | - __module_free(mod->arch.phys_plt_tbl); |
| 245 | - mod->arch.phys_plt_tbl = NULL; |
| 246 | - return -ENOMEM; |
| 247 | - } |
| 248 | - |
| 215 | 249 | return 0; |
| 216 | 250 | } |
| 217 | 251 | |
| 218 | | @@ -254,41 +97,27 @@ static int apply_r_mips_32_rela(struct m |
| 252 | @@ -285,37 +97,27 @@ |
| 219 | 253 | return 0; |
| 220 | 254 | } |
| 221 | 255 | |
| ... | ... | |
| 235 | 269 | - tramp[1] = 0x27390000 | (v & 0xffff); /* addiu t9, t9, lo16 */ |
| 236 | 270 | - tramp[2] = 0x03200008; /* jr t9 */ |
| 237 | 271 | - tramp[3] = 0x00000000; /* nop */ |
| 238 | | - |
| 239 | | - return (Elf_Addr) tramp; |
| 240 | | -} |
| 241 | 272 | + if (v % 4) { |
| 242 | 273 | + printk(KERN_ERR "module %s: dangerous relocation\n", me->name); |
| 243 | 274 | + return -ENOEXEC; |
| 244 | 275 | + } |
| 245 | 276 | |
| 246 | | -static Elf_Addr add_plt_entry(struct module *me, void *location, Elf_Addr v) |
| 247 | | -{ |
| 248 | | - if (location >= me->module_core && |
| 249 | | - location < me->module_core + me->core_size) |
| 250 | | - return add_plt_entry_to(&me->arch.core_plt_offset, |
| 251 | | - me->arch.plt_tbl, v); |
| 277 | - return (Elf_Addr) tramp; |
| 278 | -} |
| 252 | 279 | + if ((v & 0xf0000000) != (((unsigned long)location + 4) & 0xf0000000)) { |
| 253 | 280 | + printk(KERN_ERR |
| 254 | 281 | + "module %s: relocation overflow\n", |
| ... | ... | |
| 256 | 283 | + return -ENOEXEC; |
| 257 | 284 | + } |
| 258 | 285 | |
| 259 | | - if (location >= me->module_init && |
| 260 | | - location < me->module_init + me->init_size) |
| 261 | | - return add_plt_entry_to(&me->arch.init_plt_offset, |
| 262 | | - me->arch.plt_tbl, v); |
| 286 | -static Elf_Addr add_plt_entry(struct module *me, void *location, Elf_Addr v) |
| 287 | -{ |
| 288 | - if (is_phys_addr(location)) |
| 289 | - return add_plt_entry_to(&me->arch.phys_plt_offset, |
| 290 | - me->arch.phys_plt_tbl, v); |
| 291 | - else |
| 292 | - return add_plt_entry_to(&me->arch.virt_plt_offset, |
| 293 | - me->arch.virt_plt_tbl, v); |
| 263 | 294 | + *location = (*location & ~0x03ffffff) | |
| 264 | 295 | + ((*location + (v >> 2)) & 0x03ffffff); |
| 265 | 296 | |
| 266 | | return 0; |
| 297 | + return 0; |
| 267 | 298 | } |
| 268 | 299 | |
| 269 | 300 | -static int set_r_mips_26(struct module *me, u32 *location, u32 ofs, Elf_Addr v) |
| ... | ... | |
| 271 | 302 | { |
| 272 | 303 | if (v % 4) { |
| 273 | 304 | printk(KERN_ERR "module %s: dangerous relocation\n", me->name); |
| 274 | | @@ -296,31 +125,17 @@ static int set_r_mips_26(struct module * |
| 305 | @@ -323,31 +125,17 @@ |
| 275 | 306 | } |
| 276 | 307 | |
| 277 | 308 | if ((v & 0xf0000000) != (((unsigned long)location + 4) & 0xf0000000)) { |
| ... | ... | |
| 306 | 337 | static int apply_r_mips_hi16_rel(struct module *me, u32 *location, Elf_Addr v) |
| 307 | 338 | { |
| 308 | 339 | struct mips_hi16 *n; |
| 309 | | @@ -585,23 +400,11 @@ int module_finalize(const Elf_Ehdr *hdr, |
| 340 | @@ -612,32 +400,11 @@ |
| 310 | 341 | list_add(&me->arch.dbe_list, &dbe_list); |
| 311 | 342 | spin_unlock_irq(&dbe_lock); |
| 312 | 343 | } |
| 313 | 344 | - |
| 314 | 345 | - /* Get rid of the fixup trampoline if we're running the module |
| 315 | 346 | - * from physically mapped address space */ |
| 316 | | - if (me->arch.core_plt_offset == 0 && |
| 317 | | - me->arch.init_plt_offset == me->arch.core_plt_size && |
| 318 | | - is_phys_addr(me->module_core)) { |
| 319 | | - kfree(me->arch.plt_tbl); |
| 320 | | - me->arch.plt_tbl = NULL; |
| 347 | - if (me->arch.phys_plt_offset == 0) { |
| 348 | - __module_free(me->arch.phys_plt_tbl); |
| 349 | - me->arch.phys_plt_tbl = NULL; |
| 350 | - } |
| 351 | - if (me->arch.virt_plt_offset == 0) { |
| 352 | - __module_free(me->arch.virt_plt_tbl); |
| 353 | - me->arch.virt_plt_tbl = NULL; |
| 321 | 354 | - } |
| 322 | 355 | - |
| 323 | 356 | return 0; |
| ... | ... | |
| 325 | 358 | |
| 326 | 359 | void module_arch_cleanup(struct module *mod) |
| 327 | 360 | { |
| 328 | | - if (mod->arch.plt_tbl) |
| 329 | | - kfree(mod->arch.plt_tbl); |
| 361 | - if (mod->arch.phys_plt_tbl) { |
| 362 | - __module_free(mod->arch.phys_plt_tbl); |
| 363 | - mod->arch.phys_plt_tbl = NULL; |
| 364 | - } |
| 365 | - if (mod->arch.virt_plt_tbl) { |
| 366 | - __module_free(mod->arch.virt_plt_tbl); |
| 367 | - mod->arch.virt_plt_tbl = NULL; |
| 368 | - } |
| 369 | - |
| 330 | 370 | spin_lock_irq(&dbe_lock); |
| 331 | 371 | list_del(&mod->arch.dbe_list); |
| 332 | 372 | spin_unlock_irq(&dbe_lock); |
| target/linux/octeon/patches/106-no_module_reloc.patch |
| 1 | | diff -urN linux-2.6.30.7/arch/mips/Makefile linux-2.6.30.7.new/arch/mips/Makefile |
| 2 | | +++ linux-2.6.30.7.new/arch/mips/Makefile 2009-09-15 19:46:05.000000000 +0200 |
| 1 | diff -urN linux-2.6.30.10/arch/mips/Makefile linux-2.6.30.10.new//arch/mips/Makefile |
| 2 | --- linux-2.6.30.10/arch/mips/Makefile 2010-01-29 16:12:01.000000000 +0100 |
| 3 | 3 | @@ -83,7 +83,7 @@ |
| 4 | 4 | cflags-y += -G 0 -mno-abicalls -fno-pic -pipe |
| 5 | 5 | cflags-y += -msoft-float |
| ... | ... | |
| 10 | 10 | |
| 11 | 11 | cflags-y += -ffreestanding |
| 12 | 12 | |
| 13 | | diff -urN linux-2.6.30.7/arch/mips/include/asm/module.h linux-2.6.30.7.new/arch/mips/include/asm/module.h |
| 14 | | +++ linux-2.6.30.7.new/arch/mips/include/asm/module.h 2009-09-15 19:46:05.000000000 +0200 |
| 13 | diff -urN linux-2.6.30.10/arch/mips/include/asm/module.h linux-2.6.30.10.new//arch/mips/include/asm/module.h |
| 14 | --- linux-2.6.30.10/arch/mips/include/asm/module.h 2010-01-29 16:12:01.000000000 +0100 |
| 15 | 15 | @@ -9,11 +9,6 @@ |
| 16 | 16 | struct list_head dbe_list; |
| 17 | 17 | const struct exception_table_entry *dbe_start; |
| 18 | 18 | const struct exception_table_entry *dbe_end; |
| 19 | 19 | - |
| 20 | | - void *plt_tbl; |
| 21 | | - unsigned int core_plt_offset; |
| 22 | | - unsigned int core_plt_size; |
| 23 | | - unsigned int init_plt_offset; |
| 20 | - void *phys_plt_tbl; |
| 21 | - void *virt_plt_tbl; |
| 22 | - unsigned int phys_plt_offset; |
| 23 | - unsigned int virt_plt_offset; |
| 24 | 24 | }; |
| 25 | 25 | |
| 26 | 26 | typedef uint8_t Elf64_Byte; /* Type for a 8-bit quantity. */ |
| 27 | | diff -urN linux-2.6.30.7/arch/mips/kernel/module.c linux-2.6.30.7.new/arch/mips/kernel/module.c |
| 28 | | +++ linux-2.6.30.7.new/arch/mips/kernel/module.c 2009-09-15 19:46:05.000000000 +0200 |
| 27 | diff -urN linux-2.6.30.10/arch/mips/kernel/module.c linux-2.6.30.10.new//arch/mips/kernel/module.c |
| 28 | --- linux-2.6.30.10/arch/mips/kernel/module.c 2010-01-29 16:12:01.000000000 +0100 |
| 29 | 29 | @@ -43,116 +43,6 @@ |
| 30 | 30 | static LIST_HEAD(dbe_list); |
| 31 | 31 | static DEFINE_SPINLOCK(dbe_lock); |
| ... | ... | |
| 145 | 145 | void *module_alloc(unsigned long size) |
| 146 | 146 | { |
| 147 | 147 | #ifdef MODULE_START |
| 148 | | @@ -168,45 +58,16 @@ |
| 148 | @@ -168,101 +58,23 @@ |
| 149 | 149 | |
| 150 | 150 | return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL); |
| 151 | 151 | #else |
| ... | ... | |
| 193 | 193 | /* FIXME: If module_region == mod->init_region, trim exception |
| 194 | 194 | table entries. */ |
| 195 | 195 | } |
| 196 | | @@ -214,24 +75,6 @@ |
| 196 | |
| 197 | -static void *__module_alloc(int size, bool phys) |
| 198 | -{ |
| 199 | - void *ptr; |
| 200 | - |
| 201 | - if (phys) |
| 202 | - ptr = kmalloc(size, GFP_KERNEL); |
| 203 | - else |
| 204 | - ptr = vmalloc(size); |
| 205 | - return ptr; |
| 206 | -} |
| 207 | - |
| 208 | -static void __module_free(void *ptr) |
| 209 | -{ |
| 210 | - if (is_phys_addr(ptr)) |
| 211 | - kfree(ptr); |
| 212 | - else |
| 213 | - vfree(ptr); |
| 214 | -} |
| 215 | - |
| 197 | 216 | int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, |
| 198 | 217 | char *secstrings, struct module *mod) |
| 199 | 218 | { |
| ... | ... | |
| 208 | 227 | - core_size = get_plt_size(hdr, sechdrs, secstrings, symindex, false); |
| 209 | 228 | - init_size = get_plt_size(hdr, sechdrs, secstrings, symindex, true); |
| 210 | 229 | - |
| 211 | | - mod->arch.core_plt_offset = 0; |
| 212 | | - mod->arch.core_plt_size = core_size; |
| 213 | | - mod->arch.init_plt_offset = core_size; |
| 214 | | - mod->arch.plt_tbl = kmalloc(core_size + init_size, GFP_KERNEL); |
| 215 | | - if (!mod->arch.plt_tbl) |
| 230 | - mod->arch.phys_plt_offset = 0; |
| 231 | - mod->arch.virt_plt_offset = 0; |
| 232 | - mod->arch.phys_plt_tbl = NULL; |
| 233 | - mod->arch.virt_plt_tbl = NULL; |
| 234 | - |
| 235 | - if ((core_size + init_size) == 0) |
| 236 | - return 0; |
| 237 | - |
| 238 | - mod->arch.phys_plt_tbl = __module_alloc(core_size + init_size, 1); |
| 239 | - if (!mod->arch.phys_plt_tbl) |
| 216 | 240 | - return -ENOMEM; |
| 217 | 241 | - |
| 242 | - mod->arch.virt_plt_tbl = __module_alloc(core_size + init_size, 0); |
| 243 | - if (!mod->arch.virt_plt_tbl) { |
| 244 | - __module_free(mod->arch.phys_plt_tbl); |
| 245 | - mod->arch.phys_plt_tbl = NULL; |
| 246 | - return -ENOMEM; |
| 247 | - } |
| 248 | - |
| 218 | 249 | return 0; |
| 219 | 250 | } |
| 220 | 251 | |
| 221 | | @@ -254,41 +97,27 @@ |
| 252 | @@ -285,37 +97,27 @@ |
| 222 | 253 | return 0; |
| 223 | 254 | } |
| 224 | 255 | |
| ... | ... | |
| 238 | 269 | - tramp[1] = 0x27390000 | (v & 0xffff); /* addiu t9, t9, lo16 */ |
| 239 | 270 | - tramp[2] = 0x03200008; /* jr t9 */ |
| 240 | 271 | - tramp[3] = 0x00000000; /* nop */ |
| 241 | | - |
| 242 | | - return (Elf_Addr) tramp; |
| 243 | | -} |
| 244 | 272 | + if (v % 4) { |
| 245 | 273 | + printk(KERN_ERR "module %s: dangerous relocation\n", me->name); |
| 246 | 274 | + return -ENOEXEC; |
| 247 | 275 | + } |
| 248 | 276 | |
| 249 | | -static Elf_Addr add_plt_entry(struct module *me, void *location, Elf_Addr v) |
| 250 | | -{ |
| 251 | | - if (location >= me->module_core && |
| 252 | | - location < me->module_core + me->core_size) |
| 253 | | - return add_plt_entry_to(&me->arch.core_plt_offset, |
| 254 | | - me->arch.plt_tbl, v); |
| 277 | - return (Elf_Addr) tramp; |
| 278 | -} |
| 255 | 279 | + if ((v & 0xf0000000) != (((unsigned long)location + 4) & 0xf0000000)) { |
| 256 | 280 | + printk(KERN_ERR |
| 257 | 281 | + "module %s: relocation overflow\n", |
| ... | ... | |
| 259 | 283 | + return -ENOEXEC; |
| 260 | 284 | + } |
| 261 | 285 | |
| 262 | | - if (location >= me->module_init && |
| 263 | | - location < me->module_init + me->init_size) |
| 264 | | - return add_plt_entry_to(&me->arch.init_plt_offset, |
| 265 | | - me->arch.plt_tbl, v); |
| 286 | -static Elf_Addr add_plt_entry(struct module *me, void *location, Elf_Addr v) |
| 287 | -{ |
| 288 | - if (is_phys_addr(location)) |
| 289 | - return add_plt_entry_to(&me->arch.phys_plt_offset, |
| 290 | - me->arch.phys_plt_tbl, v); |
| 291 | - else |
| 292 | - return add_plt_entry_to(&me->arch.virt_plt_offset, |
| 293 | - me->arch.virt_plt_tbl, v); |
| 266 | 294 | + *location = (*location & ~0x03ffffff) | |
| 267 | 295 | + ((*location + (v >> 2)) & 0x03ffffff); |
| 268 | 296 | |
| 269 | | return 0; |
| 297 | + return 0; |
| 270 | 298 | } |
| 271 | 299 | |
| 272 | 300 | -static int set_r_mips_26(struct module *me, u32 *location, u32 ofs, Elf_Addr v) |
| ... | ... | |
| 274 | 302 | { |
| 275 | 303 | if (v % 4) { |
| 276 | 304 | printk(KERN_ERR "module %s: dangerous relocation\n", me->name); |
| 277 | | @@ -296,31 +125,17 @@ |
| 305 | @@ -323,31 +125,17 @@ |
| 278 | 306 | } |
| 279 | 307 | |
| 280 | 308 | if ((v & 0xf0000000) != (((unsigned long)location + 4) & 0xf0000000)) { |
| ... | ... | |
| 309 | 337 | static int apply_r_mips_hi16_rel(struct module *me, u32 *location, Elf_Addr v) |
| 310 | 338 | { |
| 311 | 339 | struct mips_hi16 *n; |
| 312 | | @@ -585,23 +400,11 @@ |
| 340 | @@ -612,32 +400,11 @@ |
| 313 | 341 | list_add(&me->arch.dbe_list, &dbe_list); |
| 314 | 342 | spin_unlock_irq(&dbe_lock); |
| 315 | 343 | } |
| 316 | 344 | - |
| 317 | 345 | - /* Get rid of the fixup trampoline if we're running the module |
| 318 | 346 | - * from physically mapped address space */ |
| 319 | | - if (me->arch.core_plt_offset == 0 && |
| 320 | | - me->arch.init_plt_offset == me->arch.core_plt_size && |
| 321 | | - is_phys_addr(me->module_core)) { |
| 322 | | - kfree(me->arch.plt_tbl); |
| 323 | | - me->arch.plt_tbl = NULL; |
| 347 | - if (me->arch.phys_plt_offset == 0) { |
| 348 | - __module_free(me->arch.phys_plt_tbl); |
| 349 | - me->arch.phys_plt_tbl = NULL; |
| 350 | - } |
| 351 | - if (me->arch.virt_plt_offset == 0) { |
| 352 | - __module_free(me->arch.virt_plt_tbl); |
| 353 | - me->arch.virt_plt_tbl = NULL; |
| 324 | 354 | - } |
| 325 | 355 | - |
| 326 | 356 | return 0; |
| ... | ... | |
| 328 | 358 | |
| 329 | 359 | void module_arch_cleanup(struct module *mod) |
| 330 | 360 | { |
| 331 | | - if (mod->arch.plt_tbl) |
| 332 | | - kfree(mod->arch.plt_tbl); |
| 361 | - if (mod->arch.phys_plt_tbl) { |
| 362 | - __module_free(mod->arch.phys_plt_tbl); |
| 363 | - mod->arch.phys_plt_tbl = NULL; |
| 364 | - } |
| 365 | - if (mod->arch.virt_plt_tbl) { |
| 366 | - __module_free(mod->arch.virt_plt_tbl); |
| 367 | - mod->arch.virt_plt_tbl = NULL; |
| 368 | - } |
| 369 | - |
| 333 | 370 | spin_lock_irq(&dbe_lock); |
| 334 | 371 | list_del(&mod->arch.dbe_list); |
| 335 | 372 | spin_unlock_irq(&dbe_lock); |
| target/linux/sibyte/patches/106-no_module_reloc.patch |
| 1 | | diff -urN linux-2.6.30.7/arch/mips/Makefile linux-2.6.30.7.new/arch/mips/Makefile |
| 2 | | +++ linux-2.6.30.7.new/arch/mips/Makefile 2009-09-15 19:46:05.000000000 +0200 |
| 1 | diff -urN linux-2.6.30.10/arch/mips/Makefile linux-2.6.30.10.new//arch/mips/Makefile |
| 2 | --- linux-2.6.30.10/arch/mips/Makefile 2010-01-29 16:12:01.000000000 +0100 |
| 3 | 3 | @@ -83,7 +83,7 @@ |
| 4 | 4 | cflags-y += -G 0 -mno-abicalls -fno-pic -pipe |
| 5 | 5 | cflags-y += -msoft-float |
| ... | ... | |
| 10 | 10 | |
| 11 | 11 | cflags-y += -ffreestanding |
| 12 | 12 | |
| 13 | | diff -urN linux-2.6.30.7/arch/mips/include/asm/module.h linux-2.6.30.7.new/arch/mips/include/asm/module.h |
| 14 | | +++ linux-2.6.30.7.new/arch/mips/include/asm/module.h 2009-09-15 19:46:05.000000000 +0200 |
| 13 | diff -urN linux-2.6.30.10/arch/mips/include/asm/module.h linux-2.6.30.10.new//arch/mips/include/asm/module.h |
| 14 | --- linux-2.6.30.10/arch/mips/include/asm/module.h 2010-01-29 16:12:01.000000000 +0100 |
| 15 | 15 | @@ -9,11 +9,6 @@ |
| 16 | 16 | struct list_head dbe_list; |
| 17 | 17 | const struct exception_table_entry *dbe_start; |
| 18 | 18 | const struct exception_table_entry *dbe_end; |
| 19 | 19 | - |
| 20 | | - void *plt_tbl; |
| 21 | | - unsigned int core_plt_offset; |
| 22 | | - unsigned int core_plt_size; |
| 23 | | - unsigned int init_plt_offset; |
| 20 | - void *phys_plt_tbl; |
| 21 | - void *virt_plt_tbl; |
| 22 | - unsigned int phys_plt_offset; |
| 23 | - unsigned int virt_plt_offset; |
| 24 | 24 | }; |
| 25 | 25 | |
| 26 | 26 | typedef uint8_t Elf64_Byte; /* Type for a 8-bit quantity. */ |
| 27 | | diff -urN linux-2.6.30.7/arch/mips/kernel/module.c linux-2.6.30.7.new/arch/mips/kernel/module.c |
| 28 | | +++ linux-2.6.30.7.new/arch/mips/kernel/module.c 2009-09-15 19:46:05.000000000 +0200 |
| 27 | diff -urN linux-2.6.30.10/arch/mips/kernel/module.c linux-2.6.30.10.new//arch/mips/kernel/module.c |
| 28 | --- linux-2.6.30.10/arch/mips/kernel/module.c 2010-01-29 16:12:01.000000000 +0100 |
| 29 | 29 | @@ -43,116 +43,6 @@ |
| 30 | 30 | static LIST_HEAD(dbe_list); |
| 31 | 31 | static DEFINE_SPINLOCK(dbe_lock); |
| ... | ... | |
| 145 | 145 | void *module_alloc(unsigned long size) |
| 146 | 146 | { |
| 147 | 147 | #ifdef MODULE_START |
| 148 | | @@ -168,45 +58,16 @@ |
| 148 | @@ -168,101 +58,23 @@ |
| 149 | 149 | |
| 150 | 150 | return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL); |
| 151 | 151 | #else |
| ... | ... | |
| 193 | 193 | /* FIXME: If module_region == mod->init_region, trim exception |
| 194 | 194 | table entries. */ |
| 195 | 195 | } |
| 196 | | @@ -214,24 +75,6 @@ |
| 196 | |
| 197 | -static void *__module_alloc(int size, bool phys) |
| 198 | -{ |
| 199 | - void *ptr; |
| 200 | - |
| 201 | - if (phys) |
| 202 | - ptr = kmalloc(size, GFP_KERNEL); |
| 203 | - else |
| 204 | - ptr = vmalloc(size); |
| 205 | - return ptr; |
| 206 | -} |
| 207 | - |
| 208 | -static void __module_free(void *ptr) |
| 209 | -{ |
| 210 | - if (is_phys_addr(ptr)) |
| 211 | - kfree(ptr); |
| 212 | - else |
| 213 | - vfree(ptr); |
| 214 | -} |
| 215 | - |
| 197 | 216 | int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, |
| 198 | 217 | char *secstrings, struct module *mod) |
| 199 | 218 | { |
| ... | ... | |
| 208 | 227 | - core_size = get_plt_size(hdr, sechdrs, secstrings, symindex, false); |
| 209 | 228 | - init_size = get_plt_size(hdr, sechdrs, secstrings, symindex, true); |
| 210 | 229 | - |
| 211 | | - mod->arch.core_plt_offset = 0; |
| 212 | | - mod->arch.core_plt_size = core_size; |
| 213 | | - mod->arch.init_plt_offset = core_size; |
| 214 | | - mod->arch.plt_tbl = kmalloc(core_size + init_size, GFP_KERNEL); |
| 215 | | - if (!mod->arch.plt_tbl) |
| 230 | - mod->arch.phys_plt_offset = 0; |
| 231 | - mod->arch.virt_plt_offset = 0; |
| 232 | - mod->arch.phys_plt_tbl = NULL; |
| 233 | - mod->arch.virt_plt_tbl = NULL; |
| 234 | - |
| 235 | - if ((core_size + init_size) == 0) |
| 236 | - return 0; |
| 237 | - |
| 238 | - mod->arch.phys_plt_tbl = __module_alloc(core_size + init_size, 1); |
| 239 | - if (!mod->arch.phys_plt_tbl) |
| 216 | 240 | - return -ENOMEM; |
| 217 | 241 | - |
| 242 | - mod->arch.virt_plt_tbl = __module_alloc(core_size + init_size, 0); |
| 243 | - if (!mod->arch.virt_plt_tbl) { |
| 244 | - __module_free(mod->arch.phys_plt_tbl); |
| 245 | - mod->arch.phys_plt_tbl = NULL; |
| 246 | - return -ENOMEM; |
| 247 | - } |
| 248 | - |
| 218 | 249 | return 0; |
| 219 | 250 | } |
| 220 | 251 | |
| 221 | | @@ -254,41 +97,27 @@ |
| 252 | @@ -285,37 +97,27 @@ |
| 222 | 253 | return 0; |
| 223 | 254 | } |
| 224 | 255 | |
| ... | ... | |
| 238 | 269 | - tramp[1] = 0x27390000 | (v & 0xffff); /* addiu t9, t9, lo16 */ |
| 239 | 270 | - tramp[2] = 0x03200008; /* jr t9 */ |
| 240 | 271 | - tramp[3] = 0x00000000; /* nop */ |
| 241 | | - |
| 242 | | - return (Elf_Addr) tramp; |
| 243 | | -} |
| 244 | 272 | + if (v % 4) { |
| 245 | 273 | + printk(KERN_ERR "module %s: dangerous relocation\n", me->name); |
| 246 | 274 | + return -ENOEXEC; |
| 247 | 275 | + } |
| 248 | 276 | |
| 249 | | -static Elf_Addr add_plt_entry(struct module *me, void *location, Elf_Addr v) |
| 250 | | -{ |
| 251 | | - if (location >= me->module_core && |
| 252 | | - location < me->module_core + me->core_size) |
| 253 | | - return add_plt_entry_to(&me->arch.core_plt_offset, |
| 254 | | - me->arch.plt_tbl, v); |
| 277 | - return (Elf_Addr) tramp; |
| 278 | -} |
| 255 | 279 | + if ((v & 0xf0000000) != (((unsigned long)location + 4) & 0xf0000000)) { |
| 256 | 280 | + printk(KERN_ERR |
| 257 | 281 | + "module %s: relocation overflow\n", |
| ... | ... | |
| 259 | 283 | + return -ENOEXEC; |
| 260 | 284 | + } |
| 261 | 285 | |
| 262 | | - if (location >= me->module_init && |
| 263 | | - location < me->module_init + me->init_size) |
| 264 | | - return add_plt_entry_to(&me->arch.init_plt_offset, |
| 265 | | - me->arch.plt_tbl, v); |
| 286 | -static Elf_Addr add_plt_entry(struct module *me, void *location, Elf_Addr v) |
| 287 | -{ |
| 288 | - if (is_phys_addr(location)) |
| 289 | - return add_plt_entry_to(&me->arch.phys_plt_offset, |
| 290 | - me->arch.phys_plt_tbl, v); |
| 291 | - else |
| 292 | - return add_plt_entry_to(&me->arch.virt_plt_offset, |
| 293 | - me->arch.virt_plt_tbl, v); |
| 266 | 294 | + *location = (*location & ~0x03ffffff) | |
| 267 | 295 | + ((*location + (v >> 2)) & 0x03ffffff); |
| 268 | 296 | |
| 269 | | return 0; |
| 297 | + return 0; |
| 270 | 298 | } |
| 271 | 299 | |
| 272 | 300 | -static int set_r_mips_26(struct module *me, u32 *location, u32 ofs, Elf_Addr v) |
| ... | ... | |
| 274 | 302 | { |
| 275 | 303 | if (v % 4) { |
| 276 | 304 | printk(KERN_ERR "module %s: dangerous relocation\n", me->name); |
| 277 | | @@ -296,31 +125,17 @@ |
| 305 | @@ -323,31 +125,17 @@ |
| 278 | 306 | } |
| 279 | 307 | |
| 280 | 308 | if ((v & 0xf0000000) != (((unsigned long)location + 4) & 0xf0000000)) { |
| ... | ... | |
| 309 | 337 | static int apply_r_mips_hi16_rel(struct module *me, u32 *location, Elf_Addr v) |
| 310 | 338 | { |
| 311 | 339 | struct mips_hi16 *n; |
| 312 | | @@ -585,23 +400,11 @@ |
| 340 | @@ -612,32 +400,11 @@ |
| 313 | 341 | list_add(&me->arch.dbe_list, &dbe_list); |
| 314 | 342 | spin_unlock_irq(&dbe_lock); |
| 315 | 343 | } |
| 316 | 344 | - |
| 317 | 345 | - /* Get rid of the fixup trampoline if we're running the module |
| 318 | 346 | - * from physically mapped address space */ |
| 319 | | - if (me->arch.core_plt_offset == 0 && |
| 320 | | - me->arch.init_plt_offset == me->arch.core_plt_size && |
| 321 | | - is_phys_addr(me->module_core)) { |
| 322 | | - kfree(me->arch.plt_tbl); |
| 323 | | - me->arch.plt_tbl = NULL; |
| 347 | - if (me->arch.phys_plt_offset == 0) { |
| 348 | - __module_free(me->arch.phys_plt_tbl); |
| 349 | - me->arch.phys_plt_tbl = NULL; |
| 350 | - } |
| 351 | - if (me->arch.virt_plt_offset == 0) { |
| 352 | - __module_free(me->arch.virt_plt_tbl); |
| 353 | - me->arch.virt_plt_tbl = NULL; |
| 324 | 354 | - } |
| 325 | 355 | - |
| 326 | 356 | return 0; |
| ... | ... | |
| 328 | 358 | |
| 329 | 359 | void module_arch_cleanup(struct module *mod) |
| 330 | 360 | { |
| 331 | | - if (mod->arch.plt_tbl) |
| 332 | | - kfree(mod->arch.plt_tbl); |
| 361 | - if (mod->arch.phys_plt_tbl) { |
| 362 | - __module_free(mod->arch.phys_plt_tbl); |
| 363 | - mod->arch.phys_plt_tbl = NULL; |
| 364 | - } |
| 365 | - if (mod->arch.virt_plt_tbl) { |
| 366 | - __module_free(mod->arch.virt_plt_tbl); |
| 367 | - mod->arch.virt_plt_tbl = NULL; |
| 368 | - } |
| 369 | - |
| 333 | 370 | spin_lock_irq(&dbe_lock); |
| 334 | 371 | list_del(&mod->arch.dbe_list); |
| 335 | 372 | spin_unlock_irq(&dbe_lock); |