Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge git://github.com/rustyrussell/linux

Pull module and param updates from Rusty Russell:
"I'm getting married next week, and then honeymoon until 6th May. I'll
be offline from next week, except to post the compulsory pictures if
Alex shaves her head..."

I'm sure Rusty can take time off from his honeymoon if something comes
up. And here's the explanation about head shaving:

http://baldalex.org/

in case you wondered and wanted to support another insane caper or
Rusty's involving shaving.

What *is* it with Rusty and shaving, anyway?

* git://github.com/rustyrussell/linux:
module: Remove module size limit
module: move __module_get and try_module_get() out of line.
params: <level>_initcall-like kernel parameters
module_param: remove support for bool parameters which are really int.
module: add kernel param to force disable module load

+173 -100
+2
Documentation/kernel-parameters.txt
··· 1869 1869 shutdown the other cpus. Instead use the REBOOT_VECTOR 1870 1870 irq. 1871 1871 1872 + nomodule Disable module load 1873 + 1872 1874 nopat [X86] Disable PAT (page attribute table extension of 1873 1875 pagetables) support. 1874 1876
+2 -1
arch/powerpc/mm/hugetlbpage.c
··· 310 310 int i; 311 311 312 312 strlcpy(cmdline, boot_command_line, COMMAND_LINE_SIZE); 313 - parse_args("hugetlb gpages", cmdline, NULL, 0, &do_gpage_early_setup); 313 + parse_args("hugetlb gpages", cmdline, NULL, 0, 0, 0, 314 + &do_gpage_early_setup); 314 315 315 316 /* 316 317 * Walk gpage list in reverse, allocating larger page sizes first.
+14 -21
include/asm-generic/vmlinux.lds.h
··· 616 616 *(.init.setup) \ 617 617 VMLINUX_SYMBOL(__setup_end) = .; 618 618 619 - #define INITCALLS \ 620 - *(.initcallearly.init) \ 621 - VMLINUX_SYMBOL(__early_initcall_end) = .; \ 622 - *(.initcall0.init) \ 623 - *(.initcall0s.init) \ 624 - *(.initcall1.init) \ 625 - *(.initcall1s.init) \ 626 - *(.initcall2.init) \ 627 - *(.initcall2s.init) \ 628 - *(.initcall3.init) \ 629 - *(.initcall3s.init) \ 630 - *(.initcall4.init) \ 631 - *(.initcall4s.init) \ 632 - *(.initcall5.init) \ 633 - *(.initcall5s.init) \ 634 - *(.initcallrootfs.init) \ 635 - *(.initcall6.init) \ 636 - *(.initcall6s.init) \ 637 - *(.initcall7.init) \ 638 - *(.initcall7s.init) 619 + #define INIT_CALLS_LEVEL(level) \ 620 + VMLINUX_SYMBOL(__initcall##level##_start) = .; \ 621 + *(.initcall##level##.init) \ 622 + *(.initcall##level##s.init) \ 639 623 640 624 #define INIT_CALLS \ 641 625 VMLINUX_SYMBOL(__initcall_start) = .; \ 642 - INITCALLS \ 626 + *(.initcallearly.init) \ 627 + INIT_CALLS_LEVEL(0) \ 628 + INIT_CALLS_LEVEL(1) \ 629 + INIT_CALLS_LEVEL(2) \ 630 + INIT_CALLS_LEVEL(3) \ 631 + INIT_CALLS_LEVEL(4) \ 632 + INIT_CALLS_LEVEL(5) \ 633 + INIT_CALLS_LEVEL(rootfs) \ 634 + INIT_CALLS_LEVEL(6) \ 635 + INIT_CALLS_LEVEL(7) \ 643 636 VMLINUX_SYMBOL(__initcall_end) = .; 644 637 645 638 #define CON_INITCALL \
+4 -28
include/linux/module.h
··· 21 21 #include <linux/percpu.h> 22 22 #include <asm/module.h> 23 23 24 - #include <trace/events/module.h> 25 - 26 24 /* Not Yet Implemented */ 27 25 #define MODULE_SUPPORTED_DEVICE(name) 28 26 ··· 450 452 451 453 /* Sometimes we know we already have a refcount, and it's easier not 452 454 to handle the error case (which only happens with rmmod --wait). */ 453 - static inline void __module_get(struct module *module) 454 - { 455 - if (module) { 456 - preempt_disable(); 457 - __this_cpu_inc(module->refptr->incs); 458 - trace_module_get(module, _THIS_IP_); 459 - preempt_enable(); 460 - } 461 - } 455 + extern void __module_get(struct module *module); 462 456 463 - static inline int try_module_get(struct module *module) 464 - { 465 - int ret = 1; 466 - 467 - if (module) { 468 - preempt_disable(); 469 - 470 - if (likely(module_is_live(module))) { 471 - __this_cpu_inc(module->refptr->incs); 472 - trace_module_get(module, _THIS_IP_); 473 - } else 474 - ret = 0; 475 - 476 - preempt_enable(); 477 - } 478 - return ret; 479 - } 457 + /* This is the Right Way to get a module: if it fails, it's being removed, 458 + * so pretend it's not there. */ 459 + extern bool try_module_get(struct module *module); 480 460 481 461 extern void module_put(struct module *module); 482 462
+43 -15
include/linux/moduleparam.h
··· 47 47 void (*free)(void *arg); 48 48 }; 49 49 50 - /* Flag bits for kernel_param.flags */ 51 - #define KPARAM_ISBOOL 2 52 - 53 50 struct kernel_param { 54 51 const char *name; 55 52 const struct kernel_param_ops *ops; 56 53 u16 perm; 57 - u16 flags; 54 + s16 level; 58 55 union { 59 56 void *arg; 60 57 const struct kparam_string *str; ··· 128 131 * The ops can have NULL set or get functions. 129 132 */ 130 133 #define module_param_cb(name, ops, arg, perm) \ 131 - __module_param_call(MODULE_PARAM_PREFIX, \ 132 - name, ops, arg, __same_type((arg), bool *), perm) 134 + __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, 0) 135 + 136 + /** 137 + * <level>_param_cb - general callback for a module/cmdline parameter 138 + * to be evaluated before certain initcall level 139 + * @name: a valid C identifier which is the parameter name. 140 + * @ops: the set & get operations for this parameter. 141 + * @perm: visibility in sysfs. 142 + * 143 + * The ops can have NULL set or get functions. 144 + */ 145 + #define __level_param_cb(name, ops, arg, perm, level) \ 146 + __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, level) 147 + 148 + #define core_param_cb(name, ops, arg, perm) \ 149 + __level_param_cb(name, ops, arg, perm, 1) 150 + 151 + #define postcore_param_cb(name, ops, arg, perm) \ 152 + __level_param_cb(name, ops, arg, perm, 2) 153 + 154 + #define arch_param_cb(name, ops, arg, perm) \ 155 + __level_param_cb(name, ops, arg, perm, 3) 156 + 157 + #define subsys_param_cb(name, ops, arg, perm) \ 158 + __level_param_cb(name, ops, arg, perm, 4) 159 + 160 + #define fs_param_cb(name, ops, arg, perm) \ 161 + __level_param_cb(name, ops, arg, perm, 5) 162 + 163 + #define device_param_cb(name, ops, arg, perm) \ 164 + __level_param_cb(name, ops, arg, perm, 6) 165 + 166 + #define late_param_cb(name, ops, arg, perm) \ 167 + __level_param_cb(name, ops, arg, perm, 7) 133 168 134 169 /* On alpha, ia64 and ppc64 relocations to global data cannot go into 135 170 read-only sections (which is part of respective UNIX ABI on these ··· 175 146 176 147 /* This is the fundamental function for registering boot/module 177 148 parameters. */ 178 - #define __module_param_call(prefix, name, ops, arg, isbool, perm) \ 149 + #define __module_param_call(prefix, name, ops, arg, perm, level) \ 179 150 /* Default value instead of permissions? */ \ 180 151 static int __param_perm_check_##name __attribute__((unused)) = \ 181 152 BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)) \ ··· 184 155 static struct kernel_param __moduleparam_const __param_##name \ 185 156 __used \ 186 157 __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ 187 - = { __param_str_##name, ops, perm, isbool ? KPARAM_ISBOOL : 0, \ 188 - { arg } } 158 + = { __param_str_##name, ops, perm, level, { arg } } 189 159 190 160 /* Obsolete - use module_param_cb() */ 191 161 #define module_param_call(name, set, get, arg, perm) \ ··· 192 164 { (void *)set, (void *)get }; \ 193 165 __module_param_call(MODULE_PARAM_PREFIX, \ 194 166 name, &__param_ops_##name, arg, \ 195 - __same_type(arg, bool *), \ 196 - (perm) + sizeof(__check_old_set_param(set))*0) 167 + (perm) + sizeof(__check_old_set_param(set))*0, 0) 197 168 198 169 /* We don't get oldget: it's often a new-style param_get_uint, etc. */ 199 170 static inline int ··· 272 245 */ 273 246 #define core_param(name, var, type, perm) \ 274 247 param_check_##type(name, &(var)); \ 275 - __module_param_call("", name, &param_ops_##type, \ 276 - &var, __same_type(var, bool), perm) 248 + __module_param_call("", name, &param_ops_##type, &var, perm, 0) 277 249 #endif /* !MODULE */ 278 250 279 251 /** ··· 290 264 = { len, string }; \ 291 265 __module_param_call(MODULE_PARAM_PREFIX, name, \ 292 266 &param_ops_string, \ 293 - .str = &__param_string_##name, 0, perm); \ 267 + .str = &__param_string_##name, perm, 0); \ 294 268 __MODULE_PARM_TYPE(name, "string") 295 269 296 270 /** ··· 318 292 char *args, 319 293 const struct kernel_param *params, 320 294 unsigned num, 295 + s16 level_min, 296 + s16 level_max, 321 297 int (*unknown)(char *param, char *val)); 322 298 323 299 /* Called by module remove. */ ··· 431 403 __module_param_call(MODULE_PARAM_PREFIX, name, \ 432 404 &param_array_ops, \ 433 405 .arr = &__param_arr_##name, \ 434 - __same_type(array[0], bool), perm); \ 406 + perm, 0); \ 435 407 __MODULE_PARM_TYPE(name, "array of " #type) 436 408 437 409 extern struct kernel_param_ops param_array_ops;
+60 -7
init/main.c
··· 400 400 401 401 void __init parse_early_options(char *cmdline) 402 402 { 403 - parse_args("early options", cmdline, NULL, 0, do_early_param); 403 + parse_args("early options", cmdline, NULL, 0, 0, 0, do_early_param); 404 404 } 405 405 406 406 /* Arch code calls this early on, or if not, just before other parsing. */ ··· 503 503 parse_early_param(); 504 504 parse_args("Booting kernel", static_command_line, __start___param, 505 505 __stop___param - __start___param, 506 - &unknown_bootoption); 506 + 0, 0, &unknown_bootoption); 507 507 508 508 jump_label_init(); 509 509 ··· 699 699 } 700 700 701 701 702 - extern initcall_t __initcall_start[], __initcall_end[], __early_initcall_end[]; 702 + extern initcall_t __initcall_start[]; 703 + extern initcall_t __initcall0_start[]; 704 + extern initcall_t __initcall1_start[]; 705 + extern initcall_t __initcall2_start[]; 706 + extern initcall_t __initcall3_start[]; 707 + extern initcall_t __initcall4_start[]; 708 + extern initcall_t __initcall5_start[]; 709 + extern initcall_t __initcall6_start[]; 710 + extern initcall_t __initcall7_start[]; 711 + extern initcall_t __initcall_end[]; 712 + 713 + static initcall_t *initcall_levels[] __initdata = { 714 + __initcall0_start, 715 + __initcall1_start, 716 + __initcall2_start, 717 + __initcall3_start, 718 + __initcall4_start, 719 + __initcall5_start, 720 + __initcall6_start, 721 + __initcall7_start, 722 + __initcall_end, 723 + }; 724 + 725 + static char *initcall_level_names[] __initdata = { 726 + "early parameters", 727 + "core parameters", 728 + "postcore parameters", 729 + "arch parameters", 730 + "subsys parameters", 731 + "fs parameters", 732 + "device parameters", 733 + "late parameters", 734 + }; 735 + 736 + static int __init ignore_unknown_bootoption(char *param, char *val) 737 + { 738 + return 0; 739 + } 740 + 741 + static void __init do_initcall_level(int level) 742 + { 743 + extern const struct kernel_param __start___param[], __stop___param[]; 744 + initcall_t *fn; 745 + 746 + strcpy(static_command_line, saved_command_line); 747 + parse_args(initcall_level_names[level], 748 + static_command_line, __start___param, 749 + __stop___param - __start___param, 750 + level, level, 751 + ignore_unknown_bootoption); 752 + 753 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) 754 + do_one_initcall(*fn); 755 + } 703 756 704 757 static void __init do_initcalls(void) 705 758 { 706 - initcall_t *fn; 759 + int level; 707 760 708 - for (fn = __early_initcall_end; fn < __initcall_end; fn++) 709 - do_one_initcall(*fn); 761 + for (level = 0; level < ARRAY_SIZE(initcall_levels) - 1; level++) 762 + do_initcall_level(level); 710 763 } 711 764 712 765 /* ··· 785 732 { 786 733 initcall_t *fn; 787 734 788 - for (fn = __initcall_start; fn < __early_initcall_end; fn++) 735 + for (fn = __initcall_start; fn < __initcall0_start; fn++) 789 736 do_one_initcall(*fn); 790 737 } 791 738
+34 -3
kernel/module.c
··· 105 105 106 106 /* Block module loading/unloading? */ 107 107 int modules_disabled = 0; 108 + core_param(nomodule, modules_disabled, bint, 0); 108 109 109 110 /* Waiting for a module to finish initializing? */ 110 111 static DECLARE_WAIT_QUEUE_HEAD(module_wq); ··· 903 902 904 903 static struct module_attribute modinfo_refcnt = 905 904 __ATTR(refcnt, 0444, show_refcnt, NULL); 905 + 906 + void __module_get(struct module *module) 907 + { 908 + if (module) { 909 + preempt_disable(); 910 + __this_cpu_inc(module->refptr->incs); 911 + trace_module_get(module, _RET_IP_); 912 + preempt_enable(); 913 + } 914 + } 915 + EXPORT_SYMBOL(__module_get); 916 + 917 + bool try_module_get(struct module *module) 918 + { 919 + bool ret = true; 920 + 921 + if (module) { 922 + preempt_disable(); 923 + 924 + if (likely(module_is_live(module))) { 925 + __this_cpu_inc(module->refptr->incs); 926 + trace_module_get(module, _RET_IP_); 927 + } else 928 + ret = false; 929 + 930 + preempt_enable(); 931 + } 932 + return ret; 933 + } 934 + EXPORT_SYMBOL(try_module_get); 906 935 907 936 void module_put(struct module *module) 908 937 { ··· 2411 2380 return -ENOEXEC; 2412 2381 2413 2382 /* Suck in entire file: we'll want most of it. */ 2414 - /* vmalloc barfs on "unusual" numbers. Check here */ 2415 - if (len > 64 * 1024 * 1024 || (hdr = vmalloc(len)) == NULL) 2383 + if ((hdr = vmalloc(len)) == NULL) 2416 2384 return -ENOMEM; 2417 2385 2418 2386 if (copy_from_user(hdr, umod, len) != 0) { ··· 2952 2922 mutex_unlock(&module_mutex); 2953 2923 2954 2924 /* Module is ready to execute: parsing args may do that. */ 2955 - err = parse_args(mod->name, mod->args, mod->kp, mod->num_kp, NULL); 2925 + err = parse_args(mod->name, mod->args, mod->kp, mod->num_kp, 2926 + -32768, 32767, NULL); 2956 2927 if (err < 0) 2957 2928 goto unlink; 2958 2929
+14 -25
kernel/params.c
··· 87 87 char *val, 88 88 const struct kernel_param *params, 89 89 unsigned num_params, 90 + s16 min_level, 91 + s16 max_level, 90 92 int (*handle_unknown)(char *param, char *val)) 91 93 { 92 94 unsigned int i; ··· 97 95 /* Find parameter */ 98 96 for (i = 0; i < num_params; i++) { 99 97 if (parameq(param, params[i].name)) { 98 + if (params[i].level < min_level 99 + || params[i].level > max_level) 100 + return 0; 100 101 /* No one handled NULL, so do it here. */ 101 102 if (!val && params[i].ops->set != param_set_bool 102 103 && params[i].ops->set != param_set_bint) ··· 179 174 char *args, 180 175 const struct kernel_param *params, 181 176 unsigned num, 177 + s16 min_level, 178 + s16 max_level, 182 179 int (*unknown)(char *param, char *val)) 183 180 { 184 181 char *param, *val; ··· 196 189 197 190 args = next_arg(args, &param, &val); 198 191 irq_was_disabled = irqs_disabled(); 199 - ret = parse_one(param, val, params, num, unknown); 192 + ret = parse_one(param, val, params, num, 193 + min_level, max_level, unknown); 200 194 if (irq_was_disabled && !irqs_disabled()) { 201 195 printk(KERN_WARNING "parse_args(): option '%s' enabled " 202 196 "irq's!\n", param); ··· 305 297 /* Actually could be a bool or an int, for historical reasons. */ 306 298 int param_set_bool(const char *val, const struct kernel_param *kp) 307 299 { 308 - bool v; 309 - int ret; 310 - 311 300 /* No equals means "set"... */ 312 301 if (!val) val = "1"; 313 302 314 303 /* One of =[yYnN01] */ 315 - ret = strtobool(val, &v); 316 - if (ret) 317 - return ret; 318 - 319 - if (kp->flags & KPARAM_ISBOOL) 320 - *(bool *)kp->arg = v; 321 - else 322 - *(int *)kp->arg = v; 323 - return 0; 304 + return strtobool(val, kp->arg); 324 305 } 325 306 EXPORT_SYMBOL(param_set_bool); 326 307 327 308 int param_get_bool(char *buffer, const struct kernel_param *kp) 328 309 { 329 - bool val; 330 - if (kp->flags & KPARAM_ISBOOL) 331 - val = *(bool *)kp->arg; 332 - else 333 - val = *(int *)kp->arg; 334 - 335 310 /* Y and N chosen as being relatively non-coder friendly */ 336 - return sprintf(buffer, "%c", val ? 'Y' : 'N'); 311 + return sprintf(buffer, "%c", *(bool *)kp->arg ? 'Y' : 'N'); 337 312 } 338 313 EXPORT_SYMBOL(param_get_bool); 339 314 ··· 334 343 struct kernel_param dummy; 335 344 336 345 dummy.arg = &boolval; 337 - dummy.flags = KPARAM_ISBOOL; 338 346 ret = param_set_bool(val, &dummy); 339 347 if (ret == 0) 340 348 *(bool *)kp->arg = !boolval; ··· 362 372 /* Match bool exactly, by re-using it. */ 363 373 boolkp = *kp; 364 374 boolkp.arg = &v; 365 - boolkp.flags |= KPARAM_ISBOOL; 366 375 367 376 ret = param_set_bool(val, &boolkp); 368 377 if (ret == 0) ··· 382 393 unsigned int min, unsigned int max, 383 394 void *elem, int elemsize, 384 395 int (*set)(const char *, const struct kernel_param *kp), 385 - u16 flags, 396 + s16 level, 386 397 unsigned int *num) 387 398 { 388 399 int ret; ··· 392 403 /* Get the name right for errors. */ 393 404 kp.name = name; 394 405 kp.arg = elem; 395 - kp.flags = flags; 406 + kp.level = level; 396 407 397 408 *num = 0; 398 409 /* We expect a comma-separated list of values. */ ··· 433 444 unsigned int temp_num; 434 445 435 446 return param_array(kp->name, val, 1, arr->max, arr->elem, 436 - arr->elemsize, arr->ops->set, kp->flags, 447 + arr->elemsize, arr->ops->set, kp->level, 437 448 arr->num ?: &temp_num); 438 449 } 439 450