aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-generic
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-generic')
-rw-r--r--include/asm-generic/4level-fixup.h2
-rw-r--r--include/asm-generic/bitops/ext2-non-atomic.h2
-rw-r--r--include/asm-generic/bitops/le.h4
-rw-r--r--include/asm-generic/bug.h17
-rw-r--r--include/asm-generic/cputime.h1
-rw-r--r--include/asm-generic/gpio.h98
-rw-r--r--include/asm-generic/percpu.h97
-rw-r--r--include/asm-generic/pgtable-nopmd.h2
-rw-r--r--include/asm-generic/pgtable-nopud.h2
-rw-r--r--include/asm-generic/resource.h7
-rw-r--r--include/asm-generic/rtc.h11
-rw-r--r--include/asm-generic/sections.h2
-rw-r--r--include/asm-generic/vmlinux.lds.h90
13 files changed, 279 insertions, 56 deletions
diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
index 7b88d3931e34..9d40e879f99e 100644
--- a/include/asm-generic/4level-fixup.h
+++ b/include/asm-generic/4level-fixup.h
@@ -28,7 +28,7 @@
28 28
29#undef pud_free_tlb 29#undef pud_free_tlb
30#define pud_free_tlb(tlb, x) do { } while (0) 30#define pud_free_tlb(tlb, x) do { } while (0)
31#define pud_free(x) do { } while (0) 31#define pud_free(mm, x) do { } while (0)
32#define __pud_free_tlb(tlb, x) do { } while (0) 32#define __pud_free_tlb(tlb, x) do { } while (0)
33 33
34#undef pud_addr_end 34#undef pud_addr_end
diff --git a/include/asm-generic/bitops/ext2-non-atomic.h b/include/asm-generic/bitops/ext2-non-atomic.h
index 1697404afa05..63cf822431a2 100644
--- a/include/asm-generic/bitops/ext2-non-atomic.h
+++ b/include/asm-generic/bitops/ext2-non-atomic.h
@@ -14,5 +14,7 @@
14 generic_find_first_zero_le_bit((unsigned long *)(addr), (size)) 14 generic_find_first_zero_le_bit((unsigned long *)(addr), (size))
15#define ext2_find_next_zero_bit(addr, size, off) \ 15#define ext2_find_next_zero_bit(addr, size, off) \
16 generic_find_next_zero_le_bit((unsigned long *)(addr), (size), (off)) 16 generic_find_next_zero_le_bit((unsigned long *)(addr), (size), (off))
17#define ext2_find_next_bit(addr, size, off) \
18 generic_find_next_le_bit((unsigned long *)(addr), (size), (off))
17 19
18#endif /* _ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_ */ 20#endif /* _ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_ */
diff --git a/include/asm-generic/bitops/le.h b/include/asm-generic/bitops/le.h
index b9c7e5d2d2ad..80e3bf13b2b9 100644
--- a/include/asm-generic/bitops/le.h
+++ b/include/asm-generic/bitops/le.h
@@ -20,6 +20,8 @@
20#define generic___test_and_clear_le_bit(nr, addr) __test_and_clear_bit(nr, addr) 20#define generic___test_and_clear_le_bit(nr, addr) __test_and_clear_bit(nr, addr)
21 21
22#define generic_find_next_zero_le_bit(addr, size, offset) find_next_zero_bit(addr, size, offset) 22#define generic_find_next_zero_le_bit(addr, size, offset) find_next_zero_bit(addr, size, offset)
23#define generic_find_next_le_bit(addr, size, offset) \
24 find_next_bit(addr, size, offset)
23 25
24#elif defined(__BIG_ENDIAN) 26#elif defined(__BIG_ENDIAN)
25 27
@@ -42,6 +44,8 @@
42 44
43extern unsigned long generic_find_next_zero_le_bit(const unsigned long *addr, 45extern unsigned long generic_find_next_zero_le_bit(const unsigned long *addr,
44 unsigned long size, unsigned long offset); 46 unsigned long size, unsigned long offset);
47extern unsigned long generic_find_next_le_bit(const unsigned long *addr,
48 unsigned long size, unsigned long offset);
45 49
46#else 50#else
47#error "Please fix <asm/byteorder.h>" 51#error "Please fix <asm/byteorder.h>"
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index d56fedbb457a..2632328d8646 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -31,14 +31,19 @@ struct bug_entry {
31#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0) 31#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
32#endif 32#endif
33 33
34#ifndef HAVE_ARCH_WARN_ON 34#ifndef __WARN
35#ifndef __ASSEMBLY__
36extern void warn_on_slowpath(const char *file, const int line);
37#define WANT_WARN_ON_SLOWPATH
38#endif
39#define __WARN() warn_on_slowpath(__FILE__, __LINE__)
40#endif
41
42#ifndef WARN_ON
35#define WARN_ON(condition) ({ \ 43#define WARN_ON(condition) ({ \
36 int __ret_warn_on = !!(condition); \ 44 int __ret_warn_on = !!(condition); \
37 if (unlikely(__ret_warn_on)) { \ 45 if (unlikely(__ret_warn_on)) \
38 printk("WARNING: at %s:%d %s()\n", __FILE__, \ 46 __WARN(); \
39 __LINE__, __FUNCTION__); \
40 dump_stack(); \
41 } \
42 unlikely(__ret_warn_on); \ 47 unlikely(__ret_warn_on); \
43}) 48})
44#endif 49#endif
diff --git a/include/asm-generic/cputime.h b/include/asm-generic/cputime.h
index 09204e40d663..1c1fa422d18a 100644
--- a/include/asm-generic/cputime.h
+++ b/include/asm-generic/cputime.h
@@ -18,6 +18,7 @@ typedef unsigned long cputime_t;
18#define cputime_lt(__a, __b) ((__a) < (__b)) 18#define cputime_lt(__a, __b) ((__a) < (__b))
19#define cputime_le(__a, __b) ((__a) <= (__b)) 19#define cputime_le(__a, __b) ((__a) <= (__b))
20#define cputime_to_jiffies(__ct) (__ct) 20#define cputime_to_jiffies(__ct) (__ct)
21#define cputime_to_scaled(__ct) (__ct)
21#define jiffies_to_cputime(__hz) (__hz) 22#define jiffies_to_cputime(__hz) (__hz)
22 23
23typedef u64 cputime64_t; 24typedef u64 cputime64_t;
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 2d0aab1d8611..f29a502f4a6c 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -1,6 +1,102 @@
1#ifndef _ASM_GENERIC_GPIO_H 1#ifndef _ASM_GENERIC_GPIO_H
2#define _ASM_GENERIC_GPIO_H 2#define _ASM_GENERIC_GPIO_H
3 3
4#ifdef CONFIG_HAVE_GPIO_LIB
5
6/* Platforms may implement their GPIO interface with library code,
7 * at a small performance cost for non-inlined operations and some
8 * extra memory (for code and for per-GPIO table entries).
9 *
10 * While the GPIO programming interface defines valid GPIO numbers
11 * to be in the range 0..MAX_INT, this library restricts them to the
12 * smaller range 0..ARCH_NR_GPIOS.
13 */
14
15#ifndef ARCH_NR_GPIOS
16#define ARCH_NR_GPIOS 256
17#endif
18
19struct seq_file;
20
21/**
22 * struct gpio_chip - abstract a GPIO controller
23 * @label: for diagnostics
24 * @direction_input: configures signal "offset" as input, or returns error
25 * @get: returns value for signal "offset"; for output signals this
26 * returns either the value actually sensed, or zero
27 * @direction_output: configures signal "offset" as output, or returns error
28 * @set: assigns output value for signal "offset"
29 * @dbg_show: optional routine to show contents in debugfs; default code
30 * will be used when this is omitted, but custom code can show extra
31 * state (such as pullup/pulldown configuration).
32 * @base: identifies the first GPIO number handled by this chip; or, if
33 * negative during registration, requests dynamic ID allocation.
34 * @ngpio: the number of GPIOs handled by this controller; the last GPIO
35 * handled is (base + ngpio - 1).
36 * @can_sleep: flag must be set iff get()/set() methods sleep, as they
37 * must while accessing GPIO expander chips over I2C or SPI
38 *
39 * A gpio_chip can help platforms abstract various sources of GPIOs so
40 * they can all be accessed through a common programing interface.
41 * Example sources would be SOC controllers, FPGAs, multifunction
42 * chips, dedicated GPIO expanders, and so on.
43 *
44 * Each chip controls a number of signals, identified in method calls
45 * by "offset" values in the range 0..(@ngpio - 1). When those signals
46 * are referenced through calls like gpio_get_value(gpio), the offset
47 * is calculated by subtracting @base from the gpio number.
48 */
49struct gpio_chip {
50 char *label;
51
52 int (*direction_input)(struct gpio_chip *chip,
53 unsigned offset);
54 int (*get)(struct gpio_chip *chip,
55 unsigned offset);
56 int (*direction_output)(struct gpio_chip *chip,
57 unsigned offset, int value);
58 void (*set)(struct gpio_chip *chip,
59 unsigned offset, int value);
60 void (*dbg_show)(struct seq_file *s,
61 struct gpio_chip *chip);
62 int base;
63 u16 ngpio;
64 unsigned can_sleep:1;
65};
66
67extern const char *gpiochip_is_requested(struct gpio_chip *chip,
68 unsigned offset);
69
70/* add/remove chips */
71extern int gpiochip_add(struct gpio_chip *chip);
72extern int __must_check gpiochip_remove(struct gpio_chip *chip);
73
74
75/* Always use the library code for GPIO management calls,
76 * or when sleeping may be involved.
77 */
78extern int gpio_request(unsigned gpio, const char *label);
79extern void gpio_free(unsigned gpio);
80
81extern int gpio_direction_input(unsigned gpio);
82extern int gpio_direction_output(unsigned gpio, int value);
83
84extern int gpio_get_value_cansleep(unsigned gpio);
85extern void gpio_set_value_cansleep(unsigned gpio, int value);
86
87
88/* A platform's <asm/gpio.h> code may want to inline the I/O calls when
89 * the GPIO is constant and refers to some always-present controller,
90 * giving direct access to chip registers and tight bitbanging loops.
91 */
92extern int __gpio_get_value(unsigned gpio);
93extern void __gpio_set_value(unsigned gpio, int value);
94
95extern int __gpio_cansleep(unsigned gpio);
96
97
98#else
99
4/* platforms that don't directly support access to GPIOs through I2C, SPI, 100/* platforms that don't directly support access to GPIOs through I2C, SPI,
5 * or other blocking infrastructure can use these wrappers. 101 * or other blocking infrastructure can use these wrappers.
6 */ 102 */
@@ -22,4 +118,6 @@ static inline void gpio_set_value_cansleep(unsigned gpio, int value)
22 gpio_set_value(gpio, value); 118 gpio_set_value(gpio, value);
23} 119}
24 120
121#endif
122
25#endif /* _ASM_GENERIC_GPIO_H */ 123#endif /* _ASM_GENERIC_GPIO_H */
diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h
index d85172e9ed45..4b8d31cda1a0 100644
--- a/include/asm-generic/percpu.h
+++ b/include/asm-generic/percpu.h
@@ -3,54 +3,79 @@
3#include <linux/compiler.h> 3#include <linux/compiler.h>
4#include <linux/threads.h> 4#include <linux/threads.h>
5 5
6#define __GENERIC_PER_CPU 6/*
7 * Determine the real variable name from the name visible in the
8 * kernel sources.
9 */
10#define per_cpu_var(var) per_cpu__##var
11
7#ifdef CONFIG_SMP 12#ifdef CONFIG_SMP
8 13
14/*
15 * per_cpu_offset() is the offset that has to be added to a
16 * percpu variable to get to the instance for a certain processor.
17 *
18 * Most arches use the __per_cpu_offset array for those offsets but
19 * some arches have their own ways of determining the offset (x86_64, s390).
20 */
21#ifndef __per_cpu_offset
9extern unsigned long __per_cpu_offset[NR_CPUS]; 22extern unsigned long __per_cpu_offset[NR_CPUS];
10 23
11#define per_cpu_offset(x) (__per_cpu_offset[x]) 24#define per_cpu_offset(x) (__per_cpu_offset[x])
25#endif
12 26
13/* Separate out the type, so (int[3], foo) works. */ 27/*
14#define DEFINE_PER_CPU(type, name) \ 28 * Determine the offset for the currently active processor.
15 __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name 29 * An arch may define __my_cpu_offset to provide a more effective
16 30 * means of obtaining the offset to the per cpu variables of the
17#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \ 31 * current processor.
18 __attribute__((__section__(".data.percpu.shared_aligned"))) \ 32 */
19 __typeof__(type) per_cpu__##name \ 33#ifndef __my_cpu_offset
20 ____cacheline_aligned_in_smp 34#define __my_cpu_offset per_cpu_offset(raw_smp_processor_id())
21 35#define my_cpu_offset per_cpu_offset(smp_processor_id())
22/* var is in discarded region: offset to particular copy we want */ 36#else
23#define per_cpu(var, cpu) (*({ \ 37#define my_cpu_offset __my_cpu_offset
24 extern int simple_identifier_##var(void); \ 38#endif
25 RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]); })) 39
26#define __get_cpu_var(var) per_cpu(var, smp_processor_id()) 40/*
27#define __raw_get_cpu_var(var) per_cpu(var, raw_smp_processor_id()) 41 * Add a offset to a pointer but keep the pointer as is.
28 42 *
29/* A macro to avoid #include hell... */ 43 * Only S390 provides its own means of moving the pointer.
30#define percpu_modcopy(pcpudst, src, size) \ 44 */
31do { \ 45#ifndef SHIFT_PERCPU_PTR
32 unsigned int __i; \ 46#define SHIFT_PERCPU_PTR(__p, __offset) RELOC_HIDE((__p), (__offset))
33 for_each_possible_cpu(__i) \ 47#endif
34 memcpy((pcpudst)+__per_cpu_offset[__i], \
35 (src), (size)); \
36} while (0)
37#else /* ! SMP */
38 48
39#define DEFINE_PER_CPU(type, name) \ 49/*
40 __typeof__(type) per_cpu__##name 50 * A percpu variable may point to a discarded regions. The following are
51 * established ways to produce a usable pointer from the percpu variable
52 * offset.
53 */
54#define per_cpu(var, cpu) \
55 (*SHIFT_PERCPU_PTR(&per_cpu_var(var), per_cpu_offset(cpu)))
56#define __get_cpu_var(var) \
57 (*SHIFT_PERCPU_PTR(&per_cpu_var(var), my_cpu_offset))
58#define __raw_get_cpu_var(var) \
59 (*SHIFT_PERCPU_PTR(&per_cpu_var(var), __my_cpu_offset))
41 60
42#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
43 DEFINE_PER_CPU(type, name)
44 61
45#define per_cpu(var, cpu) (*((void)(cpu), &per_cpu__##var)) 62#ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA
46#define __get_cpu_var(var) per_cpu__##var 63extern void setup_per_cpu_areas(void);
47#define __raw_get_cpu_var(var) per_cpu__##var 64#endif
65
66#else /* ! SMP */
67
68#define per_cpu(var, cpu) (*((void)(cpu), &per_cpu_var(var)))
69#define __get_cpu_var(var) per_cpu_var(var)
70#define __raw_get_cpu_var(var) per_cpu_var(var)
48 71
49#endif /* SMP */ 72#endif /* SMP */
50 73
51#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name 74#ifndef PER_CPU_ATTRIBUTES
75#define PER_CPU_ATTRIBUTES
76#endif
52 77
53#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var) 78#define DECLARE_PER_CPU(type, name) extern PER_CPU_ATTRIBUTES \
54#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var) 79 __typeof__(type) per_cpu_var(name)
55 80
56#endif /* _ASM_GENERIC_PERCPU_H_ */ 81#endif /* _ASM_GENERIC_PERCPU_H_ */
diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
index 29ff5d84d8c3..087325ede76c 100644
--- a/include/asm-generic/pgtable-nopmd.h
+++ b/include/asm-generic/pgtable-nopmd.h
@@ -54,7 +54,7 @@ static inline pmd_t * pmd_offset(pud_t * pud, unsigned long address)
54 * inside the pud, so has no extra memory associated with it. 54 * inside the pud, so has no extra memory associated with it.
55 */ 55 */
56#define pmd_alloc_one(mm, address) NULL 56#define pmd_alloc_one(mm, address) NULL
57#define pmd_free(x) do { } while (0) 57#define pmd_free(mm, x) do { } while (0)
58#define __pmd_free_tlb(tlb, x) do { } while (0) 58#define __pmd_free_tlb(tlb, x) do { } while (0)
59 59
60#undef pmd_addr_end 60#undef pmd_addr_end
diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
index 566464500558..87cf449a6df3 100644
--- a/include/asm-generic/pgtable-nopud.h
+++ b/include/asm-generic/pgtable-nopud.h
@@ -51,7 +51,7 @@ static inline pud_t * pud_offset(pgd_t * pgd, unsigned long address)
51 * inside the pgd, so has no extra memory associated with it. 51 * inside the pgd, so has no extra memory associated with it.
52 */ 52 */
53#define pud_alloc_one(mm, address) NULL 53#define pud_alloc_one(mm, address) NULL
54#define pud_free(x) do { } while (0) 54#define pud_free(mm, x) do { } while (0)
55#define __pud_free_tlb(tlb, x) do { } while (0) 55#define __pud_free_tlb(tlb, x) do { } while (0)
56 56
57#undef pud_addr_end 57#undef pud_addr_end
diff --git a/include/asm-generic/resource.h b/include/asm-generic/resource.h
index cfe3692b23e5..587566f95f6c 100644
--- a/include/asm-generic/resource.h
+++ b/include/asm-generic/resource.h
@@ -12,7 +12,7 @@
12 * then it defines them prior including asm-generic/resource.h. ) 12 * then it defines them prior including asm-generic/resource.h. )
13 */ 13 */
14 14
15#define RLIMIT_CPU 0 /* CPU time in ms */ 15#define RLIMIT_CPU 0 /* CPU time in sec */
16#define RLIMIT_FSIZE 1 /* Maximum filesize */ 16#define RLIMIT_FSIZE 1 /* Maximum filesize */
17#define RLIMIT_DATA 2 /* max data size */ 17#define RLIMIT_DATA 2 /* max data size */
18#define RLIMIT_STACK 3 /* max stack size */ 18#define RLIMIT_STACK 3 /* max stack size */
@@ -44,8 +44,8 @@
44#define RLIMIT_NICE 13 /* max nice prio allowed to raise to 44#define RLIMIT_NICE 13 /* max nice prio allowed to raise to
45 0-39 for nice level 19 .. -20 */ 45 0-39 for nice level 19 .. -20 */
46#define RLIMIT_RTPRIO 14 /* maximum realtime priority */ 46#define RLIMIT_RTPRIO 14 /* maximum realtime priority */
47 47#define RLIMIT_RTTIME 15 /* timeout for RT tasks in us */
48#define RLIM_NLIMITS 15 48#define RLIM_NLIMITS 16
49 49
50/* 50/*
51 * SuS says limits have to be unsigned. 51 * SuS says limits have to be unsigned.
@@ -86,6 +86,7 @@
86 [RLIMIT_MSGQUEUE] = { MQ_BYTES_MAX, MQ_BYTES_MAX }, \ 86 [RLIMIT_MSGQUEUE] = { MQ_BYTES_MAX, MQ_BYTES_MAX }, \
87 [RLIMIT_NICE] = { 0, 0 }, \ 87 [RLIMIT_NICE] = { 0, 0 }, \
88 [RLIMIT_RTPRIO] = { 0, 0 }, \ 88 [RLIMIT_RTPRIO] = { 0, 0 }, \
89 [RLIMIT_RTTIME] = { RLIM_INFINITY, RLIM_INFINITY }, \
89} 90}
90 91
91#endif /* __KERNEL__ */ 92#endif /* __KERNEL__ */
diff --git a/include/asm-generic/rtc.h b/include/asm-generic/rtc.h
index d3238f1f70a6..dd1bed860e64 100644
--- a/include/asm-generic/rtc.h
+++ b/include/asm-generic/rtc.h
@@ -35,10 +35,11 @@
35static inline unsigned char rtc_is_updating(void) 35static inline unsigned char rtc_is_updating(void)
36{ 36{
37 unsigned char uip; 37 unsigned char uip;
38 unsigned long flags;
38 39
39 spin_lock_irq(&rtc_lock); 40 spin_lock_irqsave(&rtc_lock, flags);
40 uip = (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP); 41 uip = (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP);
41 spin_unlock_irq(&rtc_lock); 42 spin_unlock_irqrestore(&rtc_lock, flags);
42 return uip; 43 return uip;
43} 44}
44 45
@@ -46,6 +47,8 @@ static inline unsigned int get_rtc_time(struct rtc_time *time)
46{ 47{
47 unsigned long uip_watchdog = jiffies; 48 unsigned long uip_watchdog = jiffies;
48 unsigned char ctrl; 49 unsigned char ctrl;
50 unsigned long flags;
51
49#ifdef CONFIG_MACH_DECSTATION 52#ifdef CONFIG_MACH_DECSTATION
50 unsigned int real_year; 53 unsigned int real_year;
51#endif 54#endif
@@ -72,7 +75,7 @@ static inline unsigned int get_rtc_time(struct rtc_time *time)
72 * RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated 75 * RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated
73 * by the RTC when initially set to a non-zero value. 76 * by the RTC when initially set to a non-zero value.
74 */ 77 */
75 spin_lock_irq(&rtc_lock); 78 spin_lock_irqsave(&rtc_lock, flags);
76 time->tm_sec = CMOS_READ(RTC_SECONDS); 79 time->tm_sec = CMOS_READ(RTC_SECONDS);
77 time->tm_min = CMOS_READ(RTC_MINUTES); 80 time->tm_min = CMOS_READ(RTC_MINUTES);
78 time->tm_hour = CMOS_READ(RTC_HOURS); 81 time->tm_hour = CMOS_READ(RTC_HOURS);
@@ -83,7 +86,7 @@ static inline unsigned int get_rtc_time(struct rtc_time *time)
83 real_year = CMOS_READ(RTC_DEC_YEAR); 86 real_year = CMOS_READ(RTC_DEC_YEAR);
84#endif 87#endif
85 ctrl = CMOS_READ(RTC_CONTROL); 88 ctrl = CMOS_READ(RTC_CONTROL);
86 spin_unlock_irq(&rtc_lock); 89 spin_unlock_irqrestore(&rtc_lock, flags);
87 90
88 if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD) 91 if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
89 { 92 {
diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index 962cad7cfbbd..8feeae1f2369 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -8,8 +8,6 @@ extern char _data[], _sdata[], _edata[];
8extern char __bss_start[], __bss_stop[]; 8extern char __bss_start[], __bss_stop[];
9extern char __init_begin[], __init_end[]; 9extern char __init_begin[], __init_end[];
10extern char _sinittext[], _einittext[]; 10extern char _sinittext[], _einittext[];
11extern char _sextratext[] __attribute__((weak));
12extern char _eextratext[] __attribute__((weak));
13extern char _end[]; 11extern char _end[];
14extern char __per_cpu_start[], __per_cpu_end[]; 12extern char __per_cpu_start[], __per_cpu_end[];
15extern char __kprobes_text_start[], __kprobes_text_end[]; 13extern char __kprobes_text_start[], __kprobes_text_end[];
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 9f584cc5c5fb..f784d2f34149 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -9,10 +9,46 @@
9/* Align . to a 8 byte boundary equals to maximum function alignment. */ 9/* Align . to a 8 byte boundary equals to maximum function alignment. */
10#define ALIGN_FUNCTION() . = ALIGN(8) 10#define ALIGN_FUNCTION() . = ALIGN(8)
11 11
12/* The actual configuration determine if the init/exit sections
13 * are handled as text/data or they can be discarded (which
14 * often happens at runtime)
15 */
16#ifdef CONFIG_HOTPLUG
17#define DEV_KEEP(sec) *(.dev##sec)
18#define DEV_DISCARD(sec)
19#else
20#define DEV_KEEP(sec)
21#define DEV_DISCARD(sec) *(.dev##sec)
22#endif
23
24#ifdef CONFIG_HOTPLUG_CPU
25#define CPU_KEEP(sec) *(.cpu##sec)
26#define CPU_DISCARD(sec)
27#else
28#define CPU_KEEP(sec)
29#define CPU_DISCARD(sec) *(.cpu##sec)
30#endif
31
32#if defined(CONFIG_MEMORY_HOTPLUG)
33#define MEM_KEEP(sec) *(.mem##sec)
34#define MEM_DISCARD(sec)
35#else
36#define MEM_KEEP(sec)
37#define MEM_DISCARD(sec) *(.mem##sec)
38#endif
39
40
12/* .data section */ 41/* .data section */
13#define DATA_DATA \ 42#define DATA_DATA \
14 *(.data) \ 43 *(.data) \
15 *(.data.init.refok) \ 44 *(.data.init.refok) \
45 *(.ref.data) \
46 DEV_KEEP(init.data) \
47 DEV_KEEP(exit.data) \
48 CPU_KEEP(init.data) \
49 CPU_KEEP(exit.data) \
50 MEM_KEEP(init.data) \
51 MEM_KEEP(exit.data) \
16 . = ALIGN(8); \ 52 . = ALIGN(8); \
17 VMLINUX_SYMBOL(__start___markers) = .; \ 53 VMLINUX_SYMBOL(__start___markers) = .; \
18 *(__markers) \ 54 *(__markers) \
@@ -132,14 +168,25 @@
132 *(__ksymtab_strings) \ 168 *(__ksymtab_strings) \
133 } \ 169 } \
134 \ 170 \
171 /* __*init sections */ \
172 __init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) { \
173 *(.ref.rodata) \
174 DEV_KEEP(init.rodata) \
175 DEV_KEEP(exit.rodata) \
176 CPU_KEEP(init.rodata) \
177 CPU_KEEP(exit.rodata) \
178 MEM_KEEP(init.rodata) \
179 MEM_KEEP(exit.rodata) \
180 } \
181 \
135 /* Built-in module parameters. */ \ 182 /* Built-in module parameters. */ \
136 __param : AT(ADDR(__param) - LOAD_OFFSET) { \ 183 __param : AT(ADDR(__param) - LOAD_OFFSET) { \
137 VMLINUX_SYMBOL(__start___param) = .; \ 184 VMLINUX_SYMBOL(__start___param) = .; \
138 *(__param) \ 185 *(__param) \
139 VMLINUX_SYMBOL(__stop___param) = .; \ 186 VMLINUX_SYMBOL(__stop___param) = .; \
187 . = ALIGN((align)); \
140 VMLINUX_SYMBOL(__end_rodata) = .; \ 188 VMLINUX_SYMBOL(__end_rodata) = .; \
141 } \ 189 } \
142 \
143 . = ALIGN((align)); 190 . = ALIGN((align));
144 191
145/* RODATA provided for backward compatibility. 192/* RODATA provided for backward compatibility.
@@ -158,8 +205,16 @@
158#define TEXT_TEXT \ 205#define TEXT_TEXT \
159 ALIGN_FUNCTION(); \ 206 ALIGN_FUNCTION(); \
160 *(.text) \ 207 *(.text) \
208 *(.ref.text) \
161 *(.text.init.refok) \ 209 *(.text.init.refok) \
162 *(.exit.text.refok) 210 *(.exit.text.refok) \
211 DEV_KEEP(init.text) \
212 DEV_KEEP(exit.text) \
213 CPU_KEEP(init.text) \
214 CPU_KEEP(exit.text) \
215 MEM_KEEP(init.text) \
216 MEM_KEEP(exit.text)
217
163 218
164/* sched.text is aling to function alignment to secure we have same 219/* sched.text is aling to function alignment to secure we have same
165 * address even at second ld pass when generating System.map */ 220 * address even at second ld pass when generating System.map */
@@ -183,6 +238,37 @@
183 *(.kprobes.text) \ 238 *(.kprobes.text) \
184 VMLINUX_SYMBOL(__kprobes_text_end) = .; 239 VMLINUX_SYMBOL(__kprobes_text_end) = .;
185 240
241/* init and exit section handling */
242#define INIT_DATA \
243 *(.init.data) \
244 DEV_DISCARD(init.data) \
245 DEV_DISCARD(init.rodata) \
246 CPU_DISCARD(init.data) \
247 CPU_DISCARD(init.rodata) \
248 MEM_DISCARD(init.data) \
249 MEM_DISCARD(init.rodata)
250
251#define INIT_TEXT \
252 *(.init.text) \
253 DEV_DISCARD(init.text) \
254 CPU_DISCARD(init.text) \
255 MEM_DISCARD(init.text)
256
257#define EXIT_DATA \
258 *(.exit.data) \
259 DEV_DISCARD(exit.data) \
260 DEV_DISCARD(exit.rodata) \
261 CPU_DISCARD(exit.data) \
262 CPU_DISCARD(exit.rodata) \
263 MEM_DISCARD(exit.data) \
264 MEM_DISCARD(exit.rodata)
265
266#define EXIT_TEXT \
267 *(.exit.text) \
268 DEV_DISCARD(exit.text) \
269 CPU_DISCARD(exit.text) \
270 MEM_DISCARD(exit.text)
271
186 /* DWARF debug sections. 272 /* DWARF debug sections.
187 Symbols in the DWARF debugging sections are relative to 273 Symbols in the DWARF debugging sections are relative to
188 the beginning of the section so we begin them at 0. */ 274 the beginning of the section so we begin them at 0. */