1 |
commit: 46898fdfdc57bdd74842993ae8666a0242893cf7 |
2 |
Author: Alice Ferrazzi <alicef <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Feb 28 15:02:14 2018 +0000 |
4 |
Commit: Alice Ferrazzi <alicef <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Feb 28 15:02:21 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=46898fdf |
7 |
|
8 |
linux kernel 4.9.85 |
9 |
|
10 |
0000_README | 4 + |
11 |
1084_linux-4.9.85.patch | 1371 +++++++++++++++++++++++++++++++++++++++++++++++ |
12 |
2 files changed, 1375 insertions(+) |
13 |
|
14 |
diff --git a/0000_README b/0000_README |
15 |
index 0832d17..c56bd07 100644 |
16 |
--- a/0000_README |
17 |
+++ b/0000_README |
18 |
@@ -379,6 +379,10 @@ Patch: 1083_linux-4.9.84.patch |
19 |
From: http://www.kernel.org |
20 |
Desc: Linux 4.9.84 |
21 |
|
22 |
+Patch: 1084_linux-4.9.85.patch |
23 |
+From: http://www.kernel.org |
24 |
+Desc: Linux 4.9.85 |
25 |
+ |
26 |
Patch: 1500_XATTR_USER_PREFIX.patch |
27 |
From: https://bugs.gentoo.org/show_bug.cgi?id=470644 |
28 |
Desc: Support for namespace user.pax.* on tmpfs. |
29 |
|
30 |
diff --git a/1084_linux-4.9.85.patch b/1084_linux-4.9.85.patch |
31 |
new file mode 100644 |
32 |
index 0000000..e5556ed |
33 |
--- /dev/null |
34 |
+++ b/1084_linux-4.9.85.patch |
35 |
@@ -0,0 +1,1371 @@ |
36 |
+diff --git a/Makefile b/Makefile |
37 |
+index db13b13cdcc2..77deaa395d69 100644 |
38 |
+--- a/Makefile |
39 |
++++ b/Makefile |
40 |
+@@ -1,6 +1,6 @@ |
41 |
+ VERSION = 4 |
42 |
+ PATCHLEVEL = 9 |
43 |
+-SUBLEVEL = 84 |
44 |
++SUBLEVEL = 85 |
45 |
+ EXTRAVERSION = |
46 |
+ NAME = Roaring Lionus |
47 |
+ |
48 |
+diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c |
49 |
+index c743d1fd8286..5963be2e05f0 100644 |
50 |
+--- a/arch/arm64/kernel/traps.c |
51 |
++++ b/arch/arm64/kernel/traps.c |
52 |
+@@ -50,7 +50,7 @@ static const char *handler[]= { |
53 |
+ "Error" |
54 |
+ }; |
55 |
+ |
56 |
+-int show_unhandled_signals = 1; |
57 |
++int show_unhandled_signals = 0; |
58 |
+ |
59 |
+ /* |
60 |
+ * Dump out the contents of some kernel memory nicely... |
61 |
+diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S |
62 |
+index db5009ce065a..8d7e4d48db0d 100644 |
63 |
+--- a/arch/x86/entry/entry_64.S |
64 |
++++ b/arch/x86/entry/entry_64.S |
65 |
+@@ -176,13 +176,26 @@ GLOBAL(entry_SYSCALL_64_after_swapgs) |
66 |
+ pushq %r8 /* pt_regs->r8 */ |
67 |
+ pushq %r9 /* pt_regs->r9 */ |
68 |
+ pushq %r10 /* pt_regs->r10 */ |
69 |
++ /* |
70 |
++ * Clear extra registers that a speculation attack might |
71 |
++ * otherwise want to exploit. Interleave XOR with PUSH |
72 |
++ * for better uop scheduling: |
73 |
++ */ |
74 |
++ xorq %r10, %r10 /* nospec r10 */ |
75 |
+ pushq %r11 /* pt_regs->r11 */ |
76 |
++ xorq %r11, %r11 /* nospec r11 */ |
77 |
+ pushq %rbx /* pt_regs->rbx */ |
78 |
++ xorl %ebx, %ebx /* nospec rbx */ |
79 |
+ pushq %rbp /* pt_regs->rbp */ |
80 |
++ xorl %ebp, %ebp /* nospec rbp */ |
81 |
+ pushq %r12 /* pt_regs->r12 */ |
82 |
++ xorq %r12, %r12 /* nospec r12 */ |
83 |
+ pushq %r13 /* pt_regs->r13 */ |
84 |
++ xorq %r13, %r13 /* nospec r13 */ |
85 |
+ pushq %r14 /* pt_regs->r14 */ |
86 |
++ xorq %r14, %r14 /* nospec r14 */ |
87 |
+ pushq %r15 /* pt_regs->r15 */ |
88 |
++ xorq %r15, %r15 /* nospec r15 */ |
89 |
+ |
90 |
+ /* IRQs are off. */ |
91 |
+ movq %rsp, %rdi |
92 |
+diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c |
93 |
+index 28c04123b6dd..842ca3cab6b3 100644 |
94 |
+--- a/arch/x86/oprofile/nmi_int.c |
95 |
++++ b/arch/x86/oprofile/nmi_int.c |
96 |
+@@ -472,7 +472,7 @@ static int nmi_setup(void) |
97 |
+ goto fail; |
98 |
+ |
99 |
+ for_each_possible_cpu(cpu) { |
100 |
+- if (!cpu) |
101 |
++ if (!IS_ENABLED(CONFIG_SMP) || !cpu) |
102 |
+ continue; |
103 |
+ |
104 |
+ memcpy(per_cpu(cpu_msrs, cpu).counters, |
105 |
+diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c |
106 |
+index 80e4cfb2471a..d5abdf8878fe 100644 |
107 |
+--- a/arch/xtensa/mm/init.c |
108 |
++++ b/arch/xtensa/mm/init.c |
109 |
+@@ -77,19 +77,75 @@ void __init zones_init(void) |
110 |
+ free_area_init_node(0, zones_size, ARCH_PFN_OFFSET, NULL); |
111 |
+ } |
112 |
+ |
113 |
++#ifdef CONFIG_HIGHMEM |
114 |
++static void __init free_area_high(unsigned long pfn, unsigned long end) |
115 |
++{ |
116 |
++ for (; pfn < end; pfn++) |
117 |
++ free_highmem_page(pfn_to_page(pfn)); |
118 |
++} |
119 |
++ |
120 |
++static void __init free_highpages(void) |
121 |
++{ |
122 |
++ unsigned long max_low = max_low_pfn; |
123 |
++ struct memblock_region *mem, *res; |
124 |
++ |
125 |
++ reset_all_zones_managed_pages(); |
126 |
++ /* set highmem page free */ |
127 |
++ for_each_memblock(memory, mem) { |
128 |
++ unsigned long start = memblock_region_memory_base_pfn(mem); |
129 |
++ unsigned long end = memblock_region_memory_end_pfn(mem); |
130 |
++ |
131 |
++ /* Ignore complete lowmem entries */ |
132 |
++ if (end <= max_low) |
133 |
++ continue; |
134 |
++ |
135 |
++ if (memblock_is_nomap(mem)) |
136 |
++ continue; |
137 |
++ |
138 |
++ /* Truncate partial highmem entries */ |
139 |
++ if (start < max_low) |
140 |
++ start = max_low; |
141 |
++ |
142 |
++ /* Find and exclude any reserved regions */ |
143 |
++ for_each_memblock(reserved, res) { |
144 |
++ unsigned long res_start, res_end; |
145 |
++ |
146 |
++ res_start = memblock_region_reserved_base_pfn(res); |
147 |
++ res_end = memblock_region_reserved_end_pfn(res); |
148 |
++ |
149 |
++ if (res_end < start) |
150 |
++ continue; |
151 |
++ if (res_start < start) |
152 |
++ res_start = start; |
153 |
++ if (res_start > end) |
154 |
++ res_start = end; |
155 |
++ if (res_end > end) |
156 |
++ res_end = end; |
157 |
++ if (res_start != start) |
158 |
++ free_area_high(start, res_start); |
159 |
++ start = res_end; |
160 |
++ if (start == end) |
161 |
++ break; |
162 |
++ } |
163 |
++ |
164 |
++ /* And now free anything which remains */ |
165 |
++ if (start < end) |
166 |
++ free_area_high(start, end); |
167 |
++ } |
168 |
++} |
169 |
++#else |
170 |
++static void __init free_highpages(void) |
171 |
++{ |
172 |
++} |
173 |
++#endif |
174 |
++ |
175 |
+ /* |
176 |
+ * Initialize memory pages. |
177 |
+ */ |
178 |
+ |
179 |
+ void __init mem_init(void) |
180 |
+ { |
181 |
+-#ifdef CONFIG_HIGHMEM |
182 |
+- unsigned long tmp; |
183 |
+- |
184 |
+- reset_all_zones_managed_pages(); |
185 |
+- for (tmp = max_low_pfn; tmp < max_pfn; tmp++) |
186 |
+- free_highmem_page(pfn_to_page(tmp)); |
187 |
+-#endif |
188 |
++ free_highpages(); |
189 |
+ |
190 |
+ max_mapnr = max_pfn - ARCH_PFN_OFFSET; |
191 |
+ high_memory = (void *)__va(max_low_pfn << PAGE_SHIFT); |
192 |
+diff --git a/crypto/asymmetric_keys/pkcs7_verify.c b/crypto/asymmetric_keys/pkcs7_verify.c |
193 |
+index 5a37962d2199..df1bde273bba 100644 |
194 |
+--- a/crypto/asymmetric_keys/pkcs7_verify.c |
195 |
++++ b/crypto/asymmetric_keys/pkcs7_verify.c |
196 |
+@@ -261,7 +261,7 @@ static int pkcs7_verify_sig_chain(struct pkcs7_message *pkcs7, |
197 |
+ sinfo->index); |
198 |
+ return 0; |
199 |
+ } |
200 |
+- ret = public_key_verify_signature(p->pub, p->sig); |
201 |
++ ret = public_key_verify_signature(p->pub, x509->sig); |
202 |
+ if (ret < 0) |
203 |
+ return ret; |
204 |
+ x509->signer = p; |
205 |
+diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c |
206 |
+index 4955eb66e361..8525fe474abd 100644 |
207 |
+--- a/crypto/asymmetric_keys/public_key.c |
208 |
++++ b/crypto/asymmetric_keys/public_key.c |
209 |
+@@ -93,9 +93,11 @@ int public_key_verify_signature(const struct public_key *pkey, |
210 |
+ |
211 |
+ BUG_ON(!pkey); |
212 |
+ BUG_ON(!sig); |
213 |
+- BUG_ON(!sig->digest); |
214 |
+ BUG_ON(!sig->s); |
215 |
+ |
216 |
++ if (!sig->digest) |
217 |
++ return -ENOPKG; |
218 |
++ |
219 |
+ alg_name = sig->pkey_algo; |
220 |
+ if (strcmp(sig->pkey_algo, "rsa") == 0) { |
221 |
+ /* The data wangled by the RSA algorithm is typically padded |
222 |
+diff --git a/crypto/asymmetric_keys/restrict.c b/crypto/asymmetric_keys/restrict.c |
223 |
+index 19d1afb9890f..09b1374dc619 100644 |
224 |
+--- a/crypto/asymmetric_keys/restrict.c |
225 |
++++ b/crypto/asymmetric_keys/restrict.c |
226 |
+@@ -66,8 +66,9 @@ __setup("ca_keys=", ca_keys_setup); |
227 |
+ * |
228 |
+ * Returns 0 if the new certificate was accepted, -ENOKEY if we couldn't find a |
229 |
+ * matching parent certificate in the trusted list, -EKEYREJECTED if the |
230 |
+- * signature check fails or the key is blacklisted and some other error if |
231 |
+- * there is a matching certificate but the signature check cannot be performed. |
232 |
++ * signature check fails or the key is blacklisted, -ENOPKG if the signature |
233 |
++ * uses unsupported crypto, or some other error if there is a matching |
234 |
++ * certificate but the signature check cannot be performed. |
235 |
+ */ |
236 |
+ int restrict_link_by_signature(struct key *trust_keyring, |
237 |
+ const struct key_type *type, |
238 |
+@@ -86,6 +87,8 @@ int restrict_link_by_signature(struct key *trust_keyring, |
239 |
+ return -EOPNOTSUPP; |
240 |
+ |
241 |
+ sig = payload->data[asym_auth]; |
242 |
++ if (!sig) |
243 |
++ return -ENOPKG; |
244 |
+ if (!sig->auth_ids[0] && !sig->auth_ids[1]) |
245 |
+ return -ENOKEY; |
246 |
+ |
247 |
+diff --git a/drivers/android/binder.c b/drivers/android/binder.c |
248 |
+index 3b6ac80b2127..49199bd2ab93 100644 |
249 |
+--- a/drivers/android/binder.c |
250 |
++++ b/drivers/android/binder.c |
251 |
+@@ -2628,8 +2628,10 @@ static unsigned int binder_poll(struct file *filp, |
252 |
+ binder_lock(__func__); |
253 |
+ |
254 |
+ thread = binder_get_thread(proc); |
255 |
+- if (!thread) |
256 |
++ if (!thread) { |
257 |
++ binder_unlock(__func__); |
258 |
+ return POLLERR; |
259 |
++ } |
260 |
+ |
261 |
+ wait_for_proc_work = thread->transaction_stack == NULL && |
262 |
+ list_empty(&thread->todo) && thread->return_error == BR_OK; |
263 |
+diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c |
264 |
+index 40be3747724d..473b44c008dd 100644 |
265 |
+--- a/drivers/dax/dax.c |
266 |
++++ b/drivers/dax/dax.c |
267 |
+@@ -453,9 +453,21 @@ static int dax_dev_pmd_fault(struct vm_area_struct *vma, unsigned long addr, |
268 |
+ return rc; |
269 |
+ } |
270 |
+ |
271 |
++static int dax_dev_split(struct vm_area_struct *vma, unsigned long addr) |
272 |
++{ |
273 |
++ struct file *filp = vma->vm_file; |
274 |
++ struct dax_dev *dax_dev = filp->private_data; |
275 |
++ struct dax_region *dax_region = dax_dev->region; |
276 |
++ |
277 |
++ if (!IS_ALIGNED(addr, dax_region->align)) |
278 |
++ return -EINVAL; |
279 |
++ return 0; |
280 |
++} |
281 |
++ |
282 |
+ static const struct vm_operations_struct dax_dev_vm_ops = { |
283 |
+ .fault = dax_dev_fault, |
284 |
+ .pmd_fault = dax_dev_pmd_fault, |
285 |
++ .split = dax_dev_split, |
286 |
+ }; |
287 |
+ |
288 |
+ static int dax_mmap(struct file *filp, struct vm_area_struct *vma) |
289 |
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c |
290 |
+index 6c343a933182..0e8f8972a160 100644 |
291 |
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c |
292 |
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c |
293 |
+@@ -14,6 +14,16 @@ |
294 |
+ |
295 |
+ #include "amd_acpi.h" |
296 |
+ |
297 |
++#define AMDGPU_PX_QUIRK_FORCE_ATPX (1 << 0) |
298 |
++ |
299 |
++struct amdgpu_px_quirk { |
300 |
++ u32 chip_vendor; |
301 |
++ u32 chip_device; |
302 |
++ u32 subsys_vendor; |
303 |
++ u32 subsys_device; |
304 |
++ u32 px_quirk_flags; |
305 |
++}; |
306 |
++ |
307 |
+ struct amdgpu_atpx_functions { |
308 |
+ bool px_params; |
309 |
+ bool power_cntl; |
310 |
+@@ -35,6 +45,7 @@ struct amdgpu_atpx { |
311 |
+ static struct amdgpu_atpx_priv { |
312 |
+ bool atpx_detected; |
313 |
+ bool bridge_pm_usable; |
314 |
++ unsigned int quirks; |
315 |
+ /* handle for device - and atpx */ |
316 |
+ acpi_handle dhandle; |
317 |
+ acpi_handle other_handle; |
318 |
+@@ -205,13 +216,19 @@ static int amdgpu_atpx_validate(struct amdgpu_atpx *atpx) |
319 |
+ |
320 |
+ atpx->is_hybrid = false; |
321 |
+ if (valid_bits & ATPX_MS_HYBRID_GFX_SUPPORTED) { |
322 |
+- printk("ATPX Hybrid Graphics\n"); |
323 |
+- /* |
324 |
+- * Disable legacy PM methods only when pcie port PM is usable, |
325 |
+- * otherwise the device might fail to power off or power on. |
326 |
+- */ |
327 |
+- atpx->functions.power_cntl = !amdgpu_atpx_priv.bridge_pm_usable; |
328 |
+- atpx->is_hybrid = true; |
329 |
++ if (amdgpu_atpx_priv.quirks & AMDGPU_PX_QUIRK_FORCE_ATPX) { |
330 |
++ printk("ATPX Hybrid Graphics, forcing to ATPX\n"); |
331 |
++ atpx->functions.power_cntl = true; |
332 |
++ atpx->is_hybrid = false; |
333 |
++ } else { |
334 |
++ printk("ATPX Hybrid Graphics\n"); |
335 |
++ /* |
336 |
++ * Disable legacy PM methods only when pcie port PM is usable, |
337 |
++ * otherwise the device might fail to power off or power on. |
338 |
++ */ |
339 |
++ atpx->functions.power_cntl = !amdgpu_atpx_priv.bridge_pm_usable; |
340 |
++ atpx->is_hybrid = true; |
341 |
++ } |
342 |
+ } |
343 |
+ |
344 |
+ atpx->dgpu_req_power_for_displays = false; |
345 |
+@@ -547,6 +564,31 @@ static const struct vga_switcheroo_handler amdgpu_atpx_handler = { |
346 |
+ .get_client_id = amdgpu_atpx_get_client_id, |
347 |
+ }; |
348 |
+ |
349 |
++static const struct amdgpu_px_quirk amdgpu_px_quirk_list[] = { |
350 |
++ /* HG _PR3 doesn't seem to work on this A+A weston board */ |
351 |
++ { 0x1002, 0x6900, 0x1002, 0x0124, AMDGPU_PX_QUIRK_FORCE_ATPX }, |
352 |
++ { 0x1002, 0x6900, 0x1028, 0x0812, AMDGPU_PX_QUIRK_FORCE_ATPX }, |
353 |
++ { 0x1002, 0x6900, 0x1028, 0x0813, AMDGPU_PX_QUIRK_FORCE_ATPX }, |
354 |
++ { 0, 0, 0, 0, 0 }, |
355 |
++}; |
356 |
++ |
357 |
++static void amdgpu_atpx_get_quirks(struct pci_dev *pdev) |
358 |
++{ |
359 |
++ const struct amdgpu_px_quirk *p = amdgpu_px_quirk_list; |
360 |
++ |
361 |
++ /* Apply PX quirks */ |
362 |
++ while (p && p->chip_device != 0) { |
363 |
++ if (pdev->vendor == p->chip_vendor && |
364 |
++ pdev->device == p->chip_device && |
365 |
++ pdev->subsystem_vendor == p->subsys_vendor && |
366 |
++ pdev->subsystem_device == p->subsys_device) { |
367 |
++ amdgpu_atpx_priv.quirks |= p->px_quirk_flags; |
368 |
++ break; |
369 |
++ } |
370 |
++ ++p; |
371 |
++ } |
372 |
++} |
373 |
++ |
374 |
+ /** |
375 |
+ * amdgpu_atpx_detect - detect whether we have PX |
376 |
+ * |
377 |
+@@ -570,6 +612,7 @@ static bool amdgpu_atpx_detect(void) |
378 |
+ |
379 |
+ parent_pdev = pci_upstream_bridge(pdev); |
380 |
+ d3_supported |= parent_pdev && parent_pdev->bridge_d3; |
381 |
++ amdgpu_atpx_get_quirks(pdev); |
382 |
+ } |
383 |
+ |
384 |
+ while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) { |
385 |
+@@ -579,6 +622,7 @@ static bool amdgpu_atpx_detect(void) |
386 |
+ |
387 |
+ parent_pdev = pci_upstream_bridge(pdev); |
388 |
+ d3_supported |= parent_pdev && parent_pdev->bridge_d3; |
389 |
++ amdgpu_atpx_get_quirks(pdev); |
390 |
+ } |
391 |
+ |
392 |
+ if (has_atpx && vga_count == 2) { |
393 |
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |
394 |
+index ce9797b6f9c7..50f18f666d67 100644 |
395 |
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |
396 |
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |
397 |
+@@ -1678,8 +1678,6 @@ int amdgpu_device_init(struct amdgpu_device *adev, |
398 |
+ * ignore it */ |
399 |
+ vga_client_register(adev->pdev, adev, NULL, amdgpu_vga_set_decode); |
400 |
+ |
401 |
+- if (amdgpu_runtime_pm == 1) |
402 |
+- runtime = true; |
403 |
+ if (amdgpu_device_is_px(ddev)) |
404 |
+ runtime = true; |
405 |
+ vga_switcheroo_register_client(adev->pdev, &amdgpu_switcheroo_ops, runtime); |
406 |
+diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.c b/drivers/gpu/drm/amd/amdgpu/si_dpm.c |
407 |
+index 4cb347e88cf0..002862be2df6 100644 |
408 |
+--- a/drivers/gpu/drm/amd/amdgpu/si_dpm.c |
409 |
++++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.c |
410 |
+@@ -3507,6 +3507,11 @@ static void si_apply_state_adjust_rules(struct amdgpu_device *adev, |
411 |
+ max_sclk = 75000; |
412 |
+ max_mclk = 80000; |
413 |
+ } |
414 |
++ if ((adev->pdev->revision == 0xC3) || |
415 |
++ (adev->pdev->device == 0x6665)) { |
416 |
++ max_sclk = 60000; |
417 |
++ max_mclk = 80000; |
418 |
++ } |
419 |
+ } else if (adev->asic_type == CHIP_OLAND) { |
420 |
+ if ((adev->pdev->revision == 0xC7) || |
421 |
+ (adev->pdev->revision == 0x80) || |
422 |
+diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c |
423 |
+index 0151ed2de770..c6b281aa762f 100644 |
424 |
+--- a/drivers/gpu/drm/drm_edid.c |
425 |
++++ b/drivers/gpu/drm/drm_edid.c |
426 |
+@@ -107,6 +107,9 @@ static const struct edid_quirk { |
427 |
+ /* AEO model 0 reports 8 bpc, but is a 6 bpc panel */ |
428 |
+ { "AEO", 0, EDID_QUIRK_FORCE_6BPC }, |
429 |
+ |
430 |
++ /* CPT panel of Asus UX303LA reports 8 bpc, but is a 6 bpc panel */ |
431 |
++ { "CPT", 0x17df, EDID_QUIRK_FORCE_6BPC }, |
432 |
++ |
433 |
+ /* Belinea 10 15 55 */ |
434 |
+ { "MAX", 1516, EDID_QUIRK_PREFER_LARGE_60 }, |
435 |
+ { "MAX", 0x77e, EDID_QUIRK_PREFER_LARGE_60 }, |
436 |
+diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c |
437 |
+index 03cac5731afc..49406e106cee 100644 |
438 |
+--- a/drivers/hid/hid-core.c |
439 |
++++ b/drivers/hid/hid-core.c |
440 |
+@@ -2443,6 +2443,9 @@ static const struct hid_device_id hid_ignore_list[] = { |
441 |
+ { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) }, |
442 |
+ { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) }, |
443 |
+ { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) }, |
444 |
++ { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERANALYSERCASSY) }, |
445 |
++ { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY) }, |
446 |
++ { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETESTCASSY) }, |
447 |
+ { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, |
448 |
+ { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, |
449 |
+ { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, |
450 |
+diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h |
451 |
+index 244b97c1b74e..9347b37a1303 100644 |
452 |
+--- a/drivers/hid/hid-ids.h |
453 |
++++ b/drivers/hid/hid-ids.h |
454 |
+@@ -608,6 +608,9 @@ |
455 |
+ #define USB_DEVICE_ID_LD_MICROCASSYTIME 0x1033 |
456 |
+ #define USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE 0x1035 |
457 |
+ #define USB_DEVICE_ID_LD_MICROCASSYPH 0x1038 |
458 |
++#define USB_DEVICE_ID_LD_POWERANALYSERCASSY 0x1040 |
459 |
++#define USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY 0x1042 |
460 |
++#define USB_DEVICE_ID_LD_MACHINETESTCASSY 0x1043 |
461 |
+ #define USB_DEVICE_ID_LD_JWM 0x1080 |
462 |
+ #define USB_DEVICE_ID_LD_DMMP 0x1081 |
463 |
+ #define USB_DEVICE_ID_LD_UMIP 0x1090 |
464 |
+diff --git a/drivers/iio/imu/adis_trigger.c b/drivers/iio/imu/adis_trigger.c |
465 |
+index f53e9a803a0e..93b99bd93738 100644 |
466 |
+--- a/drivers/iio/imu/adis_trigger.c |
467 |
++++ b/drivers/iio/imu/adis_trigger.c |
468 |
+@@ -47,6 +47,10 @@ int adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev) |
469 |
+ if (adis->trig == NULL) |
470 |
+ return -ENOMEM; |
471 |
+ |
472 |
++ adis->trig->dev.parent = &adis->spi->dev; |
473 |
++ adis->trig->ops = &adis_trigger_ops; |
474 |
++ iio_trigger_set_drvdata(adis->trig, adis); |
475 |
++ |
476 |
+ ret = request_irq(adis->spi->irq, |
477 |
+ &iio_trigger_generic_data_rdy_poll, |
478 |
+ IRQF_TRIGGER_RISING, |
479 |
+@@ -55,9 +59,6 @@ int adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev) |
480 |
+ if (ret) |
481 |
+ goto error_free_trig; |
482 |
+ |
483 |
+- adis->trig->dev.parent = &adis->spi->dev; |
484 |
+- adis->trig->ops = &adis_trigger_ops; |
485 |
+- iio_trigger_set_drvdata(adis->trig, adis); |
486 |
+ ret = iio_trigger_register(adis->trig); |
487 |
+ |
488 |
+ indio_dev->trig = iio_trigger_get(adis->trig); |
489 |
+diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c |
490 |
+index 158aaf44dd95..5d05c38c4ba9 100644 |
491 |
+--- a/drivers/iio/industrialio-buffer.c |
492 |
++++ b/drivers/iio/industrialio-buffer.c |
493 |
+@@ -174,7 +174,7 @@ unsigned int iio_buffer_poll(struct file *filp, |
494 |
+ struct iio_dev *indio_dev = filp->private_data; |
495 |
+ struct iio_buffer *rb = indio_dev->buffer; |
496 |
+ |
497 |
+- if (!indio_dev->info) |
498 |
++ if (!indio_dev->info || rb == NULL) |
499 |
+ return 0; |
500 |
+ |
501 |
+ poll_wait(filp, &rb->pollq, wait); |
502 |
+diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c |
503 |
+index c22fde6207d1..8e973a2993a6 100644 |
504 |
+--- a/drivers/infiniband/core/umem.c |
505 |
++++ b/drivers/infiniband/core/umem.c |
506 |
+@@ -193,7 +193,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, |
507 |
+ sg_list_start = umem->sg_head.sgl; |
508 |
+ |
509 |
+ while (npages) { |
510 |
+- ret = get_user_pages(cur_base, |
511 |
++ ret = get_user_pages_longterm(cur_base, |
512 |
+ min_t(unsigned long, npages, |
513 |
+ PAGE_SIZE / sizeof (struct page *)), |
514 |
+ gup_flags, page_list, vma_list); |
515 |
+diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c |
516 |
+index 44b1104eb168..c5e921bf9130 100644 |
517 |
+--- a/drivers/infiniband/core/uverbs_main.c |
518 |
++++ b/drivers/infiniband/core/uverbs_main.c |
519 |
+@@ -735,12 +735,21 @@ static int verify_command_mask(struct ib_device *ib_dev, __u32 command) |
520 |
+ return -1; |
521 |
+ } |
522 |
+ |
523 |
++static bool verify_command_idx(u32 command, bool extended) |
524 |
++{ |
525 |
++ if (extended) |
526 |
++ return command < ARRAY_SIZE(uverbs_ex_cmd_table); |
527 |
++ |
528 |
++ return command < ARRAY_SIZE(uverbs_cmd_table); |
529 |
++} |
530 |
++ |
531 |
+ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, |
532 |
+ size_t count, loff_t *pos) |
533 |
+ { |
534 |
+ struct ib_uverbs_file *file = filp->private_data; |
535 |
+ struct ib_device *ib_dev; |
536 |
+ struct ib_uverbs_cmd_hdr hdr; |
537 |
++ bool extended_command; |
538 |
+ __u32 command; |
539 |
+ __u32 flags; |
540 |
+ int srcu_key; |
541 |
+@@ -770,6 +779,15 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, |
542 |
+ } |
543 |
+ |
544 |
+ command = hdr.command & IB_USER_VERBS_CMD_COMMAND_MASK; |
545 |
++ flags = (hdr.command & |
546 |
++ IB_USER_VERBS_CMD_FLAGS_MASK) >> IB_USER_VERBS_CMD_FLAGS_SHIFT; |
547 |
++ |
548 |
++ extended_command = flags & IB_USER_VERBS_CMD_FLAG_EXTENDED; |
549 |
++ if (!verify_command_idx(command, extended_command)) { |
550 |
++ ret = -EINVAL; |
551 |
++ goto out; |
552 |
++ } |
553 |
++ |
554 |
+ if (verify_command_mask(ib_dev, command)) { |
555 |
+ ret = -EOPNOTSUPP; |
556 |
+ goto out; |
557 |
+@@ -781,12 +799,8 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, |
558 |
+ goto out; |
559 |
+ } |
560 |
+ |
561 |
+- flags = (hdr.command & |
562 |
+- IB_USER_VERBS_CMD_FLAGS_MASK) >> IB_USER_VERBS_CMD_FLAGS_SHIFT; |
563 |
+- |
564 |
+ if (!flags) { |
565 |
+- if (command >= ARRAY_SIZE(uverbs_cmd_table) || |
566 |
+- !uverbs_cmd_table[command]) { |
567 |
++ if (!uverbs_cmd_table[command]) { |
568 |
+ ret = -EINVAL; |
569 |
+ goto out; |
570 |
+ } |
571 |
+@@ -807,8 +821,7 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, |
572 |
+ struct ib_udata uhw; |
573 |
+ size_t written_count = count; |
574 |
+ |
575 |
+- if (command >= ARRAY_SIZE(uverbs_ex_cmd_table) || |
576 |
+- !uverbs_ex_cmd_table[command]) { |
577 |
++ if (!uverbs_ex_cmd_table[command]) { |
578 |
+ ret = -ENOSYS; |
579 |
+ goto out; |
580 |
+ } |
581 |
+diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c |
582 |
+index a37576a1798d..fd4a78296b48 100644 |
583 |
+--- a/drivers/irqchip/irq-gic-v3.c |
584 |
++++ b/drivers/irqchip/irq-gic-v3.c |
585 |
+@@ -616,7 +616,7 @@ static void gic_raise_softirq(const struct cpumask *mask, unsigned int irq) |
586 |
+ * Ensure that stores to Normal memory are visible to the |
587 |
+ * other CPUs before issuing the IPI. |
588 |
+ */ |
589 |
+- smp_wmb(); |
590 |
++ wmb(); |
591 |
+ |
592 |
+ for_each_cpu(cpu, mask) { |
593 |
+ unsigned long cluster_id = cpu_logical_map(cpu) & ~0xffUL; |
594 |
+diff --git a/drivers/media/v4l2-core/videobuf-dma-sg.c b/drivers/media/v4l2-core/videobuf-dma-sg.c |
595 |
+index 1db0af6c7f94..b6189a4958c5 100644 |
596 |
+--- a/drivers/media/v4l2-core/videobuf-dma-sg.c |
597 |
++++ b/drivers/media/v4l2-core/videobuf-dma-sg.c |
598 |
+@@ -185,12 +185,13 @@ static int videobuf_dma_init_user_locked(struct videobuf_dmabuf *dma, |
599 |
+ dprintk(1, "init user [0x%lx+0x%lx => %d pages]\n", |
600 |
+ data, size, dma->nr_pages); |
601 |
+ |
602 |
+- err = get_user_pages(data & PAGE_MASK, dma->nr_pages, |
603 |
++ err = get_user_pages_longterm(data & PAGE_MASK, dma->nr_pages, |
604 |
+ flags, dma->pages, NULL); |
605 |
+ |
606 |
+ if (err != dma->nr_pages) { |
607 |
+ dma->nr_pages = (err >= 0) ? err : 0; |
608 |
+- dprintk(1, "get_user_pages: err=%d [%d]\n", err, dma->nr_pages); |
609 |
++ dprintk(1, "get_user_pages_longterm: err=%d [%d]\n", err, |
610 |
++ dma->nr_pages); |
611 |
+ return err < 0 ? err : -EINVAL; |
612 |
+ } |
613 |
+ return 0; |
614 |
+diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |
615 |
+index 9e073fb6870a..6fd3be69ff21 100644 |
616 |
+--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |
617 |
++++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |
618 |
+@@ -2596,7 +2596,6 @@ void t4_get_regs(struct adapter *adap, void *buf, size_t buf_size) |
619 |
+ } |
620 |
+ |
621 |
+ #define EEPROM_STAT_ADDR 0x7bfc |
622 |
+-#define VPD_SIZE 0x800 |
623 |
+ #define VPD_BASE 0x400 |
624 |
+ #define VPD_BASE_OLD 0 |
625 |
+ #define VPD_LEN 1024 |
626 |
+@@ -2634,15 +2633,6 @@ int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p) |
627 |
+ if (!vpd) |
628 |
+ return -ENOMEM; |
629 |
+ |
630 |
+- /* We have two VPD data structures stored in the adapter VPD area. |
631 |
+- * By default, Linux calculates the size of the VPD area by traversing |
632 |
+- * the first VPD area at offset 0x0, so we need to tell the OS what |
633 |
+- * our real VPD size is. |
634 |
+- */ |
635 |
+- ret = pci_set_vpd_size(adapter->pdev, VPD_SIZE); |
636 |
+- if (ret < 0) |
637 |
+- goto out; |
638 |
+- |
639 |
+ /* Card information normally starts at VPD_BASE but early cards had |
640 |
+ * it at 0. |
641 |
+ */ |
642 |
+diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c |
643 |
+index 0392eb8a0dea..8311a93cabd8 100644 |
644 |
+--- a/drivers/nvdimm/bus.c |
645 |
++++ b/drivers/nvdimm/bus.c |
646 |
+@@ -812,16 +812,17 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm, |
647 |
+ int read_only, unsigned int ioctl_cmd, unsigned long arg) |
648 |
+ { |
649 |
+ struct nvdimm_bus_descriptor *nd_desc = nvdimm_bus->nd_desc; |
650 |
+- size_t buf_len = 0, in_len = 0, out_len = 0; |
651 |
+ static char out_env[ND_CMD_MAX_ENVELOPE]; |
652 |
+ static char in_env[ND_CMD_MAX_ENVELOPE]; |
653 |
+ const struct nd_cmd_desc *desc = NULL; |
654 |
+ unsigned int cmd = _IOC_NR(ioctl_cmd); |
655 |
+ void __user *p = (void __user *) arg; |
656 |
+ struct device *dev = &nvdimm_bus->dev; |
657 |
+- struct nd_cmd_pkg pkg; |
658 |
+ const char *cmd_name, *dimm_name; |
659 |
++ u32 in_len = 0, out_len = 0; |
660 |
+ unsigned long cmd_mask; |
661 |
++ struct nd_cmd_pkg pkg; |
662 |
++ u64 buf_len = 0; |
663 |
+ void *buf; |
664 |
+ int rc, i; |
665 |
+ |
666 |
+@@ -882,7 +883,7 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm, |
667 |
+ } |
668 |
+ |
669 |
+ if (cmd == ND_CMD_CALL) { |
670 |
+- dev_dbg(dev, "%s:%s, idx: %llu, in: %zu, out: %zu, len %zu\n", |
671 |
++ dev_dbg(dev, "%s:%s, idx: %llu, in: %u, out: %u, len %llu\n", |
672 |
+ __func__, dimm_name, pkg.nd_command, |
673 |
+ in_len, out_len, buf_len); |
674 |
+ |
675 |
+@@ -912,9 +913,9 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm, |
676 |
+ out_len += out_size; |
677 |
+ } |
678 |
+ |
679 |
+- buf_len = out_len + in_len; |
680 |
++ buf_len = (u64) out_len + (u64) in_len; |
681 |
+ if (buf_len > ND_IOCTL_MAX_BUFLEN) { |
682 |
+- dev_dbg(dev, "%s:%s cmd: %s buf_len: %zu > %d\n", __func__, |
683 |
++ dev_dbg(dev, "%s:%s cmd: %s buf_len: %llu > %d\n", __func__, |
684 |
+ dimm_name, cmd_name, buf_len, |
685 |
+ ND_IOCTL_MAX_BUFLEN); |
686 |
+ return -EINVAL; |
687 |
+diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c |
688 |
+index 42abdd2391c9..d6aa59ca68b9 100644 |
689 |
+--- a/drivers/nvdimm/pfn_devs.c |
690 |
++++ b/drivers/nvdimm/pfn_devs.c |
691 |
+@@ -563,6 +563,12 @@ static struct vmem_altmap *__nvdimm_setup_pfn(struct nd_pfn *nd_pfn, |
692 |
+ return altmap; |
693 |
+ } |
694 |
+ |
695 |
++static u64 phys_pmem_align_down(struct nd_pfn *nd_pfn, u64 phys) |
696 |
++{ |
697 |
++ return min_t(u64, PHYS_SECTION_ALIGN_DOWN(phys), |
698 |
++ ALIGN_DOWN(phys, nd_pfn->align)); |
699 |
++} |
700 |
++ |
701 |
+ static int nd_pfn_init(struct nd_pfn *nd_pfn) |
702 |
+ { |
703 |
+ u32 dax_label_reserve = is_nd_dax(&nd_pfn->dev) ? SZ_128K : 0; |
704 |
+@@ -618,13 +624,16 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn) |
705 |
+ start = nsio->res.start; |
706 |
+ size = PHYS_SECTION_ALIGN_UP(start + size) - start; |
707 |
+ if (region_intersects(start, size, IORESOURCE_SYSTEM_RAM, |
708 |
+- IORES_DESC_NONE) == REGION_MIXED) { |
709 |
++ IORES_DESC_NONE) == REGION_MIXED |
710 |
++ || !IS_ALIGNED(start + resource_size(&nsio->res), |
711 |
++ nd_pfn->align)) { |
712 |
+ size = resource_size(&nsio->res); |
713 |
+- end_trunc = start + size - PHYS_SECTION_ALIGN_DOWN(start + size); |
714 |
++ end_trunc = start + size - phys_pmem_align_down(nd_pfn, |
715 |
++ start + size); |
716 |
+ } |
717 |
+ |
718 |
+ if (start_pad + end_trunc) |
719 |
+- dev_info(&nd_pfn->dev, "%s section collision, truncate %d bytes\n", |
720 |
++ dev_info(&nd_pfn->dev, "%s alignment collision, truncate %d bytes\n", |
721 |
+ dev_name(&ndns->dev), start_pad + end_trunc); |
722 |
+ |
723 |
+ /* |
724 |
+diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c |
725 |
+index 98eba9127a0b..0c9edc9d7c44 100644 |
726 |
+--- a/drivers/pci/quirks.c |
727 |
++++ b/drivers/pci/quirks.c |
728 |
+@@ -3369,22 +3369,29 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PORT_RIDGE, |
729 |
+ |
730 |
+ static void quirk_chelsio_extend_vpd(struct pci_dev *dev) |
731 |
+ { |
732 |
+- pci_set_vpd_size(dev, 8192); |
733 |
+-} |
734 |
+- |
735 |
+-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x20, quirk_chelsio_extend_vpd); |
736 |
+-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x21, quirk_chelsio_extend_vpd); |
737 |
+-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x22, quirk_chelsio_extend_vpd); |
738 |
+-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x23, quirk_chelsio_extend_vpd); |
739 |
+-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x24, quirk_chelsio_extend_vpd); |
740 |
+-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x25, quirk_chelsio_extend_vpd); |
741 |
+-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x26, quirk_chelsio_extend_vpd); |
742 |
+-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x30, quirk_chelsio_extend_vpd); |
743 |
+-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x31, quirk_chelsio_extend_vpd); |
744 |
+-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x32, quirk_chelsio_extend_vpd); |
745 |
+-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x35, quirk_chelsio_extend_vpd); |
746 |
+-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x36, quirk_chelsio_extend_vpd); |
747 |
+-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x37, quirk_chelsio_extend_vpd); |
748 |
++ int chip = (dev->device & 0xf000) >> 12; |
749 |
++ int func = (dev->device & 0x0f00) >> 8; |
750 |
++ int prod = (dev->device & 0x00ff) >> 0; |
751 |
++ |
752 |
++ /* |
753 |
++ * If this is a T3-based adapter, there's a 1KB VPD area at offset |
754 |
++ * 0xc00 which contains the preferred VPD values. If this is a T4 or |
755 |
++ * later based adapter, the special VPD is at offset 0x400 for the |
756 |
++ * Physical Functions (the SR-IOV Virtual Functions have no VPD |
757 |
++ * Capabilities). The PCI VPD Access core routines will normally |
758 |
++ * compute the size of the VPD by parsing the VPD Data Structure at |
759 |
++ * offset 0x000. This will result in silent failures when attempting |
760 |
++ * to accesses these other VPD areas which are beyond those computed |
761 |
++ * limits. |
762 |
++ */ |
763 |
++ if (chip == 0x0 && prod >= 0x20) |
764 |
++ pci_set_vpd_size(dev, 8192); |
765 |
++ else if (chip >= 0x4 && func < 0x8) |
766 |
++ pci_set_vpd_size(dev, 2048); |
767 |
++} |
768 |
++ |
769 |
++DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, PCI_ANY_ID, |
770 |
++ quirk_chelsio_extend_vpd); |
771 |
+ |
772 |
+ #ifdef CONFIG_ACPI |
773 |
+ /* |
774 |
+diff --git a/drivers/scsi/ibmvscsi/ibmvfc.h b/drivers/scsi/ibmvscsi/ibmvfc.h |
775 |
+index 9a0696f68f37..b81a53c4a9a8 100644 |
776 |
+--- a/drivers/scsi/ibmvscsi/ibmvfc.h |
777 |
++++ b/drivers/scsi/ibmvscsi/ibmvfc.h |
778 |
+@@ -367,7 +367,7 @@ enum ibmvfc_fcp_rsp_info_codes { |
779 |
+ }; |
780 |
+ |
781 |
+ struct ibmvfc_fcp_rsp_info { |
782 |
+- __be16 reserved; |
783 |
++ u8 reserved[3]; |
784 |
+ u8 rsp_code; |
785 |
+ u8 reserved2[4]; |
786 |
+ }__attribute__((packed, aligned (2))); |
787 |
+diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c |
788 |
+index c05c4f877750..774c97bb1c08 100644 |
789 |
+--- a/drivers/usb/core/quirks.c |
790 |
++++ b/drivers/usb/core/quirks.c |
791 |
+@@ -225,6 +225,9 @@ static const struct usb_device_id usb_quirk_list[] = { |
792 |
+ { USB_DEVICE(0x1a0a, 0x0200), .driver_info = |
793 |
+ USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL }, |
794 |
+ |
795 |
++ /* Corsair K70 RGB */ |
796 |
++ { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT }, |
797 |
++ |
798 |
+ /* Corsair Strafe RGB */ |
799 |
+ { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT }, |
800 |
+ |
801 |
+diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c |
802 |
+index f483c3b1e971..26efe8c7535f 100644 |
803 |
+--- a/drivers/usb/dwc3/gadget.c |
804 |
++++ b/drivers/usb/dwc3/gadget.c |
805 |
+@@ -2528,6 +2528,8 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) |
806 |
+ break; |
807 |
+ } |
808 |
+ |
809 |
++ dwc->eps[1]->endpoint.maxpacket = dwc->gadget.ep0->maxpacket; |
810 |
++ |
811 |
+ /* Enable USB2 LPM Capability */ |
812 |
+ |
813 |
+ if ((dwc->revision > DWC3_REVISION_194A) && |
814 |
+diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c |
815 |
+index d90bf57ba30e..48f52138bb1a 100644 |
816 |
+--- a/drivers/usb/gadget/function/f_fs.c |
817 |
++++ b/drivers/usb/gadget/function/f_fs.c |
818 |
+@@ -2956,10 +2956,8 @@ static int _ffs_func_bind(struct usb_configuration *c, |
819 |
+ struct ffs_data *ffs = func->ffs; |
820 |
+ |
821 |
+ const int full = !!func->ffs->fs_descs_count; |
822 |
+- const int high = gadget_is_dualspeed(func->gadget) && |
823 |
+- func->ffs->hs_descs_count; |
824 |
+- const int super = gadget_is_superspeed(func->gadget) && |
825 |
+- func->ffs->ss_descs_count; |
826 |
++ const int high = !!func->ffs->hs_descs_count; |
827 |
++ const int super = !!func->ffs->ss_descs_count; |
828 |
+ |
829 |
+ int fs_len, hs_len, ss_len, ret, i; |
830 |
+ struct ffs_ep *eps_ptr; |
831 |
+diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c |
832 |
+index f6c7a2744e5c..a646ca3b0d00 100644 |
833 |
+--- a/drivers/usb/host/ohci-hcd.c |
834 |
++++ b/drivers/usb/host/ohci-hcd.c |
835 |
+@@ -73,6 +73,7 @@ static const char hcd_name [] = "ohci_hcd"; |
836 |
+ |
837 |
+ #define STATECHANGE_DELAY msecs_to_jiffies(300) |
838 |
+ #define IO_WATCHDOG_DELAY msecs_to_jiffies(275) |
839 |
++#define IO_WATCHDOG_OFF 0xffffff00 |
840 |
+ |
841 |
+ #include "ohci.h" |
842 |
+ #include "pci-quirks.h" |
843 |
+@@ -230,7 +231,7 @@ static int ohci_urb_enqueue ( |
844 |
+ } |
845 |
+ |
846 |
+ /* Start up the I/O watchdog timer, if it's not running */ |
847 |
+- if (!timer_pending(&ohci->io_watchdog) && |
848 |
++ if (ohci->prev_frame_no == IO_WATCHDOG_OFF && |
849 |
+ list_empty(&ohci->eds_in_use) && |
850 |
+ !(ohci->flags & OHCI_QUIRK_QEMU)) { |
851 |
+ ohci->prev_frame_no = ohci_frame_no(ohci); |
852 |
+@@ -501,6 +502,7 @@ static int ohci_init (struct ohci_hcd *ohci) |
853 |
+ |
854 |
+ setup_timer(&ohci->io_watchdog, io_watchdog_func, |
855 |
+ (unsigned long) ohci); |
856 |
++ ohci->prev_frame_no = IO_WATCHDOG_OFF; |
857 |
+ |
858 |
+ ohci->hcca = dma_alloc_coherent (hcd->self.controller, |
859 |
+ sizeof(*ohci->hcca), &ohci->hcca_dma, GFP_KERNEL); |
860 |
+@@ -730,7 +732,7 @@ static void io_watchdog_func(unsigned long _ohci) |
861 |
+ u32 head; |
862 |
+ struct ed *ed; |
863 |
+ struct td *td, *td_start, *td_next; |
864 |
+- unsigned frame_no; |
865 |
++ unsigned frame_no, prev_frame_no = IO_WATCHDOG_OFF; |
866 |
+ unsigned long flags; |
867 |
+ |
868 |
+ spin_lock_irqsave(&ohci->lock, flags); |
869 |
+@@ -835,7 +837,7 @@ static void io_watchdog_func(unsigned long _ohci) |
870 |
+ } |
871 |
+ } |
872 |
+ if (!list_empty(&ohci->eds_in_use)) { |
873 |
+- ohci->prev_frame_no = frame_no; |
874 |
++ prev_frame_no = frame_no; |
875 |
+ ohci->prev_wdh_cnt = ohci->wdh_cnt; |
876 |
+ ohci->prev_donehead = ohci_readl(ohci, |
877 |
+ &ohci->regs->donehead); |
878 |
+@@ -845,6 +847,7 @@ static void io_watchdog_func(unsigned long _ohci) |
879 |
+ } |
880 |
+ |
881 |
+ done: |
882 |
++ ohci->prev_frame_no = prev_frame_no; |
883 |
+ spin_unlock_irqrestore(&ohci->lock, flags); |
884 |
+ } |
885 |
+ |
886 |
+@@ -973,6 +976,7 @@ static void ohci_stop (struct usb_hcd *hcd) |
887 |
+ if (quirk_nec(ohci)) |
888 |
+ flush_work(&ohci->nec_work); |
889 |
+ del_timer_sync(&ohci->io_watchdog); |
890 |
++ ohci->prev_frame_no = IO_WATCHDOG_OFF; |
891 |
+ |
892 |
+ ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); |
893 |
+ ohci_usb_reset(ohci); |
894 |
+diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c |
895 |
+index ed678c17c4ea..798b2d25dda9 100644 |
896 |
+--- a/drivers/usb/host/ohci-hub.c |
897 |
++++ b/drivers/usb/host/ohci-hub.c |
898 |
+@@ -310,8 +310,10 @@ static int ohci_bus_suspend (struct usb_hcd *hcd) |
899 |
+ rc = ohci_rh_suspend (ohci, 0); |
900 |
+ spin_unlock_irq (&ohci->lock); |
901 |
+ |
902 |
+- if (rc == 0) |
903 |
++ if (rc == 0) { |
904 |
+ del_timer_sync(&ohci->io_watchdog); |
905 |
++ ohci->prev_frame_no = IO_WATCHDOG_OFF; |
906 |
++ } |
907 |
+ return rc; |
908 |
+ } |
909 |
+ |
910 |
+diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c |
911 |
+index 641fed609911..24edb7674710 100644 |
912 |
+--- a/drivers/usb/host/ohci-q.c |
913 |
++++ b/drivers/usb/host/ohci-q.c |
914 |
+@@ -1018,6 +1018,8 @@ static void finish_unlinks(struct ohci_hcd *ohci) |
915 |
+ * have modified this list. normally it's just prepending |
916 |
+ * entries (which we'd ignore), but paranoia won't hurt. |
917 |
+ */ |
918 |
++ *last = ed->ed_next; |
919 |
++ ed->ed_next = NULL; |
920 |
+ modified = 0; |
921 |
+ |
922 |
+ /* unlink urbs as requested, but rescan the list after |
923 |
+@@ -1076,21 +1078,22 @@ static void finish_unlinks(struct ohci_hcd *ohci) |
924 |
+ goto rescan_this; |
925 |
+ |
926 |
+ /* |
927 |
+- * If no TDs are queued, take ED off the ed_rm_list. |
928 |
++ * If no TDs are queued, ED is now idle. |
929 |
+ * Otherwise, if the HC is running, reschedule. |
930 |
+- * If not, leave it on the list for further dequeues. |
931 |
++ * If the HC isn't running, add ED back to the |
932 |
++ * start of the list for later processing. |
933 |
+ */ |
934 |
+ if (list_empty(&ed->td_list)) { |
935 |
+- *last = ed->ed_next; |
936 |
+- ed->ed_next = NULL; |
937 |
+ ed->state = ED_IDLE; |
938 |
+ list_del(&ed->in_use_list); |
939 |
+ } else if (ohci->rh_state == OHCI_RH_RUNNING) { |
940 |
+- *last = ed->ed_next; |
941 |
+- ed->ed_next = NULL; |
942 |
+ ed_schedule(ohci, ed); |
943 |
+ } else { |
944 |
+- last = &ed->ed_next; |
945 |
++ ed->ed_next = ohci->ed_rm_list; |
946 |
++ ohci->ed_rm_list = ed; |
947 |
++ /* Don't loop on the same ED */ |
948 |
++ if (last == &ohci->ed_rm_list) |
949 |
++ last = &ed->ed_next; |
950 |
+ } |
951 |
+ |
952 |
+ if (modified) |
953 |
+diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c |
954 |
+index 9ca595632f17..c5e3032a4d6b 100644 |
955 |
+--- a/drivers/usb/misc/ldusb.c |
956 |
++++ b/drivers/usb/misc/ldusb.c |
957 |
+@@ -46,6 +46,9 @@ |
958 |
+ #define USB_DEVICE_ID_LD_MICROCASSYTIME 0x1033 /* USB Product ID of Micro-CASSY Time (reserved) */ |
959 |
+ #define USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE 0x1035 /* USB Product ID of Micro-CASSY Temperature */ |
960 |
+ #define USB_DEVICE_ID_LD_MICROCASSYPH 0x1038 /* USB Product ID of Micro-CASSY pH */ |
961 |
++#define USB_DEVICE_ID_LD_POWERANALYSERCASSY 0x1040 /* USB Product ID of Power Analyser CASSY */ |
962 |
++#define USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY 0x1042 /* USB Product ID of Converter Controller CASSY */ |
963 |
++#define USB_DEVICE_ID_LD_MACHINETESTCASSY 0x1043 /* USB Product ID of Machine Test CASSY */ |
964 |
+ #define USB_DEVICE_ID_LD_JWM 0x1080 /* USB Product ID of Joule and Wattmeter */ |
965 |
+ #define USB_DEVICE_ID_LD_DMMP 0x1081 /* USB Product ID of Digital Multimeter P (reserved) */ |
966 |
+ #define USB_DEVICE_ID_LD_UMIP 0x1090 /* USB Product ID of UMI P */ |
967 |
+@@ -88,6 +91,9 @@ static const struct usb_device_id ld_usb_table[] = { |
968 |
+ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) }, |
969 |
+ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) }, |
970 |
+ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) }, |
971 |
++ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERANALYSERCASSY) }, |
972 |
++ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CONVERTERCONTROLLERCASSY) }, |
973 |
++ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETESTCASSY) }, |
974 |
+ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, |
975 |
+ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, |
976 |
+ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, |
977 |
+diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c |
978 |
+index 55c624f2a8c0..43033895e8f6 100644 |
979 |
+--- a/drivers/usb/musb/musb_host.c |
980 |
++++ b/drivers/usb/musb/musb_host.c |
981 |
+@@ -418,13 +418,7 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb, |
982 |
+ } |
983 |
+ } |
984 |
+ |
985 |
+- /* |
986 |
+- * The pipe must be broken if current urb->status is set, so don't |
987 |
+- * start next urb. |
988 |
+- * TODO: to minimize the risk of regression, only check urb->status |
989 |
+- * for RX, until we have a test case to understand the behavior of TX. |
990 |
+- */ |
991 |
+- if ((!status || !is_in) && qh && qh->is_ready) { |
992 |
++ if (qh != NULL && qh->is_ready) { |
993 |
+ musb_dbg(musb, "... next ep%d %cX urb %p", |
994 |
+ hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh)); |
995 |
+ musb_start_urb(musb, is_in, qh); |
996 |
+diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c |
997 |
+index 6c6a3a8df07a..968ade5a35f5 100644 |
998 |
+--- a/drivers/usb/renesas_usbhs/fifo.c |
999 |
++++ b/drivers/usb/renesas_usbhs/fifo.c |
1000 |
+@@ -1001,6 +1001,10 @@ static int usbhsf_dma_prepare_pop_with_usb_dmac(struct usbhs_pkt *pkt, |
1001 |
+ if ((uintptr_t)pkt->buf & (USBHS_USB_DMAC_XFER_SIZE - 1)) |
1002 |
+ goto usbhsf_pio_prepare_pop; |
1003 |
+ |
1004 |
++ /* return at this time if the pipe is running */ |
1005 |
++ if (usbhs_pipe_is_running(pipe)) |
1006 |
++ return 0; |
1007 |
++ |
1008 |
+ usbhs_pipe_config_change_bfre(pipe, 1); |
1009 |
+ |
1010 |
+ ret = usbhsf_fifo_select(pipe, fifo, 0); |
1011 |
+@@ -1191,6 +1195,7 @@ static int usbhsf_dma_pop_done_with_usb_dmac(struct usbhs_pkt *pkt, |
1012 |
+ usbhsf_fifo_clear(pipe, fifo); |
1013 |
+ pkt->actual = usbhs_dma_calc_received_size(pkt, chan, rcv_len); |
1014 |
+ |
1015 |
++ usbhs_pipe_running(pipe, 0); |
1016 |
+ usbhsf_dma_stop(pipe, fifo); |
1017 |
+ usbhsf_dma_unmap(pkt); |
1018 |
+ usbhsf_fifo_unselect(pipe, pipe->fifo); |
1019 |
+diff --git a/fs/dax.c b/fs/dax.c |
1020 |
+index 800748f10b3d..71f87d74afe1 100644 |
1021 |
+--- a/fs/dax.c |
1022 |
++++ b/fs/dax.c |
1023 |
+@@ -785,6 +785,7 @@ int dax_writeback_mapping_range(struct address_space *mapping, |
1024 |
+ if (ret < 0) |
1025 |
+ return ret; |
1026 |
+ } |
1027 |
++ start_index = indices[pvec.nr - 1] + 1; |
1028 |
+ } |
1029 |
+ return 0; |
1030 |
+ } |
1031 |
+diff --git a/include/linux/dax.h b/include/linux/dax.h |
1032 |
+index add6c4bc568f..ed9cf2f5cd06 100644 |
1033 |
+--- a/include/linux/dax.h |
1034 |
++++ b/include/linux/dax.h |
1035 |
+@@ -61,11 +61,6 @@ static inline int dax_pmd_fault(struct vm_area_struct *vma, unsigned long addr, |
1036 |
+ int dax_pfn_mkwrite(struct vm_area_struct *, struct vm_fault *); |
1037 |
+ #define dax_mkwrite(vma, vmf, gb) dax_fault(vma, vmf, gb) |
1038 |
+ |
1039 |
+-static inline bool vma_is_dax(struct vm_area_struct *vma) |
1040 |
+-{ |
1041 |
+- return vma->vm_file && IS_DAX(vma->vm_file->f_mapping->host); |
1042 |
+-} |
1043 |
+- |
1044 |
+ static inline bool dax_mapping(struct address_space *mapping) |
1045 |
+ { |
1046 |
+ return mapping->host && IS_DAX(mapping->host); |
1047 |
+diff --git a/include/linux/fs.h b/include/linux/fs.h |
1048 |
+index d705ae084edd..745ea1b2e02c 100644 |
1049 |
+--- a/include/linux/fs.h |
1050 |
++++ b/include/linux/fs.h |
1051 |
+@@ -18,6 +18,7 @@ |
1052 |
+ #include <linux/bug.h> |
1053 |
+ #include <linux/mutex.h> |
1054 |
+ #include <linux/rwsem.h> |
1055 |
++#include <linux/mm_types.h> |
1056 |
+ #include <linux/capability.h> |
1057 |
+ #include <linux/semaphore.h> |
1058 |
+ #include <linux/fiemap.h> |
1059 |
+@@ -3033,6 +3034,25 @@ static inline bool io_is_direct(struct file *filp) |
1060 |
+ return (filp->f_flags & O_DIRECT) || IS_DAX(filp->f_mapping->host); |
1061 |
+ } |
1062 |
+ |
1063 |
++static inline bool vma_is_dax(struct vm_area_struct *vma) |
1064 |
++{ |
1065 |
++ return vma->vm_file && IS_DAX(vma->vm_file->f_mapping->host); |
1066 |
++} |
1067 |
++ |
1068 |
++static inline bool vma_is_fsdax(struct vm_area_struct *vma) |
1069 |
++{ |
1070 |
++ struct inode *inode; |
1071 |
++ |
1072 |
++ if (!vma->vm_file) |
1073 |
++ return false; |
1074 |
++ if (!vma_is_dax(vma)) |
1075 |
++ return false; |
1076 |
++ inode = file_inode(vma->vm_file); |
1077 |
++ if (inode->i_mode == S_IFCHR) |
1078 |
++ return false; /* device-dax */ |
1079 |
++ return true; |
1080 |
++} |
1081 |
++ |
1082 |
+ static inline int iocb_flags(struct file *file) |
1083 |
+ { |
1084 |
+ int res = 0; |
1085 |
+diff --git a/include/linux/kernel.h b/include/linux/kernel.h |
1086 |
+index bc6ed52a39b9..61054f12be7c 100644 |
1087 |
+--- a/include/linux/kernel.h |
1088 |
++++ b/include/linux/kernel.h |
1089 |
+@@ -46,6 +46,7 @@ |
1090 |
+ #define REPEAT_BYTE(x) ((~0ul / 0xff) * (x)) |
1091 |
+ |
1092 |
+ #define ALIGN(x, a) __ALIGN_KERNEL((x), (a)) |
1093 |
++#define ALIGN_DOWN(x, a) __ALIGN_KERNEL((x) - ((a) - 1), (a)) |
1094 |
+ #define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask)) |
1095 |
+ #define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a))) |
1096 |
+ #define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) |
1097 |
+diff --git a/include/linux/mm.h b/include/linux/mm.h |
1098 |
+index 2217e2f18247..8e506783631b 100644 |
1099 |
+--- a/include/linux/mm.h |
1100 |
++++ b/include/linux/mm.h |
1101 |
+@@ -1288,6 +1288,19 @@ long __get_user_pages_unlocked(struct task_struct *tsk, struct mm_struct *mm, |
1102 |
+ struct page **pages, unsigned int gup_flags); |
1103 |
+ long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages, |
1104 |
+ struct page **pages, unsigned int gup_flags); |
1105 |
++#ifdef CONFIG_FS_DAX |
1106 |
++long get_user_pages_longterm(unsigned long start, unsigned long nr_pages, |
1107 |
++ unsigned int gup_flags, struct page **pages, |
1108 |
++ struct vm_area_struct **vmas); |
1109 |
++#else |
1110 |
++static inline long get_user_pages_longterm(unsigned long start, |
1111 |
++ unsigned long nr_pages, unsigned int gup_flags, |
1112 |
++ struct page **pages, struct vm_area_struct **vmas) |
1113 |
++{ |
1114 |
++ return get_user_pages(start, nr_pages, gup_flags, pages, vmas); |
1115 |
++} |
1116 |
++#endif /* CONFIG_FS_DAX */ |
1117 |
++ |
1118 |
+ int get_user_pages_fast(unsigned long start, int nr_pages, int write, |
1119 |
+ struct page **pages); |
1120 |
+ |
1121 |
+diff --git a/kernel/memremap.c b/kernel/memremap.c |
1122 |
+index 426547a21a0c..f61a8c387c3e 100644 |
1123 |
+--- a/kernel/memremap.c |
1124 |
++++ b/kernel/memremap.c |
1125 |
+@@ -194,7 +194,7 @@ void put_zone_device_page(struct page *page) |
1126 |
+ } |
1127 |
+ EXPORT_SYMBOL(put_zone_device_page); |
1128 |
+ |
1129 |
+-static void pgmap_radix_release(struct resource *res) |
1130 |
++static void pgmap_radix_release(struct resource *res, resource_size_t end_key) |
1131 |
+ { |
1132 |
+ resource_size_t key, align_start, align_size, align_end; |
1133 |
+ |
1134 |
+@@ -203,8 +203,11 @@ static void pgmap_radix_release(struct resource *res) |
1135 |
+ align_end = align_start + align_size - 1; |
1136 |
+ |
1137 |
+ mutex_lock(&pgmap_lock); |
1138 |
+- for (key = res->start; key <= res->end; key += SECTION_SIZE) |
1139 |
++ for (key = res->start; key <= res->end; key += SECTION_SIZE) { |
1140 |
++ if (key >= end_key) |
1141 |
++ break; |
1142 |
+ radix_tree_delete(&pgmap_radix, key >> PA_SECTION_SHIFT); |
1143 |
++ } |
1144 |
+ mutex_unlock(&pgmap_lock); |
1145 |
+ } |
1146 |
+ |
1147 |
+@@ -255,7 +258,7 @@ static void devm_memremap_pages_release(struct device *dev, void *data) |
1148 |
+ unlock_device_hotplug(); |
1149 |
+ |
1150 |
+ untrack_pfn(NULL, PHYS_PFN(align_start), align_size); |
1151 |
+- pgmap_radix_release(res); |
1152 |
++ pgmap_radix_release(res, -1); |
1153 |
+ dev_WARN_ONCE(dev, pgmap->altmap && pgmap->altmap->alloc, |
1154 |
+ "%s: failed to free all reserved pages\n", __func__); |
1155 |
+ } |
1156 |
+@@ -289,7 +292,7 @@ struct dev_pagemap *find_dev_pagemap(resource_size_t phys) |
1157 |
+ void *devm_memremap_pages(struct device *dev, struct resource *res, |
1158 |
+ struct percpu_ref *ref, struct vmem_altmap *altmap) |
1159 |
+ { |
1160 |
+- resource_size_t key, align_start, align_size, align_end; |
1161 |
++ resource_size_t key = 0, align_start, align_size, align_end; |
1162 |
+ pgprot_t pgprot = PAGE_KERNEL; |
1163 |
+ struct dev_pagemap *pgmap; |
1164 |
+ struct page_map *page_map; |
1165 |
+@@ -392,7 +395,7 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, |
1166 |
+ untrack_pfn(NULL, PHYS_PFN(align_start), align_size); |
1167 |
+ err_pfn_remap: |
1168 |
+ err_radix: |
1169 |
+- pgmap_radix_release(res); |
1170 |
++ pgmap_radix_release(res, key); |
1171 |
+ devres_free(page_map); |
1172 |
+ return ERR_PTR(error); |
1173 |
+ } |
1174 |
+diff --git a/mm/frame_vector.c b/mm/frame_vector.c |
1175 |
+index db77dcb38afd..375a103d7a56 100644 |
1176 |
+--- a/mm/frame_vector.c |
1177 |
++++ b/mm/frame_vector.c |
1178 |
+@@ -52,6 +52,18 @@ int get_vaddr_frames(unsigned long start, unsigned int nr_frames, |
1179 |
+ ret = -EFAULT; |
1180 |
+ goto out; |
1181 |
+ } |
1182 |
++ |
1183 |
++ /* |
1184 |
++ * While get_vaddr_frames() could be used for transient (kernel |
1185 |
++ * controlled lifetime) pinning of memory pages all current |
1186 |
++ * users establish long term (userspace controlled lifetime) |
1187 |
++ * page pinning. Treat get_vaddr_frames() like |
1188 |
++ * get_user_pages_longterm() and disallow it for filesystem-dax |
1189 |
++ * mappings. |
1190 |
++ */ |
1191 |
++ if (vma_is_fsdax(vma)) |
1192 |
++ return -EOPNOTSUPP; |
1193 |
++ |
1194 |
+ if (!(vma->vm_flags & (VM_IO | VM_PFNMAP))) { |
1195 |
+ vec->got_ref = true; |
1196 |
+ vec->is_pfns = false; |
1197 |
+diff --git a/mm/gup.c b/mm/gup.c |
1198 |
+index c63a0341ae38..6c3b4e822946 100644 |
1199 |
+--- a/mm/gup.c |
1200 |
++++ b/mm/gup.c |
1201 |
+@@ -982,6 +982,70 @@ long get_user_pages(unsigned long start, unsigned long nr_pages, |
1202 |
+ } |
1203 |
+ EXPORT_SYMBOL(get_user_pages); |
1204 |
+ |
1205 |
++#ifdef CONFIG_FS_DAX |
1206 |
++/* |
1207 |
++ * This is the same as get_user_pages() in that it assumes we are |
1208 |
++ * operating on the current task's mm, but it goes further to validate |
1209 |
++ * that the vmas associated with the address range are suitable for |
1210 |
++ * longterm elevated page reference counts. For example, filesystem-dax |
1211 |
++ * mappings are subject to the lifetime enforced by the filesystem and |
1212 |
++ * we need guarantees that longterm users like RDMA and V4L2 only |
1213 |
++ * establish mappings that have a kernel enforced revocation mechanism. |
1214 |
++ * |
1215 |
++ * "longterm" == userspace controlled elevated page count lifetime. |
1216 |
++ * Contrast this to iov_iter_get_pages() usages which are transient. |
1217 |
++ */ |
1218 |
++long get_user_pages_longterm(unsigned long start, unsigned long nr_pages, |
1219 |
++ unsigned int gup_flags, struct page **pages, |
1220 |
++ struct vm_area_struct **vmas_arg) |
1221 |
++{ |
1222 |
++ struct vm_area_struct **vmas = vmas_arg; |
1223 |
++ struct vm_area_struct *vma_prev = NULL; |
1224 |
++ long rc, i; |
1225 |
++ |
1226 |
++ if (!pages) |
1227 |
++ return -EINVAL; |
1228 |
++ |
1229 |
++ if (!vmas) { |
1230 |
++ vmas = kcalloc(nr_pages, sizeof(struct vm_area_struct *), |
1231 |
++ GFP_KERNEL); |
1232 |
++ if (!vmas) |
1233 |
++ return -ENOMEM; |
1234 |
++ } |
1235 |
++ |
1236 |
++ rc = get_user_pages(start, nr_pages, gup_flags, pages, vmas); |
1237 |
++ |
1238 |
++ for (i = 0; i < rc; i++) { |
1239 |
++ struct vm_area_struct *vma = vmas[i]; |
1240 |
++ |
1241 |
++ if (vma == vma_prev) |
1242 |
++ continue; |
1243 |
++ |
1244 |
++ vma_prev = vma; |
1245 |
++ |
1246 |
++ if (vma_is_fsdax(vma)) |
1247 |
++ break; |
1248 |
++ } |
1249 |
++ |
1250 |
++ /* |
1251 |
++ * Either get_user_pages() failed, or the vma validation |
1252 |
++ * succeeded, in either case we don't need to put_page() before |
1253 |
++ * returning. |
1254 |
++ */ |
1255 |
++ if (i >= rc) |
1256 |
++ goto out; |
1257 |
++ |
1258 |
++ for (i = 0; i < rc; i++) |
1259 |
++ put_page(pages[i]); |
1260 |
++ rc = -EOPNOTSUPP; |
1261 |
++out: |
1262 |
++ if (vmas != vmas_arg) |
1263 |
++ kfree(vmas); |
1264 |
++ return rc; |
1265 |
++} |
1266 |
++EXPORT_SYMBOL(get_user_pages_longterm); |
1267 |
++#endif /* CONFIG_FS_DAX */ |
1268 |
++ |
1269 |
+ /** |
1270 |
+ * populate_vma_page_range() - populate a range of pages in the vma. |
1271 |
+ * @vma: target vma |
1272 |
+diff --git a/mm/memory.c b/mm/memory.c |
1273 |
+index e2e68767a373..d2db2c4eb0a4 100644 |
1274 |
+--- a/mm/memory.c |
1275 |
++++ b/mm/memory.c |
1276 |
+@@ -2848,6 +2848,17 @@ static int __do_fault(struct fault_env *fe, pgoff_t pgoff, |
1277 |
+ return ret; |
1278 |
+ } |
1279 |
+ |
1280 |
++/* |
1281 |
++ * The ordering of these checks is important for pmds with _PAGE_DEVMAP set. |
1282 |
++ * If we check pmd_trans_unstable() first we will trip the bad_pmd() check |
1283 |
++ * inside of pmd_none_or_trans_huge_or_clear_bad(). This will end up correctly |
1284 |
++ * returning 1 but not before it spams dmesg with the pmd_clear_bad() output. |
1285 |
++ */ |
1286 |
++static int pmd_devmap_trans_unstable(pmd_t *pmd) |
1287 |
++{ |
1288 |
++ return pmd_devmap(*pmd) || pmd_trans_unstable(pmd); |
1289 |
++} |
1290 |
++ |
1291 |
+ static int pte_alloc_one_map(struct fault_env *fe) |
1292 |
+ { |
1293 |
+ struct vm_area_struct *vma = fe->vma; |
1294 |
+@@ -2871,18 +2882,27 @@ static int pte_alloc_one_map(struct fault_env *fe) |
1295 |
+ map_pte: |
1296 |
+ /* |
1297 |
+ * If a huge pmd materialized under us just retry later. Use |
1298 |
+- * pmd_trans_unstable() instead of pmd_trans_huge() to ensure the pmd |
1299 |
+- * didn't become pmd_trans_huge under us and then back to pmd_none, as |
1300 |
+- * a result of MADV_DONTNEED running immediately after a huge pmd fault |
1301 |
+- * in a different thread of this mm, in turn leading to a misleading |
1302 |
+- * pmd_trans_huge() retval. All we have to ensure is that it is a |
1303 |
+- * regular pmd that we can walk with pte_offset_map() and we can do that |
1304 |
+- * through an atomic read in C, which is what pmd_trans_unstable() |
1305 |
+- * provides. |
1306 |
++ * pmd_trans_unstable() via pmd_devmap_trans_unstable() instead of |
1307 |
++ * pmd_trans_huge() to ensure the pmd didn't become pmd_trans_huge |
1308 |
++ * under us and then back to pmd_none, as a result of MADV_DONTNEED |
1309 |
++ * running immediately after a huge pmd fault in a different thread of |
1310 |
++ * this mm, in turn leading to a misleading pmd_trans_huge() retval. |
1311 |
++ * All we have to ensure is that it is a regular pmd that we can walk |
1312 |
++ * with pte_offset_map() and we can do that through an atomic read in |
1313 |
++ * C, which is what pmd_trans_unstable() provides. |
1314 |
+ */ |
1315 |
+- if (pmd_trans_unstable(fe->pmd) || pmd_devmap(*fe->pmd)) |
1316 |
++ if (pmd_devmap_trans_unstable(fe->pmd)) |
1317 |
+ return VM_FAULT_NOPAGE; |
1318 |
+ |
1319 |
++ /* |
1320 |
++ * At this point we know that our vmf->pmd points to a page of ptes |
1321 |
++ * and it cannot become pmd_none(), pmd_devmap() or pmd_trans_huge() |
1322 |
++ * for the duration of the fault. If a racing MADV_DONTNEED runs and |
1323 |
++ * we zap the ptes pointed to by our vmf->pmd, the vmf->ptl will still |
1324 |
++ * be valid and we will re-check to make sure the vmf->pte isn't |
1325 |
++ * pte_none() under vmf->ptl protection when we return to |
1326 |
++ * alloc_set_pte(). |
1327 |
++ */ |
1328 |
+ fe->pte = pte_offset_map_lock(vma->vm_mm, fe->pmd, fe->address, |
1329 |
+ &fe->ptl); |
1330 |
+ return 0; |
1331 |
+@@ -3456,7 +3476,7 @@ static int handle_pte_fault(struct fault_env *fe) |
1332 |
+ fe->pte = NULL; |
1333 |
+ } else { |
1334 |
+ /* See comment in pte_alloc_one_map() */ |
1335 |
+- if (pmd_trans_unstable(fe->pmd) || pmd_devmap(*fe->pmd)) |
1336 |
++ if (pmd_devmap_trans_unstable(fe->pmd)) |
1337 |
+ return 0; |
1338 |
+ /* |
1339 |
+ * A regular pmd is established and it can't morph into a huge |
1340 |
+diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c |
1341 |
+index bf62fa487262..fd1e6b8562e0 100644 |
1342 |
+--- a/net/ipv4/ip_sockglue.c |
1343 |
++++ b/net/ipv4/ip_sockglue.c |
1344 |
+@@ -1552,10 +1552,7 @@ int ip_getsockopt(struct sock *sk, int level, |
1345 |
+ if (get_user(len, optlen)) |
1346 |
+ return -EFAULT; |
1347 |
+ |
1348 |
+- lock_sock(sk); |
1349 |
+- err = nf_getsockopt(sk, PF_INET, optname, optval, |
1350 |
+- &len); |
1351 |
+- release_sock(sk); |
1352 |
++ err = nf_getsockopt(sk, PF_INET, optname, optval, &len); |
1353 |
+ if (err >= 0) |
1354 |
+ err = put_user(len, optlen); |
1355 |
+ return err; |
1356 |
+@@ -1587,9 +1584,7 @@ int compat_ip_getsockopt(struct sock *sk, int level, int optname, |
1357 |
+ if (get_user(len, optlen)) |
1358 |
+ return -EFAULT; |
1359 |
+ |
1360 |
+- lock_sock(sk); |
1361 |
+ err = compat_nf_getsockopt(sk, PF_INET, optname, optval, &len); |
1362 |
+- release_sock(sk); |
1363 |
+ if (err >= 0) |
1364 |
+ err = put_user(len, optlen); |
1365 |
+ return err; |
1366 |
+diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c |
1367 |
+index 493a32f6a5f2..c66b9a87e995 100644 |
1368 |
+--- a/net/ipv6/ipv6_sockglue.c |
1369 |
++++ b/net/ipv6/ipv6_sockglue.c |
1370 |
+@@ -1343,10 +1343,7 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname, |
1371 |
+ if (get_user(len, optlen)) |
1372 |
+ return -EFAULT; |
1373 |
+ |
1374 |
+- lock_sock(sk); |
1375 |
+- err = nf_getsockopt(sk, PF_INET6, optname, optval, |
1376 |
+- &len); |
1377 |
+- release_sock(sk); |
1378 |
++ err = nf_getsockopt(sk, PF_INET6, optname, optval, &len); |
1379 |
+ if (err >= 0) |
1380 |
+ err = put_user(len, optlen); |
1381 |
+ } |
1382 |
+@@ -1385,10 +1382,7 @@ int compat_ipv6_getsockopt(struct sock *sk, int level, int optname, |
1383 |
+ if (get_user(len, optlen)) |
1384 |
+ return -EFAULT; |
1385 |
+ |
1386 |
+- lock_sock(sk); |
1387 |
+- err = compat_nf_getsockopt(sk, PF_INET6, |
1388 |
+- optname, optval, &len); |
1389 |
+- release_sock(sk); |
1390 |
++ err = compat_nf_getsockopt(sk, PF_INET6, optname, optval, &len); |
1391 |
+ if (err >= 0) |
1392 |
+ err = put_user(len, optlen); |
1393 |
+ } |
1394 |
+diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c |
1395 |
+index 07001b6d36cc..dee60428c78c 100644 |
1396 |
+--- a/net/mac80211/cfg.c |
1397 |
++++ b/net/mac80211/cfg.c |
1398 |
+@@ -2792,7 +2792,7 @@ cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon) |
1399 |
+ } |
1400 |
+ if (beacon->probe_resp_len) { |
1401 |
+ new_beacon->probe_resp_len = beacon->probe_resp_len; |
1402 |
+- beacon->probe_resp = pos; |
1403 |
++ new_beacon->probe_resp = pos; |
1404 |
+ memcpy(pos, beacon->probe_resp, beacon->probe_resp_len); |
1405 |
+ pos += beacon->probe_resp_len; |
1406 |
+ } |