~ubuntu-branches/ubuntu/precise/linux-linaro-u8500/precise

« back to all changes in this revision

Viewing changes to kernel/module.c

  • Committer: Bazaar Package Importer
  • Author(s): John Rigby, Upstream Fixes, Andy Green, John Rigby
  • Date: 2011-04-14 12:16:06 UTC
  • Revision ID: james.westby@ubuntu.com-20110414121606-b77podkyqgr2oix7
Tags: 2.6.38-1002.3
[ Upstream Fixes ]

* MUSB: shutdown: Make sure block is awake before doing shutdown
  - LP: #745737
* Fixed gpio polarity of gpio USB-phy reset.
  - LP: #747639

[ Andy Green ]

* LINARO: SAUCE: disable CONFIG_OMAP_RESET_CLOCKS
  - LP: #752900

[ John Rigby ]

* Rebase to new upstreams:
  Linux v2.6.38.1
  linaro-linux-2.6.38-upstream-29Mar2011
  Ubuntu-2.6.38-7.35
* SAUCE: OMAP4: clock: wait for module to become accessible on
  a clk enable
  - LP: #745737
* Rebase to new upstreams:
  Linux v2.6.38.2
  linaro-linux-2.6.38-upstream-5Apr2011
  Ubuntu-2.6.38-8.41
  - LP: #732842
* Update configs for device tree, dvfs and lttng
* LINARO: add building of dtb's
* LINARO: SAUCE: Disable lowest operating freqs on omap34xx
  - LP: #732912

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
#include <linux/kmemleak.h>
58
58
#include <linux/jump_label.h>
59
59
#include <linux/pfn.h>
 
60
#include <trace/kernel.h>
60
61
 
61
62
#define CREATE_TRACE_POINTS
62
63
#include <trace/events/module.h>
99
100
 * 1) List of modules (also safely readable with preempt_disable),
100
101
 * 2) module_use links,
101
102
 * 3) module_addr_min/module_addr_max.
102
 
 * (delete uses stop_machine/add uses RCU list operations). */
 
103
 * (delete uses stop_machine/add uses RCU list operations).
 
104
 * Sorted by ascending list node address.
 
105
 */
103
106
DEFINE_MUTEX(module_mutex);
104
107
EXPORT_SYMBOL_GPL(module_mutex);
105
108
static LIST_HEAD(modules);
120
123
 * Protected by module_mutex. */
121
124
static unsigned long module_addr_min = -1UL, module_addr_max = 0;
122
125
 
 
126
DEFINE_TRACE(kernel_module_load);
 
127
DEFINE_TRACE(kernel_module_free);
 
128
 
