Added kexec patches which were not included in PR 1.3
[kernel-power] / kernel-power-2.6.28 / debian / patches / kexec.diff
1 diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
2 index 7b1f312..4a9a275 100644
3 --- a/arch/arm/boot/compressed/head.S
4 +++ b/arch/arm/boot/compressed/head.S
5 @@ -27,6 +27,14 @@
6                 .macro  writeb, ch, rb
7                 mcr     p14, 0, \ch, c0, c5, 0
8                 .endm
9 +elif defined(CONFIG_CPU_V7)
10 +               .macro  loadsp, rb
11 +               .endm
12 +               .macro  writeb, ch, rb
13 +wait:          mrc     p14, 0, pc, c0, c1, 0
14 +               bcs     wait
15 +               mcr     p14, 0, \ch, c0, c5, 0
16 +               .endm
17  #else
18                 .macro  loadsp, rb
19                 .endm
20 diff --git a/arch/arm/boot/compressed/misc.c b/arch/arm/boot/compressed/misc.c
21 index 65ce8ff..c74fc24 100644
22 --- a/arch/arm/boot/compressed/misc.c
23 +++ b/arch/arm/boot/compressed/misc.c
24 @@ -47,6 +47,17 @@ static void icedcc_putc(int ch)
25         asm("mcr p14, 0, %0, c0, c5, 0" : : "r" (ch));
26  }
27  
28 +#elif defined(CONFIG_CPU_V7)
29 +
30 +static void icedcc_putc(int ch)
31 +{
32 +       asm(
33 +       "wait:  mrc     p14, 0, pc, c0, c1, 0                   \n\
34 +               bcs     wait                                    \n\
35 +               mcr     p14, 0, %0, c0, c5, 0                   "
36 +       : : "r" (ch));
37 +}
38 +
39  #else
40  
41  static void icedcc_putc(int ch)
42 diff --git a/arch/arm/kernel/debug.S b/arch/arm/kernel/debug.S
43 index f53c582..e1866bf 100644
44 --- a/arch/arm/kernel/debug.S
45 +++ b/arch/arm/kernel/debug.S
46 @@ -49,6 +49,26 @@
47  1002:
48                 .endm
49  
50 +#elif defined(CONFIG_CPU_V7)
51 +
52 +               .macro  addruart, rx
53 +               .endm
54 +
55 +               .macro  senduart, rd, rx
56 +               mcr     p14, 0, \rd, c0, c5, 0
57 +               .endm
58 +
59 +               .macro  busyuart, rd, rx
60 +busy:          mrc     p14, 0, pc, c0, c1, 0
61 +               bcs     busy
62 +               .endm
63 +
64 +               .macro  waituart, rd, rx
65 +wait:          mrc     p14, 0, pc, c0, c1, 0
66 +               bcs     wait
67 +
68 +               .endm
69 +
70  #else
71  
72                 .macro  addruart, rx
73 diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h
74 index 5ccce0a..3ca36bb 100644
75 --- a/arch/arm/include/asm/setup.h
76 +++ b/arch/arm/include/asm/setup.h
77 @@ -21,6 +21,11 @@
78  /* The list ends with an ATAG_NONE node. */
79  #define ATAG_NONE      0x00000000
80  
81 +/* Some sanity checks are needed */
82 +#define ATAG_MAX_SZ    PAGE_SIZE
83 +#define atag_valid(tag)                                                        \
84 +       ((tag)->hdr.size && ((tag)->hdr.size <= ATAG_MAX_SZ))
85 +
86  struct tag_header {
87         __u32 size;
88         __u32 tag;
89 @@ -173,9 +178,10 @@ struct tagtable {
90         int (*parse)(const struct tag *);
91  };
92  
93 -#define tag_member_present(tag,member)                         \
94 -       ((unsigned long)(&((struct tag *)0L)->member + 1)       \
95 -               <= (tag)->hdr.size * 4)
96 +#define tag_member_present(tag,member)                                 \
97 +       (atag_valid(tag) &&                                             \
98 +               (((unsigned long)(&((struct tag *)0L)->member + 1)      \
99 +                       <= (tag)->hdr.size * 4))
100  
101  #define tag_next(t)    ((struct tag *)((__u32 *)(t) + (t)->hdr.size))
102  #define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2)
103 diff --git a/arch/arm/kernel/atags.c b/arch/arm/kernel/atags.c
104 index 42a1a14..14d0993 100644
105 --- a/arch/arm/kernel/atags.c
106 +++ b/arch/arm/kernel/atags.c
107 @@ -51,7 +51,7 @@ static int __init init_atags_procfs(void)
108                 return -EINVAL;
109         }
110  
111 -       for (; tag->hdr.size; tag = tag_next(tag))
112 +       for (; atag_valid(tag); tag = tag_next(tag))
113                 ;
114  
115         /* include the terminating ATAG_NONE */
116 diff --git a/arch/arm/kernel/compat.c b/arch/arm/kernel/compat.c
117 index 0a13854..3e63ee1 100644
118 --- a/arch/arm/kernel/compat.c
119 +++ b/arch/arm/kernel/compat.c
120 @@ -220,7 +220,7 @@ void __init convert_to_tag_list(struct tag *tags)
121  
122  void __init squash_mem_tags(struct tag *tag)
123  {
124 -       for (; tag->hdr.size; tag = tag_next(tag))
125 +       for (; atag_valid(tag); tag = tag_next(tag))
126                 if (tag->hdr.tag == ATAG_MEM)
127                         tag->hdr.tag = ATAG_NONE;
128  }
129 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
130 index c6c57b6..53d7181 100644
131 --- a/arch/arm/kernel/setup.c
132 +++ b/arch/arm/kernel/setup.c
133 @@ -556,7 +556,7 @@ request_standard_resources(struct meminfo *mi, struct machine_desc *mdesc)
134   */
135  static int __init parse_tag_core(const struct tag *tag)
136  {
137 -       if (tag->hdr.size > 2) {
138 +       if ((atag_valid(tag) && (tag->hdr.size > 2))) {
139                 if ((tag->u.core.flags & 1) == 0)
140                         root_mountflags &= ~MS_RDONLY;
141                 ROOT_DEV = old_decode_dev(tag->u.core.rootdev);
142 @@ -660,7 +660,7 @@ static int __init parse_tag(const struct tag *tag)
143   */
144  static void __init parse_tags(const struct tag *t)
145  {
146 -       for (; t->hdr.size; t = tag_next(t))
147 +       for (; atag_valid(t); t = tag_next(t))
148                 if (!parse_tag(t))
149                         printk(KERN_WARNING
150                                 "Ignoring unrecognised tag 0x%08x\n",
151 diff --git a/arch/arm/mach-orion5x/common.c b/arch/arm/mach-orion5x/common.c
152 index f87fa12..8afee34 100644
153 --- a/arch/arm/mach-orion5x/common.c
154 +++ b/arch/arm/mach-orion5x/common.c
155 @@ -717,7 +717,7 @@ void __init orion5x_init(void)
156  void __init tag_fixup_mem32(struct machine_desc *mdesc, struct tag *t,
157                             char **from, struct meminfo *meminfo)
158  {
159 -       for (; t->hdr.size; t = tag_next(t))
160 +       for (; atag_valid(t); t = tag_next(t))
161                 if (t->hdr.tag == ATAG_MEM &&
162                     (!t->u.mem.size || t->u.mem.size & ~PAGE_MASK ||
163                      t->u.mem.start & ~PAGE_MASK)) {