- Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmodule.h
More file actions
Latest commit
825 lines (687 loc) · 22.2 KB
/
Copy pathmodule.h
File metadata and controls
825 lines (687 loc) · 22.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
#ifndef_LINUX_MODULE_H
#define_LINUX_MODULE_H
/*
* Dynamic loading of modules into the kernel.
*
* Rewritten by Richard Henderson <rth@tamu.edu> Dec 1996
* Rewritten again by Rusty Russell, 2002
*/
#include<linux/list.h>
#include<linux/stat.h>
#include<linux/compiler.h>
#include<linux/cache.h>
#include<linux/kmod.h>
#include<linux/init.h>
#include<linux/elf.h>
#include<linux/stringify.h>
#include<linux/kobject.h>
#include<linux/moduleparam.h>
#include<linux/jump_label.h>
#include<linux/export.h>
#include<linux/rbtree_latch.h>
#include<linux/percpu.h>
#include<asm/module.h>
/* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
#defineMODULE_SIG_STRING "~Module signature appended~\n"
/* Not Yet Implemented */
#defineMODULE_SUPPORTED_DEVICE(name)
#defineMODULE_NAME_LEN MAX_PARAM_PREFIX_LEN
structmodversion_info {
unsigned longcrc;
charname[MODULE_NAME_LEN];
};
structmodule;
structexception_table_entry;
structmodule_kobject {
structkobjectkobj;
structmodule*mod;
structkobject*drivers_dir;
structmodule_param_attrs*mp;
structcompletion*kobj_completion;
} __randomize_layout;
structmodule_attribute {
structattributeattr;
ssize_t (*show)(structmodule_attribute*, structmodule_kobject*,
char*);
ssize_t (*store)(structmodule_attribute*, structmodule_kobject*,
constchar*, size_tcount);
void (*setup)(structmodule*, constchar*);
int (*test)(structmodule*);
void (*free)(structmodule*);
};
structmodule_version_attribute {
structmodule_attributemattr;
constchar*module_name;
constchar*version;
} __attribute__ ((__aligned__(sizeof(void*))));
externssize_t__modver_version_show(structmodule_attribute*,
structmodule_kobject*, char*);
externstructmodule_attributemodule_uevent;
/* These are either module local, or the kernel's dummy ones. */
externintinit_module(void);
externvoidcleanup_module(void);
#ifndefMODULE
/**
* module_init() - driver initialization entry point
* @x: function to be run at kernel boot time or module insertion
*
* module_init() will either be called during do_initcalls() (if
* builtin) or at module insertion time (if a module). There can only
* be one per module.
*/
#definemodule_init(x) __initcall(x);
/**
* module_exit() - driver exit entry point
* @x: function to be run when driver is removed
*
* module_exit() will wrap the driver clean-up code
* with cleanup_module() when used with rmmod when
* the driver is a module. If the driver is statically
* compiled into the kernel, module_exit() has no effect.
* There can only be one per module.
*/
#definemodule_exit(x) __exitcall(x);
#else/* MODULE */
/*
* In most cases loadable modules do not need custom
* initcall levels. There are still some valid cases where
* a driver may be needed early if built in, and does not
* matter when built as a loadable module. Like bus
* snooping debug drivers.
*/
#defineearly_initcall(fn) module_init(fn)
#definecore_initcall(fn) module_init(fn)
#definecore_initcall_sync(fn) module_init(fn)
#definepostcore_initcall(fn) module_init(fn)
#definepostcore_initcall_sync(fn) module_init(fn)
#definearch_initcall(fn) module_init(fn)
#definesubsys_initcall(fn) module_init(fn)
#definesubsys_initcall_sync(fn) module_init(fn)
#definefs_initcall(fn) module_init(fn)
#definefs_initcall_sync(fn) module_init(fn)
#definerootfs_initcall(fn) module_init(fn)
#definedevice_initcall(fn) module_init(fn)
#definedevice_initcall_sync(fn) module_init(fn)
#definelate_initcall(fn) module_init(fn)
#definelate_initcall_sync(fn) module_init(fn)
#defineconsole_initcall(fn) module_init(fn)
#definesecurity_initcall(fn) module_init(fn)
/* Each module must use one module_init(). */
#definemodule_init(initfn) \
static inline initcall_t __maybe_unused __inittest(void) \
{ return initfn; } \
int init_module(void) __attribute__((alias(#initfn)));
/* This is only required if you want to be unloadable. */
#definemodule_exit(exitfn) \
static inline exitcall_t __maybe_unused __exittest(void) \
{ return exitfn; } \
void cleanup_module(void) __attribute__((alias(#exitfn)));
#endif
/* This means "can be init if no module support, otherwise module load
may call it." */
#ifdefCONFIG_MODULES
#define__init_or_module
#define__initdata_or_module
#define__initconst_or_module
#define__INIT_OR_MODULE .text
#define__INITDATA_OR_MODULE .data
#define__INITRODATA_OR_MODULE .section ".rodata","a",%progbits
#else
#define__init_or_module __init
#define__initdata_or_module __initdata
#define__initconst_or_module __initconst
#define__INIT_OR_MODULE __INIT
#define__INITDATA_OR_MODULE __INITDATA
#define__INITRODATA_OR_MODULE __INITRODATA
#endif/*CONFIG_MODULES*/
/* Generic info of form tag = "info" */
#defineMODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
/* For userspace: you can also call me... */
#defineMODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
/* Soft module dependencies. See man modprobe.d for details.
* Example: MODULE_SOFTDEP("pre: module-foo module-bar post: module-baz")
*/
#defineMODULE_SOFTDEP(_softdep) MODULE_INFO(softdep, _softdep)
/*
* The following license idents are currently accepted as indicating free
* software modules
*
* "GPL" [GNU Public License v2 or later]
* "GPL v2" [GNU Public License v2]
* "GPL and additional rights" [GNU Public License v2 rights and more]
* "Dual BSD/GPL" [GNU Public License v2
* or BSD license choice]
* "Dual MIT/GPL" [GNU Public License v2
* or MIT license choice]
* "Dual MPL/GPL" [GNU Public License v2
* or Mozilla license choice]
*
* The following other idents are available
*
* "Proprietary" [Non free products]
*
* There are dual licensed components, but when running with Linux it is the
* GPL that is relevant so this is a non issue. Similarly LGPL linked with GPL
* is a GPL combined work.
*
* This exists for several reasons
* 1. So modinfo can show license info for users wanting to vet their setup
* is free
* 2. So the community can ignore bug reports including proprietary modules
* 3. So vendors can do likewise based on their own policies
*/
#defineMODULE_LICENSE(_license) MODULE_INFO(license, _license)
/*
* Author(s), use "Name <email>" or just "Name", for multiple
* authors use multiple MODULE_AUTHOR() statements/lines.
*/
#defineMODULE_AUTHOR(_author) MODULE_INFO(author, _author)
/* What your module does. */
#defineMODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
#ifdefMODULE
/* Creates an alias so file2alias.c can find device table. */
#defineMODULE_DEVICE_TABLE(type, name) \
extern typeof(name) __mod_##type##__##name##_device_table \
__attribute__ ((unused, alias(__stringify(name))))
#else/* !MODULE */
#defineMODULE_DEVICE_TABLE(type, name)
#endif
/* Version of form [<epoch>:]<version>[-<extra-version>].
* Or for CVS/RCS ID version, everything but the number is stripped.
* <epoch>: A (small) unsigned integer which allows you to start versions
* anew. If not mentioned, it's zero. eg. "2:1.0" is after
* "1:2.0".
* <version>: The <version> may contain only alphanumerics and the
* character `.'. Ordered by numeric sort for numeric parts,
* ascii sort for ascii parts (as per RPM or DEB algorithm).
* <extraversion>: Like <version>, but inserted for local
* customizations, eg "rh3" or "rusty1".
* Using this automatically adds a checksum of the .c files and the
* local headers in "srcversion".
*/
#if defined(MODULE) || !defined(CONFIG_SYSFS)
#defineMODULE_VERSION(_version) MODULE_INFO(version, _version)
#else
#defineMODULE_VERSION(_version) \
static struct module_version_attribute ___modver_attr = { \
.mattr = { \
.attr = { \
.name = "version", \
.mode = S_IRUGO, \
}, \
.show = __modver_version_show, \
}, \
.module_name = KBUILD_MODNAME, \
.version = _version, \
}; \
static const struct module_version_attribute \
__used __attribute__ ((__section__ ("__modver"))) \
* __moduleparam_const __modver_attr = &___modver_attr
#endif
/* Optional firmware file (or files) needed by the module
* format is simply firmware file name. Multiple firmware
* files require multiple MODULE_FIRMWARE() specifiers */
#defineMODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware)
structnotifier_block;
#ifdefCONFIG_MODULES
externintmodules_disabled; /* for sysctl */
/* Get/put a kernel symbol (calls must be symmetric) */
void*__symbol_get(constchar*symbol);
void*__symbol_get_gpl(constchar*symbol);
#definesymbol_get(x) ((typeof(&x))(__symbol_get(VMLINUX_SYMBOL_STR(x))))
/* modules using other modules: kdb wants to see this. */
structmodule_use {
structlist_headsource_list;
structlist_headtarget_list;
structmodule*source, *target;
};
enummodule_state {
MODULE_STATE_LIVE, /* Normal state. */
MODULE_STATE_COMING, /* Full formed, running module_init. */
MODULE_STATE_GOING, /* Going away. */
MODULE_STATE_UNFORMED, /* Still setting it up. */
};
structmod_tree_node {
structmodule*mod;
structlatch_tree_nodenode;
};
structmodule_layout {
/* The actual code + data. */
void*base;
/* Total size. */
unsigned intsize;
/* The size of the executable code. */
unsigned inttext_size;
/* Size of RO section of the module (text+rodata) */
unsigned intro_size;
/* Size of RO after init section */
unsigned intro_after_init_size;
#ifdefCONFIG_MODULES_TREE_LOOKUP
structmod_tree_nodemtn;
#endif
};
#ifdefCONFIG_MODULES_TREE_LOOKUP
/* Only touch one cacheline for common rbtree-for-core-layout case. */
#define__module_layout_align ____cacheline_aligned
#else
#define__module_layout_align
#endif
structmod_kallsyms {
Elf_Sym*symtab;
unsigned intnum_symtab;
char*strtab;
};
#ifdefCONFIG_LIVEPATCH
structklp_modinfo {
Elf_Ehdrhdr;
Elf_Shdr*sechdrs;
char*secstrings;
unsigned intsymndx;
};
#endif
structmodule {
enummodule_statestate;
/* Member of list of modules */
structlist_headlist;
/* Unique handle for this module */
charname[MODULE_NAME_LEN];
/* Sysfs stuff. */
structmodule_kobjectmkobj;
structmodule_attribute*modinfo_attrs;
constchar*version;
constchar*srcversion;
structkobject*holders_dir;
/* Exported symbols */
conststructkernel_symbol*syms;
consts32*crcs;
unsigned intnum_syms;
/* Kernel parameters. */
#ifdefCONFIG_SYSFS
structmutexparam_lock;
#endif
structkernel_param*kp;
unsigned intnum_kp;
/* GPL-only exported symbols. */
unsigned intnum_gpl_syms;
conststructkernel_symbol*gpl_syms;
consts32*gpl_crcs;
#ifdefCONFIG_UNUSED_SYMBOLS
/* unused exported symbols. */
conststructkernel_symbol*unused_syms;
consts32*unused_crcs;
unsigned intnum_unused_syms;
/* GPL-only, unused exported symbols. */
unsigned intnum_unused_gpl_syms;
conststructkernel_symbol*unused_gpl_syms;
consts32*unused_gpl_crcs;
#endif
#ifdefCONFIG_MODULE_SIG
/* Signature was verified. */
boolsig_ok;
#endif
boolasync_probe_requested;
/* symbols that will be GPL-only in the near future. */
conststructkernel_symbol*gpl_future_syms;
consts32*gpl_future_crcs;
unsigned intnum_gpl_future_syms;
/* Exception table */
unsigned intnum_exentries;
structexception_table_entry*extable;
/* Startup function. */
int (*init)(void);
/* Core layout: rbtree is accessed frequently, so keep together. */
structmodule_layoutcore_layout__module_layout_align;
structmodule_layoutinit_layout;
/* Arch-specific module values */
structmod_arch_specificarch;
unsigned longtaints; /* same bits as kernel:taint_flags */
#ifdefCONFIG_GENERIC_BUG
/* Support for BUG */
unsignednum_bugs;
structlist_headbug_list;
structbug_entry*bug_table;
#endif
#ifdefCONFIG_KALLSYMS
/* Protected by RCU and/or module_mutex: use rcu_dereference() */
structmod_kallsyms*kallsyms;
structmod_kallsymscore_kallsyms;
/* Section attributes */
structmodule_sect_attrs*sect_attrs;
/* Notes attributes */
structmodule_notes_attrs*notes_attrs;
#endif
/* The command line arguments (may be mangled). People like
keeping pointers to this stuff */
char*args;
#ifdefCONFIG_SMP
/* Per-cpu data. */
void__percpu*percpu;
unsigned intpercpu_size;
#endif
#ifdefCONFIG_TRACEPOINTS
unsigned intnum_tracepoints;
structtracepoint*const*tracepoints_ptrs;
#endif
#ifdefHAVE_JUMP_LABEL
structjump_entry*jump_entries;
unsigned intnum_jump_entries;
#endif
#ifdefCONFIG_TRACING
unsigned intnum_trace_bprintk_fmt;
constchar**trace_bprintk_fmt_start;
#endif
#ifdefCONFIG_EVENT_TRACING
structtrace_event_call**trace_events;
unsigned intnum_trace_events;
structtrace_eval_map**trace_evals;
unsigned intnum_trace_evals;
#endif
#ifdefCONFIG_FTRACE_MCOUNT_RECORD
unsigned intnum_ftrace_callsites;
unsigned long*ftrace_callsites;
#endif
#ifdefCONFIG_LIVEPATCH
boolklp; /* Is this a livepatch module? */
boolklp_alive;
/* Elf information */
structklp_modinfo*klp_info;
#endif
#ifdefCONFIG_MODULE_UNLOAD
/* What modules depend on me? */
structlist_headsource_list;
/* What modules do I depend on? */
structlist_headtarget_list;
/* Destruction function. */
void (*exit)(void);
atomic_trefcnt;
#endif
#ifdefCONFIG_CONSTRUCTORS
/* Constructor functions. */
ctor_fn_t*ctors;
unsigned intnum_ctors;
#endif
} ____cacheline_aligned__randomize_layout;
#ifndefMODULE_ARCH_INIT
#defineMODULE_ARCH_INIT {}
#endif
externstructmutexmodule_mutex;
/* FIXME: It'd be nice to isolate modules during init, too, so they
aren't used before they (may) fail. But presently too much code
(IDE & SCSI) require entry into the module during init.*/
staticinlineintmodule_is_live(structmodule*mod)
{
returnmod->state!=MODULE_STATE_GOING;
}
structmodule*__module_text_address(unsigned longaddr);
structmodule*__module_address(unsigned longaddr);
boolis_module_address(unsigned longaddr);
bool__is_module_percpu_address(unsigned longaddr, unsigned long*can_addr);
boolis_module_percpu_address(unsigned longaddr);
boolis_module_text_address(unsigned longaddr);
staticinlineboolwithin_module_core(unsigned longaddr,
conststructmodule*mod)
{
return (unsigned long)mod->core_layout.base <= addr&&
addr< (unsigned long)mod->core_layout.base+mod->core_layout.size;
}
staticinlineboolwithin_module_init(unsigned longaddr,
conststructmodule*mod)
{
return (unsigned long)mod->init_layout.base <= addr&&
addr< (unsigned long)mod->init_layout.base+mod->init_layout.size;
}
staticinlineboolwithin_module(unsigned longaddr, conststructmodule*mod)
{
returnwithin_module_init(addr, mod) ||within_module_core(addr, mod);
}
/* Search for module by name: must hold module_mutex. */
structmodule*find_module(constchar*name);
structsymsearch {
conststructkernel_symbol*start, *stop;
consts32*crcs;
enum {
NOT_GPL_ONLY,
GPL_ONLY,
WILL_BE_GPL_ONLY,
} licence;
boolunused;
};
/*
* Search for an exported symbol by name.
*
* Must be called with module_mutex held or preemption disabled.
*/
conststructkernel_symbol*find_symbol(constchar*name,
structmodule**owner,
consts32**crc,
boolgplok,
boolwarn);
/*
* Walk the exported symbol table
*
* Must be called with module_mutex held or preemption disabled.
*/
booleach_symbol_section(bool (*fn)(conststructsymsearch*arr,
structmodule*owner,
void*data), void*data);
/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
symnum out of range. */
intmodule_get_kallsym(unsigned intsymnum, unsigned long*value, char*type,
char*name, char*module_name, int*exported);
/* Look for this name: can be of form module:name. */
unsigned longmodule_kallsyms_lookup_name(constchar*name);
intmodule_kallsyms_on_each_symbol(int (*fn)(void*, constchar*,
structmodule*, unsigned long),
void*data);
externvoid__noreturn__module_put_and_exit(structmodule*mod,
longcode);
#definemodule_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code)
#ifdefCONFIG_MODULE_UNLOAD
intmodule_refcount(structmodule*mod);
void__symbol_put(constchar*symbol);
#definesymbol_put(x) __symbol_put(VMLINUX_SYMBOL_STR(x))
voidsymbol_put_addr(void*addr);
/* Sometimes we know we already have a refcount, and it's easier not
to handle the error case (which only happens with rmmod --wait). */
externvoid__module_get(structmodule*module);
/* This is the Right Way to get a module: if it fails, it's being removed,
* so pretend it's not there. */
externbooltry_module_get(structmodule*module);
externvoidmodule_put(structmodule*module);
#else/*!CONFIG_MODULE_UNLOAD*/
staticinlinebooltry_module_get(structmodule*module)
{
return !module||module_is_live(module);
}
staticinlinevoidmodule_put(structmodule*module)
{
}
staticinlinevoid__module_get(structmodule*module)
{
}
#definesymbol_put(x) do { } while (0)
#definesymbol_put_addr(p) do { } while (0)
#endif/* CONFIG_MODULE_UNLOAD */
intref_module(structmodule*a, structmodule*b);
/* This is a #define so the string doesn't get put in every .o file */
#definemodule_name(mod) \
({ \
struct module *__mod = (mod); \
__mod ? __mod->name : "kernel"; \
})
/* For kallsyms to ask for address resolution. namebuf should be at
* least KSYM_NAME_LEN long: a pointer to namebuf is returned if
* found, otherwise NULL. */
constchar*module_address_lookup(unsigned longaddr,
unsigned long*symbolsize,
unsigned long*offset,
char**modname,
char*namebuf);
intlookup_module_symbol_name(unsigned longaddr, char*symname);
intlookup_module_symbol_attrs(unsigned longaddr, unsigned long*size, unsigned long*offset, char*modname, char*name);
intregister_module_notifier(structnotifier_block*nb);
intunregister_module_notifier(structnotifier_block*nb);
externvoidprint_modules(void);
staticinlineboolmodule_requested_async_probing(structmodule*module)
{
returnmodule&&module->async_probe_requested;
}
#ifdefCONFIG_LIVEPATCH
staticinlineboolis_livepatch_module(structmodule*mod)
{
returnmod->klp;
}
#else/* !CONFIG_LIVEPATCH */
staticinlineboolis_livepatch_module(structmodule*mod)
{
return false;
}
#endif/* CONFIG_LIVEPATCH */
boolis_module_sig_enforced(void);
#else/* !CONFIG_MODULES... */
staticinlinestructmodule*__module_address(unsigned longaddr)
{
returnNULL;
}
staticinlinestructmodule*__module_text_address(unsigned longaddr)
{
returnNULL;
}
staticinlineboolis_module_address(unsigned longaddr)
{
return false;
}
staticinlineboolis_module_percpu_address(unsigned longaddr)
{
return false;
}
staticinlinebool__is_module_percpu_address(unsigned longaddr, unsigned long*can_addr)
{
return false;
}
staticinlineboolis_module_text_address(unsigned longaddr)
{
return false;
}
/* Get/put a kernel symbol (calls should be symmetric) */
#definesymbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); })
#definesymbol_put(x) do { } while (0)
#definesymbol_put_addr(x) do { } while (0)
staticinlinevoid__module_get(structmodule*module)
{
}
staticinlinebooltry_module_get(structmodule*module)
{
return true;
}
staticinlinevoidmodule_put(structmodule*module)
{
}
#definemodule_name(mod) "kernel"
/* For kallsyms to ask for address resolution. NULL means not found. */
staticinlineconstchar*module_address_lookup(unsigned longaddr,
unsigned long*symbolsize,
unsigned long*offset,
char**modname,
char*namebuf)
{
returnNULL;
}
staticinlineintlookup_module_symbol_name(unsigned longaddr, char*symname)
{
return-ERANGE;
}
staticinlineintlookup_module_symbol_attrs(unsigned longaddr, unsigned long*size, unsigned long*offset, char*modname, char*name)
{
return-ERANGE;
}
staticinlineintmodule_get_kallsym(unsigned intsymnum, unsigned long*value,
char*type, char*name,
char*module_name, int*exported)
{
return-ERANGE;
}
staticinlineunsigned longmodule_kallsyms_lookup_name(constchar*name)
{
return0;
}
staticinlineintmodule_kallsyms_on_each_symbol(int (*fn)(void*, constchar*,
structmodule*,
unsigned long),
void*data)
{
return0;
}
staticinlineintregister_module_notifier(structnotifier_block*nb)
{
/* no events will happen anyway, so this can always succeed */
return0;
}
staticinlineintunregister_module_notifier(structnotifier_block*nb)
{
return0;
}
#definemodule_put_and_exit(code) do_exit(code)
staticinlinevoidprint_modules(void)
{
}
staticinlineboolmodule_requested_async_probing(structmodule*module)
{
return false;
}
staticinlineboolis_module_sig_enforced(void)
{
return false;
}
#endif/* CONFIG_MODULES */
#ifdefCONFIG_SYSFS
externstructkset*module_kset;
externstructkobj_typemodule_ktype;
externintmodule_sysfs_initialized;
#endif/* CONFIG_SYSFS */
#definesymbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
/* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */
#define__MODULE_STRING(x) __stringify(x)
#ifdefCONFIG_STRICT_MODULE_RWX
externvoidset_all_modules_text_rw(void);
externvoidset_all_modules_text_ro(void);
externvoidmodule_enable_ro(conststructmodule*mod, boolafter_init);
externvoidmodule_disable_ro(conststructmodule*mod);
#else
staticinlinevoidset_all_modules_text_rw(void) { }
staticinlinevoidset_all_modules_text_ro(void) { }
staticinlinevoidmodule_enable_ro(conststructmodule*mod, boolafter_init) { }
staticinlinevoidmodule_disable_ro(conststructmodule*mod) { }
#endif
#ifdefCONFIG_GENERIC_BUG
voidmodule_bug_finalize(constElf_Ehdr*, constElf_Shdr*,
structmodule*);
voidmodule_bug_cleanup(structmodule*);
#else/* !CONFIG_GENERIC_BUG */
staticinlinevoidmodule_bug_finalize(constElf_Ehdr*hdr,
constElf_Shdr*sechdrs,
structmodule*mod)
{
}
staticinlinevoidmodule_bug_cleanup(structmodule*mod) {}
#endif/* CONFIG_GENERIC_BUG */
#ifdefRETPOLINE
externboolretpoline_module_ok(boolhas_retpoline);
#else
staticinlineboolretpoline_module_ok(boolhas_retpoline)
{
return true;
}
#endif
#ifdefCONFIG_MODULE_SIG
staticinlineboolmodule_sig_ok(structmodule*module)
{
returnmodule->sig_ok;
}
#else/* !CONFIG_MODULE_SIG */
staticinlineboolmodule_sig_ok(structmodule*module)
{
return true;
}
#endif/* CONFIG_MODULE_SIG */
#endif/* _LINUX_MODULE_H */