Gentoo Archives: gentoo-commits

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/hardened-patchset:master commit in: 3.2.57/, 3.14.2/, 3.2.58/
Date: Fri, 02 May 2014 19:17:47
Message-Id: 1399058156.d8bca9ac33b3bff1b286fab73c59643c87724d50.blueness@gentoo
1 commit: d8bca9ac33b3bff1b286fab73c59643c87724d50
2 Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
3 AuthorDate: Fri May 2 19:15:56 2014 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Fri May 2 19:15:56 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-patchset.git;a=commit;h=d8bca9ac
7
8 Grsec/PaX: 3.0-{3.2.58,3.14.2}-201405011752
9
10 ---
11 3.14.2/0000_README | 2 +-
12 ... 4420_grsecurity-3.0-3.14.2-201405011752.patch} | 19 +-
13 {3.2.57 => 3.2.58}/0000_README | 6 +-
14 {3.2.57 => 3.2.58}/1021_linux-3.2.22.patch | 0
15 {3.2.57 => 3.2.58}/1022_linux-3.2.23.patch | 0
16 {3.2.57 => 3.2.58}/1023_linux-3.2.24.patch | 0
17 {3.2.57 => 3.2.58}/1024_linux-3.2.25.patch | 0
18 {3.2.57 => 3.2.58}/1025_linux-3.2.26.patch | 0
19 {3.2.57 => 3.2.58}/1026_linux-3.2.27.patch | 0
20 {3.2.57 => 3.2.58}/1027_linux-3.2.28.patch | 0
21 {3.2.57 => 3.2.58}/1028_linux-3.2.29.patch | 0
22 {3.2.57 => 3.2.58}/1029_linux-3.2.30.patch | 0
23 {3.2.57 => 3.2.58}/1030_linux-3.2.31.patch | 0
24 {3.2.57 => 3.2.58}/1031_linux-3.2.32.patch | 0
25 {3.2.57 => 3.2.58}/1032_linux-3.2.33.patch | 0
26 {3.2.57 => 3.2.58}/1033_linux-3.2.34.patch | 0
27 {3.2.57 => 3.2.58}/1034_linux-3.2.35.patch | 0
28 {3.2.57 => 3.2.58}/1035_linux-3.2.36.patch | 0
29 {3.2.57 => 3.2.58}/1036_linux-3.2.37.patch | 0
30 {3.2.57 => 3.2.58}/1037_linux-3.2.38.patch | 0
31 {3.2.57 => 3.2.58}/1038_linux-3.2.39.patch | 0
32 {3.2.57 => 3.2.58}/1039_linux-3.2.40.patch | 0
33 {3.2.57 => 3.2.58}/1040_linux-3.2.41.patch | 0
34 {3.2.57 => 3.2.58}/1041_linux-3.2.42.patch | 0
35 {3.2.57 => 3.2.58}/1042_linux-3.2.43.patch | 0
36 {3.2.57 => 3.2.58}/1043_linux-3.2.44.patch | 0
37 {3.2.57 => 3.2.58}/1044_linux-3.2.45.patch | 0
38 {3.2.57 => 3.2.58}/1045_linux-3.2.46.patch | 0
39 {3.2.57 => 3.2.58}/1046_linux-3.2.47.patch | 0
40 {3.2.57 => 3.2.58}/1047_linux-3.2.48.patch | 0
41 {3.2.57 => 3.2.58}/1048_linux-3.2.49.patch | 0
42 {3.2.57 => 3.2.58}/1049_linux-3.2.50.patch | 0
43 {3.2.57 => 3.2.58}/1050_linux-3.2.51.patch | 0
44 {3.2.57 => 3.2.58}/1051_linux-3.2.52.patch | 0
45 {3.2.57 => 3.2.58}/1052_linux-3.2.53.patch | 0
46 {3.2.57 => 3.2.58}/1053_linux-3.2.54.patch | 0
47 {3.2.57 => 3.2.58}/1054_linux-3.2.55.patch | 0
48 {3.2.57 => 3.2.58}/1055_linux-3.2.56.patch | 0
49 {3.2.57 => 3.2.58}/1056_linux-3.2.57.patch | 0
50 3.2.58/1057_linux-3.2.58.patch | 3567 ++++++++++++++++++++
51 .../4420_grsecurity-3.0-3.2.58-201405011748.patch | 1559 +++++++--
52 {3.2.57 => 3.2.58}/4425_grsec_remove_EI_PAX.patch | 0
53 .../4427_force_XATTR_PAX_tmpfs.patch | 0
54 .../4430_grsec-remove-localversion-grsec.patch | 0
55 {3.2.57 => 3.2.58}/4435_grsec-mute-warnings.patch | 0
56 .../4440_grsec-remove-protected-paths.patch | 0
57 .../4450_grsec-kconfig-default-gids.patch | 0
58 .../4465_selinux-avc_audit-log-curr_ip.patch | 0
59 {3.2.57 => 3.2.58}/4470_disable-compat_vdso.patch | 0
60 {3.2.57 => 3.2.58}/4475_emutramp_default_on.patch | 0
61 50 files changed, 4839 insertions(+), 314 deletions(-)
62
63 diff --git a/3.14.2/0000_README b/3.14.2/0000_README
64 index cbf89b3..5d6a666 100644
65 --- a/3.14.2/0000_README
66 +++ b/3.14.2/0000_README
67 @@ -2,7 +2,7 @@ README
68 -----------------------------------------------------------------------------
69 Individual Patch Descriptions:
70 -----------------------------------------------------------------------------
71 -Patch: 4420_grsecurity-3.0-3.14.2-201404270907.patch
72 +Patch: 4420_grsecurity-3.0-3.14.2-201405011752.patch
73 From: http://www.grsecurity.net
74 Desc: hardened-sources base patch from upstream grsecurity
75
76
77 diff --git a/3.14.2/4420_grsecurity-3.0-3.14.2-201404270907.patch b/3.14.2/4420_grsecurity-3.0-3.14.2-201405011752.patch
78 similarity index 99%
79 rename from 3.14.2/4420_grsecurity-3.0-3.14.2-201404270907.patch
80 rename to 3.14.2/4420_grsecurity-3.0-3.14.2-201405011752.patch
81 index c673c36..8a795cb 100644
82 --- a/3.14.2/4420_grsecurity-3.0-3.14.2-201404270907.patch
83 +++ b/3.14.2/4420_grsecurity-3.0-3.14.2-201405011752.patch
84 @@ -44211,6 +44211,18 @@ index 9b6c3bb..baeb5c7 100644
85
86 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
87 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
88 +diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
89 +index d5a7a13..703560f 100644
90 +--- a/drivers/media/media-device.c
91 ++++ b/drivers/media/media-device.c
92 +@@ -93,6 +93,7 @@ static long media_device_enum_entities(struct media_device *mdev,
93 + struct media_entity *ent;
94 + struct media_entity_desc u_ent;
95 +
96 ++ memset(&u_ent, 0, sizeof(u_ent));
97 + if (copy_from_user(&u_ent.id, &uent->id, sizeof(u_ent.id)))
98 + return -EFAULT;
99 +
100 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
101 index ed8cb90..5ef7f79 100644
102 --- a/drivers/media/pci/cx88/cx88-video.c
103 @@ -97428,7 +97440,7 @@ index b442e7e..6f5b5a2 100644
104 {
105 struct socket *sock;
106 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
107 -index 90b96a1..cd18f16 100644
108 +index 90b96a1..cd18f16d 100644
109 --- a/net/core/skbuff.c
110 +++ b/net/core/skbuff.c
111 @@ -2003,7 +2003,7 @@ EXPORT_SYMBOL(__skb_checksum);
112 @@ -105270,12 +105282,13 @@ index 7778b8e..3d619fc 100644
113
114 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
115 new file mode 100644
116 -index 0000000..4c2c45c
117 +index 0000000..1f0214f
118 --- /dev/null
119 +++ b/tools/gcc/.gitignore
120 -@@ -0,0 +1,2 @@
121 +@@ -0,0 +1,3 @@
122 +randomize_layout_seed.h
123 +size_overflow_hash.h
124 ++size_overflow_hash_aux.h
125 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
126 new file mode 100644
127 index 0000000..5ca9688
128
129 diff --git a/3.2.57/0000_README b/3.2.58/0000_README
130 similarity index 97%
131 rename from 3.2.57/0000_README
132 rename to 3.2.58/0000_README
133 index 59ae0fd..bb2ca4f 100644
134 --- a/3.2.57/0000_README
135 +++ b/3.2.58/0000_README
136 @@ -146,7 +146,11 @@ Patch: 1056_linux-3.2.57.patch
137 From: http://www.kernel.org
138 Desc: Linux 3.2.57
139
140 -Patch: 4420_grsecurity-3.0-3.2.57-201404241714.patch
141 +Patch: 1057_linux-3.2.58.patch
142 +From: http://www.kernel.org
143 +Desc: Linux 3.2.58
144 +
145 +Patch: 4420_grsecurity-3.0-3.2.58-201405011748.patch
146 From: http://www.grsecurity.net
147 Desc: hardened-sources base patch from upstream grsecurity
148
149
150 diff --git a/3.2.57/1021_linux-3.2.22.patch b/3.2.58/1021_linux-3.2.22.patch
151 similarity index 100%
152 rename from 3.2.57/1021_linux-3.2.22.patch
153 rename to 3.2.58/1021_linux-3.2.22.patch
154
155 diff --git a/3.2.57/1022_linux-3.2.23.patch b/3.2.58/1022_linux-3.2.23.patch
156 similarity index 100%
157 rename from 3.2.57/1022_linux-3.2.23.patch
158 rename to 3.2.58/1022_linux-3.2.23.patch
159
160 diff --git a/3.2.57/1023_linux-3.2.24.patch b/3.2.58/1023_linux-3.2.24.patch
161 similarity index 100%
162 rename from 3.2.57/1023_linux-3.2.24.patch
163 rename to 3.2.58/1023_linux-3.2.24.patch
164
165 diff --git a/3.2.57/1024_linux-3.2.25.patch b/3.2.58/1024_linux-3.2.25.patch
166 similarity index 100%
167 rename from 3.2.57/1024_linux-3.2.25.patch
168 rename to 3.2.58/1024_linux-3.2.25.patch
169
170 diff --git a/3.2.57/1025_linux-3.2.26.patch b/3.2.58/1025_linux-3.2.26.patch
171 similarity index 100%
172 rename from 3.2.57/1025_linux-3.2.26.patch
173 rename to 3.2.58/1025_linux-3.2.26.patch
174
175 diff --git a/3.2.57/1026_linux-3.2.27.patch b/3.2.58/1026_linux-3.2.27.patch
176 similarity index 100%
177 rename from 3.2.57/1026_linux-3.2.27.patch
178 rename to 3.2.58/1026_linux-3.2.27.patch
179
180 diff --git a/3.2.57/1027_linux-3.2.28.patch b/3.2.58/1027_linux-3.2.28.patch
181 similarity index 100%
182 rename from 3.2.57/1027_linux-3.2.28.patch
183 rename to 3.2.58/1027_linux-3.2.28.patch
184
185 diff --git a/3.2.57/1028_linux-3.2.29.patch b/3.2.58/1028_linux-3.2.29.patch
186 similarity index 100%
187 rename from 3.2.57/1028_linux-3.2.29.patch
188 rename to 3.2.58/1028_linux-3.2.29.patch
189
190 diff --git a/3.2.57/1029_linux-3.2.30.patch b/3.2.58/1029_linux-3.2.30.patch
191 similarity index 100%
192 rename from 3.2.57/1029_linux-3.2.30.patch
193 rename to 3.2.58/1029_linux-3.2.30.patch
194
195 diff --git a/3.2.57/1030_linux-3.2.31.patch b/3.2.58/1030_linux-3.2.31.patch
196 similarity index 100%
197 rename from 3.2.57/1030_linux-3.2.31.patch
198 rename to 3.2.58/1030_linux-3.2.31.patch
199
200 diff --git a/3.2.57/1031_linux-3.2.32.patch b/3.2.58/1031_linux-3.2.32.patch
201 similarity index 100%
202 rename from 3.2.57/1031_linux-3.2.32.patch
203 rename to 3.2.58/1031_linux-3.2.32.patch
204
205 diff --git a/3.2.57/1032_linux-3.2.33.patch b/3.2.58/1032_linux-3.2.33.patch
206 similarity index 100%
207 rename from 3.2.57/1032_linux-3.2.33.patch
208 rename to 3.2.58/1032_linux-3.2.33.patch
209
210 diff --git a/3.2.57/1033_linux-3.2.34.patch b/3.2.58/1033_linux-3.2.34.patch
211 similarity index 100%
212 rename from 3.2.57/1033_linux-3.2.34.patch
213 rename to 3.2.58/1033_linux-3.2.34.patch
214
215 diff --git a/3.2.57/1034_linux-3.2.35.patch b/3.2.58/1034_linux-3.2.35.patch
216 similarity index 100%
217 rename from 3.2.57/1034_linux-3.2.35.patch
218 rename to 3.2.58/1034_linux-3.2.35.patch
219
220 diff --git a/3.2.57/1035_linux-3.2.36.patch b/3.2.58/1035_linux-3.2.36.patch
221 similarity index 100%
222 rename from 3.2.57/1035_linux-3.2.36.patch
223 rename to 3.2.58/1035_linux-3.2.36.patch
224
225 diff --git a/3.2.57/1036_linux-3.2.37.patch b/3.2.58/1036_linux-3.2.37.patch
226 similarity index 100%
227 rename from 3.2.57/1036_linux-3.2.37.patch
228 rename to 3.2.58/1036_linux-3.2.37.patch
229
230 diff --git a/3.2.57/1037_linux-3.2.38.patch b/3.2.58/1037_linux-3.2.38.patch
231 similarity index 100%
232 rename from 3.2.57/1037_linux-3.2.38.patch
233 rename to 3.2.58/1037_linux-3.2.38.patch
234
235 diff --git a/3.2.57/1038_linux-3.2.39.patch b/3.2.58/1038_linux-3.2.39.patch
236 similarity index 100%
237 rename from 3.2.57/1038_linux-3.2.39.patch
238 rename to 3.2.58/1038_linux-3.2.39.patch
239
240 diff --git a/3.2.57/1039_linux-3.2.40.patch b/3.2.58/1039_linux-3.2.40.patch
241 similarity index 100%
242 rename from 3.2.57/1039_linux-3.2.40.patch
243 rename to 3.2.58/1039_linux-3.2.40.patch
244
245 diff --git a/3.2.57/1040_linux-3.2.41.patch b/3.2.58/1040_linux-3.2.41.patch
246 similarity index 100%
247 rename from 3.2.57/1040_linux-3.2.41.patch
248 rename to 3.2.58/1040_linux-3.2.41.patch
249
250 diff --git a/3.2.57/1041_linux-3.2.42.patch b/3.2.58/1041_linux-3.2.42.patch
251 similarity index 100%
252 rename from 3.2.57/1041_linux-3.2.42.patch
253 rename to 3.2.58/1041_linux-3.2.42.patch
254
255 diff --git a/3.2.57/1042_linux-3.2.43.patch b/3.2.58/1042_linux-3.2.43.patch
256 similarity index 100%
257 rename from 3.2.57/1042_linux-3.2.43.patch
258 rename to 3.2.58/1042_linux-3.2.43.patch
259
260 diff --git a/3.2.57/1043_linux-3.2.44.patch b/3.2.58/1043_linux-3.2.44.patch
261 similarity index 100%
262 rename from 3.2.57/1043_linux-3.2.44.patch
263 rename to 3.2.58/1043_linux-3.2.44.patch
264
265 diff --git a/3.2.57/1044_linux-3.2.45.patch b/3.2.58/1044_linux-3.2.45.patch
266 similarity index 100%
267 rename from 3.2.57/1044_linux-3.2.45.patch
268 rename to 3.2.58/1044_linux-3.2.45.patch
269
270 diff --git a/3.2.57/1045_linux-3.2.46.patch b/3.2.58/1045_linux-3.2.46.patch
271 similarity index 100%
272 rename from 3.2.57/1045_linux-3.2.46.patch
273 rename to 3.2.58/1045_linux-3.2.46.patch
274
275 diff --git a/3.2.57/1046_linux-3.2.47.patch b/3.2.58/1046_linux-3.2.47.patch
276 similarity index 100%
277 rename from 3.2.57/1046_linux-3.2.47.patch
278 rename to 3.2.58/1046_linux-3.2.47.patch
279
280 diff --git a/3.2.57/1047_linux-3.2.48.patch b/3.2.58/1047_linux-3.2.48.patch
281 similarity index 100%
282 rename from 3.2.57/1047_linux-3.2.48.patch
283 rename to 3.2.58/1047_linux-3.2.48.patch
284
285 diff --git a/3.2.57/1048_linux-3.2.49.patch b/3.2.58/1048_linux-3.2.49.patch
286 similarity index 100%
287 rename from 3.2.57/1048_linux-3.2.49.patch
288 rename to 3.2.58/1048_linux-3.2.49.patch
289
290 diff --git a/3.2.57/1049_linux-3.2.50.patch b/3.2.58/1049_linux-3.2.50.patch
291 similarity index 100%
292 rename from 3.2.57/1049_linux-3.2.50.patch
293 rename to 3.2.58/1049_linux-3.2.50.patch
294
295 diff --git a/3.2.57/1050_linux-3.2.51.patch b/3.2.58/1050_linux-3.2.51.patch
296 similarity index 100%
297 rename from 3.2.57/1050_linux-3.2.51.patch
298 rename to 3.2.58/1050_linux-3.2.51.patch
299
300 diff --git a/3.2.57/1051_linux-3.2.52.patch b/3.2.58/1051_linux-3.2.52.patch
301 similarity index 100%
302 rename from 3.2.57/1051_linux-3.2.52.patch
303 rename to 3.2.58/1051_linux-3.2.52.patch
304
305 diff --git a/3.2.57/1052_linux-3.2.53.patch b/3.2.58/1052_linux-3.2.53.patch
306 similarity index 100%
307 rename from 3.2.57/1052_linux-3.2.53.patch
308 rename to 3.2.58/1052_linux-3.2.53.patch
309
310 diff --git a/3.2.57/1053_linux-3.2.54.patch b/3.2.58/1053_linux-3.2.54.patch
311 similarity index 100%
312 rename from 3.2.57/1053_linux-3.2.54.patch
313 rename to 3.2.58/1053_linux-3.2.54.patch
314
315 diff --git a/3.2.57/1054_linux-3.2.55.patch b/3.2.58/1054_linux-3.2.55.patch
316 similarity index 100%
317 rename from 3.2.57/1054_linux-3.2.55.patch
318 rename to 3.2.58/1054_linux-3.2.55.patch
319
320 diff --git a/3.2.57/1055_linux-3.2.56.patch b/3.2.58/1055_linux-3.2.56.patch
321 similarity index 100%
322 rename from 3.2.57/1055_linux-3.2.56.patch
323 rename to 3.2.58/1055_linux-3.2.56.patch
324
325 diff --git a/3.2.57/1056_linux-3.2.57.patch b/3.2.58/1056_linux-3.2.57.patch
326 similarity index 100%
327 rename from 3.2.57/1056_linux-3.2.57.patch
328 rename to 3.2.58/1056_linux-3.2.57.patch
329
330 diff --git a/3.2.58/1057_linux-3.2.58.patch b/3.2.58/1057_linux-3.2.58.patch
331 new file mode 100644
332 index 0000000..db5723a
333 --- /dev/null
334 +++ b/3.2.58/1057_linux-3.2.58.patch
335 @@ -0,0 +1,3567 @@
336 +diff --git a/Documentation/video4linux/gspca.txt b/Documentation/video4linux/gspca.txt
337 +index b15e29f..90aae856 100644
338 +--- a/Documentation/video4linux/gspca.txt
339 ++++ b/Documentation/video4linux/gspca.txt
340 +@@ -55,6 +55,7 @@ zc3xx 0458:700f Genius VideoCam Web V2
341 + sonixj 0458:7025 Genius Eye 311Q
342 + sn9c20x 0458:7029 Genius Look 320s
343 + sonixj 0458:702e Genius Slim 310 NB
344 ++sn9c20x 0458:7045 Genius Look 1320 V2
345 + sn9c20x 0458:704a Genius Slim 1320
346 + sn9c20x 0458:704c Genius i-Look 1321
347 + sn9c20x 045e:00f4 LifeCam VX-6000 (SN9C20x + OV9650)
348 +diff --git a/Makefile b/Makefile
349 +index c92db9b..d59b394 100644
350 +--- a/Makefile
351 ++++ b/Makefile
352 +@@ -1,6 +1,6 @@
353 + VERSION = 3
354 + PATCHLEVEL = 2
355 +-SUBLEVEL = 57
356 ++SUBLEVEL = 58
357 + EXTRAVERSION =
358 + NAME = Saber-toothed Squirrel
359 +
360 +diff --git a/arch/alpha/lib/csum_partial_copy.c b/arch/alpha/lib/csum_partial_copy.c
361 +index 1d2ef5a..40736da 100644
362 +--- a/arch/alpha/lib/csum_partial_copy.c
363 ++++ b/arch/alpha/lib/csum_partial_copy.c
364 +@@ -373,11 +373,6 @@ csum_partial_copy_from_user(const void __user *src, void *dst, int len,
365 + __wsum
366 + csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
367 + {
368 +- __wsum checksum;
369 +- mm_segment_t oldfs = get_fs();
370 +- set_fs(KERNEL_DS);
371 +- checksum = csum_partial_copy_from_user((__force const void __user *)src,
372 +- dst, len, sum, NULL);
373 +- set_fs(oldfs);
374 +- return checksum;
375 ++ return csum_partial_copy_from_user((__force const void __user *)src,
376 ++ dst, len, sum, NULL);
377 + }
378 +diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
379 +index 253cc86..aefd459 100644
380 +--- a/arch/arm/include/asm/futex.h
381 ++++ b/arch/arm/include/asm/futex.h
382 +@@ -3,11 +3,6 @@
383 +
384 + #ifdef __KERNEL__
385 +
386 +-#if defined(CONFIG_CPU_USE_DOMAINS) && defined(CONFIG_SMP)
387 +-/* ARM doesn't provide unprivileged exclusive memory accessors */
388 +-#include <asm-generic/futex.h>
389 +-#else
390 +-
391 + #include <linux/futex.h>
392 + #include <linux/uaccess.h>
393 + #include <asm/errno.h>
394 +@@ -163,6 +158,5 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
395 + return ret;
396 + }
397 +
398 +-#endif /* !(CPU_USE_DOMAINS && SMP) */
399 + #endif /* __KERNEL__ */
400 + #endif /* _ASM_ARM_FUTEX_H */
401 +diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
402 +index 470457e..1cb80c4 100644
403 +--- a/arch/arm/include/asm/pgtable-2level.h
404 ++++ b/arch/arm/include/asm/pgtable-2level.h
405 +@@ -123,6 +123,7 @@
406 + #define L_PTE_USER (_AT(pteval_t, 1) << 8)
407 + #define L_PTE_XN (_AT(pteval_t, 1) << 9)
408 + #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
409 ++#define L_PTE_NONE (_AT(pteval_t, 1) << 11)
410 +
411 + /*
412 + * These are the memory types, defined to be compatible with
413 +@@ -138,6 +139,7 @@
414 + #define L_PTE_MT_DEV_NONSHARED (_AT(pteval_t, 0x0c) << 2) /* 1100 */
415 + #define L_PTE_MT_DEV_WC (_AT(pteval_t, 0x09) << 2) /* 1001 */
416 + #define L_PTE_MT_DEV_CACHED (_AT(pteval_t, 0x0b) << 2) /* 1011 */
417 ++#define L_PTE_MT_VECTORS (_AT(pteval_t, 0x0f) << 2) /* 1111 */
418 + #define L_PTE_MT_MASK (_AT(pteval_t, 0x0f) << 2)
419 +
420 + #endif /* _ASM_PGTABLE_2LEVEL_H */
421 +diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
422 +index 9b419ab..fcbac3c 100644
423 +--- a/arch/arm/include/asm/pgtable.h
424 ++++ b/arch/arm/include/asm/pgtable.h
425 +@@ -74,7 +74,7 @@ extern pgprot_t pgprot_kernel;
426 +
427 + #define _MOD_PROT(p, b) __pgprot(pgprot_val(p) | (b))
428 +
429 +-#define PAGE_NONE _MOD_PROT(pgprot_user, L_PTE_XN | L_PTE_RDONLY)
430 ++#define PAGE_NONE _MOD_PROT(pgprot_user, L_PTE_XN | L_PTE_RDONLY | L_PTE_NONE)
431 + #define PAGE_SHARED _MOD_PROT(pgprot_user, L_PTE_USER | L_PTE_XN)
432 + #define PAGE_SHARED_EXEC _MOD_PROT(pgprot_user, L_PTE_USER)
433 + #define PAGE_COPY _MOD_PROT(pgprot_user, L_PTE_USER | L_PTE_RDONLY | L_PTE_XN)
434 +@@ -84,7 +84,7 @@ extern pgprot_t pgprot_kernel;
435 + #define PAGE_KERNEL _MOD_PROT(pgprot_kernel, L_PTE_XN)
436 + #define PAGE_KERNEL_EXEC pgprot_kernel
437 +
438 +-#define __PAGE_NONE __pgprot(_L_PTE_DEFAULT | L_PTE_RDONLY | L_PTE_XN)
439 ++#define __PAGE_NONE __pgprot(_L_PTE_DEFAULT | L_PTE_RDONLY | L_PTE_XN | L_PTE_NONE)
440 + #define __PAGE_SHARED __pgprot(_L_PTE_DEFAULT | L_PTE_USER | L_PTE_XN)
441 + #define __PAGE_SHARED_EXEC __pgprot(_L_PTE_DEFAULT | L_PTE_USER)
442 + #define __PAGE_COPY __pgprot(_L_PTE_DEFAULT | L_PTE_USER | L_PTE_RDONLY | L_PTE_XN)
443 +@@ -279,7 +279,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
444 +
445 + static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
446 + {
447 +- const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER;
448 ++ const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER | L_PTE_NONE;
449 + pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
450 + return pte;
451 + }
452 +diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
453 +index 67f75a0..4e1ef6e 100644
454 +--- a/arch/arm/mm/Kconfig
455 ++++ b/arch/arm/mm/Kconfig
456 +@@ -458,7 +458,6 @@ config CPU_32v5
457 + config CPU_32v6
458 + bool
459 + select TLS_REG_EMUL if !CPU_32v6K && !MMU
460 +- select CPU_USE_DOMAINS if CPU_V6 && MMU
461 +
462 + config CPU_32v6K
463 + bool
464 +@@ -652,7 +651,7 @@ config ARM_THUMBEE
465 +
466 + config SWP_EMULATE
467 + bool "Emulate SWP/SWPB instructions"
468 +- depends on !CPU_USE_DOMAINS && CPU_V7
469 ++ depends on CPU_V7
470 + select HAVE_PROC_CPU if PROC_FS
471 + default y if SMP
472 + help
473 +diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
474 +index 9e28fdb..082fa18 100644
475 +--- a/arch/arm/mm/mmu.c
476 ++++ b/arch/arm/mm/mmu.c
477 +@@ -426,6 +426,14 @@ static void __init build_mem_type_table(void)
478 + mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
479 + }
480 + /*
481 ++ * We don't use domains on ARMv6 (since this causes problems with
482 ++ * v6/v7 kernels), so we must use a separate memory type for user
483 ++ * r/o, kernel r/w to map the vectors page.
484 ++ */
485 ++ if (cpu_arch == CPU_ARCH_ARMv6)
486 ++ vecs_pgprot |= L_PTE_MT_VECTORS;
487 ++
488 ++ /*
489 + * ARMv6 and above have extended page tables.
490 + */
491 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
492 +diff --git a/arch/arm/mm/proc-macros.S b/arch/arm/mm/proc-macros.S
493 +index 307a4de..8a3edd4 100644
494 +--- a/arch/arm/mm/proc-macros.S
495 ++++ b/arch/arm/mm/proc-macros.S
496 +@@ -106,13 +106,9 @@
497 + * 100x 1 0 1 r/o no acc
498 + * 10x0 1 0 1 r/o no acc
499 + * 1011 0 0 1 r/w no acc
500 +- * 110x 0 1 0 r/w r/o
501 +- * 11x0 0 1 0 r/w r/o
502 +- * 1111 0 1 1 r/w r/w
503 +- *
504 +- * If !CONFIG_CPU_USE_DOMAINS, the following permissions are changed:
505 + * 110x 1 1 1 r/o r/o
506 + * 11x0 1 1 1 r/o r/o
507 ++ * 1111 0 1 1 r/w r/w
508 + */
509 + .macro armv6_mt_table pfx
510 + \pfx\()_mt_table:
511 +@@ -131,7 +127,7 @@
512 + .long PTE_EXT_TEX(2) @ L_PTE_MT_DEV_NONSHARED
513 + .long 0x00 @ unused
514 + .long 0x00 @ unused
515 +- .long 0x00 @ unused
516 ++ .long PTE_CACHEABLE | PTE_BUFFERABLE | PTE_EXT_APX @ L_PTE_MT_VECTORS
517 + .endm
518 +
519 + .macro armv6_set_pte_ext pfx
520 +@@ -152,20 +148,21 @@
521 +
522 + tst r1, #L_PTE_USER
523 + orrne r3, r3, #PTE_EXT_AP1
524 +-#ifdef CONFIG_CPU_USE_DOMAINS
525 +- @ allow kernel read/write access to read-only user pages
526 + tstne r3, #PTE_EXT_APX
527 +- bicne r3, r3, #PTE_EXT_APX | PTE_EXT_AP0
528 +-#endif
529 ++
530 ++ @ user read-only -> kernel read-only
531 ++ bicne r3, r3, #PTE_EXT_AP0
532 +
533 + tst r1, #L_PTE_XN
534 + orrne r3, r3, #PTE_EXT_XN
535 +
536 +- orr r3, r3, r2
537 ++ eor r3, r3, r2
538 +
539 + tst r1, #L_PTE_YOUNG
540 + tstne r1, #L_PTE_PRESENT
541 + moveq r3, #0
542 ++ tstne r1, #L_PTE_NONE
543 ++ movne r3, #0
544 +
545 + str r3, [r0]
546 + mcr p15, 0, r0, c7, c10, 1 @ flush_pte
547 +diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
548 +index 19d21ff..43c6981 100644
549 +--- a/arch/arm/mm/proc-v7.S
550 ++++ b/arch/arm/mm/proc-v7.S
551 +@@ -160,17 +160,14 @@ ENTRY(cpu_v7_set_pte_ext)
552 +
553 + tst r1, #L_PTE_USER
554 + orrne r3, r3, #PTE_EXT_AP1
555 +-#ifdef CONFIG_CPU_USE_DOMAINS
556 +- @ allow kernel read/write access to read-only user pages
557 +- tstne r3, #PTE_EXT_APX
558 +- bicne r3, r3, #PTE_EXT_APX | PTE_EXT_AP0
559 +-#endif
560 +
561 + tst r1, #L_PTE_XN
562 + orrne r3, r3, #PTE_EXT_XN
563 +
564 + tst r1, #L_PTE_YOUNG
565 + tstne r1, #L_PTE_PRESENT
566 ++ eorne r1, r1, #L_PTE_NONE
567 ++ tstne r1, #L_PTE_NONE
568 + moveq r3, #0
569 +
570 + ARM( str r3, [r0, #2048]! )
571 +diff --git a/arch/mips/power/hibernate.S b/arch/mips/power/hibernate.S
572 +index f8a751c..5bf34ec 100644
573 +--- a/arch/mips/power/hibernate.S
574 ++++ b/arch/mips/power/hibernate.S
575 +@@ -44,6 +44,7 @@ LEAF(swsusp_arch_resume)
576 + bne t1, t3, 1b
577 + PTR_L t0, PBE_NEXT(t0)
578 + bnez t0, 0b
579 ++ jal local_flush_tlb_all /* Avoid TLB mismatch after kernel resume */
580 + PTR_LA t0, saved_regs
581 + PTR_L ra, PT_R31(t0)
582 + PTR_L sp, PT_R29(t0)
583 +diff --git a/arch/sh/kernel/dumpstack.c b/arch/sh/kernel/dumpstack.c
584 +index 694158b..3a6528c 100644
585 +--- a/arch/sh/kernel/dumpstack.c
586 ++++ b/arch/sh/kernel/dumpstack.c
587 +@@ -80,7 +80,7 @@ static int print_trace_stack(void *data, char *name)
588 + */
589 + static void print_trace_address(void *data, unsigned long addr, int reliable)
590 + {
591 +- printk(data);
592 ++ printk("%s", (char *)data);
593 + printk_address(addr, reliable);
594 + }
595 +
596 +diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
597 +index 87537e2..88d442d 100644
598 +--- a/arch/sparc/Kconfig
599 ++++ b/arch/sparc/Kconfig
600 +@@ -24,7 +24,7 @@ config SPARC
601 + select HAVE_IRQ_WORK
602 + select HAVE_DMA_ATTRS
603 + select HAVE_DMA_API_DEBUG
604 +- select HAVE_ARCH_JUMP_LABEL
605 ++ select HAVE_ARCH_JUMP_LABEL if SPARC64
606 + select HAVE_GENERIC_HARDIRQS
607 + select GENERIC_IRQ_SHOW
608 + select USE_GENERIC_SMP_HELPERS if SMP
609 +diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
610 +index 3e1449f..6d6c731 100644
611 +--- a/arch/sparc/include/asm/uaccess_64.h
612 ++++ b/arch/sparc/include/asm/uaccess_64.h
613 +@@ -267,8 +267,8 @@ extern long __strnlen_user(const char __user *, long len);
614 +
615 + #define strlen_user __strlen_user
616 + #define strnlen_user __strnlen_user
617 +-#define __copy_to_user_inatomic ___copy_to_user
618 +-#define __copy_from_user_inatomic ___copy_from_user
619 ++#define __copy_to_user_inatomic __copy_to_user
620 ++#define __copy_from_user_inatomic __copy_from_user
621 +
622 + #endif /* __ASSEMBLY__ */
623 +
624 +diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
625 +index 31111e3..656b5b6 100644
626 +--- a/arch/sparc/kernel/pci.c
627 ++++ b/arch/sparc/kernel/pci.c
628 +@@ -487,8 +487,8 @@ static void __devinit apb_fake_ranges(struct pci_dev *dev,
629 + pci_read_config_byte(dev, APB_MEM_ADDRESS_MAP, &map);
630 + apb_calc_first_last(map, &first, &last);
631 + res = bus->resource[1];
632 +- res->start = (first << 21);
633 +- res->end = (last << 21) + ((1 << 21) - 1);
634 ++ res->start = (first << 29);
635 ++ res->end = (last << 29) + ((1 << 29) - 1);
636 + res->flags = IORESOURCE_MEM;
637 + pci_resource_adjust(res, &pbm->mem_space);
638 + }
639 +diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
640 +index 817187d..557212c 100644
641 +--- a/arch/sparc/kernel/syscalls.S
642 ++++ b/arch/sparc/kernel/syscalls.S
643 +@@ -184,7 +184,8 @@ linux_sparc_syscall32:
644 + mov %i0, %l5 ! IEU1
645 + 5: call %l7 ! CTI Group brk forced
646 + srl %i5, 0, %o5 ! IEU1
647 +- ba,a,pt %xcc, 3f
648 ++ ba,pt %xcc, 3f
649 ++ sra %o0, 0, %o0
650 +
651 + /* Linux native system calls enter here... */
652 + .align 32
653 +@@ -212,7 +213,6 @@ linux_sparc_syscall:
654 + 3: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
655 + ret_sys_call:
656 + ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
657 +- sra %o0, 0, %o0
658 + mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
659 + sllx %g2, 32, %g2
660 +
661 +diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
662 +index 646d192..1a3cf6e 100644
663 +--- a/arch/x86/kernel/cpu/mshyperv.c
664 ++++ b/arch/x86/kernel/cpu/mshyperv.c
665 +@@ -18,6 +18,7 @@
666 + #include <asm/hypervisor.h>
667 + #include <asm/hyperv.h>
668 + #include <asm/mshyperv.h>
669 ++#include <asm/timer.h>
670 +
671 + struct ms_hyperv_info ms_hyperv;
672 + EXPORT_SYMBOL_GPL(ms_hyperv);
673 +@@ -70,6 +71,11 @@ static void __init ms_hyperv_init_platform(void)
674 +
675 + if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE)
676 + clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
677 ++
678 ++#ifdef CONFIG_X86_IO_APIC
679 ++ no_timer_check = 1;
680 ++#endif
681 ++
682 + }
683 +
684 + const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
685 +diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
686 +index ea69726..4ac4531 100644
687 +--- a/arch/x86/kernel/ldt.c
688 ++++ b/arch/x86/kernel/ldt.c
689 +@@ -230,6 +230,17 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
690 + }
691 + }
692 +
693 ++ /*
694 ++ * On x86-64 we do not support 16-bit segments due to
695 ++ * IRET leaking the high bits of the kernel stack address.
696 ++ */
697 ++#ifdef CONFIG_X86_64
698 ++ if (!ldt_info.seg_32bit) {
699 ++ error = -EINVAL;
700 ++ goto out_unlock;
701 ++ }
702 ++#endif
703 ++
704 + fill_ldt(&ldt, &ldt_info);
705 + if (oldmode)
706 + ldt.avl = 0;
707 +diff --git a/block/blk-core.c b/block/blk-core.c
708 +index a219c89..ec494ff 100644
709 +--- a/block/blk-core.c
710 ++++ b/block/blk-core.c
711 +@@ -2077,7 +2077,7 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes)
712 + if (!req->bio)
713 + return false;
714 +
715 +- trace_block_rq_complete(req->q, req);
716 ++ trace_block_rq_complete(req->q, req, nr_bytes);
717 +
718 + /*
719 + * For fs requests, rq is just carrier of independent bio's
720 +diff --git a/drivers/char/ipmi/ipmi_bt_sm.c b/drivers/char/ipmi/ipmi_bt_sm.c
721 +index 92ce302..263f899 100644
722 +--- a/drivers/char/ipmi/ipmi_bt_sm.c
723 ++++ b/drivers/char/ipmi/ipmi_bt_sm.c
724 +@@ -352,7 +352,7 @@ static inline void write_all_bytes(struct si_sm_data *bt)
725 +
726 + static inline int read_all_bytes(struct si_sm_data *bt)
727 + {
728 +- unsigned char i;
729 ++ unsigned int i;
730 +
731 + /*
732 + * length is "framing info", minimum = 4: NetFn, Seq, Cmd, cCode.
733 +diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c
734 +index b3379d6..2c6b671 100644
735 +--- a/drivers/cpufreq/powernow-k6.c
736 ++++ b/drivers/cpufreq/powernow-k6.c
737 +@@ -25,41 +25,108 @@
738 + static unsigned int busfreq; /* FSB, in 10 kHz */
739 + static unsigned int max_multiplier;
740 +
741 ++static unsigned int param_busfreq = 0;
742 ++static unsigned int param_max_multiplier = 0;
743 ++
744 ++module_param_named(max_multiplier, param_max_multiplier, uint, S_IRUGO);
745 ++MODULE_PARM_DESC(max_multiplier, "Maximum multiplier (allowed values: 20 30 35 40 45 50 55 60)");
746 ++
747 ++module_param_named(bus_frequency, param_busfreq, uint, S_IRUGO);
748 ++MODULE_PARM_DESC(bus_frequency, "Bus frequency in kHz");
749 +
750 + /* Clock ratio multiplied by 10 - see table 27 in AMD#23446 */
751 + static struct cpufreq_frequency_table clock_ratio[] = {
752 +- {45, /* 000 -> 4.5x */ 0},
753 ++ {60, /* 110 -> 6.0x */ 0},
754 ++ {55, /* 011 -> 5.5x */ 0},
755 + {50, /* 001 -> 5.0x */ 0},
756 ++ {45, /* 000 -> 4.5x */ 0},
757 + {40, /* 010 -> 4.0x */ 0},
758 +- {55, /* 011 -> 5.5x */ 0},
759 +- {20, /* 100 -> 2.0x */ 0},
760 +- {30, /* 101 -> 3.0x */ 0},
761 +- {60, /* 110 -> 6.0x */ 0},
762 + {35, /* 111 -> 3.5x */ 0},
763 ++ {30, /* 101 -> 3.0x */ 0},
764 ++ {20, /* 100 -> 2.0x */ 0},
765 + {0, CPUFREQ_TABLE_END}
766 + };
767 +
768 ++static const u8 index_to_register[8] = { 6, 3, 1, 0, 2, 7, 5, 4 };
769 ++static const u8 register_to_index[8] = { 3, 2, 4, 1, 7, 6, 0, 5 };
770 ++
771 ++static const struct {
772 ++ unsigned freq;
773 ++ unsigned mult;
774 ++} usual_frequency_table[] = {
775 ++ { 400000, 40 }, // 100 * 4
776 ++ { 450000, 45 }, // 100 * 4.5
777 ++ { 475000, 50 }, // 95 * 5
778 ++ { 500000, 50 }, // 100 * 5
779 ++ { 506250, 45 }, // 112.5 * 4.5
780 ++ { 533500, 55 }, // 97 * 5.5
781 ++ { 550000, 55 }, // 100 * 5.5
782 ++ { 562500, 50 }, // 112.5 * 5
783 ++ { 570000, 60 }, // 95 * 6
784 ++ { 600000, 60 }, // 100 * 6
785 ++ { 618750, 55 }, // 112.5 * 5.5
786 ++ { 660000, 55 }, // 120 * 5.5
787 ++ { 675000, 60 }, // 112.5 * 6
788 ++ { 720000, 60 }, // 120 * 6
789 ++};
790 ++
791 ++#define FREQ_RANGE 3000
792 +
793 + /**
794 + * powernow_k6_get_cpu_multiplier - returns the current FSB multiplier
795 + *
796 +- * Returns the current setting of the frequency multiplier. Core clock
797 ++ * Returns the current setting of the frequency multiplier. Core clock
798 + * speed is frequency of the Front-Side Bus multiplied with this value.
799 + */
800 + static int powernow_k6_get_cpu_multiplier(void)
801 + {
802 +- u64 invalue = 0;
803 ++ unsigned long invalue = 0;
804 + u32 msrval;
805 +
806 ++ local_irq_disable();
807 ++
808 + msrval = POWERNOW_IOPORT + 0x1;
809 + wrmsr(MSR_K6_EPMR, msrval, 0); /* enable the PowerNow port */
810 + invalue = inl(POWERNOW_IOPORT + 0x8);
811 + msrval = POWERNOW_IOPORT + 0x0;
812 + wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */
813 +
814 +- return clock_ratio[(invalue >> 5)&7].index;
815 ++ local_irq_enable();
816 ++
817 ++ return clock_ratio[register_to_index[(invalue >> 5)&7]].index;
818 + }
819 +
820 ++static void powernow_k6_set_cpu_multiplier(unsigned int best_i)
821 ++{
822 ++ unsigned long outvalue, invalue;
823 ++ unsigned long msrval;
824 ++ unsigned long cr0;
825 ++
826 ++ /* we now need to transform best_i to the BVC format, see AMD#23446 */
827 ++
828 ++ /*
829 ++ * The processor doesn't respond to inquiry cycles while changing the
830 ++ * frequency, so we must disable cache.
831 ++ */
832 ++ local_irq_disable();
833 ++ cr0 = read_cr0();
834 ++ write_cr0(cr0 | X86_CR0_CD);
835 ++ wbinvd();
836 ++
837 ++ outvalue = (1<<12) | (1<<10) | (1<<9) | (index_to_register[best_i]<<5);
838 ++
839 ++ msrval = POWERNOW_IOPORT + 0x1;
840 ++ wrmsr(MSR_K6_EPMR, msrval, 0); /* enable the PowerNow port */
841 ++ invalue = inl(POWERNOW_IOPORT + 0x8);
842 ++ invalue = invalue & 0x1f;
843 ++ outvalue = outvalue | invalue;
844 ++ outl(outvalue, (POWERNOW_IOPORT + 0x8));
845 ++ msrval = POWERNOW_IOPORT + 0x0;
846 ++ wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */
847 ++
848 ++ write_cr0(cr0);
849 ++ local_irq_enable();
850 ++}
851 +
852 + /**
853 + * powernow_k6_set_state - set the PowerNow! multiplier
854 +@@ -69,8 +136,6 @@ static int powernow_k6_get_cpu_multiplier(void)
855 + */
856 + static void powernow_k6_set_state(unsigned int best_i)
857 + {
858 +- unsigned long outvalue = 0, invalue = 0;
859 +- unsigned long msrval;
860 + struct cpufreq_freqs freqs;
861 +
862 + if (clock_ratio[best_i].index > max_multiplier) {
863 +@@ -84,18 +149,7 @@ static void powernow_k6_set_state(unsigned int best_i)
864 +
865 + cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
866 +
867 +- /* we now need to transform best_i to the BVC format, see AMD#23446 */
868 +-
869 +- outvalue = (1<<12) | (1<<10) | (1<<9) | (best_i<<5);
870 +-
871 +- msrval = POWERNOW_IOPORT + 0x1;
872 +- wrmsr(MSR_K6_EPMR, msrval, 0); /* enable the PowerNow port */
873 +- invalue = inl(POWERNOW_IOPORT + 0x8);
874 +- invalue = invalue & 0xf;
875 +- outvalue = outvalue | invalue;
876 +- outl(outvalue , (POWERNOW_IOPORT + 0x8));
877 +- msrval = POWERNOW_IOPORT + 0x0;
878 +- wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */
879 ++ powernow_k6_set_cpu_multiplier(best_i);
880 +
881 + cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
882 +
883 +@@ -140,18 +194,57 @@ static int powernow_k6_target(struct cpufreq_policy *policy,
884 + return 0;
885 + }
886 +
887 +-
888 + static int powernow_k6_cpu_init(struct cpufreq_policy *policy)
889 + {
890 + unsigned int i, f;
891 + int result;
892 ++ unsigned khz;
893 +
894 + if (policy->cpu != 0)
895 + return -ENODEV;
896 +
897 +- /* get frequencies */
898 +- max_multiplier = powernow_k6_get_cpu_multiplier();
899 +- busfreq = cpu_khz / max_multiplier;
900 ++ max_multiplier = 0;
901 ++ khz = cpu_khz;
902 ++ for (i = 0; i < ARRAY_SIZE(usual_frequency_table); i++) {
903 ++ if (khz >= usual_frequency_table[i].freq - FREQ_RANGE &&
904 ++ khz <= usual_frequency_table[i].freq + FREQ_RANGE) {
905 ++ khz = usual_frequency_table[i].freq;
906 ++ max_multiplier = usual_frequency_table[i].mult;
907 ++ break;
908 ++ }
909 ++ }
910 ++ if (param_max_multiplier) {
911 ++ for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) {
912 ++ if (clock_ratio[i].index == param_max_multiplier) {
913 ++ max_multiplier = param_max_multiplier;
914 ++ goto have_max_multiplier;
915 ++ }
916 ++ }
917 ++ printk(KERN_ERR "powernow-k6: invalid max_multiplier parameter, valid parameters 20, 30, 35, 40, 45, 50, 55, 60\n");
918 ++ return -EINVAL;
919 ++ }
920 ++
921 ++ if (!max_multiplier) {
922 ++ printk(KERN_WARNING "powernow-k6: unknown frequency %u, cannot determine current multiplier\n", khz);
923 ++ printk(KERN_WARNING "powernow-k6: use module parameters max_multiplier and bus_frequency\n");
924 ++ return -EOPNOTSUPP;
925 ++ }
926 ++
927 ++have_max_multiplier:
928 ++ param_max_multiplier = max_multiplier;
929 ++
930 ++ if (param_busfreq) {
931 ++ if (param_busfreq >= 50000 && param_busfreq <= 150000) {
932 ++ busfreq = param_busfreq / 10;
933 ++ goto have_busfreq;
934 ++ }
935 ++ printk(KERN_ERR "powernow-k6: invalid bus_frequency parameter, allowed range 50000 - 150000 kHz\n");
936 ++ return -EINVAL;
937 ++ }
938 ++
939 ++ busfreq = khz / max_multiplier;
940 ++have_busfreq:
941 ++ param_busfreq = busfreq * 10;
942 +
943 + /* table init */
944 + for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) {
945 +@@ -163,7 +256,7 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy)
946 + }
947 +
948 + /* cpuinfo and default policy values */
949 +- policy->cpuinfo.transition_latency = 200000;
950 ++ policy->cpuinfo.transition_latency = 500000;
951 + policy->cur = busfreq * max_multiplier;
952 +
953 + result = cpufreq_frequency_table_cpuinfo(policy, clock_ratio);
954 +diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
955 +index 385c58e..0f8114d 100644
956 +--- a/drivers/gpio/gpio-mxs.c
957 ++++ b/drivers/gpio/gpio-mxs.c
958 +@@ -167,7 +167,8 @@ static void __init mxs_gpio_init_gc(struct mxs_gpio_port *port)
959 + ct->regs.ack = PINCTRL_IRQSTAT(port->id) + MXS_CLR;
960 + ct->regs.mask = PINCTRL_IRQEN(port->id);
961 +
962 +- irq_setup_generic_chip(gc, IRQ_MSK(32), 0, IRQ_NOREQUEST, 0);
963 ++ irq_setup_generic_chip(gc, IRQ_MSK(32), IRQ_GC_INIT_NESTED_LOCK,
964 ++ IRQ_NOREQUEST, 0);
965 + }
966 +
967 + static int mxs_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
968 +diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
969 +index 2ea8a96..27999d9 100644
970 +--- a/drivers/gpu/drm/i915/intel_display.c
971 ++++ b/drivers/gpu/drm/i915/intel_display.c
972 +@@ -8946,6 +8946,12 @@ struct intel_quirk intel_quirks[] = {
973 + /* Acer/Packard Bell NCL20 */
974 + { 0x2a42, 0x1025, 0x034b, quirk_invert_brightness },
975 +
976 ++ /* Acer Aspire 4736Z */
977 ++ { 0x2a42, 0x1025, 0x0260, quirk_invert_brightness },
978 ++
979 ++ /* Acer Aspire 5336 */
980 ++ { 0x2a42, 0x1025, 0x048a, quirk_invert_brightness },
981 ++
982 + /* Dell XPS13 HD Sandy Bridge */
983 + { 0x0116, 0x1028, 0x052e, quirk_no_pcm_pwm_enable },
984 + /* Dell XPS13 HD and XPS13 FHD Ivy Bridge */
985 +diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c
986 +index 12041fa..b221f2b 100644
987 +--- a/drivers/gpu/drm/i915/intel_tv.c
988 ++++ b/drivers/gpu/drm/i915/intel_tv.c
989 +@@ -1599,9 +1599,14 @@ static int tv_is_present_in_vbt(struct drm_device *dev)
990 + /*
991 + * If the device type is not TV, continue.
992 + */
993 +- if (p_child->device_type != DEVICE_TYPE_INT_TV &&
994 +- p_child->device_type != DEVICE_TYPE_TV)
995 ++ switch (p_child->device_type) {
996 ++ case DEVICE_TYPE_INT_TV:
997 ++ case DEVICE_TYPE_TV:
998 ++ case DEVICE_TYPE_TV_SVIDEO_COMPOSITE:
999 ++ break;
1000 ++ default:
1001 + continue;
1002 ++ }
1003 + /* Only when the addin_offset is non-zero, it is regarded
1004 + * as present.
1005 + */
1006 +diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
1007 +index 63e7143..3291ab8 100644
1008 +--- a/drivers/gpu/drm/radeon/radeon_display.c
1009 ++++ b/drivers/gpu/drm/radeon/radeon_display.c
1010 +@@ -738,6 +738,7 @@ int radeon_ddc_get_modes(struct radeon_connector *radeon_connector)
1011 + if (radeon_connector->edid) {
1012 + drm_mode_connector_update_edid_property(&radeon_connector->base, radeon_connector->edid);
1013 + ret = drm_add_edid_modes(&radeon_connector->base, radeon_connector->edid);
1014 ++ drm_edid_to_eld(&radeon_connector->base, radeon_connector->edid);
1015 + return ret;
1016 + }
1017 + drm_mode_connector_update_edid_property(&radeon_connector->base, NULL);
1018 +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
1019 +index 34e51a1..907c26f 100644
1020 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
1021 ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
1022 +@@ -147,7 +147,7 @@ static int vmw_fb_check_var(struct fb_var_screeninfo *var,
1023 + }
1024 +
1025 + if (!vmw_kms_validate_mode_vram(vmw_priv,
1026 +- info->fix.line_length,
1027 ++ var->xres * var->bits_per_pixel/8,
1028 + var->yoffset + var->yres)) {
1029 + DRM_ERROR("Requested geom can not fit in framebuffer\n");
1030 + return -EINVAL;
1031 +@@ -162,6 +162,8 @@ static int vmw_fb_set_par(struct fb_info *info)
1032 + struct vmw_private *vmw_priv = par->vmw_priv;
1033 + int ret;
1034 +
1035 ++ info->fix.line_length = info->var.xres * info->var.bits_per_pixel/8;
1036 ++
1037 + ret = vmw_kms_write_svga(vmw_priv, info->var.xres, info->var.yres,
1038 + info->fix.line_length,
1039 + par->bpp, par->depth);
1040 +@@ -177,6 +179,7 @@ static int vmw_fb_set_par(struct fb_info *info)
1041 + vmw_write(vmw_priv, SVGA_REG_DISPLAY_POSITION_Y, info->var.yoffset);
1042 + vmw_write(vmw_priv, SVGA_REG_DISPLAY_WIDTH, info->var.xres);
1043 + vmw_write(vmw_priv, SVGA_REG_DISPLAY_HEIGHT, info->var.yres);
1044 ++ vmw_write(vmw_priv, SVGA_REG_BYTES_PER_LINE, info->fix.line_length);
1045 + vmw_write(vmw_priv, SVGA_REG_DISPLAY_ID, SVGA_ID_INVALID);
1046 + }
1047 +
1048 +diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
1049 +index 810658e..d01edf3 100644
1050 +--- a/drivers/hv/ring_buffer.c
1051 ++++ b/drivers/hv/ring_buffer.c
1052 +@@ -485,7 +485,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info *inring_info, void *buffer,
1053 + /* Make sure all reads are done before we update the read index since */
1054 + /* the writer may start writing to the read area once the read index */
1055 + /*is updated */
1056 +- smp_mb();
1057 ++ mb();
1058 +
1059 + /* Update the read index */
1060 + hv_set_next_read_location(inring_info, next_read_location);
1061 +diff --git a/drivers/infiniband/hw/ehca/ehca_cq.c b/drivers/infiniband/hw/ehca/ehca_cq.c
1062 +index d9b0ebc..6eeb84d 100644
1063 +--- a/drivers/infiniband/hw/ehca/ehca_cq.c
1064 ++++ b/drivers/infiniband/hw/ehca/ehca_cq.c
1065 +@@ -296,6 +296,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
1066 + (my_cq->galpas.user.fw_handle & (PAGE_SIZE - 1));
1067 + if (ib_copy_to_udata(udata, &resp, sizeof(resp))) {
1068 + ehca_err(device, "Copy to udata failed.");
1069 ++ cq = ERR_PTR(-EFAULT);
1070 + goto create_cq_exit4;
1071 + }
1072 + }
1073 +diff --git a/drivers/infiniband/hw/ipath/ipath_diag.c b/drivers/infiniband/hw/ipath/ipath_diag.c
1074 +index 714293b..e2f9a51 100644
1075 +--- a/drivers/infiniband/hw/ipath/ipath_diag.c
1076 ++++ b/drivers/infiniband/hw/ipath/ipath_diag.c
1077 +@@ -326,7 +326,7 @@ static ssize_t ipath_diagpkt_write(struct file *fp,
1078 + size_t count, loff_t *off)
1079 + {
1080 + u32 __iomem *piobuf;
1081 +- u32 plen, clen, pbufn;
1082 ++ u32 plen, pbufn, maxlen_reserve;
1083 + struct ipath_diag_pkt odp;
1084 + struct ipath_diag_xpkt dp;
1085 + u32 *tmpbuf = NULL;
1086 +@@ -335,51 +335,29 @@ static ssize_t ipath_diagpkt_write(struct file *fp,
1087 + u64 val;
1088 + u32 l_state, lt_state; /* LinkState, LinkTrainingState */
1089 +
1090 +- if (count < sizeof(odp)) {
1091 +- ret = -EINVAL;
1092 +- goto bail;
1093 +- }
1094 +
1095 + if (count == sizeof(dp)) {
1096 + if (copy_from_user(&dp, data, sizeof(dp))) {
1097 + ret = -EFAULT;
1098 + goto bail;
1099 + }
1100 +- } else if (copy_from_user(&odp, data, sizeof(odp))) {
1101 +- ret = -EFAULT;
1102 ++ } else if (count == sizeof(odp)) {
1103 ++ if (copy_from_user(&odp, data, sizeof(odp))) {
1104 ++ ret = -EFAULT;
1105 ++ goto bail;
1106 ++ }
1107 ++ } else {
1108 ++ ret = -EINVAL;
1109 + goto bail;
1110 + }
1111 +
1112 +- /*
1113 +- * Due to padding/alignment issues (lessened with new struct)
1114 +- * the old and new structs are the same length. We need to
1115 +- * disambiguate them, which we can do because odp.len has never
1116 +- * been less than the total of LRH+BTH+DETH so far, while
1117 +- * dp.unit (same offset) unit is unlikely to get that high.
1118 +- * Similarly, dp.data, the pointer to user at the same offset
1119 +- * as odp.unit, is almost certainly at least one (512byte)page
1120 +- * "above" NULL. The if-block below can be omitted if compatibility
1121 +- * between a new driver and older diagnostic code is unimportant.
1122 +- * compatibility the other direction (new diags, old driver) is
1123 +- * handled in the diagnostic code, with a warning.
1124 +- */
1125 +- if (dp.unit >= 20 && dp.data < 512) {
1126 +- /* very probable version mismatch. Fix it up */
1127 +- memcpy(&odp, &dp, sizeof(odp));
1128 +- /* We got a legacy dp, copy elements to dp */
1129 +- dp.unit = odp.unit;
1130 +- dp.data = odp.data;
1131 +- dp.len = odp.len;
1132 +- dp.pbc_wd = 0; /* Indicate we need to compute PBC wd */
1133 +- }
1134 +-
1135 + /* send count must be an exact number of dwords */
1136 + if (dp.len & 3) {
1137 + ret = -EINVAL;
1138 + goto bail;
1139 + }
1140 +
1141 +- clen = dp.len >> 2;
1142 ++ plen = dp.len >> 2;
1143 +
1144 + dd = ipath_lookup(dp.unit);
1145 + if (!dd || !(dd->ipath_flags & IPATH_PRESENT) ||
1146 +@@ -422,16 +400,22 @@ static ssize_t ipath_diagpkt_write(struct file *fp,
1147 + goto bail;
1148 + }
1149 +
1150 +- /* need total length before first word written */
1151 +- /* +1 word is for the qword padding */
1152 +- plen = sizeof(u32) + dp.len;
1153 +-
1154 +- if ((plen + 4) > dd->ipath_ibmaxlen) {
1155 ++ /*
1156 ++ * need total length before first word written, plus 2 Dwords. One Dword
1157 ++ * is for padding so we get the full user data when not aligned on
1158 ++ * a word boundary. The other Dword is to make sure we have room for the
1159 ++ * ICRC which gets tacked on later.
1160 ++ */
1161 ++ maxlen_reserve = 2 * sizeof(u32);
1162 ++ if (dp.len > dd->ipath_ibmaxlen - maxlen_reserve) {
1163 + ipath_dbg("Pkt len 0x%x > ibmaxlen %x\n",
1164 +- plen - 4, dd->ipath_ibmaxlen);
1165 ++ dp.len, dd->ipath_ibmaxlen);
1166 + ret = -EINVAL;
1167 +- goto bail; /* before writing pbc */
1168 ++ goto bail;
1169 + }
1170 ++
1171 ++ plen = sizeof(u32) + dp.len;
1172 ++
1173 + tmpbuf = vmalloc(plen);
1174 + if (!tmpbuf) {
1175 + dev_info(&dd->pcidev->dev, "Unable to allocate tmp buffer, "
1176 +@@ -473,11 +457,11 @@ static ssize_t ipath_diagpkt_write(struct file *fp,
1177 + */
1178 + if (dd->ipath_flags & IPATH_PIO_FLUSH_WC) {
1179 + ipath_flush_wc();
1180 +- __iowrite32_copy(piobuf + 2, tmpbuf, clen - 1);
1181 ++ __iowrite32_copy(piobuf + 2, tmpbuf, plen - 1);
1182 + ipath_flush_wc();
1183 +- __raw_writel(tmpbuf[clen - 1], piobuf + clen + 1);
1184 ++ __raw_writel(tmpbuf[plen - 1], piobuf + plen + 1);
1185 + } else
1186 +- __iowrite32_copy(piobuf + 2, tmpbuf, clen);
1187 ++ __iowrite32_copy(piobuf + 2, tmpbuf, plen);
1188 +
1189 + ipath_flush_wc();
1190 +
1191 +diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
1192 +index 5b71d43..42dde06 100644
1193 +--- a/drivers/infiniband/hw/mthca/mthca_provider.c
1194 ++++ b/drivers/infiniband/hw/mthca/mthca_provider.c
1195 +@@ -695,6 +695,7 @@ static struct ib_cq *mthca_create_cq(struct ib_device *ibdev, int entries,
1196 +
1197 + if (context && ib_copy_to_udata(udata, &cq->cqn, sizeof (__u32))) {
1198 + mthca_free_cq(to_mdev(ibdev), cq);
1199 ++ err = -EFAULT;
1200 + goto err_free;
1201 + }
1202 +
1203 +diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
1204 +index b0471b4..330eb6e 100644
1205 +--- a/drivers/infiniband/hw/nes/nes_verbs.c
1206 ++++ b/drivers/infiniband/hw/nes/nes_verbs.c
1207 +@@ -1183,7 +1183,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
1208 + nes_free_resource(nesadapter, nesadapter->allocated_qps, qp_num);
1209 + kfree(nesqp->allocated_buffer);
1210 + nes_debug(NES_DBG_QP, "ib_copy_from_udata() Failed \n");
1211 +- return NULL;
1212 ++ return ERR_PTR(-EFAULT);
1213 + }
1214 + if (req.user_wqe_buffers) {
1215 + virt_wqs = 1;
1216 +diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
1217 +index 4df80fb..75ca5d2 100644
1218 +--- a/drivers/isdn/isdnloop/isdnloop.c
1219 ++++ b/drivers/isdn/isdnloop/isdnloop.c
1220 +@@ -518,9 +518,9 @@ static isdnloop_stat isdnloop_cmd_table[] =
1221 + static void
1222 + isdnloop_fake_err(isdnloop_card * card)
1223 + {
1224 +- char buf[60];
1225 ++ char buf[64];
1226 +
1227 +- sprintf(buf, "E%s", card->omsg);
1228 ++ snprintf(buf, sizeof(buf), "E%s", card->omsg);
1229 + isdnloop_fake(card, buf, -1);
1230 + isdnloop_fake(card, "NAK", -1);
1231 + }
1232 +@@ -903,6 +903,8 @@ isdnloop_parse_cmd(isdnloop_card * card)
1233 + case 7:
1234 + /* 0x;EAZ */
1235 + p += 3;
1236 ++ if (strlen(p) >= sizeof(card->eazlist[0]))
1237 ++ break;
1238 + strcpy(card->eazlist[ch - 1], p);
1239 + break;
1240 + case 8:
1241 +@@ -1070,6 +1072,12 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
1242 + return -EBUSY;
1243 + if (copy_from_user((char *) &sdef, (char *) sdefp, sizeof(sdef)))
1244 + return -EFAULT;
1245 ++
1246 ++ for (i = 0; i < 3; i++) {
1247 ++ if (!memchr(sdef.num[i], 0, sizeof(sdef.num[i])))
1248 ++ return -EINVAL;
1249 ++ }
1250 ++
1251 + spin_lock_irqsave(&card->isdnloop_lock, flags);
1252 + switch (sdef.ptype) {
1253 + case ISDN_PTYPE_EURO:
1254 +@@ -1127,7 +1135,7 @@ isdnloop_command(isdn_ctrl * c, isdnloop_card * card)
1255 + {
1256 + ulong a;
1257 + int i;
1258 +- char cbuf[60];
1259 ++ char cbuf[80];
1260 + isdn_ctrl cmd;
1261 + isdnloop_cdef cdef;
1262 +
1263 +@@ -1192,7 +1200,6 @@ isdnloop_command(isdn_ctrl * c, isdnloop_card * card)
1264 + break;
1265 + if ((c->arg & 255) < ISDNLOOP_BCH) {
1266 + char *p;
1267 +- char dial[50];
1268 + char dcode[4];
1269 +
1270 + a = c->arg;
1271 +@@ -1204,10 +1211,10 @@ isdnloop_command(isdn_ctrl * c, isdnloop_card * card)
1272 + } else
1273 + /* Normal Dial */
1274 + strcpy(dcode, "CAL");
1275 +- strcpy(dial, p);
1276 +- sprintf(cbuf, "%02d;D%s_R%s,%02d,%02d,%s\n", (int) (a + 1),
1277 +- dcode, dial, c->parm.setup.si1,
1278 +- c->parm.setup.si2, c->parm.setup.eazmsn);
1279 ++ snprintf(cbuf, sizeof(cbuf),
1280 ++ "%02d;D%s_R%s,%02d,%02d,%s\n", (int) (a + 1),
1281 ++ dcode, p, c->parm.setup.si1,
1282 ++ c->parm.setup.si2, c->parm.setup.eazmsn);
1283 + i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card);
1284 + }
1285 + break;
1286 +diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
1287 +index 2c9dd2c..80f8bd5 100644
1288 +--- a/drivers/md/dm-thin.c
1289 ++++ b/drivers/md/dm-thin.c
1290 +@@ -1298,9 +1298,9 @@ static void process_deferred_bios(struct pool *pool)
1291 + */
1292 + if (ensure_next_mapping(pool)) {
1293 + spin_lock_irqsave(&pool->lock, flags);
1294 ++ bio_list_add(&pool->deferred_bios, bio);
1295 + bio_list_merge(&pool->deferred_bios, &bios);
1296 + spin_unlock_irqrestore(&pool->lock, flags);
1297 +-
1298 + break;
1299 + }
1300 + process_bio(tc, bio);
1301 +diff --git a/drivers/media/video/gspca/sn9c20x.c b/drivers/media/video/gspca/sn9c20x.c
1302 +index 86e07a1..509e202 100644
1303 +--- a/drivers/media/video/gspca/sn9c20x.c
1304 ++++ b/drivers/media/video/gspca/sn9c20x.c
1305 +@@ -2521,6 +2521,7 @@ static const struct usb_device_id device_table[] = {
1306 + {USB_DEVICE(0x045e, 0x00f4), SN9C20X(OV9650, 0x30, 0)},
1307 + {USB_DEVICE(0x145f, 0x013d), SN9C20X(OV7660, 0x21, 0)},
1308 + {USB_DEVICE(0x0458, 0x7029), SN9C20X(HV7131R, 0x11, 0)},
1309 ++ {USB_DEVICE(0x0458, 0x7045), SN9C20X(MT9M112, 0x5d, LED_REVERSE)},
1310 + {USB_DEVICE(0x0458, 0x704a), SN9C20X(MT9M112, 0x5d, 0)},
1311 + {USB_DEVICE(0x0458, 0x704c), SN9C20X(MT9M112, 0x5d, 0)},
1312 + {USB_DEVICE(0xa168, 0x0610), SN9C20X(HV7131R, 0x11, 0)},
1313 +diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c
1314 +index b015e8e..af5c040 100644
1315 +--- a/drivers/media/video/uvc/uvc_video.c
1316 ++++ b/drivers/media/video/uvc/uvc_video.c
1317 +@@ -1267,7 +1267,25 @@ int uvc_video_enable(struct uvc_streaming *stream, int enable)
1318 +
1319 + if (!enable) {
1320 + uvc_uninit_video(stream, 1);
1321 +- usb_set_interface(stream->dev->udev, stream->intfnum, 0);
1322 ++ if (stream->intf->num_altsetting > 1) {
1323 ++ usb_set_interface(stream->dev->udev,
1324 ++ stream->intfnum, 0);
1325 ++ } else {
1326 ++ /* UVC doesn't specify how to inform a bulk-based device
1327 ++ * when the video stream is stopped. Windows sends a
1328 ++ * CLEAR_FEATURE(HALT) request to the video streaming
1329 ++ * bulk endpoint, mimic the same behaviour.
1330 ++ */
1331 ++ unsigned int epnum = stream->header.bEndpointAddress
1332 ++ & USB_ENDPOINT_NUMBER_MASK;
1333 ++ unsigned int dir = stream->header.bEndpointAddress
1334 ++ & USB_ENDPOINT_DIR_MASK;
1335 ++ unsigned int pipe;
1336 ++
1337 ++ pipe = usb_sndbulkpipe(stream->dev->udev, epnum) | dir;
1338 ++ usb_clear_halt(stream->dev->udev, pipe);
1339 ++ }
1340 ++
1341 + uvc_queue_enable(&stream->queue, 0);
1342 + return 0;
1343 + }
1344 +diff --git a/drivers/mfd/88pm860x-i2c.c b/drivers/mfd/88pm860x-i2c.c
1345 +index e017dc8..f035dd3 100644
1346 +--- a/drivers/mfd/88pm860x-i2c.c
1347 ++++ b/drivers/mfd/88pm860x-i2c.c
1348 +@@ -290,6 +290,12 @@ static int __devinit pm860x_probe(struct i2c_client *client,
1349 + chip->companion_addr = pdata->companion_addr;
1350 + chip->companion = i2c_new_dummy(chip->client->adapter,
1351 + chip->companion_addr);
1352 ++ if (!chip->companion) {
1353 ++ dev_err(&client->dev,
1354 ++ "Failed to allocate I2C companion device\n");
1355 ++ kfree(chip);
1356 ++ return -ENODEV;
1357 ++ }
1358 + i2c_set_clientdata(chip->companion, chip);
1359 + }
1360 +
1361 +diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
1362 +index f1391c2..b2b6916 100644
1363 +--- a/drivers/mfd/Kconfig
1364 ++++ b/drivers/mfd/Kconfig
1365 +@@ -772,9 +772,6 @@ config MFD_INTEL_MSIC
1366 + Passage) chip. This chip embeds audio, battery, GPIO, etc.
1367 + devices used in Intel Medfield platforms.
1368 +
1369 +-endmenu
1370 +-endif
1371 +-
1372 + menu "Multimedia Capabilities Port drivers"
1373 + depends on ARCH_SA1100
1374 +
1375 +@@ -797,3 +794,6 @@ config MCP_UCB1200_TS
1376 + depends on MCP_UCB1200 && INPUT
1377 +
1378 + endmenu
1379 ++
1380 ++endmenu
1381 ++endif
1382 +diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
1383 +index 0219115..90b450c 100644
1384 +--- a/drivers/mfd/max8925-i2c.c
1385 ++++ b/drivers/mfd/max8925-i2c.c
1386 +@@ -156,9 +156,18 @@ static int __devinit max8925_probe(struct i2c_client *client,
1387 + mutex_init(&chip->io_lock);
1388 +
1389 + chip->rtc = i2c_new_dummy(chip->i2c->adapter, RTC_I2C_ADDR);
1390 ++ if (!chip->rtc) {
1391 ++ dev_err(chip->dev, "Failed to allocate I2C device for RTC\n");
1392 ++ return -ENODEV;
1393 ++ }
1394 + i2c_set_clientdata(chip->rtc, chip);
1395 +
1396 + chip->adc = i2c_new_dummy(chip->i2c->adapter, ADC_I2C_ADDR);
1397 ++ if (!chip->adc) {
1398 ++ dev_err(chip->dev, "Failed to allocate I2C device for ADC\n");
1399 ++ i2c_unregister_device(chip->rtc);
1400 ++ return -ENODEV;
1401 ++ }
1402 + i2c_set_clientdata(chip->adc, chip);
1403 +
1404 + max8925_device_init(chip, pdata);
1405 +diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
1406 +index 5be53ae..1926a54 100644
1407 +--- a/drivers/mfd/max8997.c
1408 ++++ b/drivers/mfd/max8997.c
1409 +@@ -148,10 +148,26 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
1410 + mutex_init(&max8997->iolock);
1411 +
1412 + max8997->rtc = i2c_new_dummy(i2c->adapter, I2C_ADDR_RTC);
1413 ++ if (!max8997->rtc) {
1414 ++ dev_err(max8997->dev, "Failed to allocate I2C device for RTC\n");
1415 ++ return -ENODEV;
1416 ++ }
1417 + i2c_set_clientdata(max8997->rtc, max8997);
1418 ++
1419 + max8997->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC);
1420 ++ if (!max8997->haptic) {
1421 ++ dev_err(max8997->dev, "Failed to allocate I2C device for Haptic\n");
1422 ++ ret = -ENODEV;
1423 ++ goto err_i2c_haptic;
1424 ++ }
1425 + i2c_set_clientdata(max8997->haptic, max8997);
1426 ++
1427 + max8997->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC);
1428 ++ if (!max8997->muic) {
1429 ++ dev_err(max8997->dev, "Failed to allocate I2C device for MUIC\n");
1430 ++ ret = -ENODEV;
1431 ++ goto err_i2c_muic;
1432 ++ }
1433 + i2c_set_clientdata(max8997->muic, max8997);
1434 +
1435 + pm_runtime_set_active(max8997->dev);
1436 +@@ -178,7 +194,9 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
1437 + err_mfd:
1438 + mfd_remove_devices(max8997->dev);
1439 + i2c_unregister_device(max8997->muic);
1440 ++err_i2c_muic:
1441 + i2c_unregister_device(max8997->haptic);
1442 ++err_i2c_haptic:
1443 + i2c_unregister_device(max8997->rtc);
1444 + err:
1445 + kfree(max8997);
1446 +diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c
1447 +index de4096a..2fa6a28 100644
1448 +--- a/drivers/mfd/max8998.c
1449 ++++ b/drivers/mfd/max8998.c
1450 +@@ -152,6 +152,10 @@ static int max8998_i2c_probe(struct i2c_client *i2c,
1451 + mutex_init(&max8998->iolock);
1452 +
1453 + max8998->rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR);
1454 ++ if (!max8998->rtc) {
1455 ++ dev_err(&i2c->dev, "Failed to allocate I2C device for RTC\n");
1456 ++ return -ENODEV;
1457 ++ }
1458 + i2c_set_clientdata(max8998->rtc, max8998);
1459 +
1460 + max8998_irq_init(max8998);
1461 +diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
1462 +index 2e88af1..a0ba5ac 100644
1463 +--- a/drivers/net/wireless/ath/ath9k/xmit.c
1464 ++++ b/drivers/net/wireless/ath/ath9k/xmit.c
1465 +@@ -1390,7 +1390,7 @@ int ath_cabq_update(struct ath_softc *sc)
1466 + else if (sc->config.cabqReadytime > ATH9K_READY_TIME_HI_BOUND)
1467 + sc->config.cabqReadytime = ATH9K_READY_TIME_HI_BOUND;
1468 +
1469 +- qi.tqi_readyTime = (cur_conf->beacon_interval *
1470 ++ qi.tqi_readyTime = (TU_TO_USEC(cur_conf->beacon_interval) *
1471 + sc->config.cabqReadytime) / 100;
1472 + ath_txq_update(sc, qnum, &qi);
1473 +
1474 +diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
1475 +index b17d9b6..0490c7c 100644
1476 +--- a/drivers/net/wireless/b43/phy_n.c
1477 ++++ b/drivers/net/wireless/b43/phy_n.c
1478 +@@ -3937,22 +3937,22 @@ static void b43_nphy_channel_setup(struct b43_wldev *dev,
1479 + struct b43_phy_n *nphy = dev->phy.n;
1480 +
1481 + u16 old_band_5ghz;
1482 +- u32 tmp32;
1483 ++ u16 tmp16;
1484 +
1485 + old_band_5ghz =
1486 + b43_phy_read(dev, B43_NPHY_BANDCTL) & B43_NPHY_BANDCTL_5GHZ;
1487 + if (new_channel->band == IEEE80211_BAND_5GHZ && !old_band_5ghz) {
1488 +- tmp32 = b43_read32(dev, B43_MMIO_PSM_PHY_HDR);
1489 +- b43_write32(dev, B43_MMIO_PSM_PHY_HDR, tmp32 | 4);
1490 ++ tmp16 = b43_read16(dev, B43_MMIO_PSM_PHY_HDR);
1491 ++ b43_write16(dev, B43_MMIO_PSM_PHY_HDR, tmp16 | 4);
1492 + b43_phy_set(dev, B43_PHY_B_BBCFG, 0xC000);
1493 +- b43_write32(dev, B43_MMIO_PSM_PHY_HDR, tmp32);
1494 ++ b43_write16(dev, B43_MMIO_PSM_PHY_HDR, tmp16);
1495 + b43_phy_set(dev, B43_NPHY_BANDCTL, B43_NPHY_BANDCTL_5GHZ);
1496 + } else if (new_channel->band == IEEE80211_BAND_2GHZ && old_band_5ghz) {
1497 + b43_phy_mask(dev, B43_NPHY_BANDCTL, ~B43_NPHY_BANDCTL_5GHZ);
1498 +- tmp32 = b43_read32(dev, B43_MMIO_PSM_PHY_HDR);
1499 +- b43_write32(dev, B43_MMIO_PSM_PHY_HDR, tmp32 | 4);
1500 ++ tmp16 = b43_read16(dev, B43_MMIO_PSM_PHY_HDR);
1501 ++ b43_write16(dev, B43_MMIO_PSM_PHY_HDR, tmp16 | 4);
1502 + b43_phy_mask(dev, B43_PHY_B_BBCFG, 0x3FFF);
1503 +- b43_write32(dev, B43_MMIO_PSM_PHY_HDR, tmp32);
1504 ++ b43_write16(dev, B43_MMIO_PSM_PHY_HDR, tmp16);
1505 + }
1506 +
1507 + b43_chantab_phy_upload(dev, e);
1508 +diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
1509 +index 94d35ad..4a36973 100644
1510 +--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
1511 ++++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
1512 +@@ -246,13 +246,17 @@ static void iwl_bg_bt_runtime_config(struct work_struct *work)
1513 + struct iwl_priv *priv =
1514 + container_of(work, struct iwl_priv, bt_runtime_config);
1515 +
1516 ++ mutex_lock(&priv->shrd->mutex);
1517 + if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status))
1518 +- return;
1519 ++ goto out;
1520 +
1521 + /* dont send host command if rf-kill is on */
1522 + if (!iwl_is_ready_rf(priv->shrd))
1523 +- return;
1524 ++ goto out;
1525 ++
1526 + iwlagn_send_advance_bt_config(priv);
1527 ++out:
1528 ++ mutex_unlock(&priv->shrd->mutex);
1529 + }
1530 +
1531 + static void iwl_bg_bt_full_concurrency(struct work_struct *work)
1532 +diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
1533 +index c474486..503c160 100644
1534 +--- a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
1535 ++++ b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
1536 +@@ -924,7 +924,7 @@ int rtl92se_hw_init(struct ieee80211_hw *hw)
1537 + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
1538 + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
1539 + u8 tmp_byte = 0;
1540 +-
1541 ++ unsigned long flags;
1542 + bool rtstatus = true;
1543 + u8 tmp_u1b;
1544 + int err = false;
1545 +@@ -936,6 +936,16 @@ int rtl92se_hw_init(struct ieee80211_hw *hw)
1546 +
1547 + rtlpci->being_init_adapter = true;
1548 +
1549 ++ /* As this function can take a very long time (up to 350 ms)
1550 ++ * and can be called with irqs disabled, reenable the irqs
1551 ++ * to let the other devices continue being serviced.
1552 ++ *
1553 ++ * It is safe doing so since our own interrupts will only be enabled
1554 ++ * in a subsequent step.
1555 ++ */
1556 ++ local_save_flags(flags);
1557 ++ local_irq_enable();
1558 ++
1559 + rtlpriv->intf_ops->disable_aspm(hw);
1560 +
1561 + /* 1. MAC Initialize */
1562 +@@ -969,7 +979,8 @@ int rtl92se_hw_init(struct ieee80211_hw *hw)
1563 + /* 3. Initialize MAC/PHY Config by MACPHY_reg.txt */
1564 + if (rtl92s_phy_mac_config(hw) != true) {
1565 + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("MAC Config failed\n"));
1566 +- return rtstatus;
1567 ++ err = rtstatus;
1568 ++ goto exit;
1569 + }
1570 +
1571 + /* Make sure BB/RF write OK. We should prevent enter IPS. radio off. */
1572 +@@ -979,7 +990,8 @@ int rtl92se_hw_init(struct ieee80211_hw *hw)
1573 + /* 4. Initialize BB After MAC Config PHY_reg.txt, AGC_Tab.txt */
1574 + if (rtl92s_phy_bb_config(hw) != true) {
1575 + RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, ("BB Config failed\n"));
1576 +- return rtstatus;
1577 ++ err = rtstatus;
1578 ++ goto exit;
1579 + }
1580 +
1581 + /* 5. Initiailze RF RAIO_A.txt RF RAIO_B.txt */
1582 +@@ -1015,7 +1027,8 @@ int rtl92se_hw_init(struct ieee80211_hw *hw)
1583 +
1584 + if (rtl92s_phy_rf_config(hw) != true) {
1585 + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("RF Config failed\n"));
1586 +- return rtstatus;
1587 ++ err = rtstatus;
1588 ++ goto exit;
1589 + }
1590 +
1591 + /* After read predefined TXT, we must set BB/MAC/RF
1592 +@@ -1089,8 +1102,9 @@ int rtl92se_hw_init(struct ieee80211_hw *hw)
1593 +
1594 + rtlpriv->cfg->ops->led_control(hw, LED_CTL_POWER_ON);
1595 + rtl92s_dm_init(hw);
1596 ++exit:
1597 ++ local_irq_restore(flags);
1598 + rtlpci->being_init_adapter = false;
1599 +-
1600 + return err;
1601 + }
1602 +
1603 +diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
1604 +index 9a4626c..b2528f6 100644
1605 +--- a/drivers/net/xen-netback/netback.c
1606 ++++ b/drivers/net/xen-netback/netback.c
1607 +@@ -346,8 +346,8 @@ static bool start_new_rx_buffer(int offset, unsigned long size, int head)
1608 + * into multiple copies tend to give large frags their
1609 + * own buffers as before.
1610 + */
1611 +- if ((offset + size > MAX_BUFFER_OFFSET) &&
1612 +- (size <= MAX_BUFFER_OFFSET) && offset && !head)
1613 ++ BUG_ON(size > MAX_BUFFER_OFFSET);
1614 ++ if ((offset + size > MAX_BUFFER_OFFSET) && offset && !head)
1615 + return true;
1616 +
1617 + return false;
1618 +diff --git a/drivers/scsi/isci/port_config.c b/drivers/scsi/isci/port_config.c
1619 +index 21a6769..38a99d2 100644
1620 +--- a/drivers/scsi/isci/port_config.c
1621 ++++ b/drivers/scsi/isci/port_config.c
1622 +@@ -610,6 +610,13 @@ static void sci_apc_agent_link_up(struct isci_host *ihost,
1623 + sci_apc_agent_configure_ports(ihost, port_agent, iphy, true);
1624 + } else {
1625 + /* the phy is already the part of the port */
1626 ++ u32 port_state = iport->sm.current_state_id;
1627 ++
1628 ++ /* if the PORT'S state is resetting then the link up is from
1629 ++ * port hard reset in this case, we need to tell the port
1630 ++ * that link up is recieved
1631 ++ */
1632 ++ BUG_ON(port_state != SCI_PORT_RESETTING);
1633 + port_agent->phy_ready_mask |= 1 << phy_index;
1634 + sci_port_link_up(iport, iphy);
1635 + }
1636 +diff --git a/drivers/scsi/isci/task.c b/drivers/scsi/isci/task.c
1637 +index 60a530f..e294d11 100644
1638 +--- a/drivers/scsi/isci/task.c
1639 ++++ b/drivers/scsi/isci/task.c
1640 +@@ -1390,7 +1390,7 @@ int isci_task_I_T_nexus_reset(struct domain_device *dev)
1641 + spin_unlock_irqrestore(&ihost->scic_lock, flags);
1642 +
1643 + if (!idev || !test_bit(IDEV_EH, &idev->flags)) {
1644 +- ret = -ENODEV;
1645 ++ ret = TMF_RESP_FUNC_COMPLETE;
1646 + goto out;
1647 + }
1648 +
1649 +diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c
1650 +index c44e41a..c2731ca 100644
1651 +--- a/drivers/staging/serqt_usb2/serqt_usb2.c
1652 ++++ b/drivers/staging/serqt_usb2/serqt_usb2.c
1653 +@@ -772,7 +772,7 @@ static int qt_startup(struct usb_serial *serial)
1654 + goto startup_error;
1655 + }
1656 +
1657 +- switch (serial->dev->descriptor.idProduct) {
1658 ++ switch (le16_to_cpu(serial->dev->descriptor.idProduct)) {
1659 + case QUATECH_DSU100:
1660 + case QUATECH_QSU100:
1661 + case QUATECH_ESU100A:
1662 +diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
1663 +index 4a88eea..ab5dd16 100644
1664 +--- a/drivers/target/iscsi/iscsi_target.c
1665 ++++ b/drivers/target/iscsi/iscsi_target.c
1666 +@@ -2358,6 +2358,7 @@ static void iscsit_build_conn_drop_async_message(struct iscsi_conn *conn)
1667 + {
1668 + struct iscsi_cmd *cmd;
1669 + struct iscsi_conn *conn_p;
1670 ++ bool found = false;
1671 +
1672 + /*
1673 + * Only send a Asynchronous Message on connections whos network
1674 +@@ -2366,11 +2367,12 @@ static void iscsit_build_conn_drop_async_message(struct iscsi_conn *conn)
1675 + list_for_each_entry(conn_p, &conn->sess->sess_conn_list, conn_list) {
1676 + if (conn_p->conn_state == TARG_CONN_STATE_LOGGED_IN) {
1677 + iscsit_inc_conn_usage_count(conn_p);
1678 ++ found = true;
1679 + break;
1680 + }
1681 + }
1682 +
1683 +- if (!conn_p)
1684 ++ if (!found)
1685 + return;
1686 +
1687 + cmd = iscsit_allocate_cmd(conn_p, GFP_ATOMIC);
1688 +diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c
1689 +index ab0a3fa..b328011 100644
1690 +--- a/drivers/target/tcm_fc/tfc_sess.c
1691 ++++ b/drivers/target/tcm_fc/tfc_sess.c
1692 +@@ -72,6 +72,7 @@ static struct ft_tport *ft_tport_create(struct fc_lport *lport)
1693 +
1694 + if (tport) {
1695 + tport->tpg = tpg;
1696 ++ tpg->tport = tport;
1697 + return tport;
1698 + }
1699 +
1700 +diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
1701 +index b6b2d18..7b97e7e 100644
1702 +--- a/drivers/tty/hvc/hvc_console.c
1703 ++++ b/drivers/tty/hvc/hvc_console.c
1704 +@@ -31,6 +31,7 @@
1705 + #include <linux/list.h>
1706 + #include <linux/module.h>
1707 + #include <linux/major.h>
1708 ++#include <linux/atomic.h>
1709 + #include <linux/sysrq.h>
1710 + #include <linux/tty.h>
1711 + #include <linux/tty_flip.h>
1712 +@@ -70,6 +71,9 @@ static struct task_struct *hvc_task;
1713 + /* Picks up late kicks after list walk but before schedule() */
1714 + static int hvc_kicked;
1715 +
1716 ++/* hvc_init is triggered from hvc_alloc, i.e. only when actually used */
1717 ++static atomic_t hvc_needs_init __read_mostly = ATOMIC_INIT(-1);
1718 ++
1719 + static int hvc_init(void);
1720 +
1721 + #ifdef CONFIG_MAGIC_SYSRQ
1722 +@@ -825,7 +829,7 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
1723 + int i;
1724 +
1725 + /* We wait until a driver actually comes along */
1726 +- if (!hvc_driver) {
1727 ++ if (atomic_inc_not_zero(&hvc_needs_init)) {
1728 + int err = hvc_init();
1729 + if (err)
1730 + return ERR_PTR(err);
1731 +diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
1732 +index 3f35e42..446df6b 100644
1733 +--- a/drivers/tty/tty_io.c
1734 ++++ b/drivers/tty/tty_io.c
1735 +@@ -1222,9 +1222,9 @@ static void pty_line_name(struct tty_driver *driver, int index, char *p)
1736 + *
1737 + * Locking: None
1738 + */
1739 +-static void tty_line_name(struct tty_driver *driver, int index, char *p)
1740 ++static ssize_t tty_line_name(struct tty_driver *driver, int index, char *p)
1741 + {
1742 +- sprintf(p, "%s%d", driver->name, index + driver->name_base);
1743 ++ return sprintf(p, "%s%d", driver->name, index + driver->name_base);
1744 + }
1745 +
1746 + /**
1747 +@@ -3321,9 +3321,19 @@ static ssize_t show_cons_active(struct device *dev,
1748 + if (i >= ARRAY_SIZE(cs))
1749 + break;
1750 + }
1751 +- while (i--)
1752 +- count += sprintf(buf + count, "%s%d%c",
1753 +- cs[i]->name, cs[i]->index, i ? ' ':'\n');
1754 ++ while (i--) {
1755 ++ int index = cs[i]->index;
1756 ++ struct tty_driver *drv = cs[i]->device(cs[i], &index);
1757 ++
1758 ++ /* don't resolve tty0 as some programs depend on it */
1759 ++ if (drv && (cs[i]->index > 0 || drv->major != TTY_MAJOR))
1760 ++ count += tty_line_name(drv, index, buf + count);
1761 ++ else
1762 ++ count += sprintf(buf + count, "%s%d",
1763 ++ cs[i]->name, cs[i]->index);
1764 ++
1765 ++ count += sprintf(buf + count, "%c", i ? ' ':'\n');
1766 ++ }
1767 + console_unlock();
1768 +
1769 + return count;
1770 +diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
1771 +index 4795c0c..ae2b763 100644
1772 +--- a/drivers/usb/dwc3/core.h
1773 ++++ b/drivers/usb/dwc3/core.h
1774 +@@ -716,15 +716,15 @@ struct dwc3_event_depevt {
1775 + * 12 - VndrDevTstRcved
1776 + * @reserved15_12: Reserved, not used
1777 + * @event_info: Information about this event
1778 +- * @reserved31_24: Reserved, not used
1779 ++ * @reserved31_25: Reserved, not used
1780 + */
1781 + struct dwc3_event_devt {
1782 + u32 one_bit:1;
1783 + u32 device_event:7;
1784 + u32 type:4;
1785 + u32 reserved15_12:4;
1786 +- u32 event_info:8;
1787 +- u32 reserved31_24:8;
1788 ++ u32 event_info:9;
1789 ++ u32 reserved31_25:7;
1790 + } __packed;
1791 +
1792 + /**
1793 +diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
1794 +index 271a9d8..b299c32 100644
1795 +--- a/drivers/usb/gadget/atmel_usba_udc.c
1796 ++++ b/drivers/usb/gadget/atmel_usba_udc.c
1797 +@@ -1875,12 +1875,13 @@ static int atmel_usba_stop(struct usb_gadget_driver *driver)
1798 +
1799 + driver->unbind(&udc->gadget);
1800 + udc->gadget.dev.driver = NULL;
1801 +- udc->driver = NULL;
1802 +
1803 + clk_disable(udc->hclk);
1804 + clk_disable(udc->pclk);
1805 +
1806 +- DBG(DBG_GADGET, "unregistered driver `%s'\n", driver->driver.name);
1807 ++ DBG(DBG_GADGET, "unregistered driver `%s'\n", udc->driver->driver.name);
1808 ++
1809 ++ udc->driver = NULL;
1810 +
1811 + return 0;
1812 + }
1813 +diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
1814 +index 5c58128..7ef84c1 100644
1815 +--- a/drivers/vhost/net.c
1816 ++++ b/drivers/vhost/net.c
1817 +@@ -319,9 +319,13 @@ static int get_rx_bufs(struct vhost_virtqueue *vq,
1818 + r = -ENOBUFS;
1819 + goto err;
1820 + }
1821 +- d = vhost_get_vq_desc(vq->dev, vq, vq->iov + seg,
1822 ++ r = vhost_get_vq_desc(vq->dev, vq, vq->iov + seg,
1823 + ARRAY_SIZE(vq->iov) - seg, &out,
1824 + &in, log, log_num);
1825 ++ if (unlikely(r < 0))
1826 ++ goto err;
1827 ++
1828 ++ d = r;
1829 + if (d == vq->num) {
1830 + r = 0;
1831 + goto err;
1832 +@@ -346,6 +350,12 @@ static int get_rx_bufs(struct vhost_virtqueue *vq,
1833 + *iovcount = seg;
1834 + if (unlikely(log))
1835 + *log_num = nlogs;
1836 ++
1837 ++ /* Detect overrun */
1838 ++ if (unlikely(datalen > 0)) {
1839 ++ r = UIO_MAXIOV + 1;
1840 ++ goto err;
1841 ++ }
1842 + return headcount;
1843 + err:
1844 + vhost_discard_vq_desc(vq, headcount);
1845 +@@ -400,6 +410,14 @@ static void handle_rx(struct vhost_net *net)
1846 + /* On error, stop handling until the next kick. */
1847 + if (unlikely(headcount < 0))
1848 + break;
1849 ++ /* On overrun, truncate and discard */
1850 ++ if (unlikely(headcount > UIO_MAXIOV)) {
1851 ++ msg.msg_iovlen = 1;
1852 ++ err = sock->ops->recvmsg(NULL, sock, &msg,
1853 ++ 1, MSG_DONTWAIT | MSG_TRUNC);
1854 ++ pr_debug("Discarded rx packet: len %zd\n", sock_len);
1855 ++ continue;
1856 ++ }
1857 + /* OK, now we need to know about added descriptors. */
1858 + if (!headcount) {
1859 + if (unlikely(vhost_enable_notify(&net->dev, vq))) {
1860 +diff --git a/drivers/video/aty/mach64_accel.c b/drivers/video/aty/mach64_accel.c
1861 +index e45833c..182bd68 100644
1862 +--- a/drivers/video/aty/mach64_accel.c
1863 ++++ b/drivers/video/aty/mach64_accel.c
1864 +@@ -4,6 +4,7 @@
1865 + */
1866 +
1867 + #include <linux/delay.h>
1868 ++#include <asm/unaligned.h>
1869 + #include <linux/fb.h>
1870 + #include <video/mach64.h>
1871 + #include "atyfb.h"
1872 +@@ -419,7 +420,7 @@ void atyfb_imageblit(struct fb_info *info, const struct fb_image *image)
1873 + u32 *pbitmap, dwords = (src_bytes + 3) / 4;
1874 + for (pbitmap = (u32*)(image->data); dwords; dwords--, pbitmap++) {
1875 + wait_for_fifo(1, par);
1876 +- aty_st_le32(HOST_DATA0, le32_to_cpup(pbitmap), par);
1877 ++ aty_st_le32(HOST_DATA0, get_unaligned_le32(pbitmap), par);
1878 + }
1879 + }
1880 +
1881 +diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
1882 +index 46f72ed..4b87318 100644
1883 +--- a/drivers/video/aty/mach64_cursor.c
1884 ++++ b/drivers/video/aty/mach64_cursor.c
1885 +@@ -5,6 +5,7 @@
1886 + #include <linux/fb.h>
1887 + #include <linux/init.h>
1888 + #include <linux/string.h>
1889 ++#include "../fb_draw.h"
1890 +
1891 + #include <asm/io.h>
1892 +
1893 +@@ -157,24 +158,33 @@ static int atyfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1894 +
1895 + for (i = 0; i < height; i++) {
1896 + for (j = 0; j < width; j++) {
1897 ++ u16 l = 0xaaaa;
1898 + b = *src++;
1899 + m = *msk++;
1900 + switch (cursor->rop) {
1901 + case ROP_XOR:
1902 + // Upper 4 bits of mask data
1903 +- fb_writeb(cursor_bits_lookup[(b ^ m) >> 4], dst++);
1904 ++ l = cursor_bits_lookup[(b ^ m) >> 4] |
1905 + // Lower 4 bits of mask
1906 +- fb_writeb(cursor_bits_lookup[(b ^ m) & 0x0f],
1907 +- dst++);
1908 ++ (cursor_bits_lookup[(b ^ m) & 0x0f] << 8);
1909 + break;
1910 + case ROP_COPY:
1911 + // Upper 4 bits of mask data
1912 +- fb_writeb(cursor_bits_lookup[(b & m) >> 4], dst++);
1913 ++ l = cursor_bits_lookup[(b & m) >> 4] |
1914 + // Lower 4 bits of mask
1915 +- fb_writeb(cursor_bits_lookup[(b & m) & 0x0f],
1916 +- dst++);
1917 ++ (cursor_bits_lookup[(b & m) & 0x0f] << 8);
1918 + break;
1919 + }
1920 ++ /*
1921 ++ * If cursor size is not a multiple of 8 characters
1922 ++ * we must pad it with transparent pattern (0xaaaa).
1923 ++ */
1924 ++ if ((j + 1) * 8 > cursor->image.width) {
1925 ++ l = comp(l, 0xaaaa,
1926 ++ (1 << ((cursor->image.width & 7) * 2)) - 1);
1927 ++ }
1928 ++ fb_writeb(l & 0xff, dst++);
1929 ++ fb_writeb(l >> 8, dst++);
1930 + }
1931 + dst += offset;
1932 + }
1933 +diff --git a/drivers/video/cfbcopyarea.c b/drivers/video/cfbcopyarea.c
1934 +index bb5a96b..bcb5723 100644
1935 +--- a/drivers/video/cfbcopyarea.c
1936 ++++ b/drivers/video/cfbcopyarea.c
1937 +@@ -43,13 +43,22 @@
1938 + */
1939 +
1940 + static void
1941 +-bitcpy(struct fb_info *p, unsigned long __iomem *dst, int dst_idx,
1942 +- const unsigned long __iomem *src, int src_idx, int bits,
1943 ++bitcpy(struct fb_info *p, unsigned long __iomem *dst, unsigned dst_idx,
1944 ++ const unsigned long __iomem *src, unsigned src_idx, int bits,
1945 + unsigned n, u32 bswapmask)
1946 + {
1947 + unsigned long first, last;
1948 + int const shift = dst_idx-src_idx;
1949 +- int left, right;
1950 ++
1951 ++#if 0
1952 ++ /*
1953 ++ * If you suspect bug in this function, compare it with this simple
1954 ++ * memmove implementation.
1955 ++ */
1956 ++ fb_memmove((char *)dst + ((dst_idx & (bits - 1))) / 8,
1957 ++ (char *)src + ((src_idx & (bits - 1))) / 8, n / 8);
1958 ++ return;
1959 ++#endif
1960 +
1961 + first = fb_shifted_pixels_mask_long(p, dst_idx, bswapmask);
1962 + last = ~fb_shifted_pixels_mask_long(p, (dst_idx+n) % bits, bswapmask);
1963 +@@ -98,9 +107,8 @@ bitcpy(struct fb_info *p, unsigned long __iomem *dst, int dst_idx,
1964 + unsigned long d0, d1;
1965 + int m;
1966 +
1967 +- right = shift & (bits - 1);
1968 +- left = -shift & (bits - 1);
1969 +- bswapmask &= shift;
1970 ++ int const left = shift & (bits - 1);
1971 ++ int const right = -shift & (bits - 1);
1972 +
1973 + if (dst_idx+n <= bits) {
1974 + // Single destination word
1975 +@@ -110,15 +118,15 @@ bitcpy(struct fb_info *p, unsigned long __iomem *dst, int dst_idx,
1976 + d0 = fb_rev_pixels_in_long(d0, bswapmask);
1977 + if (shift > 0) {
1978 + // Single source word
1979 +- d0 >>= right;
1980 ++ d0 <<= left;
1981 + } else if (src_idx+n <= bits) {
1982 + // Single source word
1983 +- d0 <<= left;
1984 ++ d0 >>= right;
1985 + } else {
1986 + // 2 source words
1987 + d1 = FB_READL(src + 1);
1988 + d1 = fb_rev_pixels_in_long(d1, bswapmask);
1989 +- d0 = d0<<left | d1>>right;
1990 ++ d0 = d0 >> right | d1 << left;
1991 + }
1992 + d0 = fb_rev_pixels_in_long(d0, bswapmask);
1993 + FB_WRITEL(comp(d0, FB_READL(dst), first), dst);
1994 +@@ -135,60 +143,59 @@ bitcpy(struct fb_info *p, unsigned long __iomem *dst, int dst_idx,
1995 + if (shift > 0) {
1996 + // Single source word
1997 + d1 = d0;
1998 +- d0 >>= right;
1999 +- dst++;
2000 ++ d0 <<= left;
2001 + n -= bits - dst_idx;
2002 + } else {
2003 + // 2 source words
2004 + d1 = FB_READL(src++);
2005 + d1 = fb_rev_pixels_in_long(d1, bswapmask);
2006 +
2007 +- d0 = d0<<left | d1>>right;
2008 +- dst++;
2009 ++ d0 = d0 >> right | d1 << left;
2010 + n -= bits - dst_idx;
2011 + }
2012 + d0 = fb_rev_pixels_in_long(d0, bswapmask);
2013 + FB_WRITEL(comp(d0, FB_READL(dst), first), dst);
2014 + d0 = d1;
2015 ++ dst++;
2016 +
2017 + // Main chunk
2018 + m = n % bits;
2019 + n /= bits;
2020 + while ((n >= 4) && !bswapmask) {
2021 + d1 = FB_READL(src++);
2022 +- FB_WRITEL(d0 << left | d1 >> right, dst++);
2023 ++ FB_WRITEL(d0 >> right | d1 << left, dst++);
2024 + d0 = d1;
2025 + d1 = FB_READL(src++);
2026 +- FB_WRITEL(d0 << left | d1 >> right, dst++);
2027 ++ FB_WRITEL(d0 >> right | d1 << left, dst++);
2028 + d0 = d1;
2029 + d1 = FB_READL(src++);
2030 +- FB_WRITEL(d0 << left | d1 >> right, dst++);
2031 ++ FB_WRITEL(d0 >> right | d1 << left, dst++);
2032 + d0 = d1;
2033 + d1 = FB_READL(src++);
2034 +- FB_WRITEL(d0 << left | d1 >> right, dst++);
2035 ++ FB_WRITEL(d0 >> right | d1 << left, dst++);
2036 + d0 = d1;
2037 + n -= 4;
2038 + }
2039 + while (n--) {
2040 + d1 = FB_READL(src++);
2041 + d1 = fb_rev_pixels_in_long(d1, bswapmask);
2042 +- d0 = d0 << left | d1 >> right;
2043 ++ d0 = d0 >> right | d1 << left;
2044 + d0 = fb_rev_pixels_in_long(d0, bswapmask);
2045 + FB_WRITEL(d0, dst++);
2046 + d0 = d1;
2047 + }
2048 +
2049 + // Trailing bits
2050 +- if (last) {
2051 +- if (m <= right) {
2052 ++ if (m) {
2053 ++ if (m <= bits - right) {
2054 + // Single source word
2055 +- d0 <<= left;
2056 ++ d0 >>= right;
2057 + } else {
2058 + // 2 source words
2059 + d1 = FB_READL(src);
2060 + d1 = fb_rev_pixels_in_long(d1,
2061 + bswapmask);
2062 +- d0 = d0<<left | d1>>right;
2063 ++ d0 = d0 >> right | d1 << left;
2064 + }
2065 + d0 = fb_rev_pixels_in_long(d0, bswapmask);
2066 + FB_WRITEL(comp(d0, FB_READL(dst), last), dst);
2067 +@@ -202,43 +209,46 @@ bitcpy(struct fb_info *p, unsigned long __iomem *dst, int dst_idx,
2068 + */
2069 +
2070 + static void
2071 +-bitcpy_rev(struct fb_info *p, unsigned long __iomem *dst, int dst_idx,
2072 +- const unsigned long __iomem *src, int src_idx, int bits,
2073 ++bitcpy_rev(struct fb_info *p, unsigned long __iomem *dst, unsigned dst_idx,
2074 ++ const unsigned long __iomem *src, unsigned src_idx, int bits,
2075 + unsigned n, u32 bswapmask)
2076 + {
2077 + unsigned long first, last;
2078 + int shift;
2079 +
2080 +- dst += (n-1)/bits;
2081 +- src += (n-1)/bits;
2082 +- if ((n-1) % bits) {
2083 +- dst_idx += (n-1) % bits;
2084 +- dst += dst_idx >> (ffs(bits) - 1);
2085 +- dst_idx &= bits - 1;
2086 +- src_idx += (n-1) % bits;
2087 +- src += src_idx >> (ffs(bits) - 1);
2088 +- src_idx &= bits - 1;
2089 +- }
2090 ++#if 0
2091 ++ /*
2092 ++ * If you suspect bug in this function, compare it with this simple
2093 ++ * memmove implementation.
2094 ++ */
2095 ++ fb_memmove((char *)dst + ((dst_idx & (bits - 1))) / 8,
2096 ++ (char *)src + ((src_idx & (bits - 1))) / 8, n / 8);
2097 ++ return;
2098 ++#endif
2099 ++
2100 ++ dst += (dst_idx + n - 1) / bits;
2101 ++ src += (src_idx + n - 1) / bits;
2102 ++ dst_idx = (dst_idx + n - 1) % bits;
2103 ++ src_idx = (src_idx + n - 1) % bits;
2104 +
2105 + shift = dst_idx-src_idx;
2106 +
2107 +- first = fb_shifted_pixels_mask_long(p, bits - 1 - dst_idx, bswapmask);
2108 +- last = ~fb_shifted_pixels_mask_long(p, bits - 1 - ((dst_idx-n) % bits),
2109 +- bswapmask);
2110 ++ first = ~fb_shifted_pixels_mask_long(p, (dst_idx + 1) % bits, bswapmask);
2111 ++ last = fb_shifted_pixels_mask_long(p, (bits + dst_idx + 1 - n) % bits, bswapmask);
2112 +
2113 + if (!shift) {
2114 + // Same alignment for source and dest
2115 +
2116 + if ((unsigned long)dst_idx+1 >= n) {
2117 + // Single word
2118 +- if (last)
2119 +- first &= last;
2120 +- FB_WRITEL( comp( FB_READL(src), FB_READL(dst), first), dst);
2121 ++ if (first)
2122 ++ last &= first;
2123 ++ FB_WRITEL( comp( FB_READL(src), FB_READL(dst), last), dst);
2124 + } else {
2125 + // Multiple destination words
2126 +
2127 + // Leading bits
2128 +- if (first != ~0UL) {
2129 ++ if (first) {
2130 + FB_WRITEL( comp( FB_READL(src), FB_READL(dst), first), dst);
2131 + dst--;
2132 + src--;
2133 +@@ -262,7 +272,7 @@ bitcpy_rev(struct fb_info *p, unsigned long __iomem *dst, int dst_idx,
2134 + FB_WRITEL(FB_READL(src--), dst--);
2135 +
2136 + // Trailing bits
2137 +- if (last)
2138 ++ if (last != -1UL)
2139 + FB_WRITEL( comp( FB_READL(src), FB_READL(dst), last), dst);
2140 + }
2141 + } else {
2142 +@@ -270,29 +280,28 @@ bitcpy_rev(struct fb_info *p, unsigned long __iomem *dst, int dst_idx,
2143 + unsigned long d0, d1;
2144 + int m;
2145 +
2146 +- int const left = -shift & (bits-1);
2147 +- int const right = shift & (bits-1);
2148 +- bswapmask &= shift;
2149 ++ int const left = shift & (bits-1);
2150 ++ int const right = -shift & (bits-1);
2151 +
2152 + if ((unsigned long)dst_idx+1 >= n) {
2153 + // Single destination word
2154 +- if (last)
2155 +- first &= last;
2156 ++ if (first)
2157 ++ last &= first;
2158 + d0 = FB_READL(src);
2159 + if (shift < 0) {
2160 + // Single source word
2161 +- d0 <<= left;
2162 ++ d0 >>= right;
2163 + } else if (1+(unsigned long)src_idx >= n) {
2164 + // Single source word
2165 +- d0 >>= right;
2166 ++ d0 <<= left;
2167 + } else {
2168 + // 2 source words
2169 + d1 = FB_READL(src - 1);
2170 + d1 = fb_rev_pixels_in_long(d1, bswapmask);
2171 +- d0 = d0>>right | d1<<left;
2172 ++ d0 = d0 << left | d1 >> right;
2173 + }
2174 + d0 = fb_rev_pixels_in_long(d0, bswapmask);
2175 +- FB_WRITEL(comp(d0, FB_READL(dst), first), dst);
2176 ++ FB_WRITEL(comp(d0, FB_READL(dst), last), dst);
2177 + } else {
2178 + // Multiple destination words
2179 + /** We must always remember the last value read, because in case
2180 +@@ -307,12 +316,12 @@ bitcpy_rev(struct fb_info *p, unsigned long __iomem *dst, int dst_idx,
2181 + if (shift < 0) {
2182 + // Single source word
2183 + d1 = d0;
2184 +- d0 <<= left;
2185 ++ d0 >>= right;
2186 + } else {
2187 + // 2 source words
2188 + d1 = FB_READL(src--);
2189 + d1 = fb_rev_pixels_in_long(d1, bswapmask);
2190 +- d0 = d0>>right | d1<<left;
2191 ++ d0 = d0 << left | d1 >> right;
2192 + }
2193 + d0 = fb_rev_pixels_in_long(d0, bswapmask);
2194 + FB_WRITEL(comp(d0, FB_READL(dst), first), dst);
2195 +@@ -325,39 +334,39 @@ bitcpy_rev(struct fb_info *p, unsigned long __iomem *dst, int dst_idx,
2196 + n /= bits;
2197 + while ((n >= 4) && !bswapmask) {
2198 + d1 = FB_READL(src--);
2199 +- FB_WRITEL(d0 >> right | d1 << left, dst--);
2200 ++ FB_WRITEL(d0 << left | d1 >> right, dst--);
2201 + d0 = d1;
2202 + d1 = FB_READL(src--);
2203 +- FB_WRITEL(d0 >> right | d1 << left, dst--);
2204 ++ FB_WRITEL(d0 << left | d1 >> right, dst--);
2205 + d0 = d1;
2206 + d1 = FB_READL(src--);
2207 +- FB_WRITEL(d0 >> right | d1 << left, dst--);
2208 ++ FB_WRITEL(d0 << left | d1 >> right, dst--);
2209 + d0 = d1;
2210 + d1 = FB_READL(src--);
2211 +- FB_WRITEL(d0 >> right | d1 << left, dst--);
2212 ++ FB_WRITEL(d0 << left | d1 >> right, dst--);
2213 + d0 = d1;
2214 + n -= 4;
2215 + }
2216 + while (n--) {
2217 + d1 = FB_READL(src--);
2218 + d1 = fb_rev_pixels_in_long(d1, bswapmask);
2219 +- d0 = d0 >> right | d1 << left;
2220 ++ d0 = d0 << left | d1 >> right;
2221 + d0 = fb_rev_pixels_in_long(d0, bswapmask);
2222 + FB_WRITEL(d0, dst--);
2223 + d0 = d1;
2224 + }
2225 +
2226 + // Trailing bits
2227 +- if (last) {
2228 +- if (m <= left) {
2229 ++ if (m) {
2230 ++ if (m <= bits - left) {
2231 + // Single source word
2232 +- d0 >>= right;
2233 ++ d0 <<= left;
2234 + } else {
2235 + // 2 source words
2236 + d1 = FB_READL(src);
2237 + d1 = fb_rev_pixels_in_long(d1,
2238 + bswapmask);
2239 +- d0 = d0>>right | d1<<left;
2240 ++ d0 = d0 << left | d1 >> right;
2241 + }
2242 + d0 = fb_rev_pixels_in_long(d0, bswapmask);
2243 + FB_WRITEL(comp(d0, FB_READL(dst), last), dst);
2244 +@@ -371,9 +380,9 @@ void cfb_copyarea(struct fb_info *p, const struct fb_copyarea *area)
2245 + u32 dx = area->dx, dy = area->dy, sx = area->sx, sy = area->sy;
2246 + u32 height = area->height, width = area->width;
2247 + unsigned long const bits_per_line = p->fix.line_length*8u;
2248 +- unsigned long __iomem *dst = NULL, *src = NULL;
2249 ++ unsigned long __iomem *base = NULL;
2250 + int bits = BITS_PER_LONG, bytes = bits >> 3;
2251 +- int dst_idx = 0, src_idx = 0, rev_copy = 0;
2252 ++ unsigned dst_idx = 0, src_idx = 0, rev_copy = 0;
2253 + u32 bswapmask = fb_compute_bswapmask(p);
2254 +
2255 + if (p->state != FBINFO_STATE_RUNNING)
2256 +@@ -389,7 +398,7 @@ void cfb_copyarea(struct fb_info *p, const struct fb_copyarea *area)
2257 +
2258 + // split the base of the framebuffer into a long-aligned address and the
2259 + // index of the first bit
2260 +- dst = src = (unsigned long __iomem *)((unsigned long)p->screen_base & ~(bytes-1));
2261 ++ base = (unsigned long __iomem *)((unsigned long)p->screen_base & ~(bytes-1));
2262 + dst_idx = src_idx = 8*((unsigned long)p->screen_base & (bytes-1));
2263 + // add offset of source and target area
2264 + dst_idx += dy*bits_per_line + dx*p->var.bits_per_pixel;
2265 +@@ -402,20 +411,14 @@ void cfb_copyarea(struct fb_info *p, const struct fb_copyarea *area)
2266 + while (height--) {
2267 + dst_idx -= bits_per_line;
2268 + src_idx -= bits_per_line;
2269 +- dst += dst_idx >> (ffs(bits) - 1);
2270 +- dst_idx &= (bytes - 1);
2271 +- src += src_idx >> (ffs(bits) - 1);
2272 +- src_idx &= (bytes - 1);
2273 +- bitcpy_rev(p, dst, dst_idx, src, src_idx, bits,
2274 ++ bitcpy_rev(p, base + (dst_idx / bits), dst_idx % bits,
2275 ++ base + (src_idx / bits), src_idx % bits, bits,
2276 + width*p->var.bits_per_pixel, bswapmask);
2277 + }
2278 + } else {
2279 + while (height--) {
2280 +- dst += dst_idx >> (ffs(bits) - 1);
2281 +- dst_idx &= (bytes - 1);
2282 +- src += src_idx >> (ffs(bits) - 1);
2283 +- src_idx &= (bytes - 1);
2284 +- bitcpy(p, dst, dst_idx, src, src_idx, bits,
2285 ++ bitcpy(p, base + (dst_idx / bits), dst_idx % bits,
2286 ++ base + (src_idx / bits), src_idx % bits, bits,
2287 + width*p->var.bits_per_pixel, bswapmask);
2288 + dst_idx += bits_per_line;
2289 + src_idx += bits_per_line;
2290 +diff --git a/drivers/video/matrox/matroxfb_accel.c b/drivers/video/matrox/matroxfb_accel.c
2291 +index 8335a6f..0d5cb85 100644
2292 +--- a/drivers/video/matrox/matroxfb_accel.c
2293 ++++ b/drivers/video/matrox/matroxfb_accel.c
2294 +@@ -192,10 +192,18 @@ void matrox_cfbX_init(struct matrox_fb_info *minfo)
2295 + minfo->accel.m_dwg_rect = M_DWG_TRAP | M_DWG_SOLID | M_DWG_ARZERO | M_DWG_SGNZERO | M_DWG_SHIFTZERO;
2296 + if (isMilleniumII(minfo)) minfo->accel.m_dwg_rect |= M_DWG_TRANSC;
2297 + minfo->accel.m_opmode = mopmode;
2298 ++ minfo->accel.m_access = maccess;
2299 ++ minfo->accel.m_pitch = mpitch;
2300 + }
2301 +
2302 + EXPORT_SYMBOL(matrox_cfbX_init);
2303 +
2304 ++static void matrox_accel_restore_maccess(struct matrox_fb_info *minfo)
2305 ++{
2306 ++ mga_outl(M_MACCESS, minfo->accel.m_access);
2307 ++ mga_outl(M_PITCH, minfo->accel.m_pitch);
2308 ++}
2309 ++
2310 + static void matrox_accel_bmove(struct matrox_fb_info *minfo, int vxres, int sy,
2311 + int sx, int dy, int dx, int height, int width)
2312 + {
2313 +@@ -207,7 +215,8 @@ static void matrox_accel_bmove(struct matrox_fb_info *minfo, int vxres, int sy,
2314 + CRITBEGIN
2315 +
2316 + if ((dy < sy) || ((dy == sy) && (dx <= sx))) {
2317 +- mga_fifo(2);
2318 ++ mga_fifo(4);
2319 ++ matrox_accel_restore_maccess(minfo);
2320 + mga_outl(M_DWGCTL, M_DWG_BITBLT | M_DWG_SHIFTZERO | M_DWG_SGNZERO |
2321 + M_DWG_BFCOL | M_DWG_REPLACE);
2322 + mga_outl(M_AR5, vxres);
2323 +@@ -215,7 +224,8 @@ static void matrox_accel_bmove(struct matrox_fb_info *minfo, int vxres, int sy,
2324 + start = sy*vxres+sx+curr_ydstorg(minfo);
2325 + end = start+width;
2326 + } else {
2327 +- mga_fifo(3);
2328 ++ mga_fifo(5);
2329 ++ matrox_accel_restore_maccess(minfo);
2330 + mga_outl(M_DWGCTL, M_DWG_BITBLT | M_DWG_SHIFTZERO | M_DWG_BFCOL | M_DWG_REPLACE);
2331 + mga_outl(M_SGN, 5);
2332 + mga_outl(M_AR5, -vxres);
2333 +@@ -224,7 +234,8 @@ static void matrox_accel_bmove(struct matrox_fb_info *minfo, int vxres, int sy,
2334 + start = end+width;
2335 + dy += height-1;
2336 + }
2337 +- mga_fifo(4);
2338 ++ mga_fifo(6);
2339 ++ matrox_accel_restore_maccess(minfo);
2340 + mga_outl(M_AR0, end);
2341 + mga_outl(M_AR3, start);
2342 + mga_outl(M_FXBNDRY, ((dx+width)<<16) | dx);
2343 +@@ -246,7 +257,8 @@ static void matrox_accel_bmove_lin(struct matrox_fb_info *minfo, int vxres,
2344 + CRITBEGIN
2345 +
2346 + if ((dy < sy) || ((dy == sy) && (dx <= sx))) {
2347 +- mga_fifo(2);
2348 ++ mga_fifo(4);
2349 ++ matrox_accel_restore_maccess(minfo);
2350 + mga_outl(M_DWGCTL, M_DWG_BITBLT | M_DWG_SHIFTZERO | M_DWG_SGNZERO |
2351 + M_DWG_BFCOL | M_DWG_REPLACE);
2352 + mga_outl(M_AR5, vxres);
2353 +@@ -254,7 +266,8 @@ static void matrox_accel_bmove_lin(struct matrox_fb_info *minfo, int vxres,
2354 + start = sy*vxres+sx+curr_ydstorg(minfo);
2355 + end = start+width;
2356 + } else {
2357 +- mga_fifo(3);
2358 ++ mga_fifo(5);
2359 ++ matrox_accel_restore_maccess(minfo);
2360 + mga_outl(M_DWGCTL, M_DWG_BITBLT | M_DWG_SHIFTZERO | M_DWG_BFCOL | M_DWG_REPLACE);
2361 + mga_outl(M_SGN, 5);
2362 + mga_outl(M_AR5, -vxres);
2363 +@@ -263,7 +276,8 @@ static void matrox_accel_bmove_lin(struct matrox_fb_info *minfo, int vxres,
2364 + start = end+width;
2365 + dy += height-1;
2366 + }
2367 +- mga_fifo(5);
2368 ++ mga_fifo(7);
2369 ++ matrox_accel_restore_maccess(minfo);
2370 + mga_outl(M_AR0, end);
2371 + mga_outl(M_AR3, start);
2372 + mga_outl(M_FXBNDRY, ((dx+width)<<16) | dx);
2373 +@@ -298,7 +312,8 @@ static void matroxfb_accel_clear(struct matrox_fb_info *minfo, u_int32_t color,
2374 +
2375 + CRITBEGIN
2376 +
2377 +- mga_fifo(5);
2378 ++ mga_fifo(7);
2379 ++ matrox_accel_restore_maccess(minfo);
2380 + mga_outl(M_DWGCTL, minfo->accel.m_dwg_rect | M_DWG_REPLACE);
2381 + mga_outl(M_FCOL, color);
2382 + mga_outl(M_FXBNDRY, ((sx + width) << 16) | sx);
2383 +@@ -341,7 +356,8 @@ static void matroxfb_cfb4_clear(struct matrox_fb_info *minfo, u_int32_t bgx,
2384 + width >>= 1;
2385 + sx >>= 1;
2386 + if (width) {
2387 +- mga_fifo(5);
2388 ++ mga_fifo(7);
2389 ++ matrox_accel_restore_maccess(minfo);
2390 + mga_outl(M_DWGCTL, minfo->accel.m_dwg_rect | M_DWG_REPLACE2);
2391 + mga_outl(M_FCOL, bgx);
2392 + mga_outl(M_FXBNDRY, ((sx + width) << 16) | sx);
2393 +@@ -415,7 +431,8 @@ static void matroxfb_1bpp_imageblit(struct matrox_fb_info *minfo, u_int32_t fgx,
2394 +
2395 + CRITBEGIN
2396 +
2397 +- mga_fifo(3);
2398 ++ mga_fifo(5);
2399 ++ matrox_accel_restore_maccess(minfo);
2400 + if (easy)
2401 + mga_outl(M_DWGCTL, M_DWG_ILOAD | M_DWG_SGNZERO | M_DWG_SHIFTZERO | M_DWG_BMONOWF | M_DWG_LINEAR | M_DWG_REPLACE);
2402 + else
2403 +@@ -425,7 +442,8 @@ static void matroxfb_1bpp_imageblit(struct matrox_fb_info *minfo, u_int32_t fgx,
2404 + fxbndry = ((xx + width - 1) << 16) | xx;
2405 + mmio = minfo->mmio.vbase;
2406 +
2407 +- mga_fifo(6);
2408 ++ mga_fifo(8);
2409 ++ matrox_accel_restore_maccess(minfo);
2410 + mga_writel(mmio, M_FXBNDRY, fxbndry);
2411 + mga_writel(mmio, M_AR0, ar0);
2412 + mga_writel(mmio, M_AR3, 0);
2413 +diff --git a/drivers/video/matrox/matroxfb_base.h b/drivers/video/matrox/matroxfb_base.h
2414 +index 11ed57b..556d96c 100644
2415 +--- a/drivers/video/matrox/matroxfb_base.h
2416 ++++ b/drivers/video/matrox/matroxfb_base.h
2417 +@@ -307,6 +307,8 @@ struct matrox_accel_data {
2418 + #endif
2419 + u_int32_t m_dwg_rect;
2420 + u_int32_t m_opmode;
2421 ++ u_int32_t m_access;
2422 ++ u_int32_t m_pitch;
2423 + };
2424 +
2425 + struct v4l2_queryctrl;
2426 +diff --git a/drivers/video/tgafb.c b/drivers/video/tgafb.c
2427 +index aba7686..ac2cf6d 100644
2428 +--- a/drivers/video/tgafb.c
2429 ++++ b/drivers/video/tgafb.c
2430 +@@ -1146,222 +1146,57 @@ copyarea_line_32bpp(struct fb_info *info, u32 dy, u32 sy,
2431 + __raw_writel(TGA_MODE_SBM_24BPP|TGA_MODE_SIMPLE, tga_regs+TGA_MODE_REG);
2432 + }
2433 +
2434 +-/* The general case of forward copy in 8bpp mode. */
2435 ++/* The (almost) general case of backward copy in 8bpp mode. */
2436 + static inline void
2437 +-copyarea_foreward_8bpp(struct fb_info *info, u32 dx, u32 dy, u32 sx, u32 sy,
2438 +- u32 height, u32 width, u32 line_length)
2439 ++copyarea_8bpp(struct fb_info *info, u32 dx, u32 dy, u32 sx, u32 sy,
2440 ++ u32 height, u32 width, u32 line_length,
2441 ++ const struct fb_copyarea *area)
2442 + {
2443 + struct tga_par *par = (struct tga_par *) info->par;
2444 +- unsigned long i, copied, left;
2445 +- unsigned long dpos, spos, dalign, salign, yincr;
2446 +- u32 smask_first, dmask_first, dmask_last;
2447 +- int pixel_shift, need_prime, need_second;
2448 +- unsigned long n64, n32, xincr_first;
2449 ++ unsigned i, yincr;
2450 ++ int depos, sepos, backward, last_step, step;
2451 ++ u32 mask_last;
2452 ++ unsigned n32;
2453 + void __iomem *tga_regs;
2454 + void __iomem *tga_fb;
2455 +
2456 +- yincr = line_length;
2457 +- if (dy > sy) {
2458 +- dy += height - 1;
2459 +- sy += height - 1;
2460 +- yincr = -yincr;
2461 +- }
2462 +-
2463 +- /* Compute the offsets and alignments in the frame buffer.
2464 +- More than anything else, these control how we do copies. */
2465 +- dpos = dy * line_length + dx;
2466 +- spos = sy * line_length + sx;
2467 +- dalign = dpos & 7;
2468 +- salign = spos & 7;
2469 +- dpos &= -8;
2470 +- spos &= -8;
2471 +-
2472 +- /* Compute the value for the PIXELSHIFT register. This controls
2473 +- both non-co-aligned source and destination and copy direction. */
2474 +- if (dalign >= salign)
2475 +- pixel_shift = dalign - salign;
2476 +- else
2477 +- pixel_shift = 8 - (salign - dalign);
2478 +-
2479 +- /* Figure out if we need an additional priming step for the
2480 +- residue register. */
2481 +- need_prime = (salign > dalign);
2482 +- if (need_prime)
2483 +- dpos -= 8;
2484 +-
2485 +- /* Begin by copying the leading unaligned destination. Copy enough
2486 +- to make the next destination address 32-byte aligned. */
2487 +- copied = 32 - (dalign + (dpos & 31));
2488 +- if (copied == 32)
2489 +- copied = 0;
2490 +- xincr_first = (copied + 7) & -8;
2491 +- smask_first = dmask_first = (1ul << copied) - 1;
2492 +- smask_first <<= salign;
2493 +- dmask_first <<= dalign + need_prime*8;
2494 +- if (need_prime && copied > 24)
2495 +- copied -= 8;
2496 +- left = width - copied;
2497 +-
2498 +- /* Care for small copies. */
2499 +- if (copied > width) {
2500 +- u32 t;
2501 +- t = (1ul << width) - 1;
2502 +- t <<= dalign + need_prime*8;
2503 +- dmask_first &= t;
2504 +- left = 0;
2505 +- }
2506 +-
2507 +- /* Attempt to use 64-byte copies. This is only possible if the
2508 +- source and destination are co-aligned at 64 bytes. */
2509 +- n64 = need_second = 0;
2510 +- if ((dpos & 63) == (spos & 63)
2511 +- && (height == 1 || line_length % 64 == 0)) {
2512 +- /* We may need a 32-byte copy to ensure 64 byte alignment. */
2513 +- need_second = (dpos + xincr_first) & 63;
2514 +- if ((need_second & 32) != need_second)
2515 +- printk(KERN_ERR "tgafb: need_second wrong\n");
2516 +- if (left >= need_second + 64) {
2517 +- left -= need_second;
2518 +- n64 = left / 64;
2519 +- left %= 64;
2520 +- } else
2521 +- need_second = 0;
2522 +- }
2523 +-
2524 +- /* Copy trailing full 32-byte sections. This will be the main
2525 +- loop if the 64 byte loop can't be used. */
2526 +- n32 = left / 32;
2527 +- left %= 32;
2528 +-
2529 +- /* Copy the trailing unaligned destination. */
2530 +- dmask_last = (1ul << left) - 1;
2531 +-
2532 +- tga_regs = par->tga_regs_base;
2533 +- tga_fb = par->tga_fb_base;
2534 +-
2535 +- /* Set up the MODE and PIXELSHIFT registers. */
2536 +- __raw_writel(TGA_MODE_SBM_8BPP|TGA_MODE_COPY, tga_regs+TGA_MODE_REG);
2537 +- __raw_writel(pixel_shift, tga_regs+TGA_PIXELSHIFT_REG);
2538 +- wmb();
2539 +-
2540 +- for (i = 0; i < height; ++i) {
2541 +- unsigned long j;
2542 +- void __iomem *sfb;
2543 +- void __iomem *dfb;
2544 +-
2545 +- sfb = tga_fb + spos;
2546 +- dfb = tga_fb + dpos;
2547 +- if (dmask_first) {
2548 +- __raw_writel(smask_first, sfb);
2549 +- wmb();
2550 +- __raw_writel(dmask_first, dfb);
2551 +- wmb();
2552 +- sfb += xincr_first;
2553 +- dfb += xincr_first;
2554 +- }
2555 +-
2556 +- if (need_second) {
2557 +- __raw_writel(0xffffffff, sfb);
2558 +- wmb();
2559 +- __raw_writel(0xffffffff, dfb);
2560 +- wmb();
2561 +- sfb += 32;
2562 +- dfb += 32;
2563 +- }
2564 +-
2565 +- if (n64 && (((unsigned long)sfb | (unsigned long)dfb) & 63))
2566 +- printk(KERN_ERR
2567 +- "tgafb: misaligned copy64 (s:%p, d:%p)\n",
2568 +- sfb, dfb);
2569 +-
2570 +- for (j = 0; j < n64; ++j) {
2571 +- __raw_writel(sfb - tga_fb, tga_regs+TGA_COPY64_SRC);
2572 +- wmb();
2573 +- __raw_writel(dfb - tga_fb, tga_regs+TGA_COPY64_DST);
2574 +- wmb();
2575 +- sfb += 64;
2576 +- dfb += 64;
2577 +- }
2578 +-
2579 +- for (j = 0; j < n32; ++j) {
2580 +- __raw_writel(0xffffffff, sfb);
2581 +- wmb();
2582 +- __raw_writel(0xffffffff, dfb);
2583 +- wmb();
2584 +- sfb += 32;
2585 +- dfb += 32;
2586 +- }
2587 +-
2588 +- if (dmask_last) {
2589 +- __raw_writel(0xffffffff, sfb);
2590 +- wmb();
2591 +- __raw_writel(dmask_last, dfb);
2592 +- wmb();
2593 +- }
2594 +-
2595 +- spos += yincr;
2596 +- dpos += yincr;
2597 ++ /* Do acceleration only if we are aligned on 8 pixels */
2598 ++ if ((dx | sx | width) & 7) {
2599 ++ cfb_copyarea(info, area);
2600 ++ return;
2601 + }
2602 +
2603 +- /* Reset the MODE register to normal. */
2604 +- __raw_writel(TGA_MODE_SBM_8BPP|TGA_MODE_SIMPLE, tga_regs+TGA_MODE_REG);
2605 +-}
2606 +-
2607 +-/* The (almost) general case of backward copy in 8bpp mode. */
2608 +-static inline void
2609 +-copyarea_backward_8bpp(struct fb_info *info, u32 dx, u32 dy, u32 sx, u32 sy,
2610 +- u32 height, u32 width, u32 line_length,
2611 +- const struct fb_copyarea *area)
2612 +-{
2613 +- struct tga_par *par = (struct tga_par *) info->par;
2614 +- unsigned long i, left, yincr;
2615 +- unsigned long depos, sepos, dealign, sealign;
2616 +- u32 mask_first, mask_last;
2617 +- unsigned long n32;
2618 +- void __iomem *tga_regs;
2619 +- void __iomem *tga_fb;
2620 +-
2621 + yincr = line_length;
2622 + if (dy > sy) {
2623 + dy += height - 1;
2624 + sy += height - 1;
2625 + yincr = -yincr;
2626 + }
2627 ++ backward = dy == sy && dx > sx && dx < sx + width;
2628 +
2629 + /* Compute the offsets and alignments in the frame buffer.
2630 + More than anything else, these control how we do copies. */
2631 +- depos = dy * line_length + dx + width;
2632 +- sepos = sy * line_length + sx + width;
2633 +- dealign = depos & 7;
2634 +- sealign = sepos & 7;
2635 +-
2636 +- /* ??? The documentation appears to be incorrect (or very
2637 +- misleading) wrt how pixel shifting works in backward copy
2638 +- mode, i.e. when PIXELSHIFT is negative. I give up for now.
2639 +- Do handle the common case of co-aligned backward copies,
2640 +- but frob everything else back on generic code. */
2641 +- if (dealign != sealign) {
2642 +- cfb_copyarea(info, area);
2643 +- return;
2644 +- }
2645 +-
2646 +- /* We begin the copy with the trailing pixels of the
2647 +- unaligned destination. */
2648 +- mask_first = (1ul << dealign) - 1;
2649 +- left = width - dealign;
2650 +-
2651 +- /* Care for small copies. */
2652 +- if (dealign > width) {
2653 +- mask_first ^= (1ul << (dealign - width)) - 1;
2654 +- left = 0;
2655 +- }
2656 ++ depos = dy * line_length + dx;
2657 ++ sepos = sy * line_length + sx;
2658 ++ if (backward)
2659 ++ depos += width, sepos += width;
2660 +
2661 + /* Next copy full words at a time. */
2662 +- n32 = left / 32;
2663 +- left %= 32;
2664 ++ n32 = width / 32;
2665 ++ last_step = width % 32;
2666 +
2667 + /* Finally copy the unaligned head of the span. */
2668 +- mask_last = -1 << (32 - left);
2669 ++ mask_last = (1ul << last_step) - 1;
2670 ++
2671 ++ if (!backward) {
2672 ++ step = 32;
2673 ++ last_step = 32;
2674 ++ } else {
2675 ++ step = -32;
2676 ++ last_step = -last_step;
2677 ++ sepos -= 32;
2678 ++ depos -= 32;
2679 ++ }
2680 +
2681 + tga_regs = par->tga_regs_base;
2682 + tga_fb = par->tga_fb_base;
2683 +@@ -1378,25 +1213,33 @@ copyarea_backward_8bpp(struct fb_info *info, u32 dx, u32 dy, u32 sx, u32 sy,
2684 +
2685 + sfb = tga_fb + sepos;
2686 + dfb = tga_fb + depos;
2687 +- if (mask_first) {
2688 +- __raw_writel(mask_first, sfb);
2689 +- wmb();
2690 +- __raw_writel(mask_first, dfb);
2691 +- wmb();
2692 +- }
2693 +
2694 +- for (j = 0; j < n32; ++j) {
2695 +- sfb -= 32;
2696 +- dfb -= 32;
2697 ++ for (j = 0; j < n32; j++) {
2698 ++ if (j < 2 && j + 1 < n32 && !backward &&
2699 ++ !(((unsigned long)sfb | (unsigned long)dfb) & 63)) {
2700 ++ do {
2701 ++ __raw_writel(sfb - tga_fb, tga_regs+TGA_COPY64_SRC);
2702 ++ wmb();
2703 ++ __raw_writel(dfb - tga_fb, tga_regs+TGA_COPY64_DST);
2704 ++ wmb();
2705 ++ sfb += 64;
2706 ++ dfb += 64;
2707 ++ j += 2;
2708 ++ } while (j + 1 < n32);
2709 ++ j--;
2710 ++ continue;
2711 ++ }
2712 + __raw_writel(0xffffffff, sfb);
2713 + wmb();
2714 + __raw_writel(0xffffffff, dfb);
2715 + wmb();
2716 ++ sfb += step;
2717 ++ dfb += step;
2718 + }
2719 +
2720 + if (mask_last) {
2721 +- sfb -= 32;
2722 +- dfb -= 32;
2723 ++ sfb += last_step - step;
2724 ++ dfb += last_step - step;
2725 + __raw_writel(mask_last, sfb);
2726 + wmb();
2727 + __raw_writel(mask_last, dfb);
2728 +@@ -1457,14 +1300,9 @@ tgafb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
2729 + else if (bpp == 32)
2730 + cfb_copyarea(info, area);
2731 +
2732 +- /* Detect overlapping source and destination that requires
2733 +- a backward copy. */
2734 +- else if (dy == sy && dx > sx && dx < sx + width)
2735 +- copyarea_backward_8bpp(info, dx, dy, sx, sy, height,
2736 +- width, line_length, area);
2737 + else
2738 +- copyarea_foreward_8bpp(info, dx, dy, sx, sy, height,
2739 +- width, line_length);
2740 ++ copyarea_8bpp(info, dx, dy, sx, sy, height,
2741 ++ width, line_length, area);
2742 + }
2743 +
2744 +
2745 +diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
2746 +index 94fd738..28153fb 100644
2747 +--- a/drivers/virtio/virtio_balloon.c
2748 ++++ b/drivers/virtio/virtio_balloon.c
2749 +@@ -271,6 +271,12 @@ static int balloon(void *_vballoon)
2750 + else if (diff < 0)
2751 + leak_balloon(vb, -diff);
2752 + update_balloon_size(vb);
2753 ++
2754 ++ /*
2755 ++ * For large balloon changes, we could spend a lot of time
2756 ++ * and always have work to do. Be nice if preempt disabled.
2757 ++ */
2758 ++ cond_resched();
2759 + }
2760 + return 0;
2761 + }
2762 +diff --git a/drivers/w1/w1_netlink.c b/drivers/w1/w1_netlink.c
2763 +index 40788c9..73705af 100644
2764 +--- a/drivers/w1/w1_netlink.c
2765 ++++ b/drivers/w1/w1_netlink.c
2766 +@@ -54,28 +54,29 @@ static void w1_send_slave(struct w1_master *dev, u64 rn)
2767 + struct w1_netlink_msg *hdr = (struct w1_netlink_msg *)(msg + 1);
2768 + struct w1_netlink_cmd *cmd = (struct w1_netlink_cmd *)(hdr + 1);
2769 + int avail;
2770 ++ u64 *data;
2771 +
2772 + /* update kernel slave list */
2773 + w1_slave_found(dev, rn);
2774 +
2775 + avail = dev->priv_size - cmd->len;
2776 +
2777 +- if (avail > 8) {
2778 +- u64 *data = (void *)(cmd + 1) + cmd->len;
2779 ++ if (avail < 8) {
2780 ++ msg->ack++;
2781 ++ cn_netlink_send(msg, 0, GFP_KERNEL);
2782 +
2783 +- *data = rn;
2784 +- cmd->len += 8;
2785 +- hdr->len += 8;
2786 +- msg->len += 8;
2787 +- return;
2788 ++ msg->len = sizeof(struct w1_netlink_msg) +
2789 ++ sizeof(struct w1_netlink_cmd);
2790 ++ hdr->len = sizeof(struct w1_netlink_cmd);
2791 ++ cmd->len = 0;
2792 + }
2793 +
2794 +- msg->ack++;
2795 +- cn_netlink_send(msg, 0, GFP_KERNEL);
2796 ++ data = (void *)(cmd + 1) + cmd->len;
2797 +
2798 +- msg->len = sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd);
2799 +- hdr->len = sizeof(struct w1_netlink_cmd);
2800 +- cmd->len = 0;
2801 ++ *data = rn;
2802 ++ cmd->len += 8;
2803 ++ hdr->len += 8;
2804 ++ msg->len += 8;
2805 + }
2806 +
2807 + static int w1_process_search_command(struct w1_master *dev, struct cn_msg *msg,
2808 +diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
2809 +index 6b2a724..cfdf6fe 100644
2810 +--- a/fs/btrfs/disk-io.c
2811 ++++ b/fs/btrfs/disk-io.c
2812 +@@ -2731,6 +2731,8 @@ static int barrier_all_devices(struct btrfs_fs_info *info)
2813 + /* send down all the barriers */
2814 + head = &info->fs_devices->devices;
2815 + list_for_each_entry_rcu(dev, head, dev_list) {
2816 ++ if (dev->missing)
2817 ++ continue;
2818 + if (!dev->bdev) {
2819 + errors++;
2820 + continue;
2821 +@@ -2745,6 +2747,8 @@ static int barrier_all_devices(struct btrfs_fs_info *info)
2822 +
2823 + /* wait for all the barriers */
2824 + list_for_each_entry_rcu(dev, head, dev_list) {
2825 ++ if (dev->missing)
2826 ++ continue;
2827 + if (!dev->bdev) {
2828 + errors++;
2829 + continue;
2830 +diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
2831 +index 81376d9..292e847 100644
2832 +--- a/fs/btrfs/transaction.c
2833 ++++ b/fs/btrfs/transaction.c
2834 +@@ -460,7 +460,8 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
2835 + struct btrfs_fs_info *info = root->fs_info;
2836 + int count = 0;
2837 +
2838 +- if (--trans->use_count) {
2839 ++ if (trans->use_count > 1) {
2840 ++ trans->use_count--;
2841 + trans->block_rsv = trans->orig_rsv;
2842 + return 0;
2843 + }
2844 +@@ -494,17 +495,10 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
2845 + }
2846 +
2847 + if (lock && cur_trans->blocked && !cur_trans->in_commit) {
2848 +- if (throttle) {
2849 +- /*
2850 +- * We may race with somebody else here so end up having
2851 +- * to call end_transaction on ourselves again, so inc
2852 +- * our use_count.
2853 +- */
2854 +- trans->use_count++;
2855 ++ if (throttle)
2856 + return btrfs_commit_transaction(trans, root);
2857 +- } else {
2858 ++ else
2859 + wake_up_process(info->transaction_kthread);
2860 +- }
2861 + }
2862 +
2863 + WARN_ON(cur_trans != info->running_transaction);
2864 +diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
2865 +index bf35fe0..834d9a1 100644
2866 +--- a/fs/ext4/extents.c
2867 ++++ b/fs/ext4/extents.c
2868 +@@ -2372,6 +2372,27 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
2869 + ex_ee_block = le32_to_cpu(ex->ee_block);
2870 + ex_ee_len = ext4_ext_get_actual_len(ex);
2871 +
2872 ++ /*
2873 ++ * If we're starting with an extent other than the last one in the
2874 ++ * node, we need to see if it shares a cluster with the extent to
2875 ++ * the right (towards the end of the file). If its leftmost cluster
2876 ++ * is this extent's rightmost cluster and it is not cluster aligned,
2877 ++ * we'll mark it as a partial that is not to be deallocated.
2878 ++ */
2879 ++
2880 ++ if (ex != EXT_LAST_EXTENT(eh)) {
2881 ++ ext4_fsblk_t current_pblk, right_pblk;
2882 ++ long long current_cluster, right_cluster;
2883 ++
2884 ++ current_pblk = ext4_ext_pblock(ex) + ex_ee_len - 1;
2885 ++ current_cluster = (long long)EXT4_B2C(sbi, current_pblk);
2886 ++ right_pblk = ext4_ext_pblock(ex + 1);
2887 ++ right_cluster = (long long)EXT4_B2C(sbi, right_pblk);
2888 ++ if (current_cluster == right_cluster &&
2889 ++ EXT4_PBLK_COFF(sbi, right_pblk))
2890 ++ *partial_cluster = -right_cluster;
2891 ++ }
2892 ++
2893 + trace_ext4_ext_rm_leaf(inode, start, ex, *partial_cluster);
2894 +
2895 + while (ex >= EXT_FIRST_EXTENT(eh) &&
2896 +diff --git a/fs/jffs2/compr_rtime.c b/fs/jffs2/compr_rtime.c
2897 +index 16a5047..406d9cc 100644
2898 +--- a/fs/jffs2/compr_rtime.c
2899 ++++ b/fs/jffs2/compr_rtime.c
2900 +@@ -33,7 +33,7 @@ static int jffs2_rtime_compress(unsigned char *data_in,
2901 + unsigned char *cpage_out,
2902 + uint32_t *sourcelen, uint32_t *dstlen)
2903 + {
2904 +- short positions[256];
2905 ++ unsigned short positions[256];
2906 + int outpos = 0;
2907 + int pos=0;
2908 +
2909 +@@ -74,7 +74,7 @@ static int jffs2_rtime_decompress(unsigned char *data_in,
2910 + unsigned char *cpage_out,
2911 + uint32_t srclen, uint32_t destlen)
2912 + {
2913 +- short positions[256];
2914 ++ unsigned short positions[256];
2915 + int outpos = 0;
2916 + int pos=0;
2917 +
2918 +diff --git a/fs/jffs2/nodelist.h b/fs/jffs2/nodelist.h
2919 +index e4619b0..fa35ff7 100644
2920 +--- a/fs/jffs2/nodelist.h
2921 ++++ b/fs/jffs2/nodelist.h
2922 +@@ -231,7 +231,7 @@ struct jffs2_tmp_dnode_info
2923 + uint32_t version;
2924 + uint32_t data_crc;
2925 + uint32_t partial_crc;
2926 +- uint16_t csize;
2927 ++ uint32_t csize;
2928 + uint16_t overlapped;
2929 + };
2930 +
2931 +diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c
2932 +index 694aa5b..145ba39 100644
2933 +--- a/fs/jffs2/nodemgmt.c
2934 ++++ b/fs/jffs2/nodemgmt.c
2935 +@@ -128,6 +128,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
2936 + spin_unlock(&c->erase_completion_lock);
2937 +
2938 + schedule();
2939 ++ remove_wait_queue(&c->erase_wait, &wait);
2940 + } else
2941 + spin_unlock(&c->erase_completion_lock);
2942 + } else if (ret)
2943 +@@ -158,19 +159,24 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
2944 + int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize,
2945 + uint32_t *len, uint32_t sumsize)
2946 + {
2947 +- int ret = -EAGAIN;
2948 ++ int ret;
2949 + minsize = PAD(minsize);
2950 +
2951 + D1(printk(KERN_DEBUG "jffs2_reserve_space_gc(): Requested 0x%x bytes\n", minsize));
2952 +
2953 +- spin_lock(&c->erase_completion_lock);
2954 +- while(ret == -EAGAIN) {
2955 ++ while (true) {
2956 ++ spin_lock(&c->erase_completion_lock);
2957 + ret = jffs2_do_reserve_space(c, minsize, len, sumsize);
2958 + if (ret) {
2959 + D1(printk(KERN_DEBUG "jffs2_reserve_space_gc: looping, ret is %d\n", ret));
2960 + }
2961 ++ spin_unlock(&c->erase_completion_lock);
2962 ++
2963 ++ if (ret == -EAGAIN)
2964 ++ cond_resched();
2965 ++ else
2966 ++ break;
2967 + }
2968 +- spin_unlock(&c->erase_completion_lock);
2969 + if (!ret)
2970 + ret = jffs2_prealloc_raw_node_refs(c, c->nextblock, 1);
2971 +
2972 +diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
2973 +index e065497..315a1ba 100644
2974 +--- a/fs/nfsd/nfs4proc.c
2975 ++++ b/fs/nfsd/nfs4proc.c
2976 +@@ -1224,6 +1224,12 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
2977 + /* If op is non-idempotent */
2978 + if (opdesc->op_flags & OP_MODIFIES_SOMETHING) {
2979 + plen = opdesc->op_rsize_bop(rqstp, op);
2980 ++ /*
2981 ++ * If there's still another operation, make sure
2982 ++ * we'll have space to at least encode an error:
2983 ++ */
2984 ++ if (resp->opcnt < args->opcnt)
2985 ++ plen += COMPOUND_ERR_SLACK_SPACE;
2986 + op->status = nfsd4_check_resp_size(resp, plen);
2987 + }
2988 +
2989 +@@ -1381,7 +1387,8 @@ static inline u32 nfsd4_setattr_rsize(struct svc_rqst *rqstp, struct nfsd4_op *o
2990 +
2991 + static inline u32 nfsd4_setclientid_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
2992 + {
2993 +- return (op_encode_hdr_size + 2 + 1024) * sizeof(__be32);
2994 ++ return (op_encode_hdr_size + 2 + XDR_QUADLEN(NFS4_VERIFIER_SIZE)) *
2995 ++ sizeof(__be32);
2996 + }
2997 +
2998 + static inline u32 nfsd4_write_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
2999 +diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
3000 +index ade5316..4835b90 100644
3001 +--- a/fs/nfsd/nfs4xdr.c
3002 ++++ b/fs/nfsd/nfs4xdr.c
3003 +@@ -2413,6 +2413,8 @@ out_acl:
3004 + WRITE64(stat.ino);
3005 + }
3006 + if (bmval2 & FATTR4_WORD2_SUPPATTR_EXCLCREAT) {
3007 ++ if ((buflen -= 16) < 0)
3008 ++ goto out_resource;
3009 + WRITE32(3);
3010 + WRITE32(NFSD_SUPPATTR_EXCLCREAT_WORD0);
3011 + WRITE32(NFSD_SUPPATTR_EXCLCREAT_WORD1);
3012 +diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
3013 +index 6a66fc0..11e1888 100644
3014 +--- a/fs/nfsd/vfs.c
3015 ++++ b/fs/nfsd/vfs.c
3016 +@@ -406,6 +406,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
3017 + int ftype = 0;
3018 + __be32 err;
3019 + int host_err;
3020 ++ bool get_write_count;
3021 + int size_change = 0;
3022 +
3023 + if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE))
3024 +@@ -413,10 +414,18 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
3025 + if (iap->ia_valid & ATTR_SIZE)
3026 + ftype = S_IFREG;
3027 +
3028 ++ /* Callers that do fh_verify should do the fh_want_write: */
3029 ++ get_write_count = !fhp->fh_dentry;
3030 ++
3031 + /* Get inode */
3032 + err = fh_verify(rqstp, fhp, ftype, accmode);
3033 + if (err)
3034 + goto out;
3035 ++ if (get_write_count) {
3036 ++ host_err = fh_want_write(fhp);
3037 ++ if (host_err)
3038 ++ return nfserrno(host_err);
3039 ++ }
3040 +
3041 + dentry = fhp->fh_dentry;
3042 + inode = dentry->d_inode;
3043 +diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h
3044 +index 85d4d42..c7fe962 100644
3045 +--- a/fs/nfsd/vfs.h
3046 ++++ b/fs/nfsd/vfs.h
3047 +@@ -108,4 +108,14 @@ struct posix_acl *nfsd_get_posix_acl(struct svc_fh *, int);
3048 + int nfsd_set_posix_acl(struct svc_fh *, int, struct posix_acl *);
3049 + #endif
3050 +
3051 ++static inline int fh_want_write(struct svc_fh *fh)
3052 ++{
3053 ++ return mnt_want_write(fh->fh_export->ex_path.mnt);
3054 ++}
3055 ++
3056 ++static inline void fh_drop_write(struct svc_fh *fh)
3057 ++{
3058 ++ mnt_drop_write(fh->fh_export->ex_path.mnt);
3059 ++}
3060 ++
3061 + #endif /* LINUX_NFSD_VFS_H */
3062 +diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c
3063 +index 5d18ad1..4f66e00 100644
3064 +--- a/fs/ocfs2/buffer_head_io.c
3065 ++++ b/fs/ocfs2/buffer_head_io.c
3066 +@@ -90,7 +90,6 @@ int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh,
3067 + * information for this bh as it's not marked locally
3068 + * uptodate. */
3069 + ret = -EIO;
3070 +- put_bh(bh);
3071 + mlog_errno(ret);
3072 + }
3073 +
3074 +@@ -420,7 +419,6 @@ int ocfs2_write_super_or_backup(struct ocfs2_super *osb,
3075 +
3076 + if (!buffer_uptodate(bh)) {
3077 + ret = -EIO;
3078 +- put_bh(bh);
3079 + mlog_errno(ret);
3080 + }
3081 +
3082 +diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
3083 +index 01ebfd0..d15b071 100644
3084 +--- a/fs/ocfs2/dlm/dlmrecovery.c
3085 ++++ b/fs/ocfs2/dlm/dlmrecovery.c
3086 +@@ -540,7 +540,10 @@ master_here:
3087 + /* success! see if any other nodes need recovery */
3088 + mlog(0, "DONE mastering recovery of %s:%u here(this=%u)!\n",
3089 + dlm->name, dlm->reco.dead_node, dlm->node_num);
3090 +- dlm_reset_recovery(dlm);
3091 ++ spin_lock(&dlm->spinlock);
3092 ++ __dlm_reset_recovery(dlm);
3093 ++ dlm->reco.state &= ~DLM_RECO_STATE_FINALIZE;
3094 ++ spin_unlock(&dlm->spinlock);
3095 + }
3096 + dlm_end_recovery(dlm);
3097 +
3098 +@@ -698,6 +701,14 @@ static int dlm_remaster_locks(struct dlm_ctxt *dlm, u8 dead_node)
3099 + if (all_nodes_done) {
3100 + int ret;
3101 +
3102 ++ /* Set this flag on recovery master to avoid
3103 ++ * a new recovery for another dead node start
3104 ++ * before the recovery is not done. That may
3105 ++ * cause recovery hung.*/
3106 ++ spin_lock(&dlm->spinlock);
3107 ++ dlm->reco.state |= DLM_RECO_STATE_FINALIZE;
3108 ++ spin_unlock(&dlm->spinlock);
3109 ++
3110 + /* all nodes are now in DLM_RECO_NODE_DATA_DONE state
3111 + * just send a finalize message to everyone and
3112 + * clean up */
3113 +@@ -1752,13 +1763,13 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm,
3114 + struct dlm_migratable_lockres *mres)
3115 + {
3116 + struct dlm_migratable_lock *ml;
3117 +- struct list_head *queue;
3118 ++ struct list_head *queue, *iter;
3119 + struct list_head *tmpq = NULL;
3120 + struct dlm_lock *newlock = NULL;
3121 + struct dlm_lockstatus *lksb = NULL;
3122 + int ret = 0;
3123 + int i, j, bad;
3124 +- struct dlm_lock *lock = NULL;
3125 ++ struct dlm_lock *lock;
3126 + u8 from = O2NM_MAX_NODES;
3127 + unsigned int added = 0;
3128 + __be64 c;
3129 +@@ -1793,14 +1804,16 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm,
3130 + /* MIGRATION ONLY! */
3131 + BUG_ON(!(mres->flags & DLM_MRES_MIGRATION));
3132 +
3133 ++ lock = NULL;
3134 + spin_lock(&res->spinlock);
3135 + for (j = DLM_GRANTED_LIST; j <= DLM_BLOCKED_LIST; j++) {
3136 + tmpq = dlm_list_idx_to_ptr(res, j);
3137 +- list_for_each_entry(lock, tmpq, list) {
3138 +- if (lock->ml.cookie != ml->cookie)
3139 +- lock = NULL;
3140 +- else
3141 ++ list_for_each(iter, tmpq) {
3142 ++ lock = list_entry(iter,
3143 ++ struct dlm_lock, list);
3144 ++ if (lock->ml.cookie == ml->cookie)
3145 + break;
3146 ++ lock = NULL;
3147 + }
3148 + if (lock)
3149 + break;
3150 +@@ -2870,8 +2883,8 @@ int dlm_finalize_reco_handler(struct o2net_msg *msg, u32 len, void *data,
3151 + BUG();
3152 + }
3153 + dlm->reco.state &= ~DLM_RECO_STATE_FINALIZE;
3154 ++ __dlm_reset_recovery(dlm);
3155 + spin_unlock(&dlm->spinlock);
3156 +- dlm_reset_recovery(dlm);
3157 + dlm_kick_recovery_thread(dlm);
3158 + break;
3159 + default:
3160 +diff --git a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c
3161 +index 133e935..8048eea 100644
3162 +--- a/fs/reiserfs/dir.c
3163 ++++ b/fs/reiserfs/dir.c
3164 +@@ -128,6 +128,7 @@ int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
3165 + char *d_name;
3166 + off_t d_off;
3167 + ino_t d_ino;
3168 ++ loff_t cur_pos = deh_offset(deh);
3169 +
3170 + if (!de_visible(deh))
3171 + /* it is hidden entry */
3172 +@@ -200,8 +201,9 @@ int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
3173 + if (local_buf != small_buf) {
3174 + kfree(local_buf);
3175 + }
3176 +- // next entry should be looked for with such offset
3177 +- next_pos = deh_offset(deh) + 1;
3178 ++
3179 ++ /* deh_offset(deh) may be invalid now. */
3180 ++ next_pos = cur_pos + 1;
3181 +
3182 + if (item_moved(&tmp_ih, &path_to_entry)) {
3183 + goto research;
3184 +diff --git a/include/linux/sched.h b/include/linux/sched.h
3185 +index c17fdfb..cb34ff4 100644
3186 +--- a/include/linux/sched.h
3187 ++++ b/include/linux/sched.h
3188 +@@ -1690,6 +1690,24 @@ static inline pid_t task_tgid_vnr(struct task_struct *tsk)
3189 + }
3190 +
3191 +
3192 ++static int pid_alive(const struct task_struct *p);
3193 ++static inline pid_t task_ppid_nr_ns(const struct task_struct *tsk, struct pid_namespace *ns)
3194 ++{
3195 ++ pid_t pid = 0;
3196 ++
3197 ++ rcu_read_lock();
3198 ++ if (pid_alive(tsk))
3199 ++ pid = task_tgid_nr_ns(rcu_dereference(tsk->real_parent), ns);
3200 ++ rcu_read_unlock();
3201 ++
3202 ++ return pid;
3203 ++}
3204 ++
3205 ++static inline pid_t task_ppid_nr(const struct task_struct *tsk)
3206 ++{
3207 ++ return task_ppid_nr_ns(tsk, &init_pid_ns);
3208 ++}
3209 ++
3210 + static inline pid_t task_pgrp_nr_ns(struct task_struct *tsk,
3211 + struct pid_namespace *ns)
3212 + {
3213 +@@ -1727,7 +1745,7 @@ static inline pid_t task_pgrp_nr(struct task_struct *tsk)
3214 + * If pid_alive fails, then pointers within the task structure
3215 + * can be stale and must not be dereferenced.
3216 + */
3217 +-static inline int pid_alive(struct task_struct *p)
3218 ++static inline int pid_alive(const struct task_struct *p)
3219 + {
3220 + return p->pids[PIDTYPE_PID].pid != NULL;
3221 + }
3222 +diff --git a/include/trace/events/block.h b/include/trace/events/block.h
3223 +index 05c5e61..048e265 100644
3224 +--- a/include/trace/events/block.h
3225 ++++ b/include/trace/events/block.h
3226 +@@ -81,6 +81,7 @@ DEFINE_EVENT(block_rq_with_error, block_rq_requeue,
3227 + * block_rq_complete - block IO operation completed by device driver
3228 + * @q: queue containing the block operation request
3229 + * @rq: block operations request
3230 ++ * @nr_bytes: number of completed bytes
3231 + *
3232 + * The block_rq_complete tracepoint event indicates that some portion
3233 + * of operation request has been completed by the device driver. If
3234 +@@ -88,11 +89,37 @@ DEFINE_EVENT(block_rq_with_error, block_rq_requeue,
3235 + * do for the request. If @rq->bio is non-NULL then there is
3236 + * additional work required to complete the request.
3237 + */
3238 +-DEFINE_EVENT(block_rq_with_error, block_rq_complete,
3239 ++TRACE_EVENT(block_rq_complete,
3240 +
3241 +- TP_PROTO(struct request_queue *q, struct request *rq),
3242 ++ TP_PROTO(struct request_queue *q, struct request *rq,
3243 ++ unsigned int nr_bytes),
3244 +
3245 +- TP_ARGS(q, rq)
3246 ++ TP_ARGS(q, rq, nr_bytes),
3247 ++
3248 ++ TP_STRUCT__entry(
3249 ++ __field( dev_t, dev )
3250 ++ __field( sector_t, sector )
3251 ++ __field( unsigned int, nr_sector )
3252 ++ __field( int, errors )
3253 ++ __array( char, rwbs, RWBS_LEN )
3254 ++ __dynamic_array( char, cmd, blk_cmd_buf_len(rq) )
3255 ++ ),
3256 ++
3257 ++ TP_fast_assign(
3258 ++ __entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
3259 ++ __entry->sector = blk_rq_pos(rq);
3260 ++ __entry->nr_sector = nr_bytes >> 9;
3261 ++ __entry->errors = rq->errors;
3262 ++
3263 ++ blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, nr_bytes);
3264 ++ blk_dump_cmd(__get_str(cmd), rq);
3265 ++ ),
3266 ++
3267 ++ TP_printk("%d,%d %s (%s) %llu + %u [%d]",
3268 ++ MAJOR(__entry->dev), MINOR(__entry->dev),
3269 ++ __entry->rwbs, __get_str(cmd),
3270 ++ (unsigned long long)__entry->sector,
3271 ++ __entry->nr_sector, __entry->errors)
3272 + );
3273 +
3274 + DECLARE_EVENT_CLASS(block_rq,
3275 +diff --git a/kernel/auditsc.c b/kernel/auditsc.c
3276 +index 47b7fc1..aeac7cc 100644
3277 +--- a/kernel/auditsc.c
3278 ++++ b/kernel/auditsc.c
3279 +@@ -473,7 +473,7 @@ static int audit_filter_rules(struct task_struct *tsk,
3280 + case AUDIT_PPID:
3281 + if (ctx) {
3282 + if (!ctx->ppid)
3283 +- ctx->ppid = sys_getppid();
3284 ++ ctx->ppid = task_ppid_nr(tsk);
3285 + result = audit_comparator(ctx->ppid, f->op, f->val);
3286 + }
3287 + break;
3288 +@@ -1335,7 +1335,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
3289 + /* tsk == current */
3290 + context->pid = tsk->pid;
3291 + if (!context->ppid)
3292 +- context->ppid = sys_getppid();
3293 ++ context->ppid = task_ppid_nr(tsk);
3294 + cred = current_cred();
3295 + context->uid = cred->uid;
3296 + context->gid = cred->gid;
3297 +diff --git a/kernel/exit.c b/kernel/exit.c
3298 +index 234e152..fde15f9 100644
3299 +--- a/kernel/exit.c
3300 ++++ b/kernel/exit.c
3301 +@@ -734,9 +734,6 @@ static void reparent_leader(struct task_struct *father, struct task_struct *p,
3302 + struct list_head *dead)
3303 + {
3304 + list_move_tail(&p->sibling, &p->real_parent->children);
3305 +-
3306 +- if (p->exit_state == EXIT_DEAD)
3307 +- return;
3308 + /*
3309 + * If this is a threaded reparent there is no need to
3310 + * notify anyone anything has happened.
3311 +@@ -744,9 +741,19 @@ static void reparent_leader(struct task_struct *father, struct task_struct *p,
3312 + if (same_thread_group(p->real_parent, father))
3313 + return;
3314 +
3315 +- /* We don't want people slaying init. */
3316 ++ /*
3317 ++ * We don't want people slaying init.
3318 ++ *
3319 ++ * Note: we do this even if it is EXIT_DEAD, wait_task_zombie()
3320 ++ * can change ->exit_state to EXIT_ZOMBIE. If this is the final
3321 ++ * state, do_notify_parent() was already called and ->exit_signal
3322 ++ * doesn't matter.
3323 ++ */
3324 + p->exit_signal = SIGCHLD;
3325 +
3326 ++ if (p->exit_state == EXIT_DEAD)
3327 ++ return;
3328 ++
3329 + /* If it has exited notify the new parent about this child's death. */
3330 + if (!p->ptrace &&
3331 + p->exit_state == EXIT_ZOMBIE && thread_group_empty(p)) {
3332 +diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
3333 +index 16fc34a..92cac05 100644
3334 +--- a/kernel/trace/blktrace.c
3335 ++++ b/kernel/trace/blktrace.c
3336 +@@ -699,6 +699,7 @@ void blk_trace_shutdown(struct request_queue *q)
3337 + * blk_add_trace_rq - Add a trace for a request oriented action
3338 + * @q: queue the io is for
3339 + * @rq: the source request
3340 ++ * @nr_bytes: number of completed bytes
3341 + * @what: the action
3342 + *
3343 + * Description:
3344 +@@ -706,7 +707,7 @@ void blk_trace_shutdown(struct request_queue *q)
3345 + *
3346 + **/
3347 + static void blk_add_trace_rq(struct request_queue *q, struct request *rq,
3348 +- u32 what)
3349 ++ unsigned int nr_bytes, u32 what)
3350 + {
3351 + struct blk_trace *bt = q->blk_trace;
3352 +
3353 +@@ -715,11 +716,11 @@ static void blk_add_trace_rq(struct request_queue *q, struct request *rq,
3354 +
3355 + if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
3356 + what |= BLK_TC_ACT(BLK_TC_PC);
3357 +- __blk_add_trace(bt, 0, blk_rq_bytes(rq), rq->cmd_flags,
3358 ++ __blk_add_trace(bt, 0, nr_bytes, rq->cmd_flags,
3359 + what, rq->errors, rq->cmd_len, rq->cmd);
3360 + } else {
3361 + what |= BLK_TC_ACT(BLK_TC_FS);
3362 +- __blk_add_trace(bt, blk_rq_pos(rq), blk_rq_bytes(rq),
3363 ++ __blk_add_trace(bt, blk_rq_pos(rq), nr_bytes,
3364 + rq->cmd_flags, what, rq->errors, 0, NULL);
3365 + }
3366 + }
3367 +@@ -727,33 +728,34 @@ static void blk_add_trace_rq(struct request_queue *q, struct request *rq,
3368 + static void blk_add_trace_rq_abort(void *ignore,
3369 + struct request_queue *q, struct request *rq)
3370 + {
3371 +- blk_add_trace_rq(q, rq, BLK_TA_ABORT);
3372 ++ blk_add_trace_rq(q, rq, blk_rq_bytes(rq), BLK_TA_ABORT);
3373 + }
3374 +
3375 + static void blk_add_trace_rq_insert(void *ignore,
3376 + struct request_queue *q, struct request *rq)
3377 + {
3378 +- blk_add_trace_rq(q, rq, BLK_TA_INSERT);
3379 ++ blk_add_trace_rq(q, rq, blk_rq_bytes(rq), BLK_TA_INSERT);
3380 + }
3381 +
3382 + static void blk_add_trace_rq_issue(void *ignore,
3383 + struct request_queue *q, struct request *rq)
3384 + {
3385 +- blk_add_trace_rq(q, rq, BLK_TA_ISSUE);
3386 ++ blk_add_trace_rq(q, rq, blk_rq_bytes(rq), BLK_TA_ISSUE);
3387 + }
3388 +
3389 + static void blk_add_trace_rq_requeue(void *ignore,
3390 + struct request_queue *q,
3391 + struct request *rq)
3392 + {
3393 +- blk_add_trace_rq(q, rq, BLK_TA_REQUEUE);
3394 ++ blk_add_trace_rq(q, rq, blk_rq_bytes(rq), BLK_TA_REQUEUE);
3395 + }
3396 +
3397 + static void blk_add_trace_rq_complete(void *ignore,
3398 + struct request_queue *q,
3399 +- struct request *rq)
3400 ++ struct request *rq,
3401 ++ unsigned int nr_bytes)
3402 + {
3403 +- blk_add_trace_rq(q, rq, BLK_TA_COMPLETE);
3404 ++ blk_add_trace_rq(q, rq, nr_bytes, BLK_TA_COMPLETE);
3405 + }
3406 +
3407 + /**
3408 +diff --git a/lib/nlattr.c b/lib/nlattr.c
3409 +index a8408b6..190ae10 100644
3410 +--- a/lib/nlattr.c
3411 ++++ b/lib/nlattr.c
3412 +@@ -299,9 +299,15 @@ int nla_memcmp(const struct nlattr *nla, const void *data,
3413 + */
3414 + int nla_strcmp(const struct nlattr *nla, const char *str)
3415 + {
3416 +- int len = strlen(str) + 1;
3417 +- int d = nla_len(nla) - len;
3418 ++ int len = strlen(str);
3419 ++ char *buf = nla_data(nla);
3420 ++ int attrlen = nla_len(nla);
3421 ++ int d;
3422 +
3423 ++ if (attrlen > 0 && buf[attrlen - 1] == '\0')
3424 ++ attrlen--;
3425 ++
3426 ++ d = attrlen - len;
3427 + if (d == 0)
3428 + d = memcmp(nla_data(nla), str, len);
3429 +
3430 +diff --git a/lib/percpu_counter.c b/lib/percpu_counter.c
3431 +index f8a3f1a..33459e0 100644
3432 +--- a/lib/percpu_counter.c
3433 ++++ b/lib/percpu_counter.c
3434 +@@ -166,7 +166,7 @@ static int __cpuinit percpu_counter_hotcpu_callback(struct notifier_block *nb,
3435 + struct percpu_counter *fbc;
3436 +
3437 + compute_batch_value();
3438 +- if (action != CPU_DEAD)
3439 ++ if (action != CPU_DEAD && action != CPU_DEAD_FROZEN)
3440 + return NOTIFY_OK;
3441 +
3442 + cpu = (unsigned long)hcpu;
3443 +diff --git a/mm/hugetlb.c b/mm/hugetlb.c
3444 +index 3a5aae2..d399f5f 100644
3445 +--- a/mm/hugetlb.c
3446 ++++ b/mm/hugetlb.c
3447 +@@ -1447,6 +1447,7 @@ static unsigned long set_max_huge_pages(struct hstate *h, unsigned long count,
3448 + while (min_count < persistent_huge_pages(h)) {
3449 + if (!free_pool_huge_page(h, nodes_allowed, 0))
3450 + break;
3451 ++ cond_resched_lock(&hugetlb_lock);
3452 + }
3453 + while (count < persistent_huge_pages(h)) {
3454 + if (!adjust_pool_surplus(h, nodes_allowed, 1))
3455 +diff --git a/mm/mlock.c b/mm/mlock.c
3456 +index 4f4f53b..39b3a7d 100644
3457 +--- a/mm/mlock.c
3458 ++++ b/mm/mlock.c
3459 +@@ -78,6 +78,7 @@ void __clear_page_mlock(struct page *page)
3460 + */
3461 + void mlock_vma_page(struct page *page)
3462 + {
3463 ++ /* Serialize with page migration */
3464 + BUG_ON(!PageLocked(page));
3465 +
3466 + if (!TestSetPageMlocked(page)) {
3467 +@@ -105,6 +106,7 @@ void mlock_vma_page(struct page *page)
3468 + */
3469 + void munlock_vma_page(struct page *page)
3470 + {
3471 ++ /* For try_to_munlock() and to serialize with page migration */
3472 + BUG_ON(!PageLocked(page));
3473 +
3474 + if (TestClearPageMlocked(page)) {
3475 +diff --git a/mm/rmap.c b/mm/rmap.c
3476 +index 52a2f36..9ac405b 100644
3477 +--- a/mm/rmap.c
3478 ++++ b/mm/rmap.c
3479 +@@ -1385,9 +1385,19 @@ static int try_to_unmap_cluster(unsigned long cursor, unsigned int *mapcount,
3480 + BUG_ON(!page || PageAnon(page));
3481 +
3482 + if (locked_vma) {
3483 +- mlock_vma_page(page); /* no-op if already mlocked */
3484 +- if (page == check_page)
3485 ++ if (page == check_page) {
3486 ++ /* we know we have check_page locked */
3487 ++ mlock_vma_page(page);
3488 + ret = SWAP_MLOCK;
3489 ++ } else if (trylock_page(page)) {
3490 ++ /*
3491 ++ * If we can lock the page, perform mlock.
3492 ++ * Otherwise leave the page alone, it will be
3493 ++ * eventually encountered again later.
3494 ++ */
3495 ++ mlock_vma_page(page);
3496 ++ unlock_page(page);
3497 ++ }
3498 + continue; /* don't unmap */
3499 + }
3500 +
3501 +diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
3502 +index 48a62d8..c43a788 100644
3503 +--- a/net/8021q/vlan_dev.c
3504 ++++ b/net/8021q/vlan_dev.c
3505 +@@ -529,6 +529,9 @@ static int vlan_passthru_hard_header(struct sk_buff *skb, struct net_device *dev
3506 + {
3507 + struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
3508 +
3509 ++ if (saddr == NULL)
3510 ++ saddr = dev->dev_addr;
3511 ++
3512 + return dev_hard_header(skb, real_dev, type, daddr, saddr, len);
3513 + }
3514 +
3515 +diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
3516 +index 2157984..398a297 100644
3517 +--- a/net/bridge/br_multicast.c
3518 ++++ b/net/bridge/br_multicast.c
3519 +@@ -1138,6 +1138,12 @@ static int br_ip6_multicast_query(struct net_bridge *br,
3520 +
3521 + br_multicast_query_received(br, port, !ipv6_addr_any(&ip6h->saddr));
3522 +
3523 ++ /* RFC2710+RFC3810 (MLDv1+MLDv2) require link-local source addresses */
3524 ++ if (!(ipv6_addr_type(&ip6h->saddr) & IPV6_ADDR_LINKLOCAL)) {
3525 ++ err = -EINVAL;
3526 ++ goto out;
3527 ++ }
3528 ++
3529 + if (skb->len == sizeof(*mld)) {
3530 + if (!pskb_may_pull(skb, sizeof(*mld))) {
3531 + err = -EINVAL;
3532 +diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
3533 +index 5d41293..b9edff0 100644
3534 +--- a/net/ipv6/addrconf.c
3535 ++++ b/net/ipv6/addrconf.c
3536 +@@ -900,8 +900,11 @@ retry:
3537 + * Lifetime is greater than REGEN_ADVANCE time units. In particular,
3538 + * an implementation must not create a temporary address with a zero
3539 + * Preferred Lifetime.
3540 ++ * Use age calculation as in addrconf_verify to avoid unnecessary
3541 ++ * temporary addresses being generated.
3542 + */
3543 +- if (tmp_prefered_lft <= regen_advance) {
3544 ++ age = (now - tmp_tstamp + ADDRCONF_TIMER_FUZZ_MINUS) / HZ;
3545 ++ if (tmp_prefered_lft <= regen_advance + age) {
3546 + in6_ifa_put(ifp);
3547 + in6_dev_put(idev);
3548 + ret = -1;
3549 +diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
3550 +index d505453..ceced67 100644
3551 +--- a/net/ipv6/icmp.c
3552 ++++ b/net/ipv6/icmp.c
3553 +@@ -499,7 +499,7 @@ void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info)
3554 + np->tclass, NULL, &fl6, (struct rt6_info*)dst,
3555 + MSG_DONTWAIT, np->dontfrag);
3556 + if (err) {
3557 +- ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_OUTERRORS);
3558 ++ ICMP6_INC_STATS(net, idev, ICMP6_MIB_OUTERRORS);
3559 + ip6_flush_pending_frames(sk);
3560 + } else {
3561 + err = icmpv6_push_pending_frames(sk, &fl6, &tmp_hdr,
3562 +diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
3563 +index cd4b529..7871cc6 100644
3564 +--- a/net/ipv6/ip6_output.c
3565 ++++ b/net/ipv6/ip6_output.c
3566 +@@ -1191,21 +1191,19 @@ static void ip6_append_data_mtu(unsigned int *mtu,
3567 + unsigned int fragheaderlen,
3568 + struct sk_buff *skb,
3569 + struct rt6_info *rt,
3570 +- bool pmtuprobe)
3571 ++ unsigned int orig_mtu)
3572 + {
3573 + if (!(rt->dst.flags & DST_XFRM_TUNNEL)) {
3574 + if (skb == NULL) {
3575 + /* first fragment, reserve header_len */
3576 +- *mtu = *mtu - rt->dst.header_len;
3577 ++ *mtu = orig_mtu - rt->dst.header_len;
3578 +
3579 + } else {
3580 + /*
3581 + * this fragment is not first, the headers
3582 + * space is regarded as data space.
3583 + */
3584 +- *mtu = min(*mtu, pmtuprobe ?
3585 +- rt->dst.dev->mtu :
3586 +- dst_mtu(rt->dst.path));
3587 ++ *mtu = orig_mtu;
3588 + }
3589 + *maxfraglen = ((*mtu - fragheaderlen) & ~7)
3590 + + fragheaderlen - sizeof(struct frag_hdr);
3591 +@@ -1222,7 +1220,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
3592 + struct ipv6_pinfo *np = inet6_sk(sk);
3593 + struct inet_cork *cork;
3594 + struct sk_buff *skb, *skb_prev = NULL;
3595 +- unsigned int maxfraglen, fragheaderlen, mtu;
3596 ++ unsigned int maxfraglen, fragheaderlen, mtu, orig_mtu;
3597 + int exthdrlen;
3598 + int dst_exthdrlen;
3599 + int hh_len;
3600 +@@ -1307,6 +1305,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
3601 + dst_exthdrlen = 0;
3602 + mtu = cork->fragsize;
3603 + }
3604 ++ orig_mtu = mtu;
3605 +
3606 + hh_len = LL_RESERVED_SPACE(rt->dst.dev);
3607 +
3608 +@@ -1389,8 +1388,7 @@ alloc_new_skb:
3609 + if (skb == NULL || skb_prev == NULL)
3610 + ip6_append_data_mtu(&mtu, &maxfraglen,
3611 + fragheaderlen, skb, rt,
3612 +- np->pmtudisc ==
3613 +- IPV6_PMTUDISC_PROBE);
3614 ++ orig_mtu);
3615 +
3616 + skb_prev = skb;
3617 +
3618 +@@ -1660,8 +1658,8 @@ int ip6_push_pending_frames(struct sock *sk)
3619 + if (proto == IPPROTO_ICMPV6) {
3620 + struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb));
3621 +
3622 +- ICMP6MSGOUT_INC_STATS_BH(net, idev, icmp6_hdr(skb)->icmp6_type);
3623 +- ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_OUTMSGS);
3624 ++ ICMP6MSGOUT_INC_STATS(net, idev, icmp6_hdr(skb)->icmp6_type);
3625 ++ ICMP6_INC_STATS(net, idev, ICMP6_MIB_OUTMSGS);
3626 + }
3627 +
3628 + err = ip6_local_out(skb);
3629 +diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
3630 +index d20a9be..4f12b66 100644
3631 +--- a/net/ipv6/mcast.c
3632 ++++ b/net/ipv6/mcast.c
3633 +@@ -1435,11 +1435,12 @@ static void mld_sendpack(struct sk_buff *skb)
3634 + dst_output);
3635 + out:
3636 + if (!err) {
3637 +- ICMP6MSGOUT_INC_STATS_BH(net, idev, ICMPV6_MLD2_REPORT);
3638 +- ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_OUTMSGS);
3639 +- IP6_UPD_PO_STATS_BH(net, idev, IPSTATS_MIB_OUTMCAST, payload_len);
3640 +- } else
3641 +- IP6_INC_STATS_BH(net, idev, IPSTATS_MIB_OUTDISCARDS);
3642 ++ ICMP6MSGOUT_INC_STATS(net, idev, ICMPV6_MLD2_REPORT);
3643 ++ ICMP6_INC_STATS(net, idev, ICMP6_MIB_OUTMSGS);
3644 ++ IP6_UPD_PO_STATS(net, idev, IPSTATS_MIB_OUTMCAST, payload_len);
3645 ++ } else {
3646 ++ IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTDISCARDS);
3647 ++ }
3648 +
3649 + rcu_read_unlock();
3650 + return;
3651 +diff --git a/net/ipv6/route.c b/net/ipv6/route.c
3652 +index 9a4f437..39e11f9 100644
3653 +--- a/net/ipv6/route.c
3654 ++++ b/net/ipv6/route.c
3655 +@@ -1250,7 +1250,7 @@ int ip6_route_add(struct fib6_config *cfg)
3656 + goto out;
3657 + }
3658 +
3659 +- rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, NULL, DST_NOCOUNT);
3660 ++ rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, NULL, (cfg->fc_flags & RTF_ADDRCONF) ? 0 : DST_NOCOUNT);
3661 +
3662 + if (rt == NULL) {
3663 + err = -ENOMEM;
3664 +diff --git a/net/rds/iw.c b/net/rds/iw.c
3665 +index 7826d46..5899356 100644
3666 +--- a/net/rds/iw.c
3667 ++++ b/net/rds/iw.c
3668 +@@ -239,7 +239,8 @@ static int rds_iw_laddr_check(__be32 addr)
3669 + ret = rdma_bind_addr(cm_id, (struct sockaddr *)&sin);
3670 + /* due to this, we will claim to support IB devices unless we
3671 + check node_type. */
3672 +- if (ret || cm_id->device->node_type != RDMA_NODE_RNIC)
3673 ++ if (ret || !cm_id->device ||
3674 ++ cm_id->device->node_type != RDMA_NODE_RNIC)
3675 + ret = -EADDRNOTAVAIL;
3676 +
3677 + rdsdebug("addr %pI4 ret %d node type %d\n",
3678 +diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
3679 +index 0121e0a..c95a3f2 100644
3680 +--- a/net/sctp/sm_make_chunk.c
3681 ++++ b/net/sctp/sm_make_chunk.c
3682 +@@ -1366,8 +1366,8 @@ static void sctp_chunk_destroy(struct sctp_chunk *chunk)
3683 + BUG_ON(!list_empty(&chunk->list));
3684 + list_del_init(&chunk->transmitted_list);
3685 +
3686 +- /* Free the chunk skb data and the SCTP_chunk stub itself. */
3687 +- dev_kfree_skb(chunk->skb);
3688 ++ consume_skb(chunk->skb);
3689 ++ consume_skb(chunk->auth_chunk);
3690 +
3691 + SCTP_DBG_OBJCNT_DEC(chunk);
3692 + kmem_cache_free(sctp_chunk_cachep, chunk);
3693 +diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
3694 +index f131caf..5ac33b6 100644
3695 +--- a/net/sctp/sm_statefuns.c
3696 ++++ b/net/sctp/sm_statefuns.c
3697 +@@ -749,7 +749,6 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep,
3698 +
3699 + /* Make sure that we and the peer are AUTH capable */
3700 + if (!sctp_auth_enable || !new_asoc->peer.auth_capable) {
3701 +- kfree_skb(chunk->auth_chunk);
3702 + sctp_association_free(new_asoc);
3703 + return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
3704 + }
3705 +@@ -764,10 +763,6 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep,
3706 + auth.transport = chunk->transport;
3707 +
3708 + ret = sctp_sf_authenticate(ep, new_asoc, type, &auth);
3709 +-
3710 +- /* We can now safely free the auth_chunk clone */
3711 +- kfree_skb(chunk->auth_chunk);
3712 +-
3713 + if (ret != SCTP_IERROR_NO_ERROR) {
3714 + sctp_association_free(new_asoc);
3715 + return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
3716 +diff --git a/net/socket.c b/net/socket.c
3717 +index d4faade..3faa358 100644
3718 +--- a/net/socket.c
3719 ++++ b/net/socket.c
3720 +@@ -1884,6 +1884,10 @@ static int copy_msghdr_from_user(struct msghdr *kmsg,
3721 + {
3722 + if (copy_from_user(kmsg, umsg, sizeof(struct msghdr)))
3723 + return -EFAULT;
3724 ++
3725 ++ if (kmsg->msg_namelen < 0)
3726 ++ return -EINVAL;
3727 ++
3728 + if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
3729 + kmsg->msg_namelen = sizeof(struct sockaddr_storage);
3730 + return 0;
3731 +diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
3732 +index 54fc90b..8705ee3 100644
3733 +--- a/net/unix/af_unix.c
3734 ++++ b/net/unix/af_unix.c
3735 +@@ -1771,8 +1771,11 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
3736 + goto out;
3737 +
3738 + err = mutex_lock_interruptible(&u->readlock);
3739 +- if (err) {
3740 +- err = sock_intr_errno(sock_rcvtimeo(sk, noblock));
3741 ++ if (unlikely(err)) {
3742 ++ /* recvmsg() in non blocking mode is supposed to return -EAGAIN
3743 ++ * sk_rcvtimeo is not honored by mutex_lock_interruptible()
3744 ++ */
3745 ++ err = noblock ? -EAGAIN : -ERESTARTSYS;
3746 + goto out;
3747 + }
3748 +
3749 +@@ -1887,6 +1890,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
3750 + struct unix_sock *u = unix_sk(sk);
3751 + struct sockaddr_un *sunaddr = msg->msg_name;
3752 + int copied = 0;
3753 ++ int noblock = flags & MSG_DONTWAIT;
3754 + int check_creds = 0;
3755 + int target;
3756 + int err = 0;
3757 +@@ -1901,7 +1905,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
3758 + goto out;
3759 +
3760 + target = sock_rcvlowat(sk, flags&MSG_WAITALL, size);
3761 +- timeo = sock_rcvtimeo(sk, flags&MSG_DONTWAIT);
3762 ++ timeo = sock_rcvtimeo(sk, noblock);
3763 +
3764 + /* Lock the socket to prevent queue disordering
3765 + * while sleeps in memcpy_tomsg
3766 +@@ -1913,8 +1917,11 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
3767 + }
3768 +
3769 + err = mutex_lock_interruptible(&u->readlock);
3770 +- if (err) {
3771 +- err = sock_intr_errno(timeo);
3772 ++ if (unlikely(err)) {
3773 ++ /* recvmsg() in non blocking mode is supposed to return -EAGAIN
3774 ++ * sk_rcvtimeo is not honored by mutex_lock_interruptible()
3775 ++ */
3776 ++ err = noblock ? -EAGAIN : -ERESTARTSYS;
3777 + goto out;
3778 + }
3779 +
3780 +diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
3781 +index 4fa7939..69477ff 100644
3782 +--- a/security/selinux/hooks.c
3783 ++++ b/security/selinux/hooks.c
3784 +@@ -1328,15 +1328,33 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
3785 + isec->sid = sbsec->sid;
3786 +
3787 + if ((sbsec->flags & SE_SBPROC) && !S_ISLNK(inode->i_mode)) {
3788 +- if (opt_dentry) {
3789 +- isec->sclass = inode_mode_to_security_class(inode->i_mode);
3790 +- rc = selinux_proc_get_sid(opt_dentry,
3791 +- isec->sclass,
3792 +- &sid);
3793 +- if (rc)
3794 +- goto out_unlock;
3795 +- isec->sid = sid;
3796 +- }
3797 ++ /* We must have a dentry to determine the label on
3798 ++ * procfs inodes */
3799 ++ if (opt_dentry)
3800 ++ /* Called from d_instantiate or
3801 ++ * d_splice_alias. */
3802 ++ dentry = dget(opt_dentry);
3803 ++ else
3804 ++ /* Called from selinux_complete_init, try to
3805 ++ * find a dentry. */
3806 ++ dentry = d_find_alias(inode);
3807 ++ /*
3808 ++ * This can be hit on boot when a file is accessed
3809 ++ * before the policy is loaded. When we load policy we
3810 ++ * may find inodes that have no dentry on the
3811 ++ * sbsec->isec_head list. No reason to complain as
3812 ++ * these will get fixed up the next time we go through
3813 ++ * inode_doinit() with a dentry, before these inodes
3814 ++ * could be used again by userspace.
3815 ++ */
3816 ++ if (!dentry)
3817 ++ goto out_unlock;
3818 ++ isec->sclass = inode_mode_to_security_class(inode->i_mode);
3819 ++ rc = selinux_proc_get_sid(dentry, isec->sclass, &sid);
3820 ++ dput(dentry);
3821 ++ if (rc)
3822 ++ goto out_unlock;
3823 ++ isec->sid = sid;
3824 + }
3825 + break;
3826 + }
3827 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
3828 +index 36bce68..d307adb 100644
3829 +--- a/sound/pci/hda/patch_realtek.c
3830 ++++ b/sound/pci/hda/patch_realtek.c
3831 +@@ -3855,6 +3855,7 @@ static void alc_auto_init_std(struct hda_codec *codec)
3832 +
3833 + static const struct snd_pci_quirk beep_white_list[] = {
3834 + SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
3835 ++ SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1),
3836 + SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
3837 + SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
3838 + SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
3839 +diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
3840 +index 44446f2..7a4a196 100644
3841 +--- a/sound/pci/ice1712/ice1712.c
3842 ++++ b/sound/pci/ice1712/ice1712.c
3843 +@@ -686,9 +686,10 @@ static snd_pcm_uframes_t snd_ice1712_playback_pointer(struct snd_pcm_substream *
3844 + if (!(snd_ice1712_read(ice, ICE1712_IREG_PBK_CTRL) & 1))
3845 + return 0;
3846 + ptr = runtime->buffer_size - inw(ice->ddma_port + 4);
3847 ++ ptr = bytes_to_frames(substream->runtime, ptr);
3848 + if (ptr == runtime->buffer_size)
3849 + ptr = 0;
3850 +- return bytes_to_frames(substream->runtime, ptr);
3851 ++ return ptr;
3852 + }
3853 +
3854 + static snd_pcm_uframes_t snd_ice1712_playback_ds_pointer(struct snd_pcm_substream *substream)
3855 +@@ -705,9 +706,10 @@ static snd_pcm_uframes_t snd_ice1712_playback_ds_pointer(struct snd_pcm_substrea
3856 + addr = ICE1712_DSC_ADDR0;
3857 + ptr = snd_ice1712_ds_read(ice, substream->number * 2, addr) -
3858 + ice->playback_con_virt_addr[substream->number];
3859 ++ ptr = bytes_to_frames(substream->runtime, ptr);
3860 + if (ptr == substream->runtime->buffer_size)
3861 + ptr = 0;
3862 +- return bytes_to_frames(substream->runtime, ptr);
3863 ++ return ptr;
3864 + }
3865 +
3866 + static snd_pcm_uframes_t snd_ice1712_capture_pointer(struct snd_pcm_substream *substream)
3867 +@@ -718,9 +720,10 @@ static snd_pcm_uframes_t snd_ice1712_capture_pointer(struct snd_pcm_substream *s
3868 + if (!(snd_ice1712_read(ice, ICE1712_IREG_CAP_CTRL) & 1))
3869 + return 0;
3870 + ptr = inl(ICEREG(ice, CONCAP_ADDR)) - ice->capture_con_virt_addr;
3871 ++ ptr = bytes_to_frames(substream->runtime, ptr);
3872 + if (ptr == substream->runtime->buffer_size)
3873 + ptr = 0;
3874 +- return bytes_to_frames(substream->runtime, ptr);
3875 ++ return ptr;
3876 + }
3877 +
3878 + static const struct snd_pcm_hardware snd_ice1712_playback = {
3879 +@@ -1114,9 +1117,10 @@ static snd_pcm_uframes_t snd_ice1712_playback_pro_pointer(struct snd_pcm_substre
3880 + if (!(inl(ICEMT(ice, PLAYBACK_CONTROL)) & ICE1712_PLAYBACK_START))
3881 + return 0;
3882 + ptr = ice->playback_pro_size - (inw(ICEMT(ice, PLAYBACK_SIZE)) << 2);
3883 ++ ptr = bytes_to_frames(substream->runtime, ptr);
3884 + if (ptr == substream->runtime->buffer_size)
3885 + ptr = 0;
3886 +- return bytes_to_frames(substream->runtime, ptr);
3887 ++ return ptr;
3888 + }
3889 +
3890 + static snd_pcm_uframes_t snd_ice1712_capture_pro_pointer(struct snd_pcm_substream *substream)
3891 +@@ -1127,9 +1131,10 @@ static snd_pcm_uframes_t snd_ice1712_capture_pro_pointer(struct snd_pcm_substrea
3892 + if (!(inl(ICEMT(ice, PLAYBACK_CONTROL)) & ICE1712_CAPTURE_START_SHADOW))
3893 + return 0;
3894 + ptr = ice->capture_pro_size - (inw(ICEMT(ice, CAPTURE_SIZE)) << 2);
3895 ++ ptr = bytes_to_frames(substream->runtime, ptr);
3896 + if (ptr == substream->runtime->buffer_size)
3897 + ptr = 0;
3898 +- return bytes_to_frames(substream->runtime, ptr);
3899 ++ return ptr;
3900 + }
3901 +
3902 + static const struct snd_pcm_hardware snd_ice1712_playback_pro = {
3903
3904 diff --git a/3.2.57/4420_grsecurity-3.0-3.2.57-201404241714.patch b/3.2.58/4420_grsecurity-3.0-3.2.58-201405011748.patch
3905 similarity index 99%
3906 rename from 3.2.57/4420_grsecurity-3.0-3.2.57-201404241714.patch
3907 rename to 3.2.58/4420_grsecurity-3.0-3.2.58-201405011748.patch
3908 index 3eb8a57..40e61fe 100644
3909 --- a/3.2.57/4420_grsecurity-3.0-3.2.57-201404241714.patch
3910 +++ b/3.2.58/4420_grsecurity-3.0-3.2.58-201405011748.patch
3911 @@ -273,7 +273,7 @@ index 88fd7f5..b318a78 100644
3912 ==============================================================
3913
3914 diff --git a/Makefile b/Makefile
3915 -index c92db9b..1923e89 100644
3916 +index d59b394..cbbdc10 100644
3917 --- a/Makefile
3918 +++ b/Makefile
3919 @@ -245,8 +245,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
3920 @@ -1635,10 +1635,10 @@ index 0e9ce8d..6ef1e03 100644
3921 #define arch_setup_additional_pages(bprm, uses_interp) vectors_user_mapping()
3922 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES
3923 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
3924 -index 253cc86..7be5469 100644
3925 +index aefd459..e37af12 100644
3926 --- a/arch/arm/include/asm/futex.h
3927 +++ b/arch/arm/include/asm/futex.h
3928 -@@ -75,9 +75,9 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
3929 +@@ -70,9 +70,9 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
3930
3931 #define __futex_atomic_op(insn, ret, oldval, tmp, uaddr, oparg) \
3932 __asm__ __volatile__( \
3933 @@ -1650,7 +1650,7 @@ index 253cc86..7be5469 100644
3934 " mov %0, #0\n" \
3935 __futex_atomic_ex_table("%5") \
3936 : "=&r" (ret), "=&r" (oldval), "=&r" (tmp) \
3937 -@@ -95,10 +95,10 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
3938 +@@ -90,10 +90,10 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
3939 return -EFAULT;
3940
3941 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
3942 @@ -1722,7 +1722,7 @@ index 3e08fd3..3f14f89 100644
3943 extern pgd_t *pgd_alloc(struct mm_struct *mm);
3944 extern void pgd_free(struct mm_struct *mm, pgd_t *pgd);
3945 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
3946 -index 9b419ab..0a91b08 100644
3947 +index fcbac3c..6e9b464 100644
3948 --- a/arch/arm/include/asm/pgtable.h
3949 +++ b/arch/arm/include/asm/pgtable.h
3950 @@ -26,6 +26,9 @@
3951 @@ -7529,7 +7529,7 @@ index 8303ac4..07f333d 100644
3952 }
3953
3954 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
3955 -index 3e1449f..5293a0e 100644
3956 +index 6d6c731..2f65aba 100644
3957 --- a/arch/sparc/include/asm/uaccess_64.h
3958 +++ b/arch/sparc/include/asm/uaccess_64.h
3959 @@ -10,6 +10,7 @@
3960 @@ -8035,7 +8035,7 @@ index 5e4252b..379f84f 100644
3961 mm->unmap_area = arch_unmap_area_topdown;
3962 }
3963 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
3964 -index 817187d..2cc50b0 100644
3965 +index 557212c..2cc50b0 100644
3966 --- a/arch/sparc/kernel/syscalls.S
3967 +++ b/arch/sparc/kernel/syscalls.S
3968 @@ -62,7 +62,7 @@ sys32_rt_sigreturn:
3969 @@ -8047,7 +8047,7 @@ index 817187d..2cc50b0 100644
3970 be,pt %icc, rtrap
3971 nop
3972 call syscall_trace_leave
3973 -@@ -179,12 +179,13 @@ linux_sparc_syscall32:
3974 +@@ -179,7 +179,7 @@ linux_sparc_syscall32:
3975
3976 srl %i3, 0, %o3 ! IEU0
3977 srl %i2, 0, %o2 ! IEU0 Group
3978 @@ -8056,14 +8056,7 @@ index 817187d..2cc50b0 100644
3979 bne,pn %icc, linux_syscall_trace32 ! CTI
3980 mov %i0, %l5 ! IEU1
3981 5: call %l7 ! CTI Group brk forced
3982 - srl %i5, 0, %o5 ! IEU1
3983 -- ba,a,pt %xcc, 3f
3984 -+ ba,pt %xcc, 3f
3985 -+ sra %o0, 0, %o0
3986 -
3987 - /* Linux native system calls enter here... */
3988 - .align 32
3989 -@@ -202,7 +203,7 @@ linux_sparc_syscall:
3990 +@@ -203,7 +203,7 @@ linux_sparc_syscall:
3991
3992 mov %i3, %o3 ! IEU1
3993 mov %i4, %o4 ! IEU0 Group
3994 @@ -8072,13 +8065,7 @@ index 817187d..2cc50b0 100644
3995 bne,pn %icc, linux_syscall_trace ! CTI Group
3996 mov %i0, %l5 ! IEU0
3997 2: call %l7 ! CTI Group brk forced
3998 -@@ -212,13 +213,12 @@ linux_sparc_syscall:
3999 - 3: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
4000 - ret_sys_call:
4001 - ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
4002 -- sra %o0, 0, %o0
4003 - mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
4004 - sllx %g2, 32, %g2
4005 +@@ -218,7 +218,7 @@ ret_sys_call:
4006
4007 cmp %o0, -ERESTART_RESTARTBLOCK
4008 bgeu,pn %xcc, 1f
4009 @@ -21638,7 +21625,7 @@ index a9c2116..94c1e1a 100644
4010 };
4011 #endif
4012 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
4013 -index ea69726..2476f99 100644
4014 +index 4ac4531..2476f99 100644
4015 --- a/arch/x86/kernel/ldt.c
4016 +++ b/arch/x86/kernel/ldt.c
4017 @@ -67,13 +67,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
4018 @@ -21691,7 +21678,7 @@ index ea69726..2476f99 100644
4019 return retval;
4020 }
4021
4022 -@@ -230,6 +248,24 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
4023 +@@ -230,6 +248,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
4024 }
4025 }
4026
4027 @@ -21702,20 +21689,9 @@ index ea69726..2476f99 100644
4028 + }
4029 +#endif
4030 +
4031 -+ /*
4032 -+ * On x86-64 we do not support 16-bit segments due to
4033 -+ * IRET leaking the high bits of the kernel stack address.
4034 -+ */
4035 -+#ifdef CONFIG_X86_64
4036 -+ if (!ldt_info.seg_32bit) {
4037 -+ error = -EINVAL;
4038 -+ goto out_unlock;
4039 -+ }
4040 -+#endif
4041 -+
4042 - fill_ldt(&ldt, &ldt_info);
4043 - if (oldmode)
4044 - ldt.avl = 0;
4045 + /*
4046 + * On x86-64 we do not support 16-bit segments due to
4047 + * IRET leaking the high bits of the kernel stack address.
4048 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
4049 index a3fa43b..8966f4c 100644
4050 --- a/arch/x86/kernel/machine_kexec_32.c
4051 @@ -37729,7 +37705,7 @@ index 93e74fb..4a1182d 100644
4052 INIT_WORK(&dev_priv->hotplug_work, i915_hotplug_work_func);
4053 INIT_WORK(&dev_priv->error_work, i915_error_work_func);
4054 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
4055 -index 2ea8a96..65e685e 100644
4056 +index 27999d9..28d110e 100644
4057 --- a/drivers/gpu/drm/i915/intel_display.c
4058 +++ b/drivers/gpu/drm/i915/intel_display.c
4059 @@ -2215,7 +2215,7 @@ intel_finish_fb(struct drm_framebuffer *old_fb)
4060 @@ -40256,10 +40232,10 @@ index ed9a989..6aa5dc2 100644
4061 int list_len, u64 iova, u64 total_size,
4062 u32 access, struct mthca_mr *mr)
4063 diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
4064 -index 5b71d43..35a9e14 100644
4065 +index 42dde06..1257310 100644
4066 --- a/drivers/infiniband/hw/mthca/mthca_provider.c
4067 +++ b/drivers/infiniband/hw/mthca/mthca_provider.c
4068 -@@ -763,7 +763,7 @@ unlock:
4069 +@@ -764,7 +764,7 @@ unlock:
4070 return 0;
4071 }
4072
4073 @@ -40673,7 +40649,7 @@ index c00d2f3..8834298 100644
4074
4075 /**
4076 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
4077 -index b0471b4..9ba4e9f 100644
4078 +index 330eb6e..a4bc52b 100644
4079 --- a/drivers/infiniband/hw/nes/nes_verbs.c
4080 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
4081 @@ -46,9 +46,9 @@
4082 @@ -41318,76 +41294,6 @@ index 1f355bb..43f1fea 100644
4083 return -EFAULT;
4084 } else
4085 memcpy(msg, buf, count);
4086 -diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
4087 -index 4df80fb..75ca5d2 100644
4088 ---- a/drivers/isdn/isdnloop/isdnloop.c
4089 -+++ b/drivers/isdn/isdnloop/isdnloop.c
4090 -@@ -518,9 +518,9 @@ static isdnloop_stat isdnloop_cmd_table[] =
4091 - static void
4092 - isdnloop_fake_err(isdnloop_card * card)
4093 - {
4094 -- char buf[60];
4095 -+ char buf[64];
4096 -
4097 -- sprintf(buf, "E%s", card->omsg);
4098 -+ snprintf(buf, sizeof(buf), "E%s", card->omsg);
4099 - isdnloop_fake(card, buf, -1);
4100 - isdnloop_fake(card, "NAK", -1);
4101 - }
4102 -@@ -903,6 +903,8 @@ isdnloop_parse_cmd(isdnloop_card * card)
4103 - case 7:
4104 - /* 0x;EAZ */
4105 - p += 3;
4106 -+ if (strlen(p) >= sizeof(card->eazlist[0]))
4107 -+ break;
4108 - strcpy(card->eazlist[ch - 1], p);
4109 - break;
4110 - case 8:
4111 -@@ -1070,6 +1072,12 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
4112 - return -EBUSY;
4113 - if (copy_from_user((char *) &sdef, (char *) sdefp, sizeof(sdef)))
4114 - return -EFAULT;
4115 -+
4116 -+ for (i = 0; i < 3; i++) {
4117 -+ if (!memchr(sdef.num[i], 0, sizeof(sdef.num[i])))
4118 -+ return -EINVAL;
4119 -+ }
4120 -+
4121 - spin_lock_irqsave(&card->isdnloop_lock, flags);
4122 - switch (sdef.ptype) {
4123 - case ISDN_PTYPE_EURO:
4124 -@@ -1127,7 +1135,7 @@ isdnloop_command(isdn_ctrl * c, isdnloop_card * card)
4125 - {
4126 - ulong a;
4127 - int i;
4128 -- char cbuf[60];
4129 -+ char cbuf[80];
4130 - isdn_ctrl cmd;
4131 - isdnloop_cdef cdef;
4132 -
4133 -@@ -1192,7 +1200,6 @@ isdnloop_command(isdn_ctrl * c, isdnloop_card * card)
4134 - break;
4135 - if ((c->arg & 255) < ISDNLOOP_BCH) {
4136 - char *p;
4137 -- char dial[50];
4138 - char dcode[4];
4139 -
4140 - a = c->arg;
4141 -@@ -1204,10 +1211,10 @@ isdnloop_command(isdn_ctrl * c, isdnloop_card * card)
4142 - } else
4143 - /* Normal Dial */
4144 - strcpy(dcode, "CAL");
4145 -- strcpy(dial, p);
4146 -- sprintf(cbuf, "%02d;D%s_R%s,%02d,%02d,%s\n", (int) (a + 1),
4147 -- dcode, dial, c->parm.setup.si1,
4148 -- c->parm.setup.si2, c->parm.setup.eazmsn);
4149 -+ snprintf(cbuf, sizeof(cbuf),
4150 -+ "%02d;D%s_R%s,%02d,%02d,%s\n", (int) (a + 1),
4151 -+ dcode, p, c->parm.setup.si1,
4152 -+ c->parm.setup.si2, c->parm.setup.eazmsn);
4153 - i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card);
4154 - }
4155 - break;
4156 diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
4157 index 4d395de..c504763 100644
4158 --- a/drivers/isdn/mISDN/dsp_cmx.c
4159 @@ -42235,6 +42141,18 @@ index 0564192..75b16f5 100644
4160 NGENE_ID(0x18c3, 0xabc3, ngene_info_cineS2),
4161 NGENE_ID(0x18c3, 0xabc4, ngene_info_cineS2),
4162 NGENE_ID(0x18c3, 0xdb01, ngene_info_satixS2),
4163 +diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
4164 +index 6edc9ba..298703f 100644
4165 +--- a/drivers/media/media-device.c
4166 ++++ b/drivers/media/media-device.c
4167 +@@ -90,6 +90,7 @@ static long media_device_enum_entities(struct media_device *mdev,
4168 + struct media_entity *ent;
4169 + struct media_entity_desc u_ent;
4170 +
4171 ++ memset(&u_ent, 0, sizeof(u_ent));
4172 + if (copy_from_user(&u_ent.id, &uent->id, sizeof(u_ent.id)))
4173 + return -EFAULT;
4174 +
4175 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
4176 index 16a089f..1661b11 100644
4177 --- a/drivers/media/radio/radio-cadet.c
4178 @@ -42860,7 +42778,7 @@ index 5c2a06a..8fa077c 100644
4179 #include <linux/pci.h>
4180 #include <linux/interrupt.h>
4181 diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
4182 -index 0219115..0743393 100644
4183 +index 90b450c..7a52413 100644
4184 --- a/drivers/mfd/max8925-i2c.c
4185 +++ b/drivers/mfd/max8925-i2c.c
4186 @@ -139,7 +139,7 @@ static int __devinit max8925_probe(struct i2c_client *client,
4187 @@ -46312,6 +46230,37 @@ index 2836538..30edf9d 100644
4188
4189 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
4190 if (ret) {
4191 +diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
4192 +index 06ea3bc..3d9501f 100644
4193 +--- a/drivers/scsi/Kconfig
4194 ++++ b/drivers/scsi/Kconfig
4195 +@@ -1902,6 +1902,14 @@ config SCSI_BFA_FC
4196 + To compile this driver as a module, choose M here. The module will
4197 + be called bfa.
4198 +
4199 ++config SCSI_VIRTIO
4200 ++ tristate "virtio-scsi support (EXPERIMENTAL)"
4201 ++ depends on EXPERIMENTAL && VIRTIO
4202 ++ help
4203 ++ This is the virtual HBA driver for virtio. If the kernel will
4204 ++ be used in a virtual machine, say Y or M.
4205 ++
4206 ++
4207 + endif # SCSI_LOWLEVEL
4208 +
4209 + source "drivers/scsi/pcmcia/Kconfig"
4210 +diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
4211 +index 2b88749..351b28b 100644
4212 +--- a/drivers/scsi/Makefile
4213 ++++ b/drivers/scsi/Makefile
4214 +@@ -141,6 +141,7 @@ obj-$(CONFIG_SCSI_CXGB4_ISCSI) += libiscsi.o libiscsi_tcp.o cxgbi/
4215 + obj-$(CONFIG_SCSI_BNX2_ISCSI) += libiscsi.o bnx2i/
4216 + obj-$(CONFIG_BE2ISCSI) += libiscsi.o be2iscsi/
4217 + obj-$(CONFIG_SCSI_PMCRAID) += pmcraid.o
4218 ++obj-$(CONFIG_SCSI_VIRTIO) += virtio_scsi.o
4219 + obj-$(CONFIG_VMWARE_PVSCSI) += vmw_pvscsi.o
4220 +
4221 + obj-$(CONFIG_ARM) += arm/
4222 diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
4223 index 2e658d2..46f4afb 100644
4224 --- a/drivers/scsi/aacraid/linit.c
4225 @@ -47490,6 +47439,850 @@ index 441a1c5..07cece7 100644
4226
4227 sg_proc_sgp = proc_mkdir(sg_proc_sg_dirname, NULL);
4228 if (!sg_proc_sgp)
4229 +diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
4230 +new file mode 100644
4231 +index 0000000..06c9d30
4232 +--- /dev/null
4233 ++++ b/drivers/scsi/virtio_scsi.c
4234 +@@ -0,0 +1,838 @@
4235 ++/*
4236 ++ * Virtio SCSI HBA driver
4237 ++ *
4238 ++ * Copyright IBM Corp. 2010
4239 ++ * Copyright Red Hat, Inc. 2011
4240 ++ *
4241 ++ * Authors:
4242 ++ * Stefan Hajnoczi <stefanha@××××××××××××××.com>
4243 ++ * Paolo Bonzini <pbonzini@××××××.com>
4244 ++ *
4245 ++ * This work is licensed under the terms of the GNU GPL, version 2 or later.
4246 ++ * See the COPYING file in the top-level directory.
4247 ++ *
4248 ++ */
4249 ++
4250 ++#include <linux/module.h>
4251 ++#include <linux/slab.h>
4252 ++#include <linux/mempool.h>
4253 ++#include <linux/virtio.h>
4254 ++#include <linux/virtio_ids.h>
4255 ++#include <linux/virtio_config.h>
4256 ++#include <linux/virtio_scsi.h>
4257 ++#include <scsi/scsi_host.h>
4258 ++#include <scsi/scsi_device.h>
4259 ++#include <scsi/scsi_cmnd.h>
4260 ++
4261 ++#define VIRTIO_SCSI_MEMPOOL_SZ 64
4262 ++#define VIRTIO_SCSI_EVENT_LEN 8
4263 ++
4264 ++/* Command queue element */
4265 ++struct virtio_scsi_cmd {
4266 ++ struct scsi_cmnd *sc;
4267 ++ struct completion *comp;
4268 ++ union {
4269 ++ struct virtio_scsi_cmd_req cmd;
4270 ++ struct virtio_scsi_ctrl_tmf_req tmf;
4271 ++ struct virtio_scsi_ctrl_an_req an;
4272 ++ } req;
4273 ++ union {
4274 ++ struct virtio_scsi_cmd_resp cmd;
4275 ++ struct virtio_scsi_ctrl_tmf_resp tmf;
4276 ++ struct virtio_scsi_ctrl_an_resp an;
4277 ++ struct virtio_scsi_event evt;
4278 ++ } resp;
4279 ++} ____cacheline_aligned_in_smp;
4280 ++
4281 ++struct virtio_scsi_event_node {
4282 ++ struct virtio_scsi *vscsi;
4283 ++ struct virtio_scsi_event event;
4284 ++ struct work_struct work;
4285 ++};
4286 ++
4287 ++struct virtio_scsi_vq {
4288 ++ /* Protects vq */
4289 ++ spinlock_t vq_lock;
4290 ++
4291 ++ struct virtqueue *vq;
4292 ++};
4293 ++
4294 ++/* Per-target queue state */
4295 ++struct virtio_scsi_target_state {
4296 ++ /* Protects sg. Lock hierarchy is tgt_lock -> vq_lock. */
4297 ++ spinlock_t tgt_lock;
4298 ++
4299 ++ /* For sglist construction when adding commands to the virtqueue. */
4300 ++ struct scatterlist sg[];
4301 ++};
4302 ++
4303 ++/* Driver instance state */
4304 ++struct virtio_scsi {
4305 ++ struct virtio_device *vdev;
4306 ++
4307 ++ struct virtio_scsi_vq ctrl_vq;
4308 ++ struct virtio_scsi_vq event_vq;
4309 ++ struct virtio_scsi_vq req_vq;
4310 ++
4311 ++ /* Get some buffers ready for event vq */
4312 ++ struct virtio_scsi_event_node event_list[VIRTIO_SCSI_EVENT_LEN];
4313 ++
4314 ++ struct virtio_scsi_target_state *tgt[];
4315 ++};
4316 ++
4317 ++static struct kmem_cache *virtscsi_cmd_cache;
4318 ++static mempool_t *virtscsi_cmd_pool;
4319 ++
4320 ++static inline struct Scsi_Host *virtio_scsi_host(struct virtio_device *vdev)
4321 ++{
4322 ++ return vdev->priv;
4323 ++}
4324 ++
4325 ++static void virtscsi_compute_resid(struct scsi_cmnd *sc, u32 resid)
4326 ++{
4327 ++ if (!resid)
4328 ++ return;
4329 ++
4330 ++ if (!scsi_bidi_cmnd(sc)) {
4331 ++ scsi_set_resid(sc, resid);
4332 ++ return;
4333 ++ }
4334 ++
4335 ++ scsi_in(sc)->resid = min(resid, scsi_in(sc)->length);
4336 ++ scsi_out(sc)->resid = resid - scsi_in(sc)->resid;
4337 ++}
4338 ++
4339 ++/**
4340 ++ * virtscsi_complete_cmd - finish a scsi_cmd and invoke scsi_done
4341 ++ *
4342 ++ * Called with vq_lock held.
4343 ++ */
4344 ++static void virtscsi_complete_cmd(void *buf)
4345 ++{
4346 ++ struct virtio_scsi_cmd *cmd = buf;
4347 ++ struct scsi_cmnd *sc = cmd->sc;
4348 ++ struct virtio_scsi_cmd_resp *resp = &cmd->resp.cmd;
4349 ++
4350 ++ dev_dbg(&sc->device->sdev_gendev,
4351 ++ "cmd %p response %u status %#02x sense_len %u\n",
4352 ++ sc, resp->response, resp->status, resp->sense_len);
4353 ++
4354 ++ sc->result = resp->status;
4355 ++ virtscsi_compute_resid(sc, resp->resid);
4356 ++ switch (resp->response) {
4357 ++ case VIRTIO_SCSI_S_OK:
4358 ++ set_host_byte(sc, DID_OK);
4359 ++ break;
4360 ++ case VIRTIO_SCSI_S_OVERRUN:
4361 ++ set_host_byte(sc, DID_ERROR);
4362 ++ break;
4363 ++ case VIRTIO_SCSI_S_ABORTED:
4364 ++ set_host_byte(sc, DID_ABORT);
4365 ++ break;
4366 ++ case VIRTIO_SCSI_S_BAD_TARGET:
4367 ++ set_host_byte(sc, DID_BAD_TARGET);
4368 ++ break;
4369 ++ case VIRTIO_SCSI_S_RESET:
4370 ++ set_host_byte(sc, DID_RESET);
4371 ++ break;
4372 ++ case VIRTIO_SCSI_S_BUSY:
4373 ++ set_host_byte(sc, DID_BUS_BUSY);
4374 ++ break;
4375 ++ case VIRTIO_SCSI_S_TRANSPORT_FAILURE:
4376 ++ set_host_byte(sc, DID_TRANSPORT_DISRUPTED);
4377 ++ break;
4378 ++ case VIRTIO_SCSI_S_TARGET_FAILURE:
4379 ++ set_host_byte(sc, DID_TARGET_FAILURE);
4380 ++ break;
4381 ++ case VIRTIO_SCSI_S_NEXUS_FAILURE:
4382 ++ set_host_byte(sc, DID_NEXUS_FAILURE);
4383 ++ break;
4384 ++ default:
4385 ++ scmd_printk(KERN_WARNING, sc, "Unknown response %d",
4386 ++ resp->response);
4387 ++ /* fall through */
4388 ++ case VIRTIO_SCSI_S_FAILURE:
4389 ++ set_host_byte(sc, DID_ERROR);
4390 ++ break;
4391 ++ }
4392 ++
4393 ++ WARN_ON(resp->sense_len > VIRTIO_SCSI_SENSE_SIZE);
4394 ++ if (sc->sense_buffer) {
4395 ++ memcpy(sc->sense_buffer, resp->sense,
4396 ++ min_t(u32, resp->sense_len, VIRTIO_SCSI_SENSE_SIZE));
4397 ++ if (resp->sense_len)
4398 ++ set_driver_byte(sc, DRIVER_SENSE);
4399 ++ }
4400 ++
4401 ++ mempool_free(cmd, virtscsi_cmd_pool);
4402 ++ sc->scsi_done(sc);
4403 ++}
4404 ++
4405 ++static void virtscsi_vq_done(struct virtqueue *vq, void (*fn)(void *buf))
4406 ++{
4407 ++ void *buf;
4408 ++ unsigned int len;
4409 ++
4410 ++ do {
4411 ++ virtqueue_disable_cb(vq);
4412 ++ while ((buf = virtqueue_get_buf(vq, &len)) != NULL)
4413 ++ fn(buf);
4414 ++ } while (!virtqueue_enable_cb(vq));
4415 ++}
4416 ++
4417 ++static void virtscsi_req_done(struct virtqueue *vq)
4418 ++{
4419 ++ struct Scsi_Host *sh = virtio_scsi_host(vq->vdev);
4420 ++ struct virtio_scsi *vscsi = shost_priv(sh);
4421 ++ unsigned long flags;
4422 ++
4423 ++ spin_lock_irqsave(&vscsi->req_vq.vq_lock, flags);
4424 ++ virtscsi_vq_done(vq, virtscsi_complete_cmd);
4425 ++ spin_unlock_irqrestore(&vscsi->req_vq.vq_lock, flags);
4426 ++};
4427 ++
4428 ++static void virtscsi_complete_free(void *buf)
4429 ++{
4430 ++ struct virtio_scsi_cmd *cmd = buf;
4431 ++
4432 ++ if (cmd->comp)
4433 ++ complete_all(cmd->comp);
4434 ++ else
4435 ++ mempool_free(cmd, virtscsi_cmd_pool);
4436 ++}
4437 ++
4438 ++static void virtscsi_ctrl_done(struct virtqueue *vq)
4439 ++{
4440 ++ struct Scsi_Host *sh = virtio_scsi_host(vq->vdev);
4441 ++ struct virtio_scsi *vscsi = shost_priv(sh);
4442 ++ unsigned long flags;
4443 ++
4444 ++ spin_lock_irqsave(&vscsi->ctrl_vq.vq_lock, flags);
4445 ++ virtscsi_vq_done(vq, virtscsi_complete_free);
4446 ++ spin_unlock_irqrestore(&vscsi->ctrl_vq.vq_lock, flags);
4447 ++};
4448 ++
4449 ++static int virtscsi_kick_event(struct virtio_scsi *vscsi,
4450 ++ struct virtio_scsi_event_node *event_node)
4451 ++{
4452 ++ int ret;
4453 ++ struct scatterlist sg;
4454 ++ unsigned long flags;
4455 ++
4456 ++ sg_init_one(&sg, &event_node->event, sizeof(struct virtio_scsi_event));
4457 ++
4458 ++ spin_lock_irqsave(&vscsi->event_vq.vq_lock, flags);
4459 ++
4460 ++ ret = virtqueue_add_buf_gfp(vscsi->event_vq.vq, &sg, 0, 1, event_node, GFP_ATOMIC);
4461 ++ if (ret >= 0)
4462 ++ virtqueue_kick(vscsi->event_vq.vq);
4463 ++
4464 ++ spin_unlock_irqrestore(&vscsi->event_vq.vq_lock, flags);
4465 ++
4466 ++ return ret;
4467 ++}
4468 ++
4469 ++static int virtscsi_kick_event_all(struct virtio_scsi *vscsi)
4470 ++{
4471 ++ int i;
4472 ++
4473 ++ for (i = 0; i < VIRTIO_SCSI_EVENT_LEN; i++) {
4474 ++ vscsi->event_list[i].vscsi = vscsi;
4475 ++ virtscsi_kick_event(vscsi, &vscsi->event_list[i]);
4476 ++ }
4477 ++
4478 ++ return 0;
4479 ++}
4480 ++
4481 ++static void virtscsi_cancel_event_work(struct virtio_scsi *vscsi)
4482 ++{
4483 ++ int i;
4484 ++
4485 ++ for (i = 0; i < VIRTIO_SCSI_EVENT_LEN; i++)
4486 ++ cancel_work_sync(&vscsi->event_list[i].work);
4487 ++}
4488 ++
4489 ++static void virtscsi_handle_transport_reset(struct virtio_scsi *vscsi,
4490 ++ struct virtio_scsi_event *event)
4491 ++{
4492 ++ struct scsi_device *sdev;
4493 ++ struct Scsi_Host *shost = virtio_scsi_host(vscsi->vdev);
4494 ++ unsigned int target = event->lun[1];
4495 ++ unsigned int lun = (event->lun[2] << 8) | event->lun[3];
4496 ++
4497 ++ switch (event->reason) {
4498 ++ case VIRTIO_SCSI_EVT_RESET_RESCAN:
4499 ++ scsi_add_device(shost, 0, target, lun);
4500 ++ break;
4501 ++ case VIRTIO_SCSI_EVT_RESET_REMOVED:
4502 ++ sdev = scsi_device_lookup(shost, 0, target, lun);
4503 ++ if (sdev) {
4504 ++ scsi_remove_device(sdev);
4505 ++ scsi_device_put(sdev);
4506 ++ } else {
4507 ++ pr_err("SCSI device %d 0 %d %d not found\n",
4508 ++ shost->host_no, target, lun);
4509 ++ }
4510 ++ break;
4511 ++ default:
4512 ++ pr_info("Unsupport virtio scsi event reason %x\n", event->reason);
4513 ++ }
4514 ++}
4515 ++
4516 ++static void virtscsi_handle_param_change(struct virtio_scsi *vscsi,
4517 ++ struct virtio_scsi_event *event)
4518 ++{
4519 ++ struct scsi_device *sdev;
4520 ++ struct Scsi_Host *shost = virtio_scsi_host(vscsi->vdev);
4521 ++ unsigned int target = event->lun[1];
4522 ++ unsigned int lun = (event->lun[2] << 8) | event->lun[3];
4523 ++ u8 asc = event->reason & 255;
4524 ++ u8 ascq = event->reason >> 8;
4525 ++
4526 ++ sdev = scsi_device_lookup(shost, 0, target, lun);
4527 ++ if (!sdev) {
4528 ++ pr_err("SCSI device %d 0 %d %d not found\n",
4529 ++ shost->host_no, target, lun);
4530 ++ return;
4531 ++ }
4532 ++
4533 ++ /* Handle "Parameters changed", "Mode parameters changed", and
4534 ++ "Capacity data has changed". */
4535 ++ if (asc == 0x2a && (ascq == 0x00 || ascq == 0x01 || ascq == 0x09))
4536 ++ scsi_rescan_device(&sdev->sdev_gendev);
4537 ++
4538 ++ scsi_device_put(sdev);
4539 ++}
4540 ++
4541 ++static void virtscsi_handle_event(struct work_struct *work)
4542 ++{
4543 ++ struct virtio_scsi_event_node *event_node =
4544 ++ container_of(work, struct virtio_scsi_event_node, work);
4545 ++ struct virtio_scsi *vscsi = event_node->vscsi;
4546 ++ struct virtio_scsi_event *event = &event_node->event;
4547 ++
4548 ++ if (event->event & VIRTIO_SCSI_T_EVENTS_MISSED) {
4549 ++ event->event &= ~VIRTIO_SCSI_T_EVENTS_MISSED;
4550 ++ scsi_scan_host(virtio_scsi_host(vscsi->vdev));
4551 ++ }
4552 ++
4553 ++ switch (event->event) {
4554 ++ case VIRTIO_SCSI_T_NO_EVENT:
4555 ++ break;
4556 ++ case VIRTIO_SCSI_T_TRANSPORT_RESET:
4557 ++ virtscsi_handle_transport_reset(vscsi, event);
4558 ++ break;
4559 ++ case VIRTIO_SCSI_T_PARAM_CHANGE:
4560 ++ virtscsi_handle_param_change(vscsi, event);
4561 ++ break;
4562 ++ default:
4563 ++ pr_err("Unsupport virtio scsi event %x\n", event->event);
4564 ++ }
4565 ++ virtscsi_kick_event(vscsi, event_node);
4566 ++}
4567 ++
4568 ++static void virtscsi_complete_event(void *buf)
4569 ++{
4570 ++ struct virtio_scsi_event_node *event_node = buf;
4571 ++
4572 ++ INIT_WORK(&event_node->work, virtscsi_handle_event);
4573 ++ schedule_work(&event_node->work);
4574 ++}
4575 ++
4576 ++static void virtscsi_event_done(struct virtqueue *vq)
4577 ++{
4578 ++ struct Scsi_Host *sh = virtio_scsi_host(vq->vdev);
4579 ++ struct virtio_scsi *vscsi = shost_priv(sh);
4580 ++ unsigned long flags;
4581 ++
4582 ++ spin_lock_irqsave(&vscsi->event_vq.vq_lock, flags);
4583 ++ virtscsi_vq_done(vq, virtscsi_complete_event);
4584 ++ spin_unlock_irqrestore(&vscsi->event_vq.vq_lock, flags);
4585 ++};
4586 ++
4587 ++static void virtscsi_map_sgl(struct scatterlist *sg, unsigned int *p_idx,
4588 ++ struct scsi_data_buffer *sdb)
4589 ++{
4590 ++ struct sg_table *table = &sdb->table;
4591 ++ struct scatterlist *sg_elem;
4592 ++ unsigned int idx = *p_idx;
4593 ++ int i;
4594 ++
4595 ++ for_each_sg(table->sgl, sg_elem, table->nents, i)
4596 ++ sg[idx++] = *sg_elem;
4597 ++
4598 ++ *p_idx = idx;
4599 ++}
4600 ++
4601 ++/**
4602 ++ * virtscsi_map_cmd - map a scsi_cmd to a virtqueue scatterlist
4603 ++ * @vscsi : virtio_scsi state
4604 ++ * @cmd : command structure
4605 ++ * @out_num : number of read-only elements
4606 ++ * @in_num : number of write-only elements
4607 ++ * @req_size : size of the request buffer
4608 ++ * @resp_size : size of the response buffer
4609 ++ *
4610 ++ * Called with tgt_lock held.
4611 ++ */
4612 ++static void virtscsi_map_cmd(struct virtio_scsi_target_state *tgt,
4613 ++ struct virtio_scsi_cmd *cmd,
4614 ++ unsigned *out_num, unsigned *in_num,
4615 ++ size_t req_size, size_t resp_size)
4616 ++{
4617 ++ struct scsi_cmnd *sc = cmd->sc;
4618 ++ struct scatterlist *sg = tgt->sg;
4619 ++ unsigned int idx = 0;
4620 ++
4621 ++ /* Request header. */
4622 ++ sg_set_buf(&sg[idx++], &cmd->req, req_size);
4623 ++
4624 ++ /* Data-out buffer. */
4625 ++ if (sc && sc->sc_data_direction != DMA_FROM_DEVICE)
4626 ++ virtscsi_map_sgl(sg, &idx, scsi_out(sc));
4627 ++
4628 ++ *out_num = idx;
4629 ++
4630 ++ /* Response header. */
4631 ++ sg_set_buf(&sg[idx++], &cmd->resp, resp_size);
4632 ++
4633 ++ /* Data-in buffer */
4634 ++ if (sc && sc->sc_data_direction != DMA_TO_DEVICE)
4635 ++ virtscsi_map_sgl(sg, &idx, scsi_in(sc));
4636 ++
4637 ++ *in_num = idx - *out_num;
4638 ++}
4639 ++
4640 ++static int virtscsi_kick_cmd(struct virtio_scsi_target_state *tgt,
4641 ++ struct virtio_scsi_vq *vq,
4642 ++ struct virtio_scsi_cmd *cmd,
4643 ++ size_t req_size, size_t resp_size, gfp_t gfp)
4644 ++{
4645 ++ unsigned int out_num, in_num;
4646 ++ unsigned long flags;
4647 ++ int ret;
4648 ++
4649 ++ spin_lock_irqsave(&tgt->tgt_lock, flags);
4650 ++ virtscsi_map_cmd(tgt, cmd, &out_num, &in_num, req_size, resp_size);
4651 ++
4652 ++ spin_lock(&vq->vq_lock);
4653 ++ ret = virtqueue_add_buf_gfp(vq->vq, tgt->sg, out_num, in_num, cmd, gfp);
4654 ++ spin_unlock(&tgt->tgt_lock);
4655 ++ if (ret >= 0)
4656 ++ ret = virtqueue_kick_prepare(vq->vq);
4657 ++
4658 ++ spin_unlock_irqrestore(&vq->vq_lock, flags);
4659 ++
4660 ++ if (ret > 0)
4661 ++ virtqueue_notify(vq->vq);
4662 ++ return ret;
4663 ++}
4664 ++
4665 ++static int virtscsi_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc)
4666 ++{
4667 ++ struct virtio_scsi *vscsi = shost_priv(sh);
4668 ++ struct virtio_scsi_target_state *tgt = vscsi->tgt[sc->device->id];
4669 ++ struct virtio_scsi_cmd *cmd;
4670 ++ int ret;
4671 ++
4672 ++ struct Scsi_Host *shost = virtio_scsi_host(vscsi->vdev);
4673 ++ BUG_ON(scsi_sg_count(sc) > shost->sg_tablesize);
4674 ++
4675 ++ /* TODO: check feature bit and fail if unsupported? */
4676 ++ BUG_ON(sc->sc_data_direction == DMA_BIDIRECTIONAL);
4677 ++
4678 ++ dev_dbg(&sc->device->sdev_gendev,
4679 ++ "cmd %p CDB: %#02x\n", sc, sc->cmnd[0]);
4680 ++
4681 ++ ret = SCSI_MLQUEUE_HOST_BUSY;
4682 ++ cmd = mempool_alloc(virtscsi_cmd_pool, GFP_ATOMIC);
4683 ++ if (!cmd)
4684 ++ goto out;
4685 ++
4686 ++ memset(cmd, 0, sizeof(*cmd));
4687 ++ cmd->sc = sc;
4688 ++ cmd->req.cmd = (struct virtio_scsi_cmd_req){
4689 ++ .lun[0] = 1,
4690 ++ .lun[1] = sc->device->id,
4691 ++ .lun[2] = (sc->device->lun >> 8) | 0x40,
4692 ++ .lun[3] = sc->device->lun & 0xff,
4693 ++ .tag = (unsigned long)sc,
4694 ++ .task_attr = VIRTIO_SCSI_S_SIMPLE,
4695 ++ .prio = 0,
4696 ++ .crn = 0,
4697 ++ };
4698 ++
4699 ++ BUG_ON(sc->cmd_len > VIRTIO_SCSI_CDB_SIZE);
4700 ++ memcpy(cmd->req.cmd.cdb, sc->cmnd, sc->cmd_len);
4701 ++
4702 ++ if (virtscsi_kick_cmd(tgt, &vscsi->req_vq, cmd,
4703 ++ sizeof cmd->req.cmd, sizeof cmd->resp.cmd,
4704 ++ GFP_ATOMIC) >= 0)
4705 ++ ret = 0;
4706 ++ else
4707 ++ mempool_free(cmd, virtscsi_cmd_pool);
4708 ++
4709 ++out:
4710 ++ return ret;
4711 ++}
4712 ++
4713 ++static int virtscsi_tmf(struct virtio_scsi *vscsi, struct virtio_scsi_cmd *cmd)
4714 ++{
4715 ++ DECLARE_COMPLETION_ONSTACK(comp);
4716 ++ struct virtio_scsi_target_state *tgt = vscsi->tgt[cmd->sc->device->id];
4717 ++ int ret = FAILED;
4718 ++
4719 ++ cmd->comp = &comp;
4720 ++ if (virtscsi_kick_cmd(tgt, &vscsi->ctrl_vq, cmd,
4721 ++ sizeof cmd->req.tmf, sizeof cmd->resp.tmf,
4722 ++ GFP_NOIO) < 0)
4723 ++ goto out;
4724 ++
4725 ++ wait_for_completion(&comp);
4726 ++ if (cmd->resp.tmf.response == VIRTIO_SCSI_S_OK ||
4727 ++ cmd->resp.tmf.response == VIRTIO_SCSI_S_FUNCTION_SUCCEEDED)
4728 ++ ret = SUCCESS;
4729 ++
4730 ++out:
4731 ++ mempool_free(cmd, virtscsi_cmd_pool);
4732 ++ return ret;
4733 ++}
4734 ++
4735 ++static int virtscsi_device_reset(struct scsi_cmnd *sc)
4736 ++{
4737 ++ struct virtio_scsi *vscsi = shost_priv(sc->device->host);
4738 ++ struct virtio_scsi_cmd *cmd;
4739 ++
4740 ++ sdev_printk(KERN_INFO, sc->device, "device reset\n");
4741 ++ cmd = mempool_alloc(virtscsi_cmd_pool, GFP_NOIO);
4742 ++ if (!cmd)
4743 ++ return FAILED;
4744 ++
4745 ++ memset(cmd, 0, sizeof(*cmd));
4746 ++ cmd->sc = sc;
4747 ++ cmd->req.tmf = (struct virtio_scsi_ctrl_tmf_req){
4748 ++ .type = VIRTIO_SCSI_T_TMF,
4749 ++ .subtype = VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET,
4750 ++ .lun[0] = 1,
4751 ++ .lun[1] = sc->device->id,
4752 ++ .lun[2] = (sc->device->lun >> 8) | 0x40,
4753 ++ .lun[3] = sc->device->lun & 0xff,
4754 ++ };
4755 ++ return virtscsi_tmf(vscsi, cmd);
4756 ++}
4757 ++
4758 ++static int virtscsi_abort(struct scsi_cmnd *sc)
4759 ++{
4760 ++ struct virtio_scsi *vscsi = shost_priv(sc->device->host);
4761 ++ struct virtio_scsi_cmd *cmd;
4762 ++
4763 ++ scmd_printk(KERN_INFO, sc, "abort\n");
4764 ++ cmd = mempool_alloc(virtscsi_cmd_pool, GFP_NOIO);
4765 ++ if (!cmd)
4766 ++ return FAILED;
4767 ++
4768 ++ memset(cmd, 0, sizeof(*cmd));
4769 ++ cmd->sc = sc;
4770 ++ cmd->req.tmf = (struct virtio_scsi_ctrl_tmf_req){
4771 ++ .type = VIRTIO_SCSI_T_TMF,
4772 ++ .subtype = VIRTIO_SCSI_T_TMF_ABORT_TASK,
4773 ++ .lun[0] = 1,
4774 ++ .lun[1] = sc->device->id,
4775 ++ .lun[2] = (sc->device->lun >> 8) | 0x40,
4776 ++ .lun[3] = sc->device->lun & 0xff,
4777 ++ .tag = (unsigned long)sc,
4778 ++ };
4779 ++ return virtscsi_tmf(vscsi, cmd);
4780 ++}
4781 ++
4782 ++static struct scsi_host_template virtscsi_host_template = {
4783 ++ .module = THIS_MODULE,
4784 ++ .name = "Virtio SCSI HBA",
4785 ++ .proc_name = "virtio_scsi",
4786 ++ .queuecommand = virtscsi_queuecommand,
4787 ++ .this_id = -1,
4788 ++ .eh_abort_handler = virtscsi_abort,
4789 ++ .eh_device_reset_handler = virtscsi_device_reset,
4790 ++
4791 ++ .can_queue = 1024,
4792 ++ .dma_boundary = UINT_MAX,
4793 ++ .use_clustering = ENABLE_CLUSTERING,
4794 ++};
4795 ++
4796 ++#define virtscsi_config_get(vdev, fld) \
4797 ++ ({ \
4798 ++ typeof(((struct virtio_scsi_config *)0)->fld) __val; \
4799 ++ vdev->config->get(vdev, \
4800 ++ offsetof(struct virtio_scsi_config, fld), \
4801 ++ &__val, sizeof(__val)); \
4802 ++ __val; \
4803 ++ })
4804 ++
4805 ++#define virtscsi_config_set(vdev, fld, val) \
4806 ++ (void)({ \
4807 ++ typeof(((struct virtio_scsi_config *)0)->fld) __val = (val); \
4808 ++ vdev->config->set(vdev, \
4809 ++ offsetof(struct virtio_scsi_config, fld), \
4810 ++ &__val, sizeof(__val)); \
4811 ++ })
4812 ++
4813 ++static void virtscsi_init_vq(struct virtio_scsi_vq *virtscsi_vq,
4814 ++ struct virtqueue *vq)
4815 ++{
4816 ++ spin_lock_init(&virtscsi_vq->vq_lock);
4817 ++ virtscsi_vq->vq = vq;
4818 ++}
4819 ++
4820 ++static struct virtio_scsi_target_state *virtscsi_alloc_tgt(
4821 ++ struct virtio_device *vdev, int sg_elems)
4822 ++{
4823 ++ struct virtio_scsi_target_state *tgt;
4824 ++ gfp_t gfp_mask = GFP_KERNEL;
4825 ++
4826 ++ /* We need extra sg elements at head and tail. */
4827 ++ tgt = kmalloc(sizeof(*tgt) + sizeof(tgt->sg[0]) * (sg_elems + 2),
4828 ++ gfp_mask);
4829 ++
4830 ++ if (!tgt)
4831 ++ return NULL;
4832 ++
4833 ++ spin_lock_init(&tgt->tgt_lock);
4834 ++ sg_init_table(tgt->sg, sg_elems + 2);
4835 ++ return tgt;
4836 ++}
4837 ++
4838 ++static void virtscsi_scan(struct virtio_device *vdev)
4839 ++{
4840 ++ struct Scsi_Host *shost = (struct Scsi_Host *)vdev->priv;
4841 ++
4842 ++ scsi_scan_host(shost);
4843 ++}
4844 ++
4845 ++static void virtscsi_remove_vqs(struct virtio_device *vdev)
4846 ++{
4847 ++ struct Scsi_Host *sh = virtio_scsi_host(vdev);
4848 ++ struct virtio_scsi *vscsi = shost_priv(sh);
4849 ++ u32 i, num_targets;
4850 ++
4851 ++ /* Stop all the virtqueues. */
4852 ++ vdev->config->reset(vdev);
4853 ++
4854 ++ num_targets = sh->max_id;
4855 ++ for (i = 0; i < num_targets; i++) {
4856 ++ kfree(vscsi->tgt[i]);
4857 ++ vscsi->tgt[i] = NULL;
4858 ++ }
4859 ++
4860 ++ vdev->config->del_vqs(vdev);
4861 ++}
4862 ++
4863 ++static int virtscsi_init(struct virtio_device *vdev,
4864 ++ struct virtio_scsi *vscsi, int num_targets)
4865 ++{
4866 ++ int err;
4867 ++ struct virtqueue *vqs[3];
4868 ++ u32 i, sg_elems;
4869 ++
4870 ++ vq_callback_t *callbacks[] = {
4871 ++ virtscsi_ctrl_done,
4872 ++ virtscsi_event_done,
4873 ++ virtscsi_req_done
4874 ++ };
4875 ++ const char *names[] = {
4876 ++ "control",
4877 ++ "event",
4878 ++ "request"
4879 ++ };
4880 ++
4881 ++ /* Discover virtqueues and write information to configuration. */
4882 ++ err = vdev->config->find_vqs(vdev, 3, vqs, callbacks, names);
4883 ++ if (err)
4884 ++ return err;
4885 ++
4886 ++ virtscsi_init_vq(&vscsi->ctrl_vq, vqs[0]);
4887 ++ virtscsi_init_vq(&vscsi->event_vq, vqs[1]);
4888 ++ virtscsi_init_vq(&vscsi->req_vq, vqs[2]);
4889 ++
4890 ++ virtscsi_config_set(vdev, cdb_size, VIRTIO_SCSI_CDB_SIZE);
4891 ++ virtscsi_config_set(vdev, sense_size, VIRTIO_SCSI_SENSE_SIZE);
4892 ++
4893 ++ if (virtio_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG))
4894 ++ virtscsi_kick_event_all(vscsi);
4895 ++
4896 ++ /* We need to know how many segments before we allocate. */
4897 ++ sg_elems = virtscsi_config_get(vdev, seg_max) ?: 1;
4898 ++
4899 ++ for (i = 0; i < num_targets; i++) {
4900 ++ vscsi->tgt[i] = virtscsi_alloc_tgt(vdev, sg_elems);
4901 ++ if (!vscsi->tgt[i]) {
4902 ++ err = -ENOMEM;
4903 ++ goto out;
4904 ++ }
4905 ++ }
4906 ++ err = 0;
4907 ++
4908 ++out:
4909 ++ if (err)
4910 ++ virtscsi_remove_vqs(vdev);
4911 ++ return err;
4912 ++}
4913 ++
4914 ++static int __devinit virtscsi_probe(struct virtio_device *vdev)
4915 ++{
4916 ++ struct Scsi_Host *shost;
4917 ++ struct virtio_scsi *vscsi;
4918 ++ int err;
4919 ++ u32 sg_elems, num_targets;
4920 ++ u32 cmd_per_lun;
4921 ++
4922 ++ /* Allocate memory and link the structs together. */
4923 ++ num_targets = virtscsi_config_get(vdev, max_target) + 1;
4924 ++ shost = scsi_host_alloc(&virtscsi_host_template,
4925 ++ sizeof(*vscsi)
4926 ++ + num_targets * sizeof(struct virtio_scsi_target_state));
4927 ++
4928 ++ if (!shost)
4929 ++ return -ENOMEM;
4930 ++
4931 ++ sg_elems = virtscsi_config_get(vdev, seg_max) ?: 1;
4932 ++ shost->sg_tablesize = sg_elems;
4933 ++ vscsi = shost_priv(shost);
4934 ++ vscsi->vdev = vdev;
4935 ++ vdev->priv = shost;
4936 ++
4937 ++ err = virtscsi_init(vdev, vscsi, num_targets);
4938 ++ if (err)
4939 ++ goto virtscsi_init_failed;
4940 ++
4941 ++ cmd_per_lun = virtscsi_config_get(vdev, cmd_per_lun) ?: 1;
4942 ++ shost->cmd_per_lun = min_t(u32, cmd_per_lun, shost->can_queue);
4943 ++ shost->max_sectors = virtscsi_config_get(vdev, max_sectors) ?: 0xFFFF;
4944 ++
4945 ++ /* LUNs > 256 are reported with format 1, so they go in the range
4946 ++ * 16640-32767.
4947 ++ */
4948 ++ shost->max_lun = virtscsi_config_get(vdev, max_lun) + 1 + 0x4000;
4949 ++ shost->max_id = num_targets;
4950 ++ shost->max_channel = 0;
4951 ++ shost->max_cmd_len = VIRTIO_SCSI_CDB_SIZE;
4952 ++ err = scsi_add_host(shost, &vdev->dev);
4953 ++ if (err)
4954 ++ goto scsi_add_host_failed;
4955 ++ /*
4956 ++ * scsi_scan_host() happens in virtscsi_scan() via virtio_driver->scan()
4957 ++ * after VIRTIO_CONFIG_S_DRIVER_OK has been set..
4958 ++ */
4959 ++ return 0;
4960 ++
4961 ++scsi_add_host_failed:
4962 ++ vdev->config->del_vqs(vdev);
4963 ++virtscsi_init_failed:
4964 ++ scsi_host_put(shost);
4965 ++ return err;
4966 ++}
4967 ++
4968 ++static void __devexit virtscsi_remove(struct virtio_device *vdev)
4969 ++{
4970 ++ struct Scsi_Host *shost = virtio_scsi_host(vdev);
4971 ++ struct virtio_scsi *vscsi = shost_priv(shost);
4972 ++
4973 ++ if (virtio_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG))
4974 ++ virtscsi_cancel_event_work(vscsi);
4975 ++
4976 ++ scsi_remove_host(shost);
4977 ++
4978 ++ virtscsi_remove_vqs(vdev);
4979 ++ scsi_host_put(shost);
4980 ++}
4981 ++
4982 ++#if 0
4983 ++static int virtscsi_freeze(struct virtio_device *vdev)
4984 ++{
4985 ++ virtscsi_remove_vqs(vdev);
4986 ++ return 0;
4987 ++}
4988 ++
4989 ++static int virtscsi_restore(struct virtio_device *vdev)
4990 ++{
4991 ++ struct Scsi_Host *sh = virtio_scsi_host(vdev);
4992 ++ struct virtio_scsi *vscsi = shost_priv(sh);
4993 ++
4994 ++ return virtscsi_init(vdev, vscsi, sh->max_id);
4995 ++}
4996 ++#endif
4997 ++
4998 ++static struct virtio_device_id id_table[] = {
4999 ++ { VIRTIO_ID_SCSI, VIRTIO_DEV_ANY_ID },
5000 ++ { 0 },
5001 ++};
5002 ++
5003 ++static unsigned int features[] = {
5004 ++ VIRTIO_SCSI_F_HOTPLUG,
5005 ++ VIRTIO_SCSI_F_CHANGE,
5006 ++};
5007 ++
5008 ++static struct virtio_driver virtio_scsi_driver = {
5009 ++ .feature_table = features,
5010 ++ .feature_table_size = ARRAY_SIZE(features),
5011 ++ .driver.name = KBUILD_MODNAME,
5012 ++ .driver.owner = THIS_MODULE,
5013 ++ .id_table = id_table,
5014 ++ .probe = virtscsi_probe,
5015 ++ .scan = virtscsi_scan,
5016 ++#if 0
5017 ++ .freeze = virtscsi_freeze,
5018 ++ .restore = virtscsi_restore,
5019 ++#endif
5020 ++ .remove = __devexit_p(virtscsi_remove),
5021 ++};
5022 ++
5023 ++static int __init init(void)
5024 ++{
5025 ++ int ret = -ENOMEM;
5026 ++
5027 ++ virtscsi_cmd_cache = KMEM_CACHE(virtio_scsi_cmd, 0);
5028 ++ if (!virtscsi_cmd_cache) {
5029 ++ printk(KERN_ERR "kmem_cache_create() for "
5030 ++ "virtscsi_cmd_cache failed\n");
5031 ++ goto error;
5032 ++ }
5033 ++
5034 ++
5035 ++ virtscsi_cmd_pool =
5036 ++ mempool_create_slab_pool(VIRTIO_SCSI_MEMPOOL_SZ,
5037 ++ virtscsi_cmd_cache);
5038 ++ if (!virtscsi_cmd_pool) {
5039 ++ printk(KERN_ERR "mempool_create() for"
5040 ++ "virtscsi_cmd_pool failed\n");
5041 ++ goto error;
5042 ++ }
5043 ++ ret = register_virtio_driver(&virtio_scsi_driver);
5044 ++ if (ret < 0)
5045 ++ goto error;
5046 ++
5047 ++ return 0;
5048 ++
5049 ++error:
5050 ++ if (virtscsi_cmd_pool) {
5051 ++ mempool_destroy(virtscsi_cmd_pool);
5052 ++ virtscsi_cmd_pool = NULL;
5053 ++ }
5054 ++ if (virtscsi_cmd_cache) {
5055 ++ kmem_cache_destroy(virtscsi_cmd_cache);
5056 ++ virtscsi_cmd_cache = NULL;
5057 ++ }
5058 ++ return ret;
5059 ++}
5060 ++
5061 ++static void __exit fini(void)
5062 ++{
5063 ++ unregister_virtio_driver(&virtio_scsi_driver);
5064 ++ mempool_destroy(virtscsi_cmd_pool);
5065 ++ kmem_cache_destroy(virtscsi_cmd_cache);
5066 ++}
5067 ++module_init(init);
5068 ++module_exit(fini);
5069 ++
5070 ++MODULE_DEVICE_TABLE(virtio, id_table);
5071 ++MODULE_DESCRIPTION("Virtio SCSI HBA driver");
5072 ++MODULE_LICENSE("GPL");
5073 diff --git a/drivers/spi/spi-dw-pci.c b/drivers/spi/spi-dw-pci.c
5074 index f64250e..1ee3049 100644
5075 --- a/drivers/spi/spi-dw-pci.c
5076 @@ -48006,7 +48799,7 @@ index ed147c4..94fc3c6 100644
5077
5078 /* core tmem accessor functions */
5079 diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
5080 -index 4a88eea..f00e986 100644
5081 +index ab5dd16..17f7bd2 100644
5082 --- a/drivers/target/iscsi/iscsi_target.c
5083 +++ b/drivers/target/iscsi/iscsi_target.c
5084 @@ -1357,7 +1357,7 @@ static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf)
5085 @@ -48720,7 +49513,7 @@ index 43db715..82134aa 100644
5086
5087 if (get_user(c, buf))
5088 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
5089 -index 3f35e42..9fed166 100644
5090 +index 446df6b..85128a5 100644
5091 --- a/drivers/tty/tty_io.c
5092 +++ b/drivers/tty/tty_io.c
5093 @@ -1089,7 +1089,7 @@ static inline ssize_t do_tty_write(
5094 @@ -49434,38 +50227,6 @@ index 5f6df6e..0a16602 100644
5095 }
5096
5097 /*
5098 -diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
5099 -index 5c58128..92c839d 100644
5100 ---- a/drivers/vhost/net.c
5101 -+++ b/drivers/vhost/net.c
5102 -@@ -346,6 +346,12 @@ static int get_rx_bufs(struct vhost_virtqueue *vq,
5103 - *iovcount = seg;
5104 - if (unlikely(log))
5105 - *log_num = nlogs;
5106 -+
5107 -+ /* Detect overrun */
5108 -+ if (unlikely(datalen > 0)) {
5109 -+ r = UIO_MAXIOV + 1;
5110 -+ goto err;
5111 -+ }
5112 - return headcount;
5113 - err:
5114 - vhost_discard_vq_desc(vq, headcount);
5115 -@@ -400,6 +406,14 @@ static void handle_rx(struct vhost_net *net)
5116 - /* On error, stop handling until the next kick. */
5117 - if (unlikely(headcount < 0))
5118 - break;
5119 -+ /* On overrun, truncate and discard */
5120 -+ if (unlikely(headcount > UIO_MAXIOV)) {
5121 -+ msg.msg_iovlen = 1;
5122 -+ err = sock->ops->recvmsg(NULL, sock, &msg,
5123 -+ 1, MSG_DONTWAIT | MSG_TRUNC);
5124 -+ pr_debug("Discarded rx packet: len %zd\n", sock_len);
5125 -+ continue;
5126 -+ }
5127 - /* OK, now we need to know about added descriptors. */
5128 - if (!headcount) {
5129 - if (unlikely(vhost_enable_notify(&net->dev, vq))) {
5130 diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
5131 index be32b1b..b5f6c08 100644
5132 --- a/drivers/vhost/vhost.c
5133 @@ -49527,18 +50288,18 @@ index 44bdce4..a79c55f 100644
5134 }
5135
5136 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
5137 -index 46f72ed..107788d 100644
5138 +index 4b87318..7407754 100644
5139 --- a/drivers/video/aty/mach64_cursor.c
5140 +++ b/drivers/video/aty/mach64_cursor.c
5141 -@@ -7,6 +7,7 @@
5142 - #include <linux/string.h>
5143 +@@ -8,6 +8,7 @@
5144 + #include "../fb_draw.h"
5145
5146 #include <asm/io.h>
5147 +#include <asm/pgtable.h>
5148
5149 #ifdef __sparc__
5150 #include <asm/fbio.h>
5151 -@@ -208,7 +209,9 @@ int __devinit aty_init_cursor(struct fb_info *info)
5152 +@@ -218,7 +219,9 @@ int __devinit aty_init_cursor(struct fb_info *info)
5153 info->sprite.buf_align = 16; /* and 64 lines tall. */
5154 info->sprite.flags = FB_PIXMAP_IO;
5155
5156 @@ -53025,6 +53786,105 @@ index 88714ae..16c2e11 100644
5157
5158
5159 static inline u32 get_pll_internal_frequency(u32 ref_freq,
5160 +diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
5161 +index 984c501..9167bb2 100644
5162 +--- a/drivers/virtio/virtio.c
5163 ++++ b/drivers/virtio/virtio.c
5164 +@@ -140,8 +140,11 @@ static int virtio_dev_probe(struct device *_d)
5165 + err = drv->probe(dev);
5166 + if (err)
5167 + add_status(dev, VIRTIO_CONFIG_S_FAILED);
5168 +- else
5169 ++ else {
5170 + add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
5171 ++ if (drv->scan)
5172 ++ drv->scan(dev);
5173 ++ }
5174 +
5175 + return err;
5176 + }
5177 +diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
5178 +index 4a88ac3..d2e1657 100644
5179 +--- a/drivers/virtio/virtio_ring.c
5180 ++++ b/drivers/virtio/virtio_ring.c
5181 +@@ -245,10 +245,23 @@ add_head:
5182 + }
5183 + EXPORT_SYMBOL_GPL(virtqueue_add_buf_gfp);
5184 +
5185 +-void virtqueue_kick(struct virtqueue *_vq)
5186 ++/**
5187 ++ * virtqueue_kick_prepare - first half of split virtqueue_kick call.
5188 ++ * @vq: the struct virtqueue
5189 ++ *
5190 ++ * Instead of virtqueue_kick(), you can do:
5191 ++ * if (virtqueue_kick_prepare(vq))
5192 ++ * virtqueue_notify(vq);
5193 ++ *
5194 ++ * This is sometimes useful because the virtqueue_kick_prepare() needs
5195 ++ * to be serialized, but the actual virtqueue_notify() call does not.
5196 ++ */
5197 ++bool virtqueue_kick_prepare(struct virtqueue *_vq)
5198 + {
5199 + struct vring_virtqueue *vq = to_vvq(_vq);
5200 + u16 new, old;
5201 ++ bool needs_kick;
5202 ++
5203 + START_USE(vq);
5204 + /* Descriptors and available array need to be set before we expose the
5205 + * new available array entries. */
5206 +@@ -261,13 +274,46 @@ void virtqueue_kick(struct virtqueue *_vq)
5207 + /* Need to update avail index before checking if we should notify */
5208 + virtio_mb();
5209 +
5210 +- if (vq->event ?
5211 +- vring_need_event(vring_avail_event(&vq->vring), new, old) :
5212 +- !(vq->vring.used->flags & VRING_USED_F_NO_NOTIFY))
5213 +- /* Prod other side to tell it about changes. */
5214 +- vq->notify(&vq->vq);
5215 +-
5216 ++ if (vq->event) {
5217 ++ needs_kick = vring_need_event(vring_avail_event(&vq->vring),
5218 ++ new, old);
5219 ++ } else {
5220 ++ needs_kick = !(vq->vring.used->flags & VRING_USED_F_NO_NOTIFY);
5221 ++ }
5222 + END_USE(vq);
5223 ++ return needs_kick;
5224 ++}
5225 ++EXPORT_SYMBOL_GPL(virtqueue_kick_prepare);
5226 ++
5227 ++/**
5228 ++ * virtqueue_notify - second half of split virtqueue_kick call.
5229 ++ * @vq: the struct virtqueue
5230 ++ *
5231 ++ * This does not need to be serialized.
5232 ++ */
5233 ++void virtqueue_notify(struct virtqueue *_vq)
5234 ++{
5235 ++ struct vring_virtqueue *vq = to_vvq(_vq);
5236 ++
5237 ++ /* Prod other side to tell it about changes. */
5238 ++ vq->notify(_vq);
5239 ++}
5240 ++EXPORT_SYMBOL_GPL(virtqueue_notify);
5241 ++
5242 ++/**
5243 ++ * virtqueue_kick - update after add_buf
5244 ++ * @vq: the struct virtqueue
5245 ++ *
5246 ++ * After one or more virtqueue_add_buf calls, invoke this to kick
5247 ++ * the other side.
5248 ++ *
5249 ++ * Caller must ensure we don't call this with other virtqueue
5250 ++ * operations at the same time (except where noted).
5251 ++ */
5252 ++void virtqueue_kick(struct virtqueue *vq)
5253 ++{
5254 ++ if (virtqueue_kick_prepare(vq))
5255 ++ virtqueue_notify(vq);
5256 + }
5257 + EXPORT_SYMBOL_GPL(virtqueue_kick);
5258 +
5259 diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c
5260 index 1aa3897..3a6b3f1 100644
5261 --- a/drivers/xen/xenfs/super.c
5262 @@ -60050,7 +60910,7 @@ index 1943898..396c460 100644
5263 -
5264 #endif /* CONFIG_NFS_V4 */
5265 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
5266 -index e065497..258fa11 100644
5267 +index 315a1ba..aec2a5f 100644
5268 --- a/fs/nfsd/nfs4proc.c
5269 +++ b/fs/nfsd/nfs4proc.c
5270 @@ -1048,7 +1048,7 @@ struct nfsd4_operation {
5271 @@ -60063,7 +60923,7 @@ index e065497..258fa11 100644
5272 static struct nfsd4_operation nfsd4_ops[];
5273
5274 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
5275 -index ade5316..f1a6152 100644
5276 +index 4835b90..f675029 100644
5277 --- a/fs/nfsd/nfs4xdr.c
5278 +++ b/fs/nfsd/nfs4xdr.c
5279 @@ -1445,7 +1445,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
5280 @@ -60130,10 +60990,10 @@ index c45a2ea..1a6bd66 100644
5281 #ifdef CONFIG_PROC_FS
5282 static int create_proc_exports_entry(void)
5283 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
5284 -index 6a66fc0..cfdadae 100644
5285 +index 11e1888..216bf2f 100644
5286 --- a/fs/nfsd/vfs.c
5287 +++ b/fs/nfsd/vfs.c
5288 -@@ -948,7 +948,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
5289 +@@ -957,7 +957,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
5290 } else {
5291 oldfs = get_fs();
5292 set_fs(KERNEL_DS);
5293 @@ -60142,7 +61002,7 @@ index 6a66fc0..cfdadae 100644
5294 set_fs(oldfs);
5295 }
5296
5297 -@@ -1052,7 +1052,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
5298 +@@ -1061,7 +1061,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
5299
5300 /* Write the data. */
5301 oldfs = get_fs(); set_fs(KERNEL_DS);
5302 @@ -60151,7 +61011,7 @@ index 6a66fc0..cfdadae 100644
5303 set_fs(oldfs);
5304 if (host_err < 0)
5305 goto out_nfserr;
5306 -@@ -1593,7 +1593,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
5307 +@@ -1602,7 +1602,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
5308 */
5309
5310 oldfs = get_fs(); set_fs(KERNEL_DS);
5311 @@ -62438,11 +63298,11 @@ index 356f715..c918d38 100644
5312 error = -EFAULT;
5313 else
5314 diff --git a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c
5315 -index 133e935..77359db 100644
5316 +index 8048eea..ad851ae 100644
5317 --- a/fs/reiserfs/dir.c
5318 +++ b/fs/reiserfs/dir.c
5319 -@@ -204,6 +204,8 @@ int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
5320 - next_pos = deh_offset(deh) + 1;
5321 +@@ -206,6 +206,8 @@ int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
5322 + next_pos = cur_pos + 1;
5323
5324 if (item_moved(&tmp_ih, &path_to_entry)) {
5325 + set_cpu_key_k_offset(&pos_key,
5326 @@ -79988,7 +80848,7 @@ index 2148b12..519b820 100644
5327
5328 static inline void anon_vma_merge(struct vm_area_struct *vma,
5329 diff --git a/include/linux/sched.h b/include/linux/sched.h
5330 -index c17fdfb..90df630 100644
5331 +index cb34ff4..14243ec 100644
5332 --- a/include/linux/sched.h
5333 +++ b/include/linux/sched.h
5334 @@ -101,6 +101,7 @@ struct bio_list;
5335 @@ -80263,7 +81123,7 @@ index c17fdfb..90df630 100644
5336
5337 /* Future-safe accessor for struct task_struct's cpus_allowed. */
5338 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
5339 -@@ -2098,7 +2215,9 @@ void yield(void);
5340 +@@ -2116,7 +2233,9 @@ void yield(void);
5341 extern struct exec_domain default_exec_domain;
5342
5343 union thread_union {
5344 @@ -80273,7 +81133,7 @@ index c17fdfb..90df630 100644
5345 unsigned long stack[THREAD_SIZE/sizeof(long)];
5346 };
5347
5348 -@@ -2131,6 +2250,7 @@ extern struct pid_namespace init_pid_ns;
5349 +@@ -2149,6 +2268,7 @@ extern struct pid_namespace init_pid_ns;
5350 */
5351
5352 extern struct task_struct *find_task_by_vpid(pid_t nr);
5353 @@ -80281,7 +81141,7 @@ index c17fdfb..90df630 100644
5354 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
5355 struct pid_namespace *ns);
5356
5357 -@@ -2252,6 +2372,12 @@ static inline void mmdrop(struct mm_struct * mm)
5358 +@@ -2270,6 +2390,12 @@ static inline void mmdrop(struct mm_struct * mm)
5359 extern void mmput(struct mm_struct *);
5360 /* Grab a reference to a task's mm, if it is not already going away */
5361 extern struct mm_struct *get_task_mm(struct task_struct *task);
5362 @@ -80294,7 +81154,7 @@ index c17fdfb..90df630 100644
5363 /* Remove the current tasks stale references to the old mm_struct */
5364 extern void mm_release(struct task_struct *, struct mm_struct *);
5365 /* Allocate a new mm structure and copy contents from tsk->mm */
5366 -@@ -2268,9 +2394,8 @@ extern void __cleanup_sighand(struct sighand_struct *);
5367 +@@ -2286,9 +2412,8 @@ extern void __cleanup_sighand(struct sighand_struct *);
5368 extern void exit_itimers(struct signal_struct *);
5369 extern void flush_itimer_signals(void);
5370
5371 @@ -80305,7 +81165,7 @@ index c17fdfb..90df630 100644
5372 extern int allow_signal(int);
5373 extern int disallow_signal(int);
5374
5375 -@@ -2433,9 +2558,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
5376 +@@ -2451,9 +2576,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
5377
5378 #endif
5379
5380 @@ -81536,6 +82396,172 @@ index 45a7698..76e6993 100644
5381 };
5382 } __attribute__ ((packed));
5383
5384 +diff --git a/include/linux/virtio.h b/include/linux/virtio.h
5385 +index 96c7843..e518462 100644
5386 +--- a/include/linux/virtio.h
5387 ++++ b/include/linux/virtio.h
5388 +@@ -90,6 +90,10 @@ static inline int virtqueue_add_buf(struct virtqueue *vq,
5389 +
5390 + void virtqueue_kick(struct virtqueue *vq);
5391 +
5392 ++bool virtqueue_kick_prepare(struct virtqueue *vq);
5393 ++
5394 ++void virtqueue_notify(struct virtqueue *vq);
5395 ++
5396 + void *virtqueue_get_buf(struct virtqueue *vq, unsigned int *len);
5397 +
5398 + void virtqueue_disable_cb(struct virtqueue *vq);
5399 +@@ -148,6 +152,7 @@ struct virtio_driver {
5400 + const unsigned int *feature_table;
5401 + unsigned int feature_table_size;
5402 + int (*probe)(struct virtio_device *dev);
5403 ++ void (*scan)(struct virtio_device *dev);
5404 + void (*remove)(struct virtio_device *dev);
5405 + void (*config_changed)(struct virtio_device *dev);
5406 + };
5407 +diff --git a/include/linux/virtio_ids.h b/include/linux/virtio_ids.h
5408 +index 85bb0bb..c5d8455 100644
5409 +--- a/include/linux/virtio_ids.h
5410 ++++ b/include/linux/virtio_ids.h
5411 +@@ -34,6 +34,7 @@
5412 + #define VIRTIO_ID_CONSOLE 3 /* virtio console */
5413 + #define VIRTIO_ID_RNG 4 /* virtio ring */
5414 + #define VIRTIO_ID_BALLOON 5 /* virtio balloon */
5415 ++#define VIRTIO_ID_SCSI 8 /* virtio scsi */
5416 + #define VIRTIO_ID_9P 9 /* 9p virtio console */
5417 +
5418 + #endif /* _LINUX_VIRTIO_IDS_H */
5419 +diff --git a/include/linux/virtio_scsi.h b/include/linux/virtio_scsi.h
5420 +new file mode 100644
5421 +index 0000000..d6b4440
5422 +--- /dev/null
5423 ++++ b/include/linux/virtio_scsi.h
5424 +@@ -0,0 +1,125 @@
5425 ++#ifndef _LINUX_VIRTIO_SCSI_H
5426 ++#define _LINUX_VIRTIO_SCSI_H
5427 ++/* This header is BSD licensed so anyone can use the definitions to implement
5428 ++ * compatible drivers/servers. */
5429 ++
5430 ++#define VIRTIO_SCSI_CDB_SIZE 32
5431 ++#define VIRTIO_SCSI_SENSE_SIZE 96
5432 ++
5433 ++/* SCSI command request, followed by data-out */
5434 ++struct virtio_scsi_cmd_req {
5435 ++ u8 lun[8]; /* Logical Unit Number */
5436 ++ u64 tag; /* Command identifier */
5437 ++ u8 task_attr; /* Task attribute */
5438 ++ u8 prio;
5439 ++ u8 crn;
5440 ++ u8 cdb[VIRTIO_SCSI_CDB_SIZE];
5441 ++} __packed;
5442 ++
5443 ++/* Response, followed by sense data and data-in */
5444 ++struct virtio_scsi_cmd_resp {
5445 ++ u32 sense_len; /* Sense data length */
5446 ++ u32 resid; /* Residual bytes in data buffer */
5447 ++ u16 status_qualifier; /* Status qualifier */
5448 ++ u8 status; /* Command completion status */
5449 ++ u8 response; /* Response values */
5450 ++ u8 sense[VIRTIO_SCSI_SENSE_SIZE];
5451 ++} __packed;
5452 ++
5453 ++/* Task Management Request */
5454 ++struct virtio_scsi_ctrl_tmf_req {
5455 ++ u32 type;
5456 ++ u32 subtype;
5457 ++ u8 lun[8];
5458 ++ u64 tag;
5459 ++} __packed;
5460 ++
5461 ++struct virtio_scsi_ctrl_tmf_resp {
5462 ++ u8 response;
5463 ++} __packed;
5464 ++
5465 ++/* Asynchronous notification query/subscription */
5466 ++struct virtio_scsi_ctrl_an_req {
5467 ++ u32 type;
5468 ++ u8 lun[8];
5469 ++ u32 event_requested;
5470 ++} __packed;
5471 ++
5472 ++struct virtio_scsi_ctrl_an_resp {
5473 ++ u32 event_actual;
5474 ++ u8 response;
5475 ++} __packed;
5476 ++
5477 ++struct virtio_scsi_event {
5478 ++ u32 event;
5479 ++ u8 lun[8];
5480 ++ u32 reason;
5481 ++} __packed;
5482 ++
5483 ++struct virtio_scsi_config {
5484 ++ u32 num_queues;
5485 ++ u32 seg_max;
5486 ++ u32 max_sectors;
5487 ++ u32 cmd_per_lun;
5488 ++ u32 event_info_size;
5489 ++ u32 sense_size;
5490 ++ u32 cdb_size;
5491 ++ u16 max_channel;
5492 ++ u16 max_target;
5493 ++ u32 max_lun;
5494 ++} __packed;
5495 ++
5496 ++/* Feature Bits */
5497 ++#define VIRTIO_SCSI_F_INOUT 0
5498 ++#define VIRTIO_SCSI_F_HOTPLUG 1
5499 ++#define VIRTIO_SCSI_F_CHANGE 2
5500 ++
5501 ++/* Response codes */
5502 ++#define VIRTIO_SCSI_S_OK 0
5503 ++#define VIRTIO_SCSI_S_OVERRUN 1
5504 ++#define VIRTIO_SCSI_S_ABORTED 2
5505 ++#define VIRTIO_SCSI_S_BAD_TARGET 3
5506 ++#define VIRTIO_SCSI_S_RESET 4
5507 ++#define VIRTIO_SCSI_S_BUSY 5
5508 ++#define VIRTIO_SCSI_S_TRANSPORT_FAILURE 6
5509 ++#define VIRTIO_SCSI_S_TARGET_FAILURE 7
5510 ++#define VIRTIO_SCSI_S_NEXUS_FAILURE 8
5511 ++#define VIRTIO_SCSI_S_FAILURE 9
5512 ++#define VIRTIO_SCSI_S_FUNCTION_SUCCEEDED 10
5513 ++#define VIRTIO_SCSI_S_FUNCTION_REJECTED 11
5514 ++#define VIRTIO_SCSI_S_INCORRECT_LUN 12
5515 ++
5516 ++/* Controlq type codes. */
5517 ++#define VIRTIO_SCSI_T_TMF 0
5518 ++#define VIRTIO_SCSI_T_AN_QUERY 1
5519 ++#define VIRTIO_SCSI_T_AN_SUBSCRIBE 2
5520 ++
5521 ++/* Valid TMF subtypes. */
5522 ++#define VIRTIO_SCSI_T_TMF_ABORT_TASK 0
5523 ++#define VIRTIO_SCSI_T_TMF_ABORT_TASK_SET 1
5524 ++#define VIRTIO_SCSI_T_TMF_CLEAR_ACA 2
5525 ++#define VIRTIO_SCSI_T_TMF_CLEAR_TASK_SET 3
5526 ++#define VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET 4
5527 ++#define VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET 5
5528 ++#define VIRTIO_SCSI_T_TMF_QUERY_TASK 6
5529 ++#define VIRTIO_SCSI_T_TMF_QUERY_TASK_SET 7
5530 ++
5531 ++/* Events. */
5532 ++#define VIRTIO_SCSI_T_EVENTS_MISSED 0x80000000
5533 ++#define VIRTIO_SCSI_T_NO_EVENT 0
5534 ++#define VIRTIO_SCSI_T_TRANSPORT_RESET 1
5535 ++#define VIRTIO_SCSI_T_ASYNC_NOTIFY 2
5536 ++#define VIRTIO_SCSI_T_PARAM_CHANGE 3
5537 ++
5538 ++/* Reasons of transport reset event */
5539 ++#define VIRTIO_SCSI_EVT_RESET_HARD 0
5540 ++#define VIRTIO_SCSI_EVT_RESET_RESCAN 1
5541 ++#define VIRTIO_SCSI_EVT_RESET_REMOVED 2
5542 ++
5543 ++#define VIRTIO_SCSI_S_SIMPLE 0
5544 ++#define VIRTIO_SCSI_S_ORDERED 1
5545 ++#define VIRTIO_SCSI_S_HEAD 2
5546 ++#define VIRTIO_SCSI_S_ACA 3
5547 ++
5548 ++
5549 ++#endif /* _LINUX_VIRTIO_SCSI_H */
5550 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
5551 index 4bde182..943f335 100644
5552 --- a/include/linux/vmalloc.h
5553 @@ -83853,7 +84879,7 @@ index e14bc74..bdf7f6c 100644
5554 if (!ab)
5555 return;
5556 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
5557 -index 47b7fc1..b8e1e47 100644
5558 +index aeac7cc..9fafcac 100644
5559 --- a/kernel/auditsc.c
5560 +++ b/kernel/auditsc.c
5561 @@ -67,6 +67,7 @@
5562 @@ -84614,7 +85640,7 @@ index a2101bb..f2e0354 100644
5563 do {
5564 unsigned long size = min_t(unsigned long, handle->size, len);
5565 diff --git a/kernel/exit.c b/kernel/exit.c
5566 -index 234e152..4c61aa3 100644
5567 +index fde15f9..99f1b97 100644
5568 --- a/kernel/exit.c
5569 +++ b/kernel/exit.c
5570 @@ -168,6 +168,10 @@ void release_task(struct task_struct * p)
5571 @@ -84694,7 +85720,7 @@ index 234e152..4c61aa3 100644
5572 static void close_files(struct files_struct * files)
5573 {
5574 int i, j;
5575 -@@ -874,6 +828,8 @@ NORET_TYPE void do_exit(long code)
5576 +@@ -881,6 +835,8 @@ NORET_TYPE void do_exit(long code)
5577 struct task_struct *tsk = current;
5578 int group_dead;
5579
5580 @@ -84703,7 +85729,7 @@ index 234e152..4c61aa3 100644
5581 profile_task_exit(tsk);
5582
5583 WARN_ON(blk_needs_flush_plug(tsk));
5584 -@@ -890,7 +846,6 @@ NORET_TYPE void do_exit(long code)
5585 +@@ -897,7 +853,6 @@ NORET_TYPE void do_exit(long code)
5586 * mm_release()->clear_child_tid() from writing to a user-controlled
5587 * kernel address.
5588 */
5589 @@ -84711,7 +85737,7 @@ index 234e152..4c61aa3 100644
5590
5591 ptrace_event(PTRACE_EVENT_EXIT, code);
5592
5593 -@@ -952,6 +907,9 @@ NORET_TYPE void do_exit(long code)
5594 +@@ -959,6 +914,9 @@ NORET_TYPE void do_exit(long code)
5595 tsk->exit_code = code;
5596 taskstats_exit(tsk, group_dead);
5597
5598 @@ -84721,7 +85747,7 @@ index 234e152..4c61aa3 100644
5599 exit_mm(tsk);
5600
5601 if (group_dead)
5602 -@@ -1065,7 +1023,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
5603 +@@ -1072,7 +1030,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
5604 * Take down every thread in the group. This is called by fatal signals
5605 * as well as by sys_exit_group (below).
5606 */
5607 @@ -89774,7 +90800,7 @@ index f8b05a4..ece06b3 100644
5608 };
5609
5610 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
5611 -index 16fc34a..efd8bb8 100644
5612 +index 92cac05..89f0de9 100644
5613 --- a/kernel/trace/blktrace.c
5614 +++ b/kernel/trace/blktrace.c
5615 @@ -324,7 +324,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
5616 @@ -90984,28 +92010,6 @@ index b8029a5..2b120e1 100644
5617 + pax_close_kernel();
5618 +}
5619 +EXPORT_SYMBOL(pax_list_del_rcu);
5620 -diff --git a/lib/nlattr.c b/lib/nlattr.c
5621 -index a8408b6..190ae10 100644
5622 ---- a/lib/nlattr.c
5623 -+++ b/lib/nlattr.c
5624 -@@ -299,9 +299,15 @@ int nla_memcmp(const struct nlattr *nla, const void *data,
5625 - */
5626 - int nla_strcmp(const struct nlattr *nla, const char *str)
5627 - {
5628 -- int len = strlen(str) + 1;
5629 -- int d = nla_len(nla) - len;
5630 -+ int len = strlen(str);
5631 -+ char *buf = nla_data(nla);
5632 -+ int attrlen = nla_len(nla);
5633 -+ int d;
5634 -
5635 -+ if (attrlen > 0 && buf[attrlen - 1] == '\0')
5636 -+ attrlen--;
5637 -+
5638 -+ d = attrlen - len;
5639 - if (d == 0)
5640 - d = memcmp(nla_data(nla), str, len);
5641 -
5642 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
5643 index d9df745..e73c2fe 100644
5644 --- a/lib/radix-tree.c
5645 @@ -91842,10 +92846,10 @@ index ed0ed8a..cc835b9 100644
5646 /* if an huge pmd materialized from under us just retry later */
5647 if (unlikely(pmd_trans_huge(*pmd)))
5648 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
5649 -index 3a5aae2..ef6f89a 100644
5650 +index d399f5f..786c190 100644
5651 --- a/mm/hugetlb.c
5652 +++ b/mm/hugetlb.c
5653 -@@ -2007,15 +2007,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
5654 +@@ -2008,15 +2008,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
5655 struct hstate *h = &default_hstate;
5656 unsigned long tmp;
5657 int ret;
5658 @@ -91866,7 +92870,7 @@ index 3a5aae2..ef6f89a 100644
5659 if (ret)
5660 goto out;
5661
5662 -@@ -2072,15 +2074,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
5663 +@@ -2073,15 +2075,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
5664 struct hstate *h = &default_hstate;
5665 unsigned long tmp;
5666 int ret;
5667 @@ -91887,7 +92891,7 @@ index 3a5aae2..ef6f89a 100644
5668 if (ret)
5669 goto out;
5670
5671 -@@ -2499,6 +2503,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
5672 +@@ -2500,6 +2504,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
5673 return 1;
5674 }
5675
5676 @@ -91915,7 +92919,7 @@ index 3a5aae2..ef6f89a 100644
5677 /*
5678 * Hugetlb_cow() should be called with page lock of the original hugepage held.
5679 */
5680 -@@ -2601,6 +2626,11 @@ retry_avoidcopy:
5681 +@@ -2602,6 +2627,11 @@ retry_avoidcopy:
5682 make_huge_pte(vma, new_page, 1));
5683 page_remove_rmap(old_page);
5684 hugepage_add_new_anon_rmap(new_page, vma, address);
5685 @@ -91927,7 +92931,7 @@ index 3a5aae2..ef6f89a 100644
5686 /* Make the old page be freed below */
5687 new_page = old_page;
5688 mmu_notifier_invalidate_range_end(mm,
5689 -@@ -2752,6 +2782,10 @@ retry:
5690 +@@ -2753,6 +2783,10 @@ retry:
5691 && (vma->vm_flags & VM_SHARED)));
5692 set_huge_pte_at(mm, address, ptep, new_pte);
5693
5694 @@ -91938,7 +92942,7 @@ index 3a5aae2..ef6f89a 100644
5695 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
5696 /* Optimization, do the COW without a second fault */
5697 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
5698 -@@ -2781,6 +2815,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
5699 +@@ -2782,6 +2816,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
5700 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
5701 struct hstate *h = hstate_vma(vma);
5702
5703 @@ -91949,7 +92953,7 @@ index 3a5aae2..ef6f89a 100644
5704 ptep = huge_pte_offset(mm, address);
5705 if (ptep) {
5706 entry = huge_ptep_get(ptep);
5707 -@@ -2792,6 +2830,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
5708 +@@ -2793,6 +2831,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
5709 VM_FAULT_SET_HINDEX(h - hstates);
5710 }
5711
5712 @@ -93044,7 +94048,7 @@ index 09d6a9d..c514c22 100644
5713 err = -EPERM;
5714 goto out;
5715 diff --git a/mm/mlock.c b/mm/mlock.c
5716 -index 4f4f53b..dbc8aec 100644
5717 +index 39b3a7d..660592a 100644
5718 --- a/mm/mlock.c
5719 +++ b/mm/mlock.c
5720 @@ -13,6 +13,7 @@
5721 @@ -93055,7 +94059,7 @@ index 4f4f53b..dbc8aec 100644
5722 #include <linux/sched.h>
5723 #include <linux/export.h>
5724 #include <linux/rmap.h>
5725 -@@ -376,7 +377,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
5726 +@@ -378,7 +379,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
5727 {
5728 unsigned long nstart, end, tmp;
5729 struct vm_area_struct * vma, * prev;
5730 @@ -93064,7 +94068,7 @@ index 4f4f53b..dbc8aec 100644
5731
5732 VM_BUG_ON(start & ~PAGE_MASK);
5733 VM_BUG_ON(len != PAGE_ALIGN(len));
5734 -@@ -385,6 +386,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
5735 +@@ -387,6 +388,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
5736 return -EINVAL;
5737 if (end == start)
5738 return 0;
5739 @@ -93074,7 +94078,7 @@ index 4f4f53b..dbc8aec 100644
5740 vma = find_vma_prev(current->mm, start, &prev);
5741 if (!vma || vma->vm_start > start)
5742 return -ENOMEM;
5743 -@@ -395,6 +399,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
5744 +@@ -397,6 +401,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
5745 for (nstart = start ; ; ) {
5746 vm_flags_t newflags;
5747
5748 @@ -93086,7 +94090,7 @@ index 4f4f53b..dbc8aec 100644
5749 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
5750
5751 newflags = vma->vm_flags | VM_LOCKED;
5752 -@@ -500,6 +509,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
5753 +@@ -502,6 +511,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
5754 lock_limit >>= PAGE_SHIFT;
5755
5756 /* check against resource limits */
5757 @@ -93094,7 +94098,7 @@ index 4f4f53b..dbc8aec 100644
5758 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
5759 error = do_mlock(start, len, 1);
5760 up_write(&current->mm->mmap_sem);
5761 -@@ -523,23 +533,29 @@ SYSCALL_DEFINE2(munlock, unsigned long, start, size_t, len)
5762 +@@ -525,23 +535,29 @@ SYSCALL_DEFINE2(munlock, unsigned long, start, size_t, len)
5763 static int do_mlockall(int flags)
5764 {
5765 struct vm_area_struct * vma, * prev = NULL;
5766 @@ -93127,7 +94131,7 @@ index 4f4f53b..dbc8aec 100644
5767 }
5768 out:
5769 return 0;
5770 -@@ -566,6 +582,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
5771 +@@ -568,6 +584,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
5772 lock_limit >>= PAGE_SHIFT;
5773
5774 ret = -ENOMEM;
5775 @@ -95290,7 +96294,7 @@ index cbcbb02..dfdc1de 100644
5776 pgoff_t offset, unsigned long max)
5777 {
5778 diff --git a/mm/rmap.c b/mm/rmap.c
5779 -index 52a2f36..7c99a3c 100644
5780 +index 9ac405b..921d11e 100644
5781 --- a/mm/rmap.c
5782 +++ b/mm/rmap.c
5783 @@ -153,6 +153,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
5784 @@ -97366,10 +98370,10 @@ index 14c4864..77ff888 100644
5785 err = -EFAULT;
5786 break;
5787 diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
5788 -index 2157984..430c7e1 100644
5789 +index 398a297..83fc29c 100644
5790 --- a/net/bridge/br_multicast.c
5791 +++ b/net/bridge/br_multicast.c
5792 -@@ -1410,7 +1410,7 @@ static int br_multicast_ipv6_rcv(struct net_bridge *br,
5793 +@@ -1416,7 +1416,7 @@ static int br_multicast_ipv6_rcv(struct net_bridge *br,
5794 nexthdr = ip6h->nexthdr;
5795 offset = ipv6_skip_exthdr(skb, sizeof(*ip6h), &nexthdr);
5796
5797 @@ -100272,10 +101276,10 @@ index a0b4c5d..a5818a1 100644
5798 }
5799
5800 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
5801 -index 5d41293..19a815f 100644
5802 +index b9edff0..2dba43d 100644
5803 --- a/net/ipv6/addrconf.c
5804 +++ b/net/ipv6/addrconf.c
5805 -@@ -2157,7 +2157,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
5806 +@@ -2160,7 +2160,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
5807 p.iph.ihl = 5;
5808 p.iph.protocol = IPPROTO_IPV6;
5809 p.iph.ttl = 64;
5810 @@ -100319,7 +101323,7 @@ index 65dd543..e6c6e6d 100644
5811
5812 static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
5813 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
5814 -index d505453..ff99535 100644
5815 +index ceced67..72c8c1e 100644
5816 --- a/net/ipv6/icmp.c
5817 +++ b/net/ipv6/icmp.c
5818 @@ -969,7 +969,7 @@ ctl_table ipv6_icmp_table_template[] = {
5819 @@ -100354,7 +101358,7 @@ index 1567fb1..29af910 100644
5820 dst = NULL;
5821 }
5822 diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
5823 -index cd4b529..b059726 100644
5824 +index 7871cc6..b0c4c31 100644
5825 --- a/net/ipv6/ip6_output.c
5826 +++ b/net/ipv6/ip6_output.c
5827 @@ -611,8 +611,8 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
5828 @@ -100589,18 +101593,9 @@ index eba5deb..61e026f 100644
5829 return -ENOMEM;
5830 }
5831 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
5832 -index 9a4f437..d6b0d59 100644
5833 +index 39e11f9..d6b0d59 100644
5834 --- a/net/ipv6/route.c
5835 +++ b/net/ipv6/route.c
5836 -@@ -1250,7 +1250,7 @@ int ip6_route_add(struct fib6_config *cfg)
5837 - goto out;
5838 - }
5839 -
5840 -- rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, NULL, DST_NOCOUNT);
5841 -+ rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, NULL, (cfg->fc_flags & RTF_ADDRCONF) ? 0 : DST_NOCOUNT);
5842 -
5843 - if (rt == NULL) {
5844 - err = -ENOMEM;
5845 @@ -2808,7 +2808,7 @@ ctl_table ipv6_route_table_template[] = {
5846
5847 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
5848 @@ -102963,7 +103958,7 @@ index 8da4481..d02565e 100644
5849 + (rtt >> sctp_rto_alpha);
5850 } else {
5851 diff --git a/net/socket.c b/net/socket.c
5852 -index d4faade..3d43f20 100644
5853 +index 3faa358..3d43f20 100644
5854 --- a/net/socket.c
5855 +++ b/net/socket.c
5856 @@ -88,6 +88,7 @@
5857 @@ -103147,18 +104142,7 @@ index d4faade..3d43f20 100644
5858 int err, err2;
5859 int fput_needed;
5860
5861 -@@ -1884,6 +1950,10 @@ static int copy_msghdr_from_user(struct msghdr *kmsg,
5862 - {
5863 - if (copy_from_user(kmsg, umsg, sizeof(struct msghdr)))
5864 - return -EFAULT;
5865 -+
5866 -+ if (kmsg->msg_namelen < 0)
5867 -+ return -EINVAL;
5868 -+
5869 - if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
5870 - kmsg->msg_namelen = sizeof(struct sockaddr_storage);
5871 - return 0;
5872 -@@ -1966,7 +2036,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
5873 +@@ -1970,7 +2036,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
5874 * checking falls down on this.
5875 */
5876 if (copy_from_user(ctl_buf,
5877 @@ -103167,7 +104151,7 @@ index d4faade..3d43f20 100644
5878 ctl_len))
5879 goto out_freectl;
5880 msg_sys->msg_control = ctl_buf;
5881 -@@ -2117,7 +2187,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
5882 +@@ -2121,7 +2187,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
5883 int err, iov_size, total_len, len;
5884
5885 /* kernel mode address */
5886 @@ -103176,7 +104160,7 @@ index d4faade..3d43f20 100644
5887
5888 /* user mode address pointers */
5889 struct sockaddr __user *uaddr;
5890 -@@ -2148,7 +2218,8 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
5891 +@@ -2152,7 +2218,8 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
5892 /* Save the user-mode address (verify_iovec will change the
5893 * kernel msghdr to use the kernel address space)
5894 */
5895 @@ -103186,7 +104170,7 @@ index d4faade..3d43f20 100644
5896 uaddr_len = COMPAT_NAMELEN(msg);
5897 if (MSG_CMSG_COMPAT & flags)
5898 err = verify_compat_iovec(msg_sys, iov,
5899 -@@ -2792,9 +2863,9 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
5900 +@@ -2796,9 +2863,9 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
5901 }
5902
5903 ifr = compat_alloc_user_space(buf_size);
5904 @@ -103198,7 +104182,7 @@ index d4faade..3d43f20 100644
5905 return -EFAULT;
5906
5907 if (put_user(convert_in ? rxnfc : compat_ptr(data),
5908 -@@ -2816,12 +2887,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
5909 +@@ -2820,12 +2887,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
5910 offsetof(struct ethtool_rxnfc, fs.ring_cookie));
5911
5912 if (copy_in_user(rxnfc, compat_rxnfc,
5913 @@ -103215,7 +104199,7 @@ index d4faade..3d43f20 100644
5914 copy_in_user(&rxnfc->rule_cnt, &compat_rxnfc->rule_cnt,
5915 sizeof(rxnfc->rule_cnt)))
5916 return -EFAULT;
5917 -@@ -2833,12 +2904,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
5918 +@@ -2837,12 +2904,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
5919
5920 if (convert_out) {
5921 if (copy_in_user(compat_rxnfc, rxnfc,
5922 @@ -103232,7 +104216,7 @@ index d4faade..3d43f20 100644
5923 copy_in_user(&compat_rxnfc->rule_cnt, &rxnfc->rule_cnt,
5924 sizeof(rxnfc->rule_cnt)))
5925 return -EFAULT;
5926 -@@ -2908,14 +2979,14 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
5927 +@@ -2912,14 +2979,14 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
5928 old_fs = get_fs();
5929 set_fs(KERNEL_DS);
5930 err = dev_ioctl(net, cmd,
5931 @@ -103249,7 +104233,7 @@ index d4faade..3d43f20 100644
5932 return -EFAULT;
5933
5934 if (get_user(data, &ifr32->ifr_ifru.ifru_data))
5935 -@@ -3017,7 +3088,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
5936 +@@ -3021,7 +3088,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
5937
5938 old_fs = get_fs();
5939 set_fs(KERNEL_DS);
5940 @@ -103258,7 +104242,7 @@ index d4faade..3d43f20 100644
5941 set_fs(old_fs);
5942
5943 if (cmd == SIOCGIFMAP && !err) {
5944 -@@ -3122,7 +3193,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
5945 +@@ -3126,7 +3193,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
5946 ret |= __get_user(rtdev, &(ur4->rt_dev));
5947 if (rtdev) {
5948 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
5949 @@ -103267,7 +104251,7 @@ index d4faade..3d43f20 100644
5950 devname[15] = 0;
5951 } else
5952 r4.rt_dev = NULL;
5953 -@@ -3362,8 +3433,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
5954 +@@ -3366,8 +3433,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
5955 int __user *uoptlen;
5956 int err;
5957
5958 @@ -103278,7 +104262,7 @@ index d4faade..3d43f20 100644
5959
5960 set_fs(KERNEL_DS);
5961 if (level == SOL_SOCKET)
5962 -@@ -3383,7 +3454,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
5963 +@@ -3387,7 +3454,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
5964 char __user *uoptval;
5965 int err;
5966
5967 @@ -104093,7 +105077,7 @@ index 1983717..4d6102c 100644
5968
5969 sub->evt.event = htohl(event, sub->swap);
5970 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
5971 -index 54fc90b..fb87ef6 100644
5972 +index 8705ee3..fb87ef6 100644
5973 --- a/net/unix/af_unix.c
5974 +++ b/net/unix/af_unix.c
5975 @@ -768,6 +768,12 @@ static struct sock *unix_find_other(struct net *net,
5976 @@ -104142,52 +105126,7 @@ index 54fc90b..fb87ef6 100644
5977 mutex_unlock(&path.dentry->d_inode->i_mutex);
5978 dput(path.dentry);
5979 path.dentry = dentry;
5980 -@@ -1771,8 +1791,11 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
5981 - goto out;
5982 -
5983 - err = mutex_lock_interruptible(&u->readlock);
5984 -- if (err) {
5985 -- err = sock_intr_errno(sock_rcvtimeo(sk, noblock));
5986 -+ if (unlikely(err)) {
5987 -+ /* recvmsg() in non blocking mode is supposed to return -EAGAIN
5988 -+ * sk_rcvtimeo is not honored by mutex_lock_interruptible()
5989 -+ */
5990 -+ err = noblock ? -EAGAIN : -ERESTARTSYS;
5991 - goto out;
5992 - }
5993 -
5994 -@@ -1887,6 +1910,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
5995 - struct unix_sock *u = unix_sk(sk);
5996 - struct sockaddr_un *sunaddr = msg->msg_name;
5997 - int copied = 0;
5998 -+ int noblock = flags & MSG_DONTWAIT;
5999 - int check_creds = 0;
6000 - int target;
6001 - int err = 0;
6002 -@@ -1901,7 +1925,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
6003 - goto out;
6004 -
6005 - target = sock_rcvlowat(sk, flags&MSG_WAITALL, size);
6006 -- timeo = sock_rcvtimeo(sk, flags&MSG_DONTWAIT);
6007 -+ timeo = sock_rcvtimeo(sk, noblock);
6008 -
6009 - /* Lock the socket to prevent queue disordering
6010 - * while sleeps in memcpy_tomsg
6011 -@@ -1913,8 +1937,11 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
6012 - }
6013 -
6014 - err = mutex_lock_interruptible(&u->readlock);
6015 -- if (err) {
6016 -- err = sock_intr_errno(timeo);
6017 -+ if (unlikely(err)) {
6018 -+ /* recvmsg() in non blocking mode is supposed to return -EAGAIN
6019 -+ * sk_rcvtimeo is not honored by mutex_lock_interruptible()
6020 -+ */
6021 -+ err = noblock ? -EAGAIN : -ERESTARTSYS;
6022 - goto out;
6023 - }
6024 -
6025 -@@ -2269,9 +2296,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
6026 +@@ -2276,9 +2296,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
6027 seq_puts(seq, "Num RefCount Protocol Flags Type St "
6028 "Inode Path\n");
6029 else {
6030 @@ -104202,7 +105141,7 @@ index 54fc90b..fb87ef6 100644
6031
6032 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
6033 s,
6034 -@@ -2298,8 +2329,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
6035 +@@ -2305,8 +2329,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
6036 }
6037 for ( ; i < len; i++)
6038 seq_putc(seq, u->addr->name->sun_path[i]);
6039 @@ -107473,7 +108412,7 @@ index dca1c22..4fa4591 100644
6040 lock = &avc_cache.slots_lock[hvalue];
6041
6042 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
6043 -index 4fa7939..bf547c8 100644
6044 +index 69477ff..8be0629 100644
6045 --- a/security/selinux/hooks.c
6046 +++ b/security/selinux/hooks.c
6047 @@ -95,8 +95,6 @@
6048 @@ -107485,7 +108424,7 @@ index 4fa7939..bf547c8 100644
6049 /* SECMARK reference count */
6050 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
6051
6052 -@@ -2017,6 +2015,13 @@ static int selinux_bprm_set_creds(struct linux_binprm *bprm)
6053 +@@ -2035,6 +2033,13 @@ static int selinux_bprm_set_creds(struct linux_binprm *bprm)
6054 new_tsec->sid = old_tsec->exec_sid;
6055 /* Reset exec SID on execve. */
6056 new_tsec->exec_sid = 0;
6057 @@ -107499,7 +108438,7 @@ index 4fa7939..bf547c8 100644
6058 } else {
6059 /* Check for a default transition on this program. */
6060 rc = security_transition_sid(old_tsec->sid, isec->sid,
6061 -@@ -2029,7 +2034,8 @@ static int selinux_bprm_set_creds(struct linux_binprm *bprm)
6062 +@@ -2047,7 +2052,8 @@ static int selinux_bprm_set_creds(struct linux_binprm *bprm)
6063 COMMON_AUDIT_DATA_INIT(&ad, PATH);
6064 ad.u.path = bprm->file->f_path;
6065
6066 @@ -107509,7 +108448,7 @@ index 4fa7939..bf547c8 100644
6067 new_tsec->sid = old_tsec->sid;
6068
6069 if (new_tsec->sid == old_tsec->sid) {
6070 -@@ -5554,7 +5560,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
6071 +@@ -5572,7 +5578,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
6072
6073 #endif
6074
6075 @@ -107518,7 +108457,7 @@ index 4fa7939..bf547c8 100644
6076 .name = "selinux",
6077
6078 .ptrace_access_check = selinux_ptrace_access_check,
6079 -@@ -5900,6 +5906,9 @@ static void selinux_nf_ip_exit(void)
6080 +@@ -5918,6 +5924,9 @@ static void selinux_nf_ip_exit(void)
6081 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
6082 static int selinux_disabled;
6083
6084 @@ -107528,7 +108467,7 @@ index 4fa7939..bf547c8 100644
6085 int selinux_disable(void)
6086 {
6087 if (ss_initialized) {
6088 -@@ -5917,7 +5926,9 @@ int selinux_disable(void)
6089 +@@ -5935,7 +5944,9 @@ int selinux_disable(void)
6090 selinux_disabled = 1;
6091 selinux_enabled = 0;
6092
6093 @@ -108406,12 +109345,13 @@ index 0a7ca6c..f4b948c 100644
6094 };
6095 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
6096 new file mode 100644
6097 -index 0000000..4c2c45c
6098 +index 0000000..1f0214f
6099 --- /dev/null
6100 +++ b/tools/gcc/.gitignore
6101 -@@ -0,0 +1,2 @@
6102 +@@ -0,0 +1,3 @@
6103 +randomize_layout_seed.h
6104 +size_overflow_hash.h
6105 ++size_overflow_hash_aux.h
6106 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
6107 new file mode 100644
6108 index 0000000..d25d472
6109 @@ -111926,10 +112866,10 @@ index 0000000..8dafb22
6110 +}
6111 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
6112 new file mode 100644
6113 -index 0000000..26a6734
6114 +index 0000000..7435554
6115 --- /dev/null
6116 +++ b/tools/gcc/size_overflow_hash.data
6117 -@@ -0,0 +1,5104 @@
6118 +@@ -0,0 +1,5105 @@
6119 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
6120 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
6121 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
6122 @@ -112413,6 +113353,7 @@ index 0000000..26a6734
6123 +bt_skb_send_alloc_6581 bt_skb_send_alloc 2 6581 NULL
6124 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
6125 +dn_alloc_skb_6631 dn_alloc_skb 2 6631 NULL
6126 ++virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
6127 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
6128 +iwl_dbgfs_clear_traffic_statistics_write_6681 iwl_dbgfs_clear_traffic_statistics_write 3 6681 NULL
6129 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
6130
6131 diff --git a/3.2.57/4425_grsec_remove_EI_PAX.patch b/3.2.58/4425_grsec_remove_EI_PAX.patch
6132 similarity index 100%
6133 rename from 3.2.57/4425_grsec_remove_EI_PAX.patch
6134 rename to 3.2.58/4425_grsec_remove_EI_PAX.patch
6135
6136 diff --git a/3.2.57/4427_force_XATTR_PAX_tmpfs.patch b/3.2.58/4427_force_XATTR_PAX_tmpfs.patch
6137 similarity index 100%
6138 rename from 3.2.57/4427_force_XATTR_PAX_tmpfs.patch
6139 rename to 3.2.58/4427_force_XATTR_PAX_tmpfs.patch
6140
6141 diff --git a/3.2.57/4430_grsec-remove-localversion-grsec.patch b/3.2.58/4430_grsec-remove-localversion-grsec.patch
6142 similarity index 100%
6143 rename from 3.2.57/4430_grsec-remove-localversion-grsec.patch
6144 rename to 3.2.58/4430_grsec-remove-localversion-grsec.patch
6145
6146 diff --git a/3.2.57/4435_grsec-mute-warnings.patch b/3.2.58/4435_grsec-mute-warnings.patch
6147 similarity index 100%
6148 rename from 3.2.57/4435_grsec-mute-warnings.patch
6149 rename to 3.2.58/4435_grsec-mute-warnings.patch
6150
6151 diff --git a/3.2.57/4440_grsec-remove-protected-paths.patch b/3.2.58/4440_grsec-remove-protected-paths.patch
6152 similarity index 100%
6153 rename from 3.2.57/4440_grsec-remove-protected-paths.patch
6154 rename to 3.2.58/4440_grsec-remove-protected-paths.patch
6155
6156 diff --git a/3.2.57/4450_grsec-kconfig-default-gids.patch b/3.2.58/4450_grsec-kconfig-default-gids.patch
6157 similarity index 100%
6158 rename from 3.2.57/4450_grsec-kconfig-default-gids.patch
6159 rename to 3.2.58/4450_grsec-kconfig-default-gids.patch
6160
6161 diff --git a/3.2.57/4465_selinux-avc_audit-log-curr_ip.patch b/3.2.58/4465_selinux-avc_audit-log-curr_ip.patch
6162 similarity index 100%
6163 rename from 3.2.57/4465_selinux-avc_audit-log-curr_ip.patch
6164 rename to 3.2.58/4465_selinux-avc_audit-log-curr_ip.patch
6165
6166 diff --git a/3.2.57/4470_disable-compat_vdso.patch b/3.2.58/4470_disable-compat_vdso.patch
6167 similarity index 100%
6168 rename from 3.2.57/4470_disable-compat_vdso.patch
6169 rename to 3.2.58/4470_disable-compat_vdso.patch
6170
6171 diff --git a/3.2.57/4475_emutramp_default_on.patch b/3.2.58/4475_emutramp_default_on.patch
6172 similarity index 100%
6173 rename from 3.2.57/4475_emutramp_default_on.patch
6174 rename to 3.2.58/4475_emutramp_default_on.patch