123
129
int register_module_notifier(struct notifier_block * nb)
124
130
{
125
131
        return blocking_notifier_chain_register(&module_notify_list, nb);
1675
1681
/* Free a module, remove from lists, etc. */
1676
1682
static void free_module(struct module *mod)
1677
1683
{
 
1684
        trace_kernel_module_free(mod);
1678
1685
        trace_module_free(mod);
1679
1686
 
1680
1687
        /* Delete from various lists */
2272
2279
        if (len > 64 * 1024 * 1024 || (hdr = vmalloc(len)) == NULL)
2273
2280
                return -ENOMEM;
2274
2281
 
 
2282
        /*
 
2283
         * Make sure the module text or data access never generates any page
 
2284
         * fault.
 
2285
         */
 
2286
        vmalloc_sync_all();
 
2287
 
2275
2288
        if (copy_from_user(hdr, umod, len) != 0) {
2276
2289
                err = -EFAULT;
2277
2290
                goto free_hdr;
2459
2472
                                  sizeof(*mod->ctors), &mod->num_ctors);
2460
2473
#endif
2461
2474
 
 
2475
#ifdef CONFIG_MARKERS
 
2476
        mod->markers = section_objs(info, "__markers",
 
2477
                                    sizeof(*mod->markers), &mod->num_markers);
 
2478
#endif
2462
2479
#ifdef CONFIG_TRACEPOINTS
2463
2480
        mod->tracepoints_ptrs = section_objs(info, "__tracepoints_ptrs",
2464
2481
                                             sizeof(*mod->tracepoints_ptrs),
2717
2734
                                  const char __user *uargs)
2718
2735
{
2719
2736
        struct load_info info = { NULL, };
2720
 
        struct module *mod;
 
2737
        struct module *mod, *iter;
2721
2738
        long err;
2722
2739
 
2723
2740
        DEBUGP("load_module: umod=%p, len=%lu, uargs=%p\n",
2799
2816
                goto ddebug;
2800
2817
 
2801
2818
        module_bug_finalize(info.hdr, info.sechdrs, mod);
 
2819
        /*
 
2820
         * We sort the modules by struct module pointer address to permit
 
2821
         * correct iteration over modules of, at least, kallsyms for preemptible
 
2822
         * operations, such as read(). Sorting by struct module pointer address
 
2823
         * is equivalent to sort by list node address.
 
2824
         */
 
2825
        list_for_each_entry_reverse(iter, &modules, list) {
 
2826
                BUG_ON(iter == mod);    /* Should never be in the list twice */
 
2827
                if (iter < mod) {
 
2828
                        /* We belong to the location right after iter. */
 
2829
                        list_add_rcu(&mod->list, &iter->list);
 
2830
                        goto module_added;
 
2831
                }
 
2832
        }
 
2833
        /* We should be added at the head of the list */
2802
2834
        list_add_rcu(&mod->list, &modules);
 
2835
module_added:
2803
2836
        mutex_unlock(&module_mutex);
2804
2837
 
2805
2838
        /* Module is ready to execute: parsing args may do that. */
2817
2850
        free_copy(&info);
2818
2851
 
2819
2852
        /* Done! */
 
2853
        trace_kernel_module_load(mod);
2820
2854
        trace_module_load(mod);
2821
2855
        return mod;
2822
2856
 
3196
3230
static void *m_start(struct seq_file *m, loff_t *pos)
3197
3231
{
3198
3232
        mutex_lock(&module_mutex);
3199
 
        return seq_list_start(&modules, *pos);
 
3233
        return seq_sorted_list_start(&modules, pos);
3200
3234
}
3201
3235
 
3202
3236
static void *m_next(struct seq_file *m, void *p, loff_t *pos)
3203
3237
{
3204
 
        return seq_list_next(p, &modules, pos);
 
3238
        return seq_sorted_list_next(p, &modules, pos);
3205
3239
}
3206
3240
 
3207
3241
static void m_stop(struct seq_file *m, void *p)
3266
3300
module_init(proc_modules_init);
3267
3301
#endif
3268
3302
 
 
3303
void list_modules(void *call_data)
 
3304
{
 
3305
        /* Enumerate loaded modules */
 
3306
        struct list_head        *i;
 
3307
        struct module           *mod;
 
3308
        unsigned long refcount = 0;
 
3309
 
 
3310
        mutex_lock(&module_mutex);
 
3311
        list_for_each(i, &modules) {
 
3312
                mod = list_entry(i, struct module, list);
 
3313
#ifdef CONFIG_MODULE_UNLOAD
 
3314
                refcount = module_refcount(mod);
 
3315
#endif
 
3316
                __trace_mark(0, module_state, list_module, call_data,
 
3317
                                "name %s state %d refcount %lu",
 
3318
                                mod->name, mod->state, refcount);
 
3319
        }
 
3320
        mutex_unlock(&module_mutex);
 
3321
}
 
3322
EXPORT_SYMBOL_GPL(list_modules);
 
3323
 
3269
3324
/* Given an address, look for it in the module exception tables. */
3270
3325
const struct exception_table_entry *search_module_extables(unsigned long addr)
3271
3326
{
3393
3448
                   struct modversion_info *ver,
3394
3449
                   struct kernel_param *kp,
3395
3450
                   struct kernel_symbol *ks,
 
3451
                   struct marker *marker,
3396
3452
                   struct tracepoint * const *tp)
3397
3453
{
3398
3454
}
3399
3455
EXPORT_SYMBOL(module_layout);
3400
3456
#endif
3401
3457
 
 
3458
#ifdef CONFIG_MARKERS
 
3459
void module_update_markers(void)
 
3460
{
 
3461
        struct module *mod;
 
3462
 
 
3463
        mutex_lock(&module_mutex);
 
3464
        list_for_each_entry(mod, &modules, list)
 
3465
                if (!(mod->taints & TAINT_FORCED_MODULE))
 
3466
                        marker_update_probe_range(mod->markers,
 
3467
                                mod->markers + mod->num_markers);
 
3468
        mutex_unlock(&module_mutex);
 
3469
}
 
3470
 
 
3471
/*
 
3472
 * Returns 0 if current not found.
 
3473
 * Returns 1 if current found.
 
3474
 */
 
3475
int module_get_iter_markers(struct marker_iter *iter)
 
3476
{
 
3477
        struct module *iter_mod;
 
3478
        int found = 0;
 
3479
 
 
3480
        mutex_lock(&module_mutex);
 
3481
        list_for_each_entry(iter_mod, &modules, list) {
 
3482
                if (!(iter_mod->taints & TAINT_FORCED_MODULE)) {
 
3483
                        /*
 
3484
                         * Sorted module list
 
3485
                         */
 
3486
                        if (iter_mod < iter->module)
 
3487
                                continue;
 
3488
                        else if (iter_mod > iter->module)
 
3489
                                iter->marker = NULL;
 
3490
                        found = marker_get_iter_range(&iter->marker,
 
3491
                                iter_mod->markers,
 
3492
                                iter_mod->markers + iter_mod->num_markers);
 
3493
                        if (found) {
 
3494
                                iter->module = iter_mod;
 
3495
                                break;
 
3496
                        }
 
3497
                }
 
3498
        }
 
3499
        mutex_unlock(&module_mutex);
 
3500
        return found;
 
3501
}
 
3502
#endif
 
3503
 
3402
3504
#ifdef CONFIG_TRACEPOINTS
3403
3505
void module_update_tracepoints(void)
3404
3506
{