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: 4.8.11/, 4.8.12/
Date: Mon, 05 Dec 2016 14:03:46
Message-Id: 1480946595.ddef146e89241cb6516bfa9a92b041b91912c20e.blueness@gentoo
1 commit: ddef146e89241cb6516bfa9a92b041b91912c20e
2 Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
3 AuthorDate: Mon Dec 5 14:03:15 2016 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Mon Dec 5 14:03:15 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/hardened-patchset.git/commit/?id=ddef146e
7
8 grsecurity-3.1-4.8.12-201612031658
9
10 4.8.11/1008_linux-4.8.9.patch | 3120 -------------
11 4.8.11/1009_linux-4.8.10.patch | 4759 --------------------
12 {4.8.11 => 4.8.12}/0000_README | 14 +-
13 {4.8.11 => 4.8.12}/1010_linux-4.8.11.patch | 0
14 4.8.12/1011_linux-4.8.12.patch | 1563 +++++++
15 .../4420_grsecurity-3.1-4.8.12-201612031658.patch | 83 +-
16 {4.8.11 => 4.8.12}/4425_grsec_remove_EI_PAX.patch | 0
17 .../4427_force_XATTR_PAX_tmpfs.patch | 0
18 .../4430_grsec-remove-localversion-grsec.patch | 0
19 {4.8.11 => 4.8.12}/4435_grsec-mute-warnings.patch | 0
20 .../4440_grsec-remove-protected-paths.patch | 0
21 .../4450_grsec-kconfig-default-gids.patch | 0
22 .../4465_selinux-avc_audit-log-curr_ip.patch | 0
23 {4.8.11 => 4.8.12}/4470_disable-compat_vdso.patch | 0
24 {4.8.11 => 4.8.12}/4475_emutramp_default_on.patch | 0
25 15 files changed, 1594 insertions(+), 7945 deletions(-)
26
27 diff --git a/4.8.11/1008_linux-4.8.9.patch b/4.8.11/1008_linux-4.8.9.patch
28 deleted file mode 100644
29 index 2f909eb..0000000
30 --- a/4.8.11/1008_linux-4.8.9.patch
31 +++ /dev/null
32 @@ -1,3120 +0,0 @@
33 -diff --git a/Makefile b/Makefile
34 -index 8f18daa..c1519ab 100644
35 ---- a/Makefile
36 -+++ b/Makefile
37 -@@ -1,6 +1,6 @@
38 - VERSION = 4
39 - PATCHLEVEL = 8
40 --SUBLEVEL = 8
41 -+SUBLEVEL = 9
42 - EXTRAVERSION =
43 - NAME = Psychotic Stoned Sheep
44 -
45 -diff --git a/arch/arc/kernel/time.c b/arch/arc/kernel/time.c
46 -index f927b8d..c10390d 100644
47 ---- a/arch/arc/kernel/time.c
48 -+++ b/arch/arc/kernel/time.c
49 -@@ -152,14 +152,17 @@ static cycle_t arc_read_rtc(struct clocksource *cs)
50 - cycle_t full;
51 - } stamp;
52 -
53 --
54 -- __asm__ __volatile(
55 -- "1: \n"
56 -- " lr %0, [AUX_RTC_LOW] \n"
57 -- " lr %1, [AUX_RTC_HIGH] \n"
58 -- " lr %2, [AUX_RTC_CTRL] \n"
59 -- " bbit0.nt %2, 31, 1b \n"
60 -- : "=r" (stamp.low), "=r" (stamp.high), "=r" (status));
61 -+ /*
62 -+ * hardware has an internal state machine which tracks readout of
63 -+ * low/high and updates the CTRL.status if
64 -+ * - interrupt/exception taken between the two reads
65 -+ * - high increments after low has been read
66 -+ */
67 -+ do {
68 -+ stamp.low = read_aux_reg(AUX_RTC_LOW);
69 -+ stamp.high = read_aux_reg(AUX_RTC_HIGH);
70 -+ status = read_aux_reg(AUX_RTC_CTRL);
71 -+ } while (!(status & _BITUL(31)));
72 -
73 - return stamp.full;
74 - }
75 -diff --git a/arch/arc/mm/dma.c b/arch/arc/mm/dma.c
76 -index 20afc65..9288851 100644
77 ---- a/arch/arc/mm/dma.c
78 -+++ b/arch/arc/mm/dma.c
79 -@@ -105,6 +105,31 @@ static void arc_dma_free(struct device *dev, size_t size, void *vaddr,
80 - __free_pages(page, get_order(size));
81 - }
82 -
83 -+static int arc_dma_mmap(struct device *dev, struct vm_area_struct *vma,
84 -+ void *cpu_addr, dma_addr_t dma_addr, size_t size,
85 -+ unsigned long attrs)
86 -+{
87 -+ unsigned long user_count = vma_pages(vma);
88 -+ unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT;
89 -+ unsigned long pfn = __phys_to_pfn(plat_dma_to_phys(dev, dma_addr));
90 -+ unsigned long off = vma->vm_pgoff;
91 -+ int ret = -ENXIO;
92 -+
93 -+ vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
94 -+
95 -+ if (dma_mmap_from_coherent(dev, vma, cpu_addr, size, &ret))
96 -+ return ret;
97 -+
98 -+ if (off < count && user_count <= (count - off)) {
99 -+ ret = remap_pfn_range(vma, vma->vm_start,
100 -+ pfn + off,
101 -+ user_count << PAGE_SHIFT,
102 -+ vma->vm_page_prot);
103 -+ }
104 -+
105 -+ return ret;
106 -+}
107 -+
108 - /*
109 - * streaming DMA Mapping API...
110 - * CPU accesses page via normal paddr, thus needs to explicitly made
111 -@@ -193,6 +218,7 @@ static int arc_dma_supported(struct device *dev, u64 dma_mask)
112 - struct dma_map_ops arc_dma_ops = {
113 - .alloc = arc_dma_alloc,
114 - .free = arc_dma_free,
115 -+ .mmap = arc_dma_mmap,
116 - .map_page = arc_dma_map_page,
117 - .map_sg = arc_dma_map_sg,
118 - .sync_single_for_device = arc_dma_sync_single_for_device,
119 -diff --git a/arch/s390/hypfs/hypfs_diag.c b/arch/s390/hypfs/hypfs_diag.c
120 -index 28f03ca..794bebb 100644
121 ---- a/arch/s390/hypfs/hypfs_diag.c
122 -+++ b/arch/s390/hypfs/hypfs_diag.c
123 -@@ -363,11 +363,11 @@ static void *diag204_store(void)
124 - static int diag224_get_name_table(void)
125 - {
126 - /* memory must be below 2GB */
127 -- diag224_cpu_names = kmalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
128 -+ diag224_cpu_names = (char *) __get_free_page(GFP_KERNEL | GFP_DMA);
129 - if (!diag224_cpu_names)
130 - return -ENOMEM;
131 - if (diag224(diag224_cpu_names)) {
132 -- kfree(diag224_cpu_names);
133 -+ free_page((unsigned long) diag224_cpu_names);
134 - return -EOPNOTSUPP;
135 - }
136 - EBCASC(diag224_cpu_names + 16, (*diag224_cpu_names + 1) * 16);
137 -@@ -376,7 +376,7 @@ static int diag224_get_name_table(void)
138 -
139 - static void diag224_delete_name_table(void)
140 - {
141 -- kfree(diag224_cpu_names);
142 -+ free_page((unsigned long) diag224_cpu_names);
143 - }
144 -
145 - static int diag224_idx2name(int index, char *name)
146 -diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h
147 -index 0332317..602af69 100644
148 ---- a/arch/s390/include/asm/processor.h
149 -+++ b/arch/s390/include/asm/processor.h
150 -@@ -192,7 +192,7 @@ struct task_struct;
151 - struct mm_struct;
152 - struct seq_file;
153 -
154 --typedef int (*dump_trace_func_t)(void *data, unsigned long address);
155 -+typedef int (*dump_trace_func_t)(void *data, unsigned long address, int reliable);
156 - void dump_trace(dump_trace_func_t func, void *data,
157 - struct task_struct *task, unsigned long sp);
158 -
159 -diff --git a/arch/s390/kernel/dumpstack.c b/arch/s390/kernel/dumpstack.c
160 -index 6693383..518f615 100644
161 ---- a/arch/s390/kernel/dumpstack.c
162 -+++ b/arch/s390/kernel/dumpstack.c
163 -@@ -38,10 +38,10 @@ __dump_trace(dump_trace_func_t func, void *data, unsigned long sp,
164 - if (sp < low || sp > high - sizeof(*sf))
165 - return sp;
166 - sf = (struct stack_frame *) sp;
167 -+ if (func(data, sf->gprs[8], 0))
168 -+ return sp;
169 - /* Follow the backchain. */
170 - while (1) {
171 -- if (func(data, sf->gprs[8]))
172 -- return sp;
173 - low = sp;
174 - sp = sf->back_chain;
175 - if (!sp)
176 -@@ -49,6 +49,8 @@ __dump_trace(dump_trace_func_t func, void *data, unsigned long sp,
177 - if (sp <= low || sp > high - sizeof(*sf))
178 - return sp;
179 - sf = (struct stack_frame *) sp;
180 -+ if (func(data, sf->gprs[8], 1))
181 -+ return sp;
182 - }
183 - /* Zero backchain detected, check for interrupt frame. */
184 - sp = (unsigned long) (sf + 1);
185 -@@ -56,7 +58,7 @@ __dump_trace(dump_trace_func_t func, void *data, unsigned long sp,
186 - return sp;
187 - regs = (struct pt_regs *) sp;
188 - if (!user_mode(regs)) {
189 -- if (func(data, regs->psw.addr))
190 -+ if (func(data, regs->psw.addr, 1))
191 - return sp;
192 - }
193 - low = sp;
194 -@@ -90,7 +92,7 @@ struct return_address_data {
195 - int depth;
196 - };
197 -
198 --static int __return_address(void *data, unsigned long address)
199 -+static int __return_address(void *data, unsigned long address, int reliable)
200 - {
201 - struct return_address_data *rd = data;
202 -
203 -@@ -109,9 +111,12 @@ unsigned long return_address(int depth)
204 - }
205 - EXPORT_SYMBOL_GPL(return_address);
206 -
207 --static int show_address(void *data, unsigned long address)
208 -+static int show_address(void *data, unsigned long address, int reliable)
209 - {
210 -- printk("([<%016lx>] %pSR)\n", address, (void *)address);
211 -+ if (reliable)
212 -+ printk(" [<%016lx>] %pSR \n", address, (void *)address);
213 -+ else
214 -+ printk("([<%016lx>] %pSR)\n", address, (void *)address);
215 - return 0;
216 - }
217 -
218 -diff --git a/arch/s390/kernel/perf_event.c b/arch/s390/kernel/perf_event.c
219 -index 17431f6..955a7b6 100644
220 ---- a/arch/s390/kernel/perf_event.c
221 -+++ b/arch/s390/kernel/perf_event.c
222 -@@ -222,7 +222,7 @@ static int __init service_level_perf_register(void)
223 - }
224 - arch_initcall(service_level_perf_register);
225 -
226 --static int __perf_callchain_kernel(void *data, unsigned long address)
227 -+static int __perf_callchain_kernel(void *data, unsigned long address, int reliable)
228 - {
229 - struct perf_callchain_entry_ctx *entry = data;
230 -
231 -diff --git a/arch/s390/kernel/stacktrace.c b/arch/s390/kernel/stacktrace.c
232 -index 44f84b2..355db9d 100644
233 ---- a/arch/s390/kernel/stacktrace.c
234 -+++ b/arch/s390/kernel/stacktrace.c
235 -@@ -27,12 +27,12 @@ static int __save_address(void *data, unsigned long address, int nosched)
236 - return 1;
237 - }
238 -
239 --static int save_address(void *data, unsigned long address)
240 -+static int save_address(void *data, unsigned long address, int reliable)
241 - {
242 - return __save_address(data, address, 0);
243 - }
244 -
245 --static int save_address_nosched(void *data, unsigned long address)
246 -+static int save_address_nosched(void *data, unsigned long address, int reliable)
247 - {
248 - return __save_address(data, address, 1);
249 - }
250 -diff --git a/arch/s390/oprofile/init.c b/arch/s390/oprofile/init.c
251 -index 16f4c39..9a4de45 100644
252 ---- a/arch/s390/oprofile/init.c
253 -+++ b/arch/s390/oprofile/init.c
254 -@@ -13,7 +13,7 @@
255 - #include <linux/init.h>
256 - #include <asm/processor.h>
257 -
258 --static int __s390_backtrace(void *data, unsigned long address)
259 -+static int __s390_backtrace(void *data, unsigned long address, int reliable)
260 - {
261 - unsigned int *depth = data;
262 -
263 -diff --git a/arch/x86/entry/Makefile b/arch/x86/entry/Makefile
264 -index 77f28ce..9976fce 100644
265 ---- a/arch/x86/entry/Makefile
266 -+++ b/arch/x86/entry/Makefile
267 -@@ -5,8 +5,8 @@
268 - OBJECT_FILES_NON_STANDARD_entry_$(BITS).o := y
269 - OBJECT_FILES_NON_STANDARD_entry_64_compat.o := y
270 -
271 --CFLAGS_syscall_64.o += -Wno-override-init
272 --CFLAGS_syscall_32.o += -Wno-override-init
273 -+CFLAGS_syscall_64.o += $(call cc-option,-Wno-override-init,)
274 -+CFLAGS_syscall_32.o += $(call cc-option,-Wno-override-init,)
275 - obj-y := entry_$(BITS).o thunk_$(BITS).o syscall_$(BITS).o
276 - obj-y += common.o
277 -
278 -diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
279 -index fbd1944..d99ca57 100644
280 ---- a/arch/x86/kernel/acpi/boot.c
281 -+++ b/arch/x86/kernel/acpi/boot.c
282 -@@ -453,6 +453,7 @@ static void __init acpi_sci_ioapic_setup(u8 bus_irq, u16 polarity, u16 trigger,
283 - polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK;
284 -
285 - mp_override_legacy_irq(bus_irq, polarity, trigger, gsi);
286 -+ acpi_penalize_sci_irq(bus_irq, trigger, polarity);
287 -
288 - /*
289 - * stash over-ride to indicate we've been here
290 -diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
291 -index 60746ef..caea575 100644
292 ---- a/drivers/acpi/apei/ghes.c
293 -+++ b/drivers/acpi/apei/ghes.c
294 -@@ -662,7 +662,7 @@ static int ghes_proc(struct ghes *ghes)
295 - ghes_do_proc(ghes, ghes->estatus);
296 - out:
297 - ghes_clear_estatus(ghes);
298 -- return 0;
299 -+ return rc;
300 - }
301 -
302 - static void ghes_add_timer(struct ghes *ghes)
303 -diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
304 -index c983bf7..bc3d914 100644
305 ---- a/drivers/acpi/pci_link.c
306 -+++ b/drivers/acpi/pci_link.c
307 -@@ -87,6 +87,7 @@ struct acpi_pci_link {
308 -
309 - static LIST_HEAD(acpi_link_list);
310 - static DEFINE_MUTEX(acpi_link_lock);
311 -+static int sci_irq = -1, sci_penalty;
312 -
313 - /* --------------------------------------------------------------------------
314 - PCI Link Device Management
315 -@@ -496,25 +497,13 @@ static int acpi_irq_get_penalty(int irq)
316 - {
317 - int penalty = 0;
318 -
319 -- /*
320 -- * Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict
321 -- * with PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be
322 -- * use for PCI IRQs.
323 -- */
324 -- if (irq == acpi_gbl_FADT.sci_interrupt) {
325 -- u32 type = irq_get_trigger_type(irq) & IRQ_TYPE_SENSE_MASK;
326 --
327 -- if (type != IRQ_TYPE_LEVEL_LOW)
328 -- penalty += PIRQ_PENALTY_ISA_ALWAYS;
329 -- else
330 -- penalty += PIRQ_PENALTY_PCI_USING;
331 -- }
332 -+ if (irq == sci_irq)
333 -+ penalty += sci_penalty;
334 -
335 - if (irq < ACPI_MAX_ISA_IRQS)
336 - return penalty + acpi_isa_irq_penalty[irq];
337 -
338 -- penalty += acpi_irq_pci_sharing_penalty(irq);
339 -- return penalty;
340 -+ return penalty + acpi_irq_pci_sharing_penalty(irq);
341 - }
342 -
343 - int __init acpi_irq_penalty_init(void)
344 -@@ -619,6 +608,10 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
345 - acpi_device_bid(link->device));
346 - return -ENODEV;
347 - } else {
348 -+ if (link->irq.active < ACPI_MAX_ISA_IRQS)
349 -+ acpi_isa_irq_penalty[link->irq.active] +=
350 -+ PIRQ_PENALTY_PCI_USING;
351 -+
352 - printk(KERN_WARNING PREFIX "%s [%s] enabled at IRQ %d\n",
353 - acpi_device_name(link->device),
354 - acpi_device_bid(link->device), link->irq.active);
355 -@@ -849,7 +842,7 @@ static int __init acpi_irq_penalty_update(char *str, int used)
356 - continue;
357 -
358 - if (used)
359 -- new_penalty = acpi_irq_get_penalty(irq) +
360 -+ new_penalty = acpi_isa_irq_penalty[irq] +
361 - PIRQ_PENALTY_ISA_USED;
362 - else
363 - new_penalty = 0;
364 -@@ -871,7 +864,7 @@ static int __init acpi_irq_penalty_update(char *str, int used)
365 - void acpi_penalize_isa_irq(int irq, int active)
366 - {
367 - if ((irq >= 0) && (irq < ARRAY_SIZE(acpi_isa_irq_penalty)))
368 -- acpi_isa_irq_penalty[irq] = acpi_irq_get_penalty(irq) +
369 -+ acpi_isa_irq_penalty[irq] +=
370 - (active ? PIRQ_PENALTY_ISA_USED : PIRQ_PENALTY_PCI_USING);
371 - }
372 -
373 -@@ -881,6 +874,17 @@ bool acpi_isa_irq_available(int irq)
374 - acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS);
375 - }
376 -
377 -+void acpi_penalize_sci_irq(int irq, int trigger, int polarity)
378 -+{
379 -+ sci_irq = irq;
380 -+
381 -+ if (trigger == ACPI_MADT_TRIGGER_LEVEL &&
382 -+ polarity == ACPI_MADT_POLARITY_ACTIVE_LOW)
383 -+ sci_penalty = PIRQ_PENALTY_PCI_USING;
384 -+ else
385 -+ sci_penalty = PIRQ_PENALTY_ISA_ALWAYS;
386 -+}
387 -+
388 - /*
389 - * Over-ride default table to reserve additional IRQs for use by ISA
390 - * e.g. acpi_irq_isa=5
391 -diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
392 -index 100be55..8348272 100644
393 ---- a/drivers/block/drbd/drbd_main.c
394 -+++ b/drivers/block/drbd/drbd_main.c
395 -@@ -1871,7 +1871,7 @@ int drbd_send(struct drbd_connection *connection, struct socket *sock,
396 - drbd_update_congested(connection);
397 - }
398 - do {
399 -- rv = kernel_sendmsg(sock, &msg, &iov, 1, size);
400 -+ rv = kernel_sendmsg(sock, &msg, &iov, 1, iov.iov_len);
401 - if (rv == -EAGAIN) {
402 - if (we_should_drop_the_connection(connection, sock))
403 - break;
404 -diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
405 -index 4431129..0f7d28a 100644
406 ---- a/drivers/char/agp/intel-gtt.c
407 -+++ b/drivers/char/agp/intel-gtt.c
408 -@@ -845,6 +845,8 @@ void intel_gtt_insert_page(dma_addr_t addr,
409 - unsigned int flags)
410 - {
411 - intel_private.driver->write_entry(addr, pg, flags);
412 -+ if (intel_private.driver->chipset_flush)
413 -+ intel_private.driver->chipset_flush();
414 - }
415 - EXPORT_SYMBOL(intel_gtt_insert_page);
416 -
417 -diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
418 -index 9203f2d..340f96e 100644
419 ---- a/drivers/char/hw_random/core.c
420 -+++ b/drivers/char/hw_random/core.c
421 -@@ -84,14 +84,14 @@ static size_t rng_buffer_size(void)
422 -
423 - static void add_early_randomness(struct hwrng *rng)
424 - {
425 -- unsigned char bytes[16];
426 - int bytes_read;
427 -+ size_t size = min_t(size_t, 16, rng_buffer_size());
428 -
429 - mutex_lock(&reading_mutex);
430 -- bytes_read = rng_get_data(rng, bytes, sizeof(bytes), 1);
431 -+ bytes_read = rng_get_data(rng, rng_buffer, size, 1);
432 - mutex_unlock(&reading_mutex);
433 - if (bytes_read > 0)
434 -- add_device_randomness(bytes, bytes_read);
435 -+ add_device_randomness(rng_buffer, bytes_read);
436 - }
437 -
438 - static inline void cleanup_rng(struct kref *kref)
439 -diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c
440 -index 20b1055..80ae2a5 100644
441 ---- a/drivers/clk/clk-qoriq.c
442 -+++ b/drivers/clk/clk-qoriq.c
443 -@@ -700,6 +700,7 @@ static struct clk * __init create_mux_common(struct clockgen *cg,
444 - struct mux_hwclock *hwc,
445 - const struct clk_ops *ops,
446 - unsigned long min_rate,
447 -+ unsigned long max_rate,
448 - unsigned long pct80_rate,
449 - const char *fmt, int idx)
450 - {
451 -@@ -728,6 +729,8 @@ static struct clk * __init create_mux_common(struct clockgen *cg,
452 - continue;
453 - if (rate < min_rate)
454 - continue;
455 -+ if (rate > max_rate)
456 -+ continue;
457 -
458 - parent_names[j] = div->name;
459 - hwc->parent_to_clksel[j] = i;
460 -@@ -759,7 +762,7 @@ static struct clk * __init create_one_cmux(struct clockgen *cg, int idx)
461 - struct mux_hwclock *hwc;
462 - const struct clockgen_pll_div *div;
463 - unsigned long plat_rate, min_rate;
464 -- u64 pct80_rate;
465 -+ u64 max_rate, pct80_rate;
466 - u32 clksel;
467 -
468 - hwc = kzalloc(sizeof(*hwc), GFP_KERNEL);
469 -@@ -787,8 +790,8 @@ static struct clk * __init create_one_cmux(struct clockgen *cg, int idx)
470 - return NULL;
471 - }
472 -
473 -- pct80_rate = clk_get_rate(div->clk);
474 -- pct80_rate *= 8;
475 -+ max_rate = clk_get_rate(div->clk);
476 -+ pct80_rate = max_rate * 8;
477 - do_div(pct80_rate, 10);
478 -
479 - plat_rate = clk_get_rate(cg->pll[PLATFORM_PLL].div[PLL_DIV1].clk);
480 -@@ -798,7 +801,7 @@ static struct clk * __init create_one_cmux(struct clockgen *cg, int idx)
481 - else
482 - min_rate = plat_rate / 2;
483 -
484 -- return create_mux_common(cg, hwc, &cmux_ops, min_rate,
485 -+ return create_mux_common(cg, hwc, &cmux_ops, min_rate, max_rate,
486 - pct80_rate, "cg-cmux%d", idx);
487 - }
488 -
489 -@@ -813,7 +816,7 @@ static struct clk * __init create_one_hwaccel(struct clockgen *cg, int idx)
490 - hwc->reg = cg->regs + 0x20 * idx + 0x10;
491 - hwc->info = cg->info.hwaccel[idx];
492 -
493 -- return create_mux_common(cg, hwc, &hwaccel_ops, 0, 0,
494 -+ return create_mux_common(cg, hwc, &hwaccel_ops, 0, ULONG_MAX, 0,
495 - "cg-hwaccel%d", idx);
496 - }
497 -
498 -diff --git a/drivers/clk/samsung/clk-exynos-audss.c b/drivers/clk/samsung/clk-exynos-audss.c
499 -index bdf8b97..0fa91f3 100644
500 ---- a/drivers/clk/samsung/clk-exynos-audss.c
501 -+++ b/drivers/clk/samsung/clk-exynos-audss.c
502 -@@ -82,6 +82,7 @@ static const struct of_device_id exynos_audss_clk_of_match[] = {
503 - .data = (void *)TYPE_EXYNOS5420, },
504 - {},
505 - };
506 -+MODULE_DEVICE_TABLE(of, exynos_audss_clk_of_match);
507 -
508 - static void exynos_audss_clk_teardown(void)
509 - {
510 -diff --git a/drivers/clocksource/timer-sun5i.c b/drivers/clocksource/timer-sun5i.c
511 -index c184eb8..4f87f3e 100644
512 ---- a/drivers/clocksource/timer-sun5i.c
513 -+++ b/drivers/clocksource/timer-sun5i.c
514 -@@ -152,6 +152,13 @@ static irqreturn_t sun5i_timer_interrupt(int irq, void *dev_id)
515 - return IRQ_HANDLED;
516 - }
517 -
518 -+static cycle_t sun5i_clksrc_read(struct clocksource *clksrc)
519 -+{
520 -+ struct sun5i_timer_clksrc *cs = to_sun5i_timer_clksrc(clksrc);
521 -+
522 -+ return ~readl(cs->timer.base + TIMER_CNTVAL_LO_REG(1));
523 -+}
524 -+
525 - static int sun5i_rate_cb_clksrc(struct notifier_block *nb,
526 - unsigned long event, void *data)
527 - {
528 -@@ -210,8 +217,13 @@ static int __init sun5i_setup_clocksource(struct device_node *node,
529 - writel(TIMER_CTL_ENABLE | TIMER_CTL_RELOAD,
530 - base + TIMER_CTL_REG(1));
531 -
532 -- ret = clocksource_mmio_init(base + TIMER_CNTVAL_LO_REG(1), node->name,
533 -- rate, 340, 32, clocksource_mmio_readl_down);
534 -+ cs->clksrc.name = node->name;
535 -+ cs->clksrc.rating = 340;
536 -+ cs->clksrc.read = sun5i_clksrc_read;
537 -+ cs->clksrc.mask = CLOCKSOURCE_MASK(32);
538 -+ cs->clksrc.flags = CLOCK_SOURCE_IS_CONTINUOUS;
539 -+
540 -+ ret = clocksource_register_hz(&cs->clksrc, rate);
541 - if (ret) {
542 - pr_err("Couldn't register clock source.\n");
543 - goto err_remove_notifier;
544 -diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
545 -index cd5dc27..1ed6132 100644
546 ---- a/drivers/gpio/gpio-mvebu.c
547 -+++ b/drivers/gpio/gpio-mvebu.c
548 -@@ -293,10 +293,10 @@ static void mvebu_gpio_irq_ack(struct irq_data *d)
549 - {
550 - struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
551 - struct mvebu_gpio_chip *mvchip = gc->private;
552 -- u32 mask = ~(1 << (d->irq - gc->irq_base));
553 -+ u32 mask = d->mask;
554 -
555 - irq_gc_lock(gc);
556 -- writel_relaxed(mask, mvebu_gpioreg_edge_cause(mvchip));
557 -+ writel_relaxed(~mask, mvebu_gpioreg_edge_cause(mvchip));
558 - irq_gc_unlock(gc);
559 - }
560 -
561 -@@ -305,7 +305,7 @@ static void mvebu_gpio_edge_irq_mask(struct irq_data *d)
562 - struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
563 - struct mvebu_gpio_chip *mvchip = gc->private;
564 - struct irq_chip_type *ct = irq_data_get_chip_type(d);
565 -- u32 mask = 1 << (d->irq - gc->irq_base);
566 -+ u32 mask = d->mask;
567 -
568 - irq_gc_lock(gc);
569 - ct->mask_cache_priv &= ~mask;
570 -@@ -319,8 +319,7 @@ static void mvebu_gpio_edge_irq_unmask(struct irq_data *d)
571 - struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
572 - struct mvebu_gpio_chip *mvchip = gc->private;
573 - struct irq_chip_type *ct = irq_data_get_chip_type(d);
574 --
575 -- u32 mask = 1 << (d->irq - gc->irq_base);
576 -+ u32 mask = d->mask;
577 -
578 - irq_gc_lock(gc);
579 - ct->mask_cache_priv |= mask;
580 -@@ -333,8 +332,7 @@ static void mvebu_gpio_level_irq_mask(struct irq_data *d)
581 - struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
582 - struct mvebu_gpio_chip *mvchip = gc->private;
583 - struct irq_chip_type *ct = irq_data_get_chip_type(d);
584 --
585 -- u32 mask = 1 << (d->irq - gc->irq_base);
586 -+ u32 mask = d->mask;
587 -
588 - irq_gc_lock(gc);
589 - ct->mask_cache_priv &= ~mask;
590 -@@ -347,8 +345,7 @@ static void mvebu_gpio_level_irq_unmask(struct irq_data *d)
591 - struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
592 - struct mvebu_gpio_chip *mvchip = gc->private;
593 - struct irq_chip_type *ct = irq_data_get_chip_type(d);
594 --
595 -- u32 mask = 1 << (d->irq - gc->irq_base);
596 -+ u32 mask = d->mask;
597 -
598 - irq_gc_lock(gc);
599 - ct->mask_cache_priv |= mask;
600 -@@ -462,7 +459,7 @@ static void mvebu_gpio_irq_handler(struct irq_desc *desc)
601 - for (i = 0; i < mvchip->chip.ngpio; i++) {
602 - int irq;
603 -
604 -- irq = mvchip->irqbase + i;
605 -+ irq = irq_find_mapping(mvchip->domain, i);
606 -
607 - if (!(cause & (1 << i)))
608 - continue;
609 -@@ -655,6 +652,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
610 - struct irq_chip_type *ct;
611 - struct clk *clk;
612 - unsigned int ngpios;
613 -+ bool have_irqs;
614 - int soc_variant;
615 - int i, cpu, id;
616 - int err;
617 -@@ -665,6 +663,9 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
618 - else
619 - soc_variant = MVEBU_GPIO_SOC_VARIANT_ORION;
620 -
621 -+ /* Some gpio controllers do not provide irq support */
622 -+ have_irqs = of_irq_count(np) != 0;
623 -+
624 - mvchip = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_gpio_chip),
625 - GFP_KERNEL);
626 - if (!mvchip)
627 -@@ -697,7 +698,8 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
628 - mvchip->chip.get = mvebu_gpio_get;
629 - mvchip->chip.direction_output = mvebu_gpio_direction_output;
630 - mvchip->chip.set = mvebu_gpio_set;
631 -- mvchip->chip.to_irq = mvebu_gpio_to_irq;
632 -+ if (have_irqs)
633 -+ mvchip->chip.to_irq = mvebu_gpio_to_irq;
634 - mvchip->chip.base = id * MVEBU_MAX_GPIO_PER_BANK;
635 - mvchip->chip.ngpio = ngpios;
636 - mvchip->chip.can_sleep = false;
637 -@@ -758,34 +760,30 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
638 - devm_gpiochip_add_data(&pdev->dev, &mvchip->chip, mvchip);
639 -
640 - /* Some gpio controllers do not provide irq support */
641 -- if (!of_irq_count(np))
642 -+ if (!have_irqs)
643 - return 0;
644 -
645 -- /* Setup the interrupt handlers. Each chip can have up to 4
646 -- * interrupt handlers, with each handler dealing with 8 GPIO
647 -- * pins. */
648 -- for (i = 0; i < 4; i++) {
649 -- int irq = platform_get_irq(pdev, i);
650 --
651 -- if (irq < 0)
652 -- continue;
653 -- irq_set_chained_handler_and_data(irq, mvebu_gpio_irq_handler,
654 -- mvchip);
655 -- }
656 --
657 -- mvchip->irqbase = irq_alloc_descs(-1, 0, ngpios, -1);
658 -- if (mvchip->irqbase < 0) {
659 -- dev_err(&pdev->dev, "no irqs\n");
660 -- return mvchip->irqbase;
661 -+ mvchip->domain =
662 -+ irq_domain_add_linear(np, ngpios, &irq_generic_chip_ops, NULL);
663 -+ if (!mvchip->domain) {
664 -+ dev_err(&pdev->dev, "couldn't allocate irq domain %s (DT).\n",
665 -+ mvchip->chip.label);
666 -+ return -ENODEV;
667 - }
668 -
669 -- gc = irq_alloc_generic_chip("mvebu_gpio_irq", 2, mvchip->irqbase,
670 -- mvchip->membase, handle_level_irq);
671 -- if (!gc) {
672 -- dev_err(&pdev->dev, "Cannot allocate generic irq_chip\n");
673 -- return -ENOMEM;
674 -+ err = irq_alloc_domain_generic_chips(
675 -+ mvchip->domain, ngpios, 2, np->name, handle_level_irq,
676 -+ IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_LEVEL, 0, 0);
677 -+ if (err) {
678 -+ dev_err(&pdev->dev, "couldn't allocate irq chips %s (DT).\n",
679 -+ mvchip->chip.label);
680 -+ goto err_domain;
681 - }
682 -
683 -+ /* NOTE: The common accessors cannot be used because of the percpu
684 -+ * access to the mask registers
685 -+ */
686 -+ gc = irq_get_domain_generic_chip(mvchip->domain, 0);
687 - gc->private = mvchip;
688 - ct = &gc->chip_types[0];
689 - ct->type = IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW;
690 -@@ -803,27 +801,23 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
691 - ct->handler = handle_edge_irq;
692 - ct->chip.name = mvchip->chip.label;
693 -
694 -- irq_setup_generic_chip(gc, IRQ_MSK(ngpios), 0,
695 -- IRQ_NOREQUEST, IRQ_LEVEL | IRQ_NOPROBE);
696 -+ /* Setup the interrupt handlers. Each chip can have up to 4
697 -+ * interrupt handlers, with each handler dealing with 8 GPIO
698 -+ * pins.
699 -+ */
700 -+ for (i = 0; i < 4; i++) {
701 -+ int irq = platform_get_irq(pdev, i);
702 -
703 -- /* Setup irq domain on top of the generic chip. */
704 -- mvchip->domain = irq_domain_add_simple(np, mvchip->chip.ngpio,
705 -- mvchip->irqbase,
706 -- &irq_domain_simple_ops,
707 -- mvchip);
708 -- if (!mvchip->domain) {
709 -- dev_err(&pdev->dev, "couldn't allocate irq domain %s (DT).\n",
710 -- mvchip->chip.label);
711 -- err = -ENODEV;
712 -- goto err_generic_chip;
713 -+ if (irq < 0)
714 -+ continue;
715 -+ irq_set_chained_handler_and_data(irq, mvebu_gpio_irq_handler,
716 -+ mvchip);
717 - }
718 -
719 - return 0;
720 -
721 --err_generic_chip:
722 -- irq_remove_generic_chip(gc, IRQ_MSK(ngpios), IRQ_NOREQUEST,
723 -- IRQ_LEVEL | IRQ_NOPROBE);
724 -- kfree(gc);
725 -+err_domain:
726 -+ irq_domain_remove(mvchip->domain);
727 -
728 - return err;
729 - }
730 -diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
731 -index a28feb3..e3fc901 100644
732 ---- a/drivers/gpio/gpiolib-of.c
733 -+++ b/drivers/gpio/gpiolib-of.c
734 -@@ -26,14 +26,18 @@
735 -
736 - #include "gpiolib.h"
737 -
738 --static int of_gpiochip_match_node(struct gpio_chip *chip, void *data)
739 -+static int of_gpiochip_match_node_and_xlate(struct gpio_chip *chip, void *data)
740 - {
741 -- return chip->gpiodev->dev.of_node == data;
742 -+ struct of_phandle_args *gpiospec = data;
743 -+
744 -+ return chip->gpiodev->dev.of_node == gpiospec->np &&
745 -+ chip->of_xlate(chip, gpiospec, NULL) >= 0;
746 - }
747 -
748 --static struct gpio_chip *of_find_gpiochip_by_node(struct device_node *np)
749 -+static struct gpio_chip *of_find_gpiochip_by_xlate(
750 -+ struct of_phandle_args *gpiospec)
751 - {
752 -- return gpiochip_find(np, of_gpiochip_match_node);
753 -+ return gpiochip_find(gpiospec, of_gpiochip_match_node_and_xlate);
754 - }
755 -
756 - static struct gpio_desc *of_xlate_and_get_gpiod_flags(struct gpio_chip *chip,
757 -@@ -79,7 +83,7 @@ struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np,
758 - return ERR_PTR(ret);
759 - }
760 -
761 -- chip = of_find_gpiochip_by_node(gpiospec.np);
762 -+ chip = of_find_gpiochip_by_xlate(&gpiospec);
763 - if (!chip) {
764 - desc = ERR_PTR(-EPROBE_DEFER);
765 - goto out;
766 -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
767 -index 892d60f..2057683 100644
768 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
769 -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
770 -@@ -395,9 +395,12 @@ static int acp_hw_fini(void *handle)
771 - {
772 - int i, ret;
773 - struct device *dev;
774 --
775 - struct amdgpu_device *adev = (struct amdgpu_device *)handle;
776 -
777 -+ /* return early if no ACP */
778 -+ if (!adev->acp.acp_genpd)
779 -+ return 0;
780 -+
781 - for (i = 0; i < ACP_DEVS ; i++) {
782 - dev = get_mfd_cell_dev(adev->acp.acp_cell[i].name, i);
783 - ret = pm_genpd_remove_device(&adev->acp.acp_genpd->gpd, dev);
784 -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
785 -index 9aa533c..414a160 100644
786 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
787 -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
788 -@@ -605,6 +605,7 @@ static int __init amdgpu_init(void)
789 - {
790 - amdgpu_sync_init();
791 - amdgpu_fence_slab_init();
792 -+ amd_sched_fence_slab_init();
793 - if (vgacon_text_force()) {
794 - DRM_ERROR("VGACON disables amdgpu kernel modesetting.\n");
795 - return -EINVAL;
796 -@@ -624,6 +625,7 @@ static void __exit amdgpu_exit(void)
797 - drm_pci_exit(driver, pdriver);
798 - amdgpu_unregister_atpx_handler();
799 - amdgpu_sync_fini();
800 -+ amd_sched_fence_slab_fini();
801 - amdgpu_fence_slab_fini();
802 - }
803 -
804 -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
805 -index 0b109ae..c82b95b8 100644
806 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
807 -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
808 -@@ -68,6 +68,7 @@ int amdgpu_fence_slab_init(void)
809 -
810 - void amdgpu_fence_slab_fini(void)
811 - {
812 -+ rcu_barrier();
813 - kmem_cache_destroy(amdgpu_fence_slab);
814 - }
815 - /*
816 -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
817 -index e24a8af..1ed64ae 100644
818 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
819 -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
820 -@@ -99,6 +99,8 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
821 -
822 - if ((amdgpu_runtime_pm != 0) &&
823 - amdgpu_has_atpx() &&
824 -+ (amdgpu_is_atpx_hybrid() ||
825 -+ amdgpu_has_atpx_dgpu_power_cntl()) &&
826 - ((flags & AMD_IS_APU) == 0))
827 - flags |= AMD_IS_PX;
828 -
829 -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
830 -index 80120fa..e86ca39 100644
831 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
832 -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
833 -@@ -1654,5 +1654,6 @@ void amdgpu_vm_manager_fini(struct amdgpu_device *adev)
834 - fence_put(adev->vm_manager.ids[i].first);
835 - amdgpu_sync_free(&adev->vm_manager.ids[i].active);
836 - fence_put(id->flushed_updates);
837 -+ fence_put(id->last_flush);
838 - }
839 - }
840 -diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
841 -index 963a24d..ffe1f85 100644
842 ---- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
843 -+++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
844 -@@ -34,9 +34,6 @@ static bool amd_sched_entity_is_ready(struct amd_sched_entity *entity);
845 - static void amd_sched_wakeup(struct amd_gpu_scheduler *sched);
846 - static void amd_sched_process_job(struct fence *f, struct fence_cb *cb);
847 -
848 --struct kmem_cache *sched_fence_slab;
849 --atomic_t sched_fence_slab_ref = ATOMIC_INIT(0);
850 --
851 - /* Initialize a given run queue struct */
852 - static void amd_sched_rq_init(struct amd_sched_rq *rq)
853 - {
854 -@@ -618,13 +615,6 @@ int amd_sched_init(struct amd_gpu_scheduler *sched,
855 - INIT_LIST_HEAD(&sched->ring_mirror_list);
856 - spin_lock_init(&sched->job_list_lock);
857 - atomic_set(&sched->hw_rq_count, 0);
858 -- if (atomic_inc_return(&sched_fence_slab_ref) == 1) {
859 -- sched_fence_slab = kmem_cache_create(
860 -- "amd_sched_fence", sizeof(struct amd_sched_fence), 0,
861 -- SLAB_HWCACHE_ALIGN, NULL);
862 -- if (!sched_fence_slab)
863 -- return -ENOMEM;
864 -- }
865 -
866 - /* Each scheduler will run on a seperate kernel thread */
867 - sched->thread = kthread_run(amd_sched_main, sched, sched->name);
868 -@@ -645,6 +635,4 @@ void amd_sched_fini(struct amd_gpu_scheduler *sched)
869 - {
870 - if (sched->thread)
871 - kthread_stop(sched->thread);
872 -- if (atomic_dec_and_test(&sched_fence_slab_ref))
873 -- kmem_cache_destroy(sched_fence_slab);
874 - }
875 -diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h
876 -index 7cbbbfb..51068e6 100644
877 ---- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h
878 -+++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h
879 -@@ -30,9 +30,6 @@
880 - struct amd_gpu_scheduler;
881 - struct amd_sched_rq;
882 -
883 --extern struct kmem_cache *sched_fence_slab;
884 --extern atomic_t sched_fence_slab_ref;
885 --
886 - /**
887 - * A scheduler entity is a wrapper around a job queue or a group
888 - * of other entities. Entities take turns emitting jobs from their
889 -@@ -145,6 +142,9 @@ void amd_sched_entity_fini(struct amd_gpu_scheduler *sched,
890 - struct amd_sched_entity *entity);
891 - void amd_sched_entity_push_job(struct amd_sched_job *sched_job);
892 -
893 -+int amd_sched_fence_slab_init(void);
894 -+void amd_sched_fence_slab_fini(void);
895 -+
896 - struct amd_sched_fence *amd_sched_fence_create(
897 - struct amd_sched_entity *s_entity, void *owner);
898 - void amd_sched_fence_scheduled(struct amd_sched_fence *fence);
899 -diff --git a/drivers/gpu/drm/amd/scheduler/sched_fence.c b/drivers/gpu/drm/amd/scheduler/sched_fence.c
900 -index 6b63bea..93ad2e1 100644
901 ---- a/drivers/gpu/drm/amd/scheduler/sched_fence.c
902 -+++ b/drivers/gpu/drm/amd/scheduler/sched_fence.c
903 -@@ -27,6 +27,25 @@
904 - #include <drm/drmP.h>
905 - #include "gpu_scheduler.h"
906 -
907 -+static struct kmem_cache *sched_fence_slab;
908 -+
909 -+int amd_sched_fence_slab_init(void)
910 -+{
911 -+ sched_fence_slab = kmem_cache_create(
912 -+ "amd_sched_fence", sizeof(struct amd_sched_fence), 0,
913 -+ SLAB_HWCACHE_ALIGN, NULL);
914 -+ if (!sched_fence_slab)
915 -+ return -ENOMEM;
916 -+
917 -+ return 0;
918 -+}
919 -+
920 -+void amd_sched_fence_slab_fini(void)
921 -+{
922 -+ rcu_barrier();
923 -+ kmem_cache_destroy(sched_fence_slab);
924 -+}
925 -+
926 - struct amd_sched_fence *amd_sched_fence_create(struct amd_sched_entity *entity,
927 - void *owner)
928 - {
929 -diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
930 -index 5de36d8..d46fa22 100644
931 ---- a/drivers/gpu/drm/i915/i915_drv.c
932 -+++ b/drivers/gpu/drm/i915/i915_drv.c
933 -@@ -1490,8 +1490,6 @@ static int i915_drm_suspend(struct drm_device *dev)
934 -
935 - dev_priv->suspend_count++;
936 -
937 -- intel_display_set_init_power(dev_priv, false);
938 --
939 - intel_csr_ucode_suspend(dev_priv);
940 -
941 - out:
942 -@@ -1508,6 +1506,8 @@ static int i915_drm_suspend_late(struct drm_device *drm_dev, bool hibernation)
943 -
944 - disable_rpm_wakeref_asserts(dev_priv);
945 -
946 -+ intel_display_set_init_power(dev_priv, false);
947 -+
948 - fw_csr = !IS_BROXTON(dev_priv) &&
949 - suspend_to_idle(dev_priv) && dev_priv->csr.dmc_payload;
950 - /*
951 -diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
952 -index 63462f2..e26f889 100644
953 ---- a/drivers/gpu/drm/i915/intel_display.c
954 -+++ b/drivers/gpu/drm/i915/intel_display.c
955 -@@ -9737,6 +9737,29 @@ static void bxt_modeset_commit_cdclk(struct drm_atomic_state *old_state)
956 - bxt_set_cdclk(to_i915(dev), req_cdclk);
957 - }
958 -
959 -+static int bdw_adjust_min_pipe_pixel_rate(struct intel_crtc_state *crtc_state,
960 -+ int pixel_rate)
961 -+{
962 -+ struct drm_i915_private *dev_priv = to_i915(crtc_state->base.crtc->dev);
963 -+
964 -+ /* pixel rate mustn't exceed 95% of cdclk with IPS on BDW */
965 -+ if (IS_BROADWELL(dev_priv) && crtc_state->ips_enabled)
966 -+ pixel_rate = DIV_ROUND_UP(pixel_rate * 100, 95);
967 -+
968 -+ /* BSpec says "Do not use DisplayPort with CDCLK less than
969 -+ * 432 MHz, audio enabled, port width x4, and link rate
970 -+ * HBR2 (5.4 GHz), or else there may be audio corruption or
971 -+ * screen corruption."
972 -+ */
973 -+ if (intel_crtc_has_dp_encoder(crtc_state) &&
974 -+ crtc_state->has_audio &&
975 -+ crtc_state->port_clock >= 540000 &&
976 -+ crtc_state->lane_count == 4)
977 -+ pixel_rate = max(432000, pixel_rate);
978 -+
979 -+ return pixel_rate;
980 -+}
981 -+
982 - /* compute the max rate for new configuration */
983 - static int ilk_max_pixel_rate(struct drm_atomic_state *state)
984 - {
985 -@@ -9762,9 +9785,9 @@ static int ilk_max_pixel_rate(struct drm_atomic_state *state)
986 -
987 - pixel_rate = ilk_pipe_pixel_rate(crtc_state);
988 -
989 -- /* pixel rate mustn't exceed 95% of cdclk with IPS on BDW */
990 -- if (IS_BROADWELL(dev_priv) && crtc_state->ips_enabled)
991 -- pixel_rate = DIV_ROUND_UP(pixel_rate * 100, 95);
992 -+ if (IS_BROADWELL(dev_priv) || IS_GEN9(dev_priv))
993 -+ pixel_rate = bdw_adjust_min_pipe_pixel_rate(crtc_state,
994 -+ pixel_rate);
995 -
996 - intel_state->min_pixclk[i] = pixel_rate;
997 - }
998 -diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
999 -index c3aa9e6..1421270 100644
1000 ---- a/drivers/gpu/drm/i915/intel_hdmi.c
1001 -+++ b/drivers/gpu/drm/i915/intel_hdmi.c
1002 -@@ -1759,6 +1759,50 @@ intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *c
1003 - intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_NONE;
1004 - }
1005 -
1006 -+static u8 intel_hdmi_ddc_pin(struct drm_i915_private *dev_priv,
1007 -+ enum port port)
1008 -+{
1009 -+ const struct ddi_vbt_port_info *info =
1010 -+ &dev_priv->vbt.ddi_port_info[port];
1011 -+ u8 ddc_pin;
1012 -+
1013 -+ if (info->alternate_ddc_pin) {
1014 -+ DRM_DEBUG_KMS("Using DDC pin 0x%x for port %c (VBT)\n",
1015 -+ info->alternate_ddc_pin, port_name(port));
1016 -+ return info->alternate_ddc_pin;
1017 -+ }
1018 -+
1019 -+ switch (port) {
1020 -+ case PORT_B:
1021 -+ if (IS_BROXTON(dev_priv))
1022 -+ ddc_pin = GMBUS_PIN_1_BXT;
1023 -+ else
1024 -+ ddc_pin = GMBUS_PIN_DPB;
1025 -+ break;
1026 -+ case PORT_C:
1027 -+ if (IS_BROXTON(dev_priv))
1028 -+ ddc_pin = GMBUS_PIN_2_BXT;
1029 -+ else
1030 -+ ddc_pin = GMBUS_PIN_DPC;
1031 -+ break;
1032 -+ case PORT_D:
1033 -+ if (IS_CHERRYVIEW(dev_priv))
1034 -+ ddc_pin = GMBUS_PIN_DPD_CHV;
1035 -+ else
1036 -+ ddc_pin = GMBUS_PIN_DPD;
1037 -+ break;
1038 -+ default:
1039 -+ MISSING_CASE(port);
1040 -+ ddc_pin = GMBUS_PIN_DPB;
1041 -+ break;
1042 -+ }
1043 -+
1044 -+ DRM_DEBUG_KMS("Using DDC pin 0x%x for port %c (platform default)\n",
1045 -+ ddc_pin, port_name(port));
1046 -+
1047 -+ return ddc_pin;
1048 -+}
1049 -+
1050 - void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
1051 - struct intel_connector *intel_connector)
1052 - {
1053 -@@ -1768,7 +1812,6 @@ void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
1054 - struct drm_device *dev = intel_encoder->base.dev;
1055 - struct drm_i915_private *dev_priv = to_i915(dev);
1056 - enum port port = intel_dig_port->port;
1057 -- uint8_t alternate_ddc_pin;
1058 -
1059 - DRM_DEBUG_KMS("Adding HDMI connector on port %c\n",
1060 - port_name(port));
1061 -@@ -1786,12 +1829,10 @@ void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
1062 - connector->doublescan_allowed = 0;
1063 - connector->stereo_allowed = 1;
1064 -
1065 -+ intel_hdmi->ddc_bus = intel_hdmi_ddc_pin(dev_priv, port);
1066 -+
1067 - switch (port) {
1068 - case PORT_B:
1069 -- if (IS_BROXTON(dev_priv))
1070 -- intel_hdmi->ddc_bus = GMBUS_PIN_1_BXT;
1071 -- else
1072 -- intel_hdmi->ddc_bus = GMBUS_PIN_DPB;
1073 - /*
1074 - * On BXT A0/A1, sw needs to activate DDIA HPD logic and
1075 - * interrupts to check the external panel connection.
1076 -@@ -1802,46 +1843,17 @@ void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
1077 - intel_encoder->hpd_pin = HPD_PORT_B;
1078 - break;
1079 - case PORT_C:
1080 -- if (IS_BROXTON(dev_priv))
1081 -- intel_hdmi->ddc_bus = GMBUS_PIN_2_BXT;
1082 -- else
1083 -- intel_hdmi->ddc_bus = GMBUS_PIN_DPC;
1084 - intel_encoder->hpd_pin = HPD_PORT_C;
1085 - break;
1086 - case PORT_D:
1087 -- if (WARN_ON(IS_BROXTON(dev_priv)))
1088 -- intel_hdmi->ddc_bus = GMBUS_PIN_DISABLED;
1089 -- else if (IS_CHERRYVIEW(dev_priv))
1090 -- intel_hdmi->ddc_bus = GMBUS_PIN_DPD_CHV;
1091 -- else
1092 -- intel_hdmi->ddc_bus = GMBUS_PIN_DPD;
1093 - intel_encoder->hpd_pin = HPD_PORT_D;
1094 - break;
1095 - case PORT_E:
1096 -- /* On SKL PORT E doesn't have seperate GMBUS pin
1097 -- * We rely on VBT to set a proper alternate GMBUS pin. */
1098 -- alternate_ddc_pin =
1099 -- dev_priv->vbt.ddi_port_info[PORT_E].alternate_ddc_pin;
1100 -- switch (alternate_ddc_pin) {
1101 -- case DDC_PIN_B:
1102 -- intel_hdmi->ddc_bus = GMBUS_PIN_DPB;
1103 -- break;
1104 -- case DDC_PIN_C:
1105 -- intel_hdmi->ddc_bus = GMBUS_PIN_DPC;
1106 -- break;
1107 -- case DDC_PIN_D:
1108 -- intel_hdmi->ddc_bus = GMBUS_PIN_DPD;
1109 -- break;
1110 -- default:
1111 -- MISSING_CASE(alternate_ddc_pin);
1112 -- }
1113 - intel_encoder->hpd_pin = HPD_PORT_E;
1114 - break;
1115 -- case PORT_A:
1116 -- intel_encoder->hpd_pin = HPD_PORT_A;
1117 -- /* Internal port only for eDP. */
1118 - default:
1119 -- BUG();
1120 -+ MISSING_CASE(port);
1121 -+ return;
1122 - }
1123 -
1124 - if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) {
1125 -diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
1126 -index 554ca71..edd2d03 100644
1127 ---- a/drivers/gpu/drm/radeon/radeon_device.c
1128 -+++ b/drivers/gpu/drm/radeon/radeon_device.c
1129 -@@ -104,6 +104,14 @@ static const char radeon_family_name[][16] = {
1130 - "LAST",
1131 - };
1132 -
1133 -+#if defined(CONFIG_VGA_SWITCHEROO)
1134 -+bool radeon_has_atpx_dgpu_power_cntl(void);
1135 -+bool radeon_is_atpx_hybrid(void);
1136 -+#else
1137 -+static inline bool radeon_has_atpx_dgpu_power_cntl(void) { return false; }
1138 -+static inline bool radeon_is_atpx_hybrid(void) { return false; }
1139 -+#endif
1140 -+
1141 - #define RADEON_PX_QUIRK_DISABLE_PX (1 << 0)
1142 - #define RADEON_PX_QUIRK_LONG_WAKEUP (1 << 1)
1143 -
1144 -@@ -160,6 +168,11 @@ static void radeon_device_handle_px_quirks(struct radeon_device *rdev)
1145 -
1146 - if (rdev->px_quirk_flags & RADEON_PX_QUIRK_DISABLE_PX)
1147 - rdev->flags &= ~RADEON_IS_PX;
1148 -+
1149 -+ /* disable PX is the system doesn't support dGPU power control or hybrid gfx */
1150 -+ if (!radeon_is_atpx_hybrid() &&
1151 -+ !radeon_has_atpx_dgpu_power_cntl())
1152 -+ rdev->flags &= ~RADEON_IS_PX;
1153 - }
1154 -
1155 - /**
1156 -diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
1157 -index da3fb06..ce69048 100644
1158 ---- a/drivers/iio/accel/st_accel_core.c
1159 -+++ b/drivers/iio/accel/st_accel_core.c
1160 -@@ -743,8 +743,8 @@ static int st_accel_read_raw(struct iio_dev *indio_dev,
1161 -
1162 - return IIO_VAL_INT;
1163 - case IIO_CHAN_INFO_SCALE:
1164 -- *val = 0;
1165 -- *val2 = adata->current_fullscale->gain;
1166 -+ *val = adata->current_fullscale->gain / 1000000;
1167 -+ *val2 = adata->current_fullscale->gain % 1000000;
1168 - return IIO_VAL_INT_PLUS_MICRO;
1169 - case IIO_CHAN_INFO_SAMP_FREQ:
1170 - *val = adata->odr;
1171 -@@ -763,9 +763,13 @@ static int st_accel_write_raw(struct iio_dev *indio_dev,
1172 - int err;
1173 -
1174 - switch (mask) {
1175 -- case IIO_CHAN_INFO_SCALE:
1176 -- err = st_sensors_set_fullscale_by_gain(indio_dev, val2);
1177 -+ case IIO_CHAN_INFO_SCALE: {
1178 -+ int gain;
1179 -+
1180 -+ gain = val * 1000000 + val2;
1181 -+ err = st_sensors_set_fullscale_by_gain(indio_dev, gain);
1182 - break;
1183 -+ }
1184 - case IIO_CHAN_INFO_SAMP_FREQ:
1185 - if (val2)
1186 - return -EINVAL;
1187 -diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
1188 -index dc33c1d..b5beea53 100644
1189 ---- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
1190 -+++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
1191 -@@ -30,26 +30,26 @@ static struct {
1192 - u32 usage_id;
1193 - int unit; /* 0 for default others from HID sensor spec */
1194 - int scale_val0; /* scale, whole number */
1195 -- int scale_val1; /* scale, fraction in micros */
1196 -+ int scale_val1; /* scale, fraction in nanos */
1197 - } unit_conversion[] = {
1198 -- {HID_USAGE_SENSOR_ACCEL_3D, 0, 9, 806650},
1199 -+ {HID_USAGE_SENSOR_ACCEL_3D, 0, 9, 806650000},
1200 - {HID_USAGE_SENSOR_ACCEL_3D,
1201 - HID_USAGE_SENSOR_UNITS_METERS_PER_SEC_SQRD, 1, 0},
1202 - {HID_USAGE_SENSOR_ACCEL_3D,
1203 -- HID_USAGE_SENSOR_UNITS_G, 9, 806650},
1204 -+ HID_USAGE_SENSOR_UNITS_G, 9, 806650000},
1205 -
1206 -- {HID_USAGE_SENSOR_GYRO_3D, 0, 0, 17453},
1207 -+ {HID_USAGE_SENSOR_GYRO_3D, 0, 0, 17453293},
1208 - {HID_USAGE_SENSOR_GYRO_3D,
1209 - HID_USAGE_SENSOR_UNITS_RADIANS_PER_SECOND, 1, 0},
1210 - {HID_USAGE_SENSOR_GYRO_3D,
1211 -- HID_USAGE_SENSOR_UNITS_DEGREES_PER_SECOND, 0, 17453},
1212 -+ HID_USAGE_SENSOR_UNITS_DEGREES_PER_SECOND, 0, 17453293},
1213 -
1214 -- {HID_USAGE_SENSOR_COMPASS_3D, 0, 0, 1000},
1215 -+ {HID_USAGE_SENSOR_COMPASS_3D, 0, 0, 1000000},
1216 - {HID_USAGE_SENSOR_COMPASS_3D, HID_USAGE_SENSOR_UNITS_GAUSS, 1, 0},
1217 -
1218 -- {HID_USAGE_SENSOR_INCLINOMETER_3D, 0, 0, 17453},
1219 -+ {HID_USAGE_SENSOR_INCLINOMETER_3D, 0, 0, 17453293},
1220 - {HID_USAGE_SENSOR_INCLINOMETER_3D,
1221 -- HID_USAGE_SENSOR_UNITS_DEGREES, 0, 17453},
1222 -+ HID_USAGE_SENSOR_UNITS_DEGREES, 0, 17453293},
1223 - {HID_USAGE_SENSOR_INCLINOMETER_3D,
1224 - HID_USAGE_SENSOR_UNITS_RADIANS, 1, 0},
1225 -
1226 -@@ -57,7 +57,7 @@ static struct {
1227 - {HID_USAGE_SENSOR_ALS, HID_USAGE_SENSOR_UNITS_LUX, 1, 0},
1228 -
1229 - {HID_USAGE_SENSOR_PRESSURE, 0, 100, 0},
1230 -- {HID_USAGE_SENSOR_PRESSURE, HID_USAGE_SENSOR_UNITS_PASCAL, 0, 1000},
1231 -+ {HID_USAGE_SENSOR_PRESSURE, HID_USAGE_SENSOR_UNITS_PASCAL, 0, 1000000},
1232 - };
1233 -
1234 - static int pow_10(unsigned power)
1235 -@@ -266,15 +266,15 @@ EXPORT_SYMBOL(hid_sensor_write_raw_hyst_value);
1236 - /*
1237 - * This fuction applies the unit exponent to the scale.
1238 - * For example:
1239 -- * 9.806650 ->exp:2-> val0[980]val1[665000]
1240 -- * 9.000806 ->exp:2-> val0[900]val1[80600]
1241 -- * 0.174535 ->exp:2-> val0[17]val1[453500]
1242 -- * 1.001745 ->exp:0-> val0[1]val1[1745]
1243 -- * 1.001745 ->exp:2-> val0[100]val1[174500]
1244 -- * 1.001745 ->exp:4-> val0[10017]val1[450000]
1245 -- * 9.806650 ->exp:-2-> val0[0]val1[98066]
1246 -+ * 9.806650000 ->exp:2-> val0[980]val1[665000000]
1247 -+ * 9.000806000 ->exp:2-> val0[900]val1[80600000]
1248 -+ * 0.174535293 ->exp:2-> val0[17]val1[453529300]
1249 -+ * 1.001745329 ->exp:0-> val0[1]val1[1745329]
1250 -+ * 1.001745329 ->exp:2-> val0[100]val1[174532900]
1251 -+ * 1.001745329 ->exp:4-> val0[10017]val1[453290000]
1252 -+ * 9.806650000 ->exp:-2-> val0[0]val1[98066500]
1253 - */
1254 --static void adjust_exponent_micro(int *val0, int *val1, int scale0,
1255 -+static void adjust_exponent_nano(int *val0, int *val1, int scale0,
1256 - int scale1, int exp)
1257 - {
1258 - int i;
1259 -@@ -285,32 +285,32 @@ static void adjust_exponent_micro(int *val0, int *val1, int scale0,
1260 - if (exp > 0) {
1261 - *val0 = scale0 * pow_10(exp);
1262 - res = 0;
1263 -- if (exp > 6) {
1264 -+ if (exp > 9) {
1265 - *val1 = 0;
1266 - return;
1267 - }
1268 - for (i = 0; i < exp; ++i) {
1269 -- x = scale1 / pow_10(5 - i);
1270 -+ x = scale1 / pow_10(8 - i);
1271 - res += (pow_10(exp - 1 - i) * x);
1272 -- scale1 = scale1 % pow_10(5 - i);
1273 -+ scale1 = scale1 % pow_10(8 - i);
1274 - }
1275 - *val0 += res;
1276 - *val1 = scale1 * pow_10(exp);
1277 - } else if (exp < 0) {
1278 - exp = abs(exp);
1279 -- if (exp > 6) {
1280 -+ if (exp > 9) {
1281 - *val0 = *val1 = 0;
1282 - return;
1283 - }
1284 - *val0 = scale0 / pow_10(exp);
1285 - rem = scale0 % pow_10(exp);
1286 - res = 0;
1287 -- for (i = 0; i < (6 - exp); ++i) {
1288 -- x = scale1 / pow_10(5 - i);
1289 -- res += (pow_10(5 - exp - i) * x);
1290 -- scale1 = scale1 % pow_10(5 - i);
1291 -+ for (i = 0; i < (9 - exp); ++i) {
1292 -+ x = scale1 / pow_10(8 - i);
1293 -+ res += (pow_10(8 - exp - i) * x);
1294 -+ scale1 = scale1 % pow_10(8 - i);
1295 - }
1296 -- *val1 = rem * pow_10(6 - exp) + res;
1297 -+ *val1 = rem * pow_10(9 - exp) + res;
1298 - } else {
1299 - *val0 = scale0;
1300 - *val1 = scale1;
1301 -@@ -332,14 +332,14 @@ int hid_sensor_format_scale(u32 usage_id,
1302 - unit_conversion[i].unit == attr_info->units) {
1303 - exp = hid_sensor_convert_exponent(
1304 - attr_info->unit_expo);
1305 -- adjust_exponent_micro(val0, val1,
1306 -+ adjust_exponent_nano(val0, val1,
1307 - unit_conversion[i].scale_val0,
1308 - unit_conversion[i].scale_val1, exp);
1309 - break;
1310 - }
1311 - }
1312 -
1313 -- return IIO_VAL_INT_PLUS_MICRO;
1314 -+ return IIO_VAL_INT_PLUS_NANO;
1315 - }
1316 - EXPORT_SYMBOL(hid_sensor_format_scale);
1317 -
1318 -diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
1319 -index 2d5282e..32a5946 100644
1320 ---- a/drivers/iio/common/st_sensors/st_sensors_core.c
1321 -+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
1322 -@@ -619,7 +619,7 @@ EXPORT_SYMBOL(st_sensors_sysfs_sampling_frequency_avail);
1323 - ssize_t st_sensors_sysfs_scale_avail(struct device *dev,
1324 - struct device_attribute *attr, char *buf)
1325 - {
1326 -- int i, len = 0;
1327 -+ int i, len = 0, q, r;
1328 - struct iio_dev *indio_dev = dev_get_drvdata(dev);
1329 - struct st_sensor_data *sdata = iio_priv(indio_dev);
1330 -
1331 -@@ -628,8 +628,10 @@ ssize_t st_sensors_sysfs_scale_avail(struct device *dev,
1332 - if (sdata->sensor_settings->fs.fs_avl[i].num == 0)
1333 - break;
1334 -
1335 -- len += scnprintf(buf + len, PAGE_SIZE - len, "0.%06u ",
1336 -- sdata->sensor_settings->fs.fs_avl[i].gain);
1337 -+ q = sdata->sensor_settings->fs.fs_avl[i].gain / 1000000;
1338 -+ r = sdata->sensor_settings->fs.fs_avl[i].gain % 1000000;
1339 -+
1340 -+ len += scnprintf(buf + len, PAGE_SIZE - len, "%u.%06u ", q, r);
1341 - }
1342 - mutex_unlock(&indio_dev->mlock);
1343 - buf[len - 1] = '\n';
1344 -diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c
1345 -index b98b9d9..a97e802c 100644
1346 ---- a/drivers/iio/orientation/hid-sensor-rotation.c
1347 -+++ b/drivers/iio/orientation/hid-sensor-rotation.c
1348 -@@ -335,6 +335,7 @@ static struct platform_driver hid_dev_rot_platform_driver = {
1349 - .id_table = hid_dev_rot_ids,
1350 - .driver = {
1351 - .name = KBUILD_MODNAME,
1352 -+ .pm = &hid_sensor_pm_ops,
1353 - },
1354 - .probe = hid_dev_rot_probe,
1355 - .remove = hid_dev_rot_remove,
1356 -diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
1357 -index 6f2e0e4..1ebc2c1 100644
1358 ---- a/drivers/input/rmi4/rmi_i2c.c
1359 -+++ b/drivers/input/rmi4/rmi_i2c.c
1360 -@@ -221,6 +221,21 @@ static const struct of_device_id rmi_i2c_of_match[] = {
1361 - MODULE_DEVICE_TABLE(of, rmi_i2c_of_match);
1362 - #endif
1363 -
1364 -+static void rmi_i2c_regulator_bulk_disable(void *data)
1365 -+{
1366 -+ struct rmi_i2c_xport *rmi_i2c = data;
1367 -+
1368 -+ regulator_bulk_disable(ARRAY_SIZE(rmi_i2c->supplies),
1369 -+ rmi_i2c->supplies);
1370 -+}
1371 -+
1372 -+static void rmi_i2c_unregister_transport(void *data)
1373 -+{
1374 -+ struct rmi_i2c_xport *rmi_i2c = data;
1375 -+
1376 -+ rmi_unregister_transport_device(&rmi_i2c->xport);
1377 -+}
1378 -+
1379 - static int rmi_i2c_probe(struct i2c_client *client,
1380 - const struct i2c_device_id *id)
1381 - {
1382 -@@ -264,6 +279,12 @@ static int rmi_i2c_probe(struct i2c_client *client,
1383 - if (retval < 0)
1384 - return retval;
1385 -
1386 -+ retval = devm_add_action_or_reset(&client->dev,
1387 -+ rmi_i2c_regulator_bulk_disable,
1388 -+ rmi_i2c);
1389 -+ if (retval)
1390 -+ return retval;
1391 -+
1392 - of_property_read_u32(client->dev.of_node, "syna,startup-delay-ms",
1393 - &rmi_i2c->startup_delay);
1394 -
1395 -@@ -294,6 +315,11 @@ static int rmi_i2c_probe(struct i2c_client *client,
1396 - client->addr);
1397 - return retval;
1398 - }
1399 -+ retval = devm_add_action_or_reset(&client->dev,
1400 -+ rmi_i2c_unregister_transport,
1401 -+ rmi_i2c);
1402 -+ if (retval)
1403 -+ return retval;
1404 -
1405 - retval = rmi_i2c_init_irq(client);
1406 - if (retval < 0)
1407 -@@ -304,17 +330,6 @@ static int rmi_i2c_probe(struct i2c_client *client,
1408 - return 0;
1409 - }
1410 -
1411 --static int rmi_i2c_remove(struct i2c_client *client)
1412 --{
1413 -- struct rmi_i2c_xport *rmi_i2c = i2c_get_clientdata(client);
1414 --
1415 -- rmi_unregister_transport_device(&rmi_i2c->xport);
1416 -- regulator_bulk_disable(ARRAY_SIZE(rmi_i2c->supplies),
1417 -- rmi_i2c->supplies);
1418 --
1419 -- return 0;
1420 --}
1421 --
1422 - #ifdef CONFIG_PM_SLEEP
1423 - static int rmi_i2c_suspend(struct device *dev)
1424 - {
1425 -@@ -431,7 +446,6 @@ static struct i2c_driver rmi_i2c_driver = {
1426 - },
1427 - .id_table = rmi_id,
1428 - .probe = rmi_i2c_probe,
1429 -- .remove = rmi_i2c_remove,
1430 - };
1431 -
1432 - module_i2c_driver(rmi_i2c_driver);
1433 -diff --git a/drivers/input/rmi4/rmi_spi.c b/drivers/input/rmi4/rmi_spi.c
1434 -index 55bd1b3..4ebef60 100644
1435 ---- a/drivers/input/rmi4/rmi_spi.c
1436 -+++ b/drivers/input/rmi4/rmi_spi.c
1437 -@@ -396,6 +396,13 @@ static inline int rmi_spi_of_probe(struct spi_device *spi,
1438 - }
1439 - #endif
1440 -
1441 -+static void rmi_spi_unregister_transport(void *data)
1442 -+{
1443 -+ struct rmi_spi_xport *rmi_spi = data;
1444 -+
1445 -+ rmi_unregister_transport_device(&rmi_spi->xport);
1446 -+}
1447 -+
1448 - static int rmi_spi_probe(struct spi_device *spi)
1449 - {
1450 - struct rmi_spi_xport *rmi_spi;
1451 -@@ -464,6 +471,11 @@ static int rmi_spi_probe(struct spi_device *spi)
1452 - dev_err(&spi->dev, "failed to register transport.\n");
1453 - return retval;
1454 - }
1455 -+ retval = devm_add_action_or_reset(&spi->dev,
1456 -+ rmi_spi_unregister_transport,
1457 -+ rmi_spi);
1458 -+ if (retval)
1459 -+ return retval;
1460 -
1461 - retval = rmi_spi_init_irq(spi);
1462 - if (retval < 0)
1463 -@@ -473,15 +485,6 @@ static int rmi_spi_probe(struct spi_device *spi)
1464 - return 0;
1465 - }
1466 -
1467 --static int rmi_spi_remove(struct spi_device *spi)
1468 --{
1469 -- struct rmi_spi_xport *rmi_spi = spi_get_drvdata(spi);
1470 --
1471 -- rmi_unregister_transport_device(&rmi_spi->xport);
1472 --
1473 -- return 0;
1474 --}
1475 --
1476 - #ifdef CONFIG_PM_SLEEP
1477 - static int rmi_spi_suspend(struct device *dev)
1478 - {
1479 -@@ -577,7 +580,6 @@ static struct spi_driver rmi_spi_driver = {
1480 - },
1481 - .id_table = rmi_id,
1482 - .probe = rmi_spi_probe,
1483 -- .remove = rmi_spi_remove,
1484 - };
1485 -
1486 - module_spi_driver(rmi_spi_driver);
1487 -diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
1488 -index 96de97a..822fc4a 100644
1489 ---- a/drivers/iommu/amd_iommu.c
1490 -+++ b/drivers/iommu/amd_iommu.c
1491 -@@ -1654,6 +1654,9 @@ static void dma_ops_domain_free(struct dma_ops_domain *dom)
1492 -
1493 - free_pagetable(&dom->domain);
1494 -
1495 -+ if (dom->domain.id)
1496 -+ domain_id_free(dom->domain.id);
1497 -+
1498 - kfree(dom);
1499 - }
1500 -
1501 -diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
1502 -index ebb5bf3..1257b0b 100644
1503 ---- a/drivers/iommu/intel-iommu.c
1504 -+++ b/drivers/iommu/intel-iommu.c
1505 -@@ -1711,6 +1711,7 @@ static void disable_dmar_iommu(struct intel_iommu *iommu)
1506 - if (!iommu->domains || !iommu->domain_ids)
1507 - return;
1508 -
1509 -+again:
1510 - spin_lock_irqsave(&device_domain_lock, flags);
1511 - list_for_each_entry_safe(info, tmp, &device_domain_list, global) {
1512 - struct dmar_domain *domain;
1513 -@@ -1723,10 +1724,19 @@ static void disable_dmar_iommu(struct intel_iommu *iommu)
1514 -
1515 - domain = info->domain;
1516 -
1517 -- dmar_remove_one_dev_info(domain, info->dev);
1518 -+ __dmar_remove_one_dev_info(info);
1519 -
1520 -- if (!domain_type_is_vm_or_si(domain))
1521 -+ if (!domain_type_is_vm_or_si(domain)) {
1522 -+ /*
1523 -+ * The domain_exit() function can't be called under
1524 -+ * device_domain_lock, as it takes this lock itself.
1525 -+ * So release the lock here and re-run the loop
1526 -+ * afterwards.
1527 -+ */
1528 -+ spin_unlock_irqrestore(&device_domain_lock, flags);
1529 - domain_exit(domain);
1530 -+ goto again;
1531 -+ }
1532 - }
1533 - spin_unlock_irqrestore(&device_domain_lock, flags);
1534 -
1535 -diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c
1536 -index def8ca1..f50e51c 100644
1537 ---- a/drivers/iommu/io-pgtable-arm-v7s.c
1538 -+++ b/drivers/iommu/io-pgtable-arm-v7s.c
1539 -@@ -633,6 +633,10 @@ static struct io_pgtable *arm_v7s_alloc_pgtable(struct io_pgtable_cfg *cfg,
1540 - {
1541 - struct arm_v7s_io_pgtable *data;
1542 -
1543 -+#ifdef PHYS_OFFSET
1544 -+ if (upper_32_bits(PHYS_OFFSET))
1545 -+ return NULL;
1546 -+#endif
1547 - if (cfg->ias > ARM_V7S_ADDR_BITS || cfg->oas > ARM_V7S_ADDR_BITS)
1548 - return NULL;
1549 -
1550 -diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c b/drivers/media/usb/dvb-usb/dib0700_core.c
1551 -index bf890c3..f73e108 100644
1552 ---- a/drivers/media/usb/dvb-usb/dib0700_core.c
1553 -+++ b/drivers/media/usb/dvb-usb/dib0700_core.c
1554 -@@ -677,7 +677,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
1555 - struct dvb_usb_device *d = purb->context;
1556 - struct dib0700_rc_response *poll_reply;
1557 - enum rc_type protocol;
1558 -- u32 uninitialized_var(keycode);
1559 -+ u32 keycode;
1560 - u8 toggle;
1561 -
1562 - deb_info("%s()\n", __func__);
1563 -@@ -719,7 +719,8 @@ static void dib0700_rc_urb_completion(struct urb *purb)
1564 - poll_reply->nec.data == 0x00 &&
1565 - poll_reply->nec.not_data == 0xff) {
1566 - poll_reply->data_state = 2;
1567 -- break;
1568 -+ rc_repeat(d->rc_dev);
1569 -+ goto resubmit;
1570 - }
1571 -
1572 - if ((poll_reply->nec.data ^ poll_reply->nec.not_data) != 0xff) {
1573 -diff --git a/drivers/misc/mei/bus-fixup.c b/drivers/misc/mei/bus-fixup.c
1574 -index e9e6ea3..75b9d4a 100644
1575 ---- a/drivers/misc/mei/bus-fixup.c
1576 -+++ b/drivers/misc/mei/bus-fixup.c
1577 -@@ -178,7 +178,7 @@ static int mei_nfc_if_version(struct mei_cl *cl,
1578 -
1579 - ret = 0;
1580 - bytes_recv = __mei_cl_recv(cl, (u8 *)reply, if_version_length);
1581 -- if (bytes_recv < 0 || bytes_recv < sizeof(struct mei_nfc_reply)) {
1582 -+ if (bytes_recv < if_version_length) {
1583 - dev_err(bus->dev, "Could not read IF version\n");
1584 - ret = -EIO;
1585 - goto err;
1586 -diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
1587 -index c57eb32..6ef1e3c 100644
1588 ---- a/drivers/mmc/core/mmc.c
1589 -+++ b/drivers/mmc/core/mmc.c
1590 -@@ -26,6 +26,8 @@
1591 - #include "mmc_ops.h"
1592 - #include "sd_ops.h"
1593 -
1594 -+#define DEFAULT_CMD6_TIMEOUT_MS 500
1595 -+
1596 - static const unsigned int tran_exp[] = {
1597 - 10000, 100000, 1000000, 10000000,
1598 - 0, 0, 0, 0
1599 -@@ -571,6 +573,7 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
1600 - card->erased_byte = 0x0;
1601 -
1602 - /* eMMC v4.5 or later */
1603 -+ card->ext_csd.generic_cmd6_time = DEFAULT_CMD6_TIMEOUT_MS;
1604 - if (card->ext_csd.rev >= 6) {
1605 - card->ext_csd.feature_support |= MMC_DISCARD_FEATURE;
1606 -
1607 -diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
1608 -index d839147..44ecebd 100644
1609 ---- a/drivers/mmc/host/mxs-mmc.c
1610 -+++ b/drivers/mmc/host/mxs-mmc.c
1611 -@@ -661,13 +661,13 @@ static int mxs_mmc_probe(struct platform_device *pdev)
1612 -
1613 - platform_set_drvdata(pdev, mmc);
1614 -
1615 -+ spin_lock_init(&host->lock);
1616 -+
1617 - ret = devm_request_irq(&pdev->dev, irq_err, mxs_mmc_irq_handler, 0,
1618 - dev_name(&pdev->dev), host);
1619 - if (ret)
1620 - goto out_free_dma;
1621 -
1622 -- spin_lock_init(&host->lock);
1623 --
1624 - ret = mmc_add_host(mmc);
1625 - if (ret)
1626 - goto out_free_dma;
1627 -diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
1628 -index 8ef44a2a..90ed2e1 100644
1629 ---- a/drivers/mmc/host/sdhci-msm.c
1630 -+++ b/drivers/mmc/host/sdhci-msm.c
1631 -@@ -647,6 +647,7 @@ static int sdhci_msm_probe(struct platform_device *pdev)
1632 - if (msm_host->pwr_irq < 0) {
1633 - dev_err(&pdev->dev, "Get pwr_irq failed (%d)\n",
1634 - msm_host->pwr_irq);
1635 -+ ret = msm_host->pwr_irq;
1636 - goto clk_disable;
1637 - }
1638 -
1639 -diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
1640 -index a8a022a..6eb8f07 100644
1641 ---- a/drivers/mmc/host/sdhci.c
1642 -+++ b/drivers/mmc/host/sdhci.c
1643 -@@ -2269,10 +2269,8 @@ static bool sdhci_request_done(struct sdhci_host *host)
1644 -
1645 - for (i = 0; i < SDHCI_MAX_MRQS; i++) {
1646 - mrq = host->mrqs_done[i];
1647 -- if (mrq) {
1648 -- host->mrqs_done[i] = NULL;
1649 -+ if (mrq)
1650 - break;
1651 -- }
1652 - }
1653 -
1654 - if (!mrq) {
1655 -@@ -2303,6 +2301,17 @@ static bool sdhci_request_done(struct sdhci_host *host)
1656 - * upon error conditions.
1657 - */
1658 - if (sdhci_needs_reset(host, mrq)) {
1659 -+ /*
1660 -+ * Do not finish until command and data lines are available for
1661 -+ * reset. Note there can only be one other mrq, so it cannot
1662 -+ * also be in mrqs_done, otherwise host->cmd and host->data_cmd
1663 -+ * would both be null.
1664 -+ */
1665 -+ if (host->cmd || host->data_cmd) {
1666 -+ spin_unlock_irqrestore(&host->lock, flags);
1667 -+ return true;
1668 -+ }
1669 -+
1670 - /* Some controllers need this kick or reset won't work here */
1671 - if (host->quirks & SDHCI_QUIRK_CLOCK_BEFORE_RESET)
1672 - /* This is to force an update */
1673 -@@ -2310,10 +2319,8 @@ static bool sdhci_request_done(struct sdhci_host *host)
1674 -
1675 - /* Spec says we should do both at the same time, but Ricoh
1676 - controllers do not like that. */
1677 -- if (!host->cmd)
1678 -- sdhci_do_reset(host, SDHCI_RESET_CMD);
1679 -- if (!host->data_cmd)
1680 -- sdhci_do_reset(host, SDHCI_RESET_DATA);
1681 -+ sdhci_do_reset(host, SDHCI_RESET_CMD);
1682 -+ sdhci_do_reset(host, SDHCI_RESET_DATA);
1683 -
1684 - host->pending_reset = false;
1685 - }
1686 -@@ -2321,6 +2328,8 @@ static bool sdhci_request_done(struct sdhci_host *host)
1687 - if (!sdhci_has_requests(host))
1688 - sdhci_led_deactivate(host);
1689 -
1690 -+ host->mrqs_done[i] = NULL;
1691 -+
1692 - mmiowb();
1693 - spin_unlock_irqrestore(&host->lock, flags);
1694 -
1695 -@@ -2500,9 +2509,6 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
1696 - if (!host->data) {
1697 - struct mmc_command *data_cmd = host->data_cmd;
1698 -
1699 -- if (data_cmd)
1700 -- host->data_cmd = NULL;
1701 --
1702 - /*
1703 - * The "data complete" interrupt is also used to
1704 - * indicate that a busy state has ended. See comment
1705 -@@ -2510,11 +2516,13 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
1706 - */
1707 - if (data_cmd && (data_cmd->flags & MMC_RSP_BUSY)) {
1708 - if (intmask & SDHCI_INT_DATA_TIMEOUT) {
1709 -+ host->data_cmd = NULL;
1710 - data_cmd->error = -ETIMEDOUT;
1711 - sdhci_finish_mrq(host, data_cmd->mrq);
1712 - return;
1713 - }
1714 - if (intmask & SDHCI_INT_DATA_END) {
1715 -+ host->data_cmd = NULL;
1716 - /*
1717 - * Some cards handle busy-end interrupt
1718 - * before the command completed, so make
1719 -diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
1720 -index c74d164..6b46a37 100644
1721 ---- a/drivers/net/ethernet/intel/i40e/i40e_main.c
1722 -+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
1723 -@@ -9001,7 +9001,7 @@ static int i40e_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
1724 - return 0;
1725 -
1726 - return ndo_dflt_bridge_getlink(skb, pid, seq, dev, veb->bridge_mode,
1727 -- nlflags, 0, 0, filter_mask, NULL);
1728 -+ 0, 0, nlflags, filter_mask, NULL);
1729 - }
1730 -
1731 - /* Hardware supports L4 tunnel length of 128B (=2^7) which includes
1732 -diff --git a/drivers/nfc/mei_phy.c b/drivers/nfc/mei_phy.c
1733 -index 83deda4..6f9563a 100644
1734 ---- a/drivers/nfc/mei_phy.c
1735 -+++ b/drivers/nfc/mei_phy.c
1736 -@@ -133,7 +133,7 @@ static int mei_nfc_if_version(struct nfc_mei_phy *phy)
1737 - return -ENOMEM;
1738 -
1739 - bytes_recv = mei_cldev_recv(phy->cldev, (u8 *)reply, if_version_length);
1740 -- if (bytes_recv < 0 || bytes_recv < sizeof(struct mei_nfc_reply)) {
1741 -+ if (bytes_recv < 0 || bytes_recv < if_version_length) {
1742 - pr_err("Could not read IF version\n");
1743 - r = -EIO;
1744 - goto err;
1745 -diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
1746 -index 60f7eab..da134a0 100644
1747 ---- a/drivers/nvme/host/pci.c
1748 -+++ b/drivers/nvme/host/pci.c
1749 -@@ -1531,9 +1531,9 @@ static int nvme_delete_queue(struct nvme_queue *nvmeq, u8 opcode)
1750 - return 0;
1751 - }
1752 -
1753 --static void nvme_disable_io_queues(struct nvme_dev *dev)
1754 -+static void nvme_disable_io_queues(struct nvme_dev *dev, int queues)
1755 - {
1756 -- int pass, queues = dev->online_queues - 1;
1757 -+ int pass;
1758 - unsigned long timeout;
1759 - u8 opcode = nvme_admin_delete_sq;
1760 -
1761 -@@ -1678,7 +1678,7 @@ static void nvme_pci_disable(struct nvme_dev *dev)
1762 -
1763 - static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
1764 - {
1765 -- int i;
1766 -+ int i, queues;
1767 - u32 csts = -1;
1768 -
1769 - del_timer_sync(&dev->watchdog_timer);
1770 -@@ -1689,6 +1689,7 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
1771 - csts = readl(dev->bar + NVME_REG_CSTS);
1772 - }
1773 -
1774 -+ queues = dev->online_queues - 1;
1775 - for (i = dev->queue_count - 1; i > 0; i--)
1776 - nvme_suspend_queue(dev->queues[i]);
1777 -
1778 -@@ -1700,7 +1701,7 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
1779 - if (dev->queue_count)
1780 - nvme_suspend_queue(dev->queues[0]);
1781 - } else {
1782 -- nvme_disable_io_queues(dev);
1783 -+ nvme_disable_io_queues(dev, queues);
1784 - nvme_disable_admin_queue(dev, shutdown);
1785 - }
1786 - nvme_pci_disable(dev);
1787 -diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
1788 -index 66c4d8f..9526e34 100644
1789 ---- a/drivers/pci/setup-res.c
1790 -+++ b/drivers/pci/setup-res.c
1791 -@@ -121,6 +121,14 @@ int pci_claim_resource(struct pci_dev *dev, int resource)
1792 - return -EINVAL;
1793 - }
1794 -
1795 -+ /*
1796 -+ * If we have a shadow copy in RAM, the PCI device doesn't respond
1797 -+ * to the shadow range, so we don't need to claim it, and upstream
1798 -+ * bridges don't need to route the range to the device.
1799 -+ */
1800 -+ if (res->flags & IORESOURCE_ROM_SHADOW)
1801 -+ return 0;
1802 -+
1803 - root = pci_find_parent_resource(dev, res);
1804 - if (!root) {
1805 - dev_info(&dev->dev, "can't claim BAR %d %pR: no compatible bridge window\n",
1806 -diff --git a/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c b/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
1807 -index 7f77007..5d1e505c3 100644
1808 ---- a/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
1809 -+++ b/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
1810 -@@ -844,6 +844,6 @@ static struct platform_driver iproc_gpio_driver = {
1811 -
1812 - static int __init iproc_gpio_init(void)
1813 - {
1814 -- return platform_driver_probe(&iproc_gpio_driver, iproc_gpio_probe);
1815 -+ return platform_driver_register(&iproc_gpio_driver);
1816 - }
1817 - arch_initcall_sync(iproc_gpio_init);
1818 -diff --git a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
1819 -index 35783db..c8deb8b 100644
1820 ---- a/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
1821 -+++ b/drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
1822 -@@ -741,6 +741,6 @@ static struct platform_driver nsp_gpio_driver = {
1823 -
1824 - static int __init nsp_gpio_init(void)
1825 - {
1826 -- return platform_driver_probe(&nsp_gpio_driver, nsp_gpio_probe);
1827 -+ return platform_driver_register(&nsp_gpio_driver);
1828 - }
1829 - arch_initcall_sync(nsp_gpio_init);
1830 -diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c
1831 -index 0fe8fad..bc31504 100644
1832 ---- a/drivers/pinctrl/intel/pinctrl-cherryview.c
1833 -+++ b/drivers/pinctrl/intel/pinctrl-cherryview.c
1834 -@@ -1634,12 +1634,15 @@ static int chv_pinctrl_remove(struct platform_device *pdev)
1835 - }
1836 -
1837 - #ifdef CONFIG_PM_SLEEP
1838 --static int chv_pinctrl_suspend(struct device *dev)
1839 -+static int chv_pinctrl_suspend_noirq(struct device *dev)
1840 - {
1841 - struct platform_device *pdev = to_platform_device(dev);
1842 - struct chv_pinctrl *pctrl = platform_get_drvdata(pdev);
1843 -+ unsigned long flags;
1844 - int i;
1845 -
1846 -+ raw_spin_lock_irqsave(&chv_lock, flags);
1847 -+
1848 - pctrl->saved_intmask = readl(pctrl->regs + CHV_INTMASK);
1849 -
1850 - for (i = 0; i < pctrl->community->npins; i++) {
1851 -@@ -1660,15 +1663,20 @@ static int chv_pinctrl_suspend(struct device *dev)
1852 - ctx->padctrl1 = readl(reg);
1853 - }
1854 -
1855 -+ raw_spin_unlock_irqrestore(&chv_lock, flags);
1856 -+
1857 - return 0;
1858 - }
1859 -
1860 --static int chv_pinctrl_resume(struct device *dev)
1861 -+static int chv_pinctrl_resume_noirq(struct device *dev)
1862 - {
1863 - struct platform_device *pdev = to_platform_device(dev);
1864 - struct chv_pinctrl *pctrl = platform_get_drvdata(pdev);
1865 -+ unsigned long flags;
1866 - int i;
1867 -
1868 -+ raw_spin_lock_irqsave(&chv_lock, flags);
1869 -+
1870 - /*
1871 - * Mask all interrupts before restoring per-pin configuration
1872 - * registers because we don't know in which state BIOS left them
1873 -@@ -1713,12 +1721,15 @@ static int chv_pinctrl_resume(struct device *dev)
1874 - chv_writel(0xffff, pctrl->regs + CHV_INTSTAT);
1875 - chv_writel(pctrl->saved_intmask, pctrl->regs + CHV_INTMASK);
1876 -
1877 -+ raw_spin_unlock_irqrestore(&chv_lock, flags);
1878 -+
1879 - return 0;
1880 - }
1881 - #endif
1882 -
1883 - static const struct dev_pm_ops chv_pinctrl_pm_ops = {
1884 -- SET_LATE_SYSTEM_SLEEP_PM_OPS(chv_pinctrl_suspend, chv_pinctrl_resume)
1885 -+ SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(chv_pinctrl_suspend_noirq,
1886 -+ chv_pinctrl_resume_noirq)
1887 - };
1888 -
1889 - static const struct acpi_device_id chv_pinctrl_acpi_match[] = {
1890 -diff --git a/drivers/platform/x86/toshiba-wmi.c b/drivers/platform/x86/toshiba-wmi.c
1891 -index feac457..2df07ee 100644
1892 ---- a/drivers/platform/x86/toshiba-wmi.c
1893 -+++ b/drivers/platform/x86/toshiba-wmi.c
1894 -@@ -24,14 +24,15 @@
1895 - #include <linux/acpi.h>
1896 - #include <linux/input.h>
1897 - #include <linux/input/sparse-keymap.h>
1898 -+#include <linux/dmi.h>
1899 -
1900 - MODULE_AUTHOR("Azael Avalos");
1901 - MODULE_DESCRIPTION("Toshiba WMI Hotkey Driver");
1902 - MODULE_LICENSE("GPL");
1903 -
1904 --#define TOSHIBA_WMI_EVENT_GUID "59142400-C6A3-40FA-BADB-8A2652834100"
1905 -+#define WMI_EVENT_GUID "59142400-C6A3-40FA-BADB-8A2652834100"
1906 -
1907 --MODULE_ALIAS("wmi:"TOSHIBA_WMI_EVENT_GUID);
1908 -+MODULE_ALIAS("wmi:"WMI_EVENT_GUID);
1909 -
1910 - static struct input_dev *toshiba_wmi_input_dev;
1911 -
1912 -@@ -63,6 +64,16 @@ static void toshiba_wmi_notify(u32 value, void *context)
1913 - kfree(response.pointer);
1914 - }
1915 -
1916 -+static struct dmi_system_id toshiba_wmi_dmi_table[] __initdata = {
1917 -+ {
1918 -+ .ident = "Toshiba laptop",
1919 -+ .matches = {
1920 -+ DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
1921 -+ },
1922 -+ },
1923 -+ {}
1924 -+};
1925 -+
1926 - static int __init toshiba_wmi_input_setup(void)
1927 - {
1928 - acpi_status status;
1929 -@@ -81,7 +92,7 @@ static int __init toshiba_wmi_input_setup(void)
1930 - if (err)
1931 - goto err_free_dev;
1932 -
1933 -- status = wmi_install_notify_handler(TOSHIBA_WMI_EVENT_GUID,
1934 -+ status = wmi_install_notify_handler(WMI_EVENT_GUID,
1935 - toshiba_wmi_notify, NULL);
1936 - if (ACPI_FAILURE(status)) {
1937 - err = -EIO;
1938 -@@ -95,7 +106,7 @@ static int __init toshiba_wmi_input_setup(void)
1939 - return 0;
1940 -
1941 - err_remove_notifier:
1942 -- wmi_remove_notify_handler(TOSHIBA_WMI_EVENT_GUID);
1943 -+ wmi_remove_notify_handler(WMI_EVENT_GUID);
1944 - err_free_keymap:
1945 - sparse_keymap_free(toshiba_wmi_input_dev);
1946 - err_free_dev:
1947 -@@ -105,7 +116,7 @@ static int __init toshiba_wmi_input_setup(void)
1948 -
1949 - static void toshiba_wmi_input_destroy(void)
1950 - {
1951 -- wmi_remove_notify_handler(TOSHIBA_WMI_EVENT_GUID);
1952 -+ wmi_remove_notify_handler(WMI_EVENT_GUID);
1953 - sparse_keymap_free(toshiba_wmi_input_dev);
1954 - input_unregister_device(toshiba_wmi_input_dev);
1955 - }
1956 -@@ -114,7 +125,8 @@ static int __init toshiba_wmi_init(void)
1957 - {
1958 - int ret;
1959 -
1960 -- if (!wmi_has_guid(TOSHIBA_WMI_EVENT_GUID))
1961 -+ if (!wmi_has_guid(WMI_EVENT_GUID) ||
1962 -+ !dmi_check_system(toshiba_wmi_dmi_table))
1963 - return -ENODEV;
1964 -
1965 - ret = toshiba_wmi_input_setup();
1966 -@@ -130,7 +142,7 @@ static int __init toshiba_wmi_init(void)
1967 -
1968 - static void __exit toshiba_wmi_exit(void)
1969 - {
1970 -- if (wmi_has_guid(TOSHIBA_WMI_EVENT_GUID))
1971 -+ if (wmi_has_guid(WMI_EVENT_GUID))
1972 - toshiba_wmi_input_destroy();
1973 - }
1974 -
1975 -diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c
1976 -index b4478cc..8895f77 100644
1977 ---- a/drivers/rtc/rtc-pcf2123.c
1978 -+++ b/drivers/rtc/rtc-pcf2123.c
1979 -@@ -182,7 +182,8 @@ static ssize_t pcf2123_show(struct device *dev, struct device_attribute *attr,
1980 - }
1981 -
1982 - static ssize_t pcf2123_store(struct device *dev, struct device_attribute *attr,
1983 -- const char *buffer, size_t count) {
1984 -+ const char *buffer, size_t count)
1985 -+{
1986 - struct pcf2123_sysfs_reg *r;
1987 - unsigned long reg;
1988 - unsigned long val;
1989 -@@ -199,7 +200,7 @@ static ssize_t pcf2123_store(struct device *dev, struct device_attribute *attr,
1990 - if (ret)
1991 - return ret;
1992 -
1993 -- pcf2123_write_reg(dev, reg, val);
1994 -+ ret = pcf2123_write_reg(dev, reg, val);
1995 - if (ret < 0)
1996 - return -EIO;
1997 - return count;
1998 -diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
1999 -index 752b5c9..920c421 100644
2000 ---- a/drivers/scsi/device_handler/scsi_dh_alua.c
2001 -+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
2002 -@@ -792,6 +792,7 @@ static void alua_rtpg_work(struct work_struct *work)
2003 - WARN_ON(pg->flags & ALUA_PG_RUN_RTPG);
2004 - WARN_ON(pg->flags & ALUA_PG_RUN_STPG);
2005 - spin_unlock_irqrestore(&pg->lock, flags);
2006 -+ kref_put(&pg->kref, release_port_group);
2007 - return;
2008 - }
2009 - if (pg->flags & ALUA_SYNC_STPG)
2010 -@@ -889,6 +890,7 @@ static void alua_rtpg_queue(struct alua_port_group *pg,
2011 - /* Do not queue if the worker is already running */
2012 - if (!(pg->flags & ALUA_PG_RUNNING)) {
2013 - kref_get(&pg->kref);
2014 -+ sdev = NULL;
2015 - start_queue = 1;
2016 - }
2017 - }
2018 -@@ -900,7 +902,8 @@ static void alua_rtpg_queue(struct alua_port_group *pg,
2019 - if (start_queue &&
2020 - !queue_delayed_work(alua_wq, &pg->rtpg_work,
2021 - msecs_to_jiffies(ALUA_RTPG_DELAY_MSECS))) {
2022 -- scsi_device_put(sdev);
2023 -+ if (sdev)
2024 -+ scsi_device_put(sdev);
2025 - kref_put(&pg->kref, release_port_group);
2026 - }
2027 - }
2028 -diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
2029 -index 4cb7990..46c0f5e 100644
2030 ---- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
2031 -+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
2032 -@@ -1273,9 +1273,9 @@ scsih_target_alloc(struct scsi_target *starget)
2033 - sas_target_priv_data->handle = raid_device->handle;
2034 - sas_target_priv_data->sas_address = raid_device->wwid;
2035 - sas_target_priv_data->flags |= MPT_TARGET_FLAGS_VOLUME;
2036 -- sas_target_priv_data->raid_device = raid_device;
2037 - if (ioc->is_warpdrive)
2038 -- raid_device->starget = starget;
2039 -+ sas_target_priv_data->raid_device = raid_device;
2040 -+ raid_device->starget = starget;
2041 - }
2042 - spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
2043 - return 0;
2044 -diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
2045 -index 2674f4c..e46e2c5 100644
2046 ---- a/drivers/scsi/qla2xxx/qla_os.c
2047 -+++ b/drivers/scsi/qla2xxx/qla_os.c
2048 -@@ -2341,6 +2341,8 @@ qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time)
2049 - {
2050 - scsi_qla_host_t *vha = shost_priv(shost);
2051 -
2052 -+ if (test_bit(UNLOADING, &vha->dpc_flags))
2053 -+ return 1;
2054 - if (!vha->host)
2055 - return 1;
2056 - if (time > vha->hw->loop_reset_delay * HZ)
2057 -diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c
2058 -index 7043eb0..5ab49a7 100644
2059 ---- a/drivers/staging/comedi/drivers/ni_tio.c
2060 -+++ b/drivers/staging/comedi/drivers/ni_tio.c
2061 -@@ -207,7 +207,8 @@ static int ni_tio_clock_period_ps(const struct ni_gpct *counter,
2062 - * clock period is specified by user with prescaling
2063 - * already taken into account.
2064 - */
2065 -- return counter->clock_period_ps;
2066 -+ *period_ps = counter->clock_period_ps;
2067 -+ return 0;
2068 - }
2069 -
2070 - switch (generic_clock_source & NI_GPCT_PRESCALE_MODE_CLOCK_SRC_MASK) {
2071 -diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
2072 -index 24c348d..98d9473 100644
2073 ---- a/drivers/staging/iio/impedance-analyzer/ad5933.c
2074 -+++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
2075 -@@ -655,6 +655,7 @@ static void ad5933_work(struct work_struct *work)
2076 - __be16 buf[2];
2077 - int val[2];
2078 - unsigned char status;
2079 -+ int ret;
2080 -
2081 - mutex_lock(&indio_dev->mlock);
2082 - if (st->state == AD5933_CTRL_INIT_START_FREQ) {
2083 -@@ -662,19 +663,22 @@ static void ad5933_work(struct work_struct *work)
2084 - ad5933_cmd(st, AD5933_CTRL_START_SWEEP);
2085 - st->state = AD5933_CTRL_START_SWEEP;
2086 - schedule_delayed_work(&st->work, st->poll_time_jiffies);
2087 -- mutex_unlock(&indio_dev->mlock);
2088 -- return;
2089 -+ goto out;
2090 - }
2091 -
2092 -- ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &status);
2093 -+ ret = ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &status);
2094 -+ if (ret)
2095 -+ goto out;
2096 -
2097 - if (status & AD5933_STAT_DATA_VALID) {
2098 - int scan_count = bitmap_weight(indio_dev->active_scan_mask,
2099 - indio_dev->masklength);
2100 -- ad5933_i2c_read(st->client,
2101 -+ ret = ad5933_i2c_read(st->client,
2102 - test_bit(1, indio_dev->active_scan_mask) ?
2103 - AD5933_REG_REAL_DATA : AD5933_REG_IMAG_DATA,
2104 - scan_count * 2, (u8 *)buf);
2105 -+ if (ret)
2106 -+ goto out;
2107 -
2108 - if (scan_count == 2) {
2109 - val[0] = be16_to_cpu(buf[0]);
2110 -@@ -686,8 +690,7 @@ static void ad5933_work(struct work_struct *work)
2111 - } else {
2112 - /* no data available - try again later */
2113 - schedule_delayed_work(&st->work, st->poll_time_jiffies);
2114 -- mutex_unlock(&indio_dev->mlock);
2115 -- return;
2116 -+ goto out;
2117 - }
2118 -
2119 - if (status & AD5933_STAT_SWEEP_DONE) {
2120 -@@ -700,7 +703,7 @@ static void ad5933_work(struct work_struct *work)
2121 - ad5933_cmd(st, AD5933_CTRL_INC_FREQ);
2122 - schedule_delayed_work(&st->work, st->poll_time_jiffies);
2123 - }
2124 --
2125 -+out:
2126 - mutex_unlock(&indio_dev->mlock);
2127 - }
2128 -
2129 -diff --git a/drivers/staging/nvec/nvec_ps2.c b/drivers/staging/nvec/nvec_ps2.c
2130 -index a324322..499952c 100644
2131 ---- a/drivers/staging/nvec/nvec_ps2.c
2132 -+++ b/drivers/staging/nvec/nvec_ps2.c
2133 -@@ -106,13 +106,12 @@ static int nvec_mouse_probe(struct platform_device *pdev)
2134 - {
2135 - struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent);
2136 - struct serio *ser_dev;
2137 -- char mouse_reset[] = { NVEC_PS2, SEND_COMMAND, PSMOUSE_RST, 3 };
2138 -
2139 -- ser_dev = devm_kzalloc(&pdev->dev, sizeof(struct serio), GFP_KERNEL);
2140 -+ ser_dev = kzalloc(sizeof(struct serio), GFP_KERNEL);
2141 - if (!ser_dev)
2142 - return -ENOMEM;
2143 -
2144 -- ser_dev->id.type = SERIO_PS_PSTHRU;
2145 -+ ser_dev->id.type = SERIO_8042;
2146 - ser_dev->write = ps2_sendcommand;
2147 - ser_dev->start = ps2_startstreaming;
2148 - ser_dev->stop = ps2_stopstreaming;
2149 -@@ -127,9 +126,6 @@ static int nvec_mouse_probe(struct platform_device *pdev)
2150 -
2151 - serio_register_port(ser_dev);
2152 -
2153 -- /* mouse reset */
2154 -- nvec_write_async(nvec, mouse_reset, sizeof(mouse_reset));
2155 --
2156 - return 0;
2157 - }
2158 -
2159 -diff --git a/drivers/staging/sm750fb/ddk750_reg.h b/drivers/staging/sm750fb/ddk750_reg.h
2160 -index 9552479..4ed6d8d 100644
2161 ---- a/drivers/staging/sm750fb/ddk750_reg.h
2162 -+++ b/drivers/staging/sm750fb/ddk750_reg.h
2163 -@@ -601,13 +601,13 @@
2164 -
2165 - #define PANEL_PLANE_TL 0x08001C
2166 - #define PANEL_PLANE_TL_TOP_SHIFT 16
2167 --#define PANEL_PLANE_TL_TOP_MASK (0xeff << 16)
2168 --#define PANEL_PLANE_TL_LEFT_MASK 0xeff
2169 -+#define PANEL_PLANE_TL_TOP_MASK (0x7ff << 16)
2170 -+#define PANEL_PLANE_TL_LEFT_MASK 0x7ff
2171 -
2172 - #define PANEL_PLANE_BR 0x080020
2173 - #define PANEL_PLANE_BR_BOTTOM_SHIFT 16
2174 --#define PANEL_PLANE_BR_BOTTOM_MASK (0xeff << 16)
2175 --#define PANEL_PLANE_BR_RIGHT_MASK 0xeff
2176 -+#define PANEL_PLANE_BR_BOTTOM_MASK (0x7ff << 16)
2177 -+#define PANEL_PLANE_BR_RIGHT_MASK 0x7ff
2178 -
2179 - #define PANEL_HORIZONTAL_TOTAL 0x080024
2180 - #define PANEL_HORIZONTAL_TOTAL_TOTAL_SHIFT 16
2181 -diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
2182 -index 8bbde52..21aeac5 100644
2183 ---- a/drivers/tty/serial/atmel_serial.c
2184 -+++ b/drivers/tty/serial/atmel_serial.c
2185 -@@ -2026,6 +2026,7 @@ static void atmel_serial_pm(struct uart_port *port, unsigned int state,
2186 - static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
2187 - struct ktermios *old)
2188 - {
2189 -+ struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
2190 - unsigned long flags;
2191 - unsigned int old_mode, mode, imr, quot, baud;
2192 -
2193 -@@ -2129,11 +2130,29 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
2194 - mode |= ATMEL_US_USMODE_RS485;
2195 - } else if (termios->c_cflag & CRTSCTS) {
2196 - /* RS232 with hardware handshake (RTS/CTS) */
2197 -- if (atmel_use_dma_rx(port) && !atmel_use_fifo(port)) {
2198 -- dev_info(port->dev, "not enabling hardware flow control because DMA is used");
2199 -- termios->c_cflag &= ~CRTSCTS;
2200 -- } else {
2201 -+ if (atmel_use_fifo(port) &&
2202 -+ !mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) {
2203 -+ /*
2204 -+ * with ATMEL_US_USMODE_HWHS set, the controller will
2205 -+ * be able to drive the RTS pin high/low when the RX
2206 -+ * FIFO is above RXFTHRES/below RXFTHRES2.
2207 -+ * It will also disable the transmitter when the CTS
2208 -+ * pin is high.
2209 -+ * This mode is not activated if CTS pin is a GPIO
2210 -+ * because in this case, the transmitter is always
2211 -+ * disabled (there must be an internal pull-up
2212 -+ * responsible for this behaviour).
2213 -+ * If the RTS pin is a GPIO, the controller won't be
2214 -+ * able to drive it according to the FIFO thresholds,
2215 -+ * but it will be handled by the driver.
2216 -+ */
2217 - mode |= ATMEL_US_USMODE_HWHS;
2218 -+ } else {
2219 -+ /*
2220 -+ * For platforms without FIFO, the flow control is
2221 -+ * handled by the driver.
2222 -+ */
2223 -+ mode |= ATMEL_US_USMODE_NORMAL;
2224 - }
2225 - } else {
2226 - /* RS232 without hadware handshake */
2227 -diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
2228 -index 0f3f62e..3ca9fdb 100644
2229 ---- a/drivers/usb/class/cdc-acm.c
2230 -+++ b/drivers/usb/class/cdc-acm.c
2231 -@@ -946,8 +946,6 @@ static int wait_serial_change(struct acm *acm, unsigned long arg)
2232 - DECLARE_WAITQUEUE(wait, current);
2233 - struct async_icount old, new;
2234 -
2235 -- if (arg & (TIOCM_DSR | TIOCM_RI | TIOCM_CD))
2236 -- return -EINVAL;
2237 - do {
2238 - spin_lock_irq(&acm->read_lock);
2239 - old = acm->oldcount;
2240 -@@ -1175,6 +1173,8 @@ static int acm_probe(struct usb_interface *intf,
2241 - if (quirks == IGNORE_DEVICE)
2242 - return -ENODEV;
2243 -
2244 -+ memset(&h, 0x00, sizeof(struct usb_cdc_parsed_header));
2245 -+
2246 - num_rx_buf = (quirks == SINGLE_RX_URB) ? 1 : ACM_NR;
2247 -
2248 - /* handle quirks deadly to normal probing*/
2249 -diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
2250 -index 35d0924..2d47010 100644
2251 ---- a/drivers/usb/dwc3/core.c
2252 -+++ b/drivers/usb/dwc3/core.c
2253 -@@ -669,15 +669,14 @@ static int dwc3_core_init(struct dwc3 *dwc)
2254 - return 0;
2255 -
2256 - err4:
2257 -- phy_power_off(dwc->usb2_generic_phy);
2258 -+ phy_power_off(dwc->usb3_generic_phy);
2259 -
2260 - err3:
2261 -- phy_power_off(dwc->usb3_generic_phy);
2262 -+ phy_power_off(dwc->usb2_generic_phy);
2263 -
2264 - err2:
2265 - usb_phy_set_suspend(dwc->usb2_phy, 1);
2266 - usb_phy_set_suspend(dwc->usb3_phy, 1);
2267 -- dwc3_core_exit(dwc);
2268 -
2269 - err1:
2270 - usb_phy_shutdown(dwc->usb2_phy);
2271 -diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
2272 -index 9b9e71f..f590ada 100644
2273 ---- a/drivers/usb/gadget/function/u_ether.c
2274 -+++ b/drivers/usb/gadget/function/u_ether.c
2275 -@@ -585,14 +585,6 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
2276 -
2277 - req->length = length;
2278 -
2279 -- /* throttle high/super speed IRQ rate back slightly */
2280 -- if (gadget_is_dualspeed(dev->gadget))
2281 -- req->no_interrupt = (((dev->gadget->speed == USB_SPEED_HIGH ||
2282 -- dev->gadget->speed == USB_SPEED_SUPER)) &&
2283 -- !list_empty(&dev->tx_reqs))
2284 -- ? ((atomic_read(&dev->tx_qlen) % dev->qmult) != 0)
2285 -- : 0;
2286 --
2287 - retval = usb_ep_queue(in, req, GFP_ATOMIC);
2288 - switch (retval) {
2289 - default:
2290 -diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
2291 -index 6abb83c..74265b2 100644
2292 ---- a/drivers/watchdog/watchdog_core.c
2293 -+++ b/drivers/watchdog/watchdog_core.c
2294 -@@ -349,7 +349,7 @@ int devm_watchdog_register_device(struct device *dev,
2295 - struct watchdog_device **rcwdd;
2296 - int ret;
2297 -
2298 -- rcwdd = devres_alloc(devm_watchdog_unregister_device, sizeof(*wdd),
2299 -+ rcwdd = devres_alloc(devm_watchdog_unregister_device, sizeof(*rcwdd),
2300 - GFP_KERNEL);
2301 - if (!rcwdd)
2302 - return -ENOMEM;
2303 -diff --git a/fs/coredump.c b/fs/coredump.c
2304 -index 281b768..eb9c92c 100644
2305 ---- a/fs/coredump.c
2306 -+++ b/fs/coredump.c
2307 -@@ -1,6 +1,7 @@
2308 - #include <linux/slab.h>
2309 - #include <linux/file.h>
2310 - #include <linux/fdtable.h>
2311 -+#include <linux/freezer.h>
2312 - #include <linux/mm.h>
2313 - #include <linux/stat.h>
2314 - #include <linux/fcntl.h>
2315 -@@ -423,7 +424,9 @@ static int coredump_wait(int exit_code, struct core_state *core_state)
2316 - if (core_waiters > 0) {
2317 - struct core_thread *ptr;
2318 -
2319 -+ freezer_do_not_count();
2320 - wait_for_completion(&core_state->startup);
2321 -+ freezer_count();
2322 - /*
2323 - * Wait for all the threads to become inactive, so that
2324 - * all the thread context (extended register state, like
2325 -diff --git a/fs/nfs/nfs4session.c b/fs/nfs/nfs4session.c
2326 -index b629730..150c5a1 100644
2327 ---- a/fs/nfs/nfs4session.c
2328 -+++ b/fs/nfs/nfs4session.c
2329 -@@ -178,12 +178,14 @@ static int nfs4_slot_get_seqid(struct nfs4_slot_table *tbl, u32 slotid,
2330 - __must_hold(&tbl->slot_tbl_lock)
2331 - {
2332 - struct nfs4_slot *slot;
2333 -+ int ret;
2334 -
2335 - slot = nfs4_lookup_slot(tbl, slotid);
2336 -- if (IS_ERR(slot))
2337 -- return PTR_ERR(slot);
2338 -- *seq_nr = slot->seq_nr;
2339 -- return 0;
2340 -+ ret = PTR_ERR_OR_ZERO(slot);
2341 -+ if (!ret)
2342 -+ *seq_nr = slot->seq_nr;
2343 -+
2344 -+ return ret;
2345 - }
2346 -
2347 - /*
2348 -diff --git a/include/linux/acpi.h b/include/linux/acpi.h
2349 -index c5eaf2f..67d1d3e 100644
2350 ---- a/include/linux/acpi.h
2351 -+++ b/include/linux/acpi.h
2352 -@@ -318,6 +318,7 @@ struct pci_dev;
2353 - int acpi_pci_irq_enable (struct pci_dev *dev);
2354 - void acpi_penalize_isa_irq(int irq, int active);
2355 - bool acpi_isa_irq_available(int irq);
2356 -+void acpi_penalize_sci_irq(int irq, int trigger, int polarity);
2357 - void acpi_pci_irq_disable (struct pci_dev *dev);
2358 -
2359 - extern int ec_read(u8 addr, u8 *val);
2360 -diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
2361 -index c46d2aa..1d18af0 100644
2362 ---- a/include/linux/frontswap.h
2363 -+++ b/include/linux/frontswap.h
2364 -@@ -106,8 +106,9 @@ static inline void frontswap_invalidate_area(unsigned type)
2365 -
2366 - static inline void frontswap_init(unsigned type, unsigned long *map)
2367 - {
2368 -- if (frontswap_enabled())
2369 -- __frontswap_init(type, map);
2370 -+#ifdef CONFIG_FRONTSWAP
2371 -+ __frontswap_init(type, map);
2372 -+#endif
2373 - }
2374 -
2375 - #endif /* _LINUX_FRONTSWAP_H */
2376 -diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
2377 -index d6917b8..3584bc8 100644
2378 ---- a/include/linux/sunrpc/svc_rdma.h
2379 -+++ b/include/linux/sunrpc/svc_rdma.h
2380 -@@ -86,6 +86,7 @@ struct svc_rdma_op_ctxt {
2381 - unsigned long flags;
2382 - enum dma_data_direction direction;
2383 - int count;
2384 -+ unsigned int mapped_sges;
2385 - struct ib_sge sge[RPCSVC_MAXPAGES];
2386 - struct page *pages[RPCSVC_MAXPAGES];
2387 - };
2388 -@@ -193,6 +194,14 @@ struct svcxprt_rdma {
2389 -
2390 - #define RPCSVC_MAXPAYLOAD_RDMA RPCSVC_MAXPAYLOAD
2391 -
2392 -+/* Track DMA maps for this transport and context */
2393 -+static inline void svc_rdma_count_mappings(struct svcxprt_rdma *rdma,
2394 -+ struct svc_rdma_op_ctxt *ctxt)
2395 -+{
2396 -+ ctxt->mapped_sges++;
2397 -+ atomic_inc(&rdma->sc_dma_used);
2398 -+}
2399 -+
2400 - /* svc_rdma_backchannel.c */
2401 - extern int svc_rdma_handle_bc_reply(struct rpc_xprt *xprt,
2402 - struct rpcrdma_msg *rmsgp,
2403 -diff --git a/lib/genalloc.c b/lib/genalloc.c
2404 -index 0a11396..144fe6b 100644
2405 ---- a/lib/genalloc.c
2406 -+++ b/lib/genalloc.c
2407 -@@ -292,7 +292,7 @@ unsigned long gen_pool_alloc_algo(struct gen_pool *pool, size_t size,
2408 - struct gen_pool_chunk *chunk;
2409 - unsigned long addr = 0;
2410 - int order = pool->min_alloc_order;
2411 -- int nbits, start_bit = 0, end_bit, remain;
2412 -+ int nbits, start_bit, end_bit, remain;
2413 -
2414 - #ifndef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG
2415 - BUG_ON(in_nmi());
2416 -@@ -307,6 +307,7 @@ unsigned long gen_pool_alloc_algo(struct gen_pool *pool, size_t size,
2417 - if (size > atomic_read(&chunk->avail))
2418 - continue;
2419 -
2420 -+ start_bit = 0;
2421 - end_bit = chunk_size(chunk) >> order;
2422 - retry:
2423 - start_bit = algo(chunk->bits, end_bit, start_bit,
2424 -diff --git a/mm/hugetlb.c b/mm/hugetlb.c
2425 -index 770d83e..0ddce6a 100644
2426 ---- a/mm/hugetlb.c
2427 -+++ b/mm/hugetlb.c
2428 -@@ -1826,11 +1826,17 @@ static void return_unused_surplus_pages(struct hstate *h,
2429 - * is not the case is if a reserve map was changed between calls. It
2430 - * is the responsibility of the caller to notice the difference and
2431 - * take appropriate action.
2432 -+ *
2433 -+ * vma_add_reservation is used in error paths where a reservation must
2434 -+ * be restored when a newly allocated huge page must be freed. It is
2435 -+ * to be called after calling vma_needs_reservation to determine if a
2436 -+ * reservation exists.
2437 - */
2438 - enum vma_resv_mode {
2439 - VMA_NEEDS_RESV,
2440 - VMA_COMMIT_RESV,
2441 - VMA_END_RESV,
2442 -+ VMA_ADD_RESV,
2443 - };
2444 - static long __vma_reservation_common(struct hstate *h,
2445 - struct vm_area_struct *vma, unsigned long addr,
2446 -@@ -1856,6 +1862,14 @@ static long __vma_reservation_common(struct hstate *h,
2447 - region_abort(resv, idx, idx + 1);
2448 - ret = 0;
2449 - break;
2450 -+ case VMA_ADD_RESV:
2451 -+ if (vma->vm_flags & VM_MAYSHARE)
2452 -+ ret = region_add(resv, idx, idx + 1);
2453 -+ else {
2454 -+ region_abort(resv, idx, idx + 1);
2455 -+ ret = region_del(resv, idx, idx + 1);
2456 -+ }
2457 -+ break;
2458 - default:
2459 - BUG();
2460 - }
2461 -@@ -1903,6 +1917,56 @@ static void vma_end_reservation(struct hstate *h,
2462 - (void)__vma_reservation_common(h, vma, addr, VMA_END_RESV);
2463 - }
2464 -
2465 -+static long vma_add_reservation(struct hstate *h,
2466 -+ struct vm_area_struct *vma, unsigned long addr)
2467 -+{
2468 -+ return __vma_reservation_common(h, vma, addr, VMA_ADD_RESV);
2469 -+}
2470 -+
2471 -+/*
2472 -+ * This routine is called to restore a reservation on error paths. In the
2473 -+ * specific error paths, a huge page was allocated (via alloc_huge_page)
2474 -+ * and is about to be freed. If a reservation for the page existed,
2475 -+ * alloc_huge_page would have consumed the reservation and set PagePrivate
2476 -+ * in the newly allocated page. When the page is freed via free_huge_page,
2477 -+ * the global reservation count will be incremented if PagePrivate is set.
2478 -+ * However, free_huge_page can not adjust the reserve map. Adjust the
2479 -+ * reserve map here to be consistent with global reserve count adjustments
2480 -+ * to be made by free_huge_page.
2481 -+ */
2482 -+static void restore_reserve_on_error(struct hstate *h,
2483 -+ struct vm_area_struct *vma, unsigned long address,
2484 -+ struct page *page)
2485 -+{
2486 -+ if (unlikely(PagePrivate(page))) {
2487 -+ long rc = vma_needs_reservation(h, vma, address);
2488 -+
2489 -+ if (unlikely(rc < 0)) {
2490 -+ /*
2491 -+ * Rare out of memory condition in reserve map
2492 -+ * manipulation. Clear PagePrivate so that
2493 -+ * global reserve count will not be incremented
2494 -+ * by free_huge_page. This will make it appear
2495 -+ * as though the reservation for this page was
2496 -+ * consumed. This may prevent the task from
2497 -+ * faulting in the page at a later time. This
2498 -+ * is better than inconsistent global huge page
2499 -+ * accounting of reserve counts.
2500 -+ */
2501 -+ ClearPagePrivate(page);
2502 -+ } else if (rc) {
2503 -+ rc = vma_add_reservation(h, vma, address);
2504 -+ if (unlikely(rc < 0))
2505 -+ /*
2506 -+ * See above comment about rare out of
2507 -+ * memory condition.
2508 -+ */
2509 -+ ClearPagePrivate(page);
2510 -+ } else
2511 -+ vma_end_reservation(h, vma, address);
2512 -+ }
2513 -+}
2514 -+
2515 - struct page *alloc_huge_page(struct vm_area_struct *vma,
2516 - unsigned long addr, int avoid_reserve)
2517 - {
2518 -@@ -3498,6 +3562,7 @@ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma,
2519 - spin_unlock(ptl);
2520 - mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end);
2521 - out_release_all:
2522 -+ restore_reserve_on_error(h, vma, address, new_page);
2523 - put_page(new_page);
2524 - out_release_old:
2525 - put_page(old_page);
2526 -@@ -3680,6 +3745,7 @@ static int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma,
2527 - spin_unlock(ptl);
2528 - backout_unlocked:
2529 - unlock_page(page);
2530 -+ restore_reserve_on_error(h, vma, address, page);
2531 - put_page(page);
2532 - goto out;
2533 - }
2534 -diff --git a/mm/memory-failure.c b/mm/memory-failure.c
2535 -index de88f33..19e796d 100644
2536 ---- a/mm/memory-failure.c
2537 -+++ b/mm/memory-failure.c
2538 -@@ -1112,10 +1112,10 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
2539 - }
2540 -
2541 - if (!PageHuge(p) && PageTransHuge(hpage)) {
2542 -- lock_page(hpage);
2543 -- if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) {
2544 -- unlock_page(hpage);
2545 -- if (!PageAnon(hpage))
2546 -+ lock_page(p);
2547 -+ if (!PageAnon(p) || unlikely(split_huge_page(p))) {
2548 -+ unlock_page(p);
2549 -+ if (!PageAnon(p))
2550 - pr_err("Memory failure: %#lx: non anonymous thp\n",
2551 - pfn);
2552 - else
2553 -@@ -1126,9 +1126,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
2554 - put_hwpoison_page(p);
2555 - return -EBUSY;
2556 - }
2557 -- unlock_page(hpage);
2558 -- get_hwpoison_page(p);
2559 -- put_hwpoison_page(hpage);
2560 -+ unlock_page(p);
2561 - VM_BUG_ON_PAGE(!page_count(p), p);
2562 - hpage = compound_head(p);
2563 - }
2564 -diff --git a/mm/shmem.c b/mm/shmem.c
2565 -index 971fc83..38aa5e0 100644
2566 ---- a/mm/shmem.c
2567 -+++ b/mm/shmem.c
2568 -@@ -1483,6 +1483,8 @@ static int shmem_replace_page(struct page **pagep, gfp_t gfp,
2569 - copy_highpage(newpage, oldpage);
2570 - flush_dcache_page(newpage);
2571 -
2572 -+ __SetPageLocked(newpage);
2573 -+ __SetPageSwapBacked(newpage);
2574 - SetPageUptodate(newpage);
2575 - set_page_private(newpage, swap_index);
2576 - SetPageSwapCache(newpage);
2577 -diff --git a/mm/slab_common.c b/mm/slab_common.c
2578 -index 71f0b28..329b038 100644
2579 ---- a/mm/slab_common.c
2580 -+++ b/mm/slab_common.c
2581 -@@ -533,8 +533,8 @@ void memcg_create_kmem_cache(struct mem_cgroup *memcg,
2582 -
2583 - s = create_cache(cache_name, root_cache->object_size,
2584 - root_cache->size, root_cache->align,
2585 -- root_cache->flags, root_cache->ctor,
2586 -- memcg, root_cache);
2587 -+ root_cache->flags & CACHE_CREATE_MASK,
2588 -+ root_cache->ctor, memcg, root_cache);
2589 - /*
2590 - * If we could not create a memcg cache, do not complain, because
2591 - * that's not critical at all as we can always proceed with the root
2592 -diff --git a/mm/swapfile.c b/mm/swapfile.c
2593 -index 2657acc..bf262e4 100644
2594 ---- a/mm/swapfile.c
2595 -+++ b/mm/swapfile.c
2596 -@@ -2218,6 +2218,8 @@ static unsigned long read_swap_header(struct swap_info_struct *p,
2597 - swab32s(&swap_header->info.version);
2598 - swab32s(&swap_header->info.last_page);
2599 - swab32s(&swap_header->info.nr_badpages);
2600 -+ if (swap_header->info.nr_badpages > MAX_SWAP_BADPAGES)
2601 -+ return 0;
2602 - for (i = 0; i < swap_header->info.nr_badpages; i++)
2603 - swab32s(&swap_header->info.badpages[i]);
2604 - }
2605 -diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
2606 -index 3940b5d..3e9667e 100644
2607 ---- a/net/batman-adv/originator.c
2608 -+++ b/net/batman-adv/originator.c
2609 -@@ -537,7 +537,7 @@ batadv_hardif_neigh_create(struct batadv_hard_iface *hard_iface,
2610 - if (bat_priv->algo_ops->neigh.hardif_init)
2611 - bat_priv->algo_ops->neigh.hardif_init(hardif_neigh);
2612 -
2613 -- hlist_add_head(&hardif_neigh->list, &hard_iface->neigh_list);
2614 -+ hlist_add_head_rcu(&hardif_neigh->list, &hard_iface->neigh_list);
2615 -
2616 - out:
2617 - spin_unlock_bh(&hard_iface->neigh_list_lock);
2618 -diff --git a/net/ceph/ceph_fs.c b/net/ceph/ceph_fs.c
2619 -index 7d54e94..dcbe67f 100644
2620 ---- a/net/ceph/ceph_fs.c
2621 -+++ b/net/ceph/ceph_fs.c
2622 -@@ -34,7 +34,8 @@ void ceph_file_layout_from_legacy(struct ceph_file_layout *fl,
2623 - fl->stripe_count = le32_to_cpu(legacy->fl_stripe_count);
2624 - fl->object_size = le32_to_cpu(legacy->fl_object_size);
2625 - fl->pool_id = le32_to_cpu(legacy->fl_pg_pool);
2626 -- if (fl->pool_id == 0)
2627 -+ if (fl->pool_id == 0 && fl->stripe_unit == 0 &&
2628 -+ fl->stripe_count == 0 && fl->object_size == 0)
2629 - fl->pool_id = -1;
2630 - }
2631 - EXPORT_SYMBOL(ceph_file_layout_from_legacy);
2632 -diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
2633 -index aa5847a..1df2c8d 100644
2634 ---- a/net/netfilter/nf_log.c
2635 -+++ b/net/netfilter/nf_log.c
2636 -@@ -420,7 +420,7 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
2637 - char buf[NFLOGGER_NAME_LEN];
2638 - int r = 0;
2639 - int tindex = (unsigned long)table->extra1;
2640 -- struct net *net = current->nsproxy->net_ns;
2641 -+ struct net *net = table->extra2;
2642 -
2643 - if (write) {
2644 - struct ctl_table tmp = *table;
2645 -@@ -474,7 +474,6 @@ static int netfilter_log_sysctl_init(struct net *net)
2646 - 3, "%d", i);
2647 - nf_log_sysctl_table[i].procname =
2648 - nf_log_sysctl_fnames[i];
2649 -- nf_log_sysctl_table[i].data = NULL;
2650 - nf_log_sysctl_table[i].maxlen = NFLOGGER_NAME_LEN;
2651 - nf_log_sysctl_table[i].mode = 0644;
2652 - nf_log_sysctl_table[i].proc_handler =
2653 -@@ -484,6 +483,9 @@ static int netfilter_log_sysctl_init(struct net *net)
2654 - }
2655 - }
2656 -
2657 -+ for (i = NFPROTO_UNSPEC; i < NFPROTO_NUMPROTO; i++)
2658 -+ table[i].extra2 = net;
2659 -+
2660 - net->nf.nf_log_dir_header = register_net_sysctl(net,
2661 - "net/netfilter/nf_log",
2662 - table);
2663 -diff --git a/net/sunrpc/xprtrdma/frwr_ops.c b/net/sunrpc/xprtrdma/frwr_ops.c
2664 -index 892b5e1..2761377 100644
2665 ---- a/net/sunrpc/xprtrdma/frwr_ops.c
2666 -+++ b/net/sunrpc/xprtrdma/frwr_ops.c
2667 -@@ -44,18 +44,20 @@
2668 - * being done.
2669 - *
2670 - * When the underlying transport disconnects, MRs are left in one of
2671 -- * three states:
2672 -+ * four states:
2673 - *
2674 - * INVALID: The MR was not in use before the QP entered ERROR state.
2675 -- * (Or, the LOCAL_INV WR has not completed or flushed yet).
2676 -- *
2677 -- * STALE: The MR was being registered or unregistered when the QP
2678 -- * entered ERROR state, and the pending WR was flushed.
2679 - *
2680 - * VALID: The MR was registered before the QP entered ERROR state.
2681 - *
2682 -- * When frwr_op_map encounters STALE and VALID MRs, they are recovered
2683 -- * with ib_dereg_mr and then are re-initialized. Beause MR recovery
2684 -+ * FLUSHED_FR: The MR was being registered when the QP entered ERROR
2685 -+ * state, and the pending WR was flushed.
2686 -+ *
2687 -+ * FLUSHED_LI: The MR was being invalidated when the QP entered ERROR
2688 -+ * state, and the pending WR was flushed.
2689 -+ *
2690 -+ * When frwr_op_map encounters FLUSHED and VALID MRs, they are recovered
2691 -+ * with ib_dereg_mr and then are re-initialized. Because MR recovery
2692 - * allocates fresh resources, it is deferred to a workqueue, and the
2693 - * recovered MRs are placed back on the rb_mws list when recovery is
2694 - * complete. frwr_op_map allocates another MR for the current RPC while
2695 -@@ -175,12 +177,15 @@ __frwr_reset_mr(struct rpcrdma_ia *ia, struct rpcrdma_mw *r)
2696 - static void
2697 - frwr_op_recover_mr(struct rpcrdma_mw *mw)
2698 - {
2699 -+ enum rpcrdma_frmr_state state = mw->frmr.fr_state;
2700 - struct rpcrdma_xprt *r_xprt = mw->mw_xprt;
2701 - struct rpcrdma_ia *ia = &r_xprt->rx_ia;
2702 - int rc;
2703 -
2704 - rc = __frwr_reset_mr(ia, mw);
2705 -- ib_dma_unmap_sg(ia->ri_device, mw->mw_sg, mw->mw_nents, mw->mw_dir);
2706 -+ if (state != FRMR_FLUSHED_LI)
2707 -+ ib_dma_unmap_sg(ia->ri_device,
2708 -+ mw->mw_sg, mw->mw_nents, mw->mw_dir);
2709 - if (rc)
2710 - goto out_release;
2711 -
2712 -@@ -261,10 +266,8 @@ frwr_op_maxpages(struct rpcrdma_xprt *r_xprt)
2713 - }
2714 -
2715 - static void
2716 --__frwr_sendcompletion_flush(struct ib_wc *wc, struct rpcrdma_frmr *frmr,
2717 -- const char *wr)
2718 -+__frwr_sendcompletion_flush(struct ib_wc *wc, const char *wr)
2719 - {
2720 -- frmr->fr_state = FRMR_IS_STALE;
2721 - if (wc->status != IB_WC_WR_FLUSH_ERR)
2722 - pr_err("rpcrdma: %s: %s (%u/0x%x)\n",
2723 - wr, ib_wc_status_msg(wc->status),
2724 -@@ -287,7 +290,8 @@ frwr_wc_fastreg(struct ib_cq *cq, struct ib_wc *wc)
2725 - if (wc->status != IB_WC_SUCCESS) {
2726 - cqe = wc->wr_cqe;
2727 - frmr = container_of(cqe, struct rpcrdma_frmr, fr_cqe);
2728 -- __frwr_sendcompletion_flush(wc, frmr, "fastreg");
2729 -+ frmr->fr_state = FRMR_FLUSHED_FR;
2730 -+ __frwr_sendcompletion_flush(wc, "fastreg");
2731 - }
2732 - }
2733 -
2734 -@@ -307,7 +311,8 @@ frwr_wc_localinv(struct ib_cq *cq, struct ib_wc *wc)
2735 - if (wc->status != IB_WC_SUCCESS) {
2736 - cqe = wc->wr_cqe;
2737 - frmr = container_of(cqe, struct rpcrdma_frmr, fr_cqe);
2738 -- __frwr_sendcompletion_flush(wc, frmr, "localinv");
2739 -+ frmr->fr_state = FRMR_FLUSHED_LI;
2740 -+ __frwr_sendcompletion_flush(wc, "localinv");
2741 - }
2742 - }
2743 -
2744 -@@ -327,9 +332,11 @@ frwr_wc_localinv_wake(struct ib_cq *cq, struct ib_wc *wc)
2745 - /* WARNING: Only wr_cqe and status are reliable at this point */
2746 - cqe = wc->wr_cqe;
2747 - frmr = container_of(cqe, struct rpcrdma_frmr, fr_cqe);
2748 -- if (wc->status != IB_WC_SUCCESS)
2749 -- __frwr_sendcompletion_flush(wc, frmr, "localinv");
2750 -- complete_all(&frmr->fr_linv_done);
2751 -+ if (wc->status != IB_WC_SUCCESS) {
2752 -+ frmr->fr_state = FRMR_FLUSHED_LI;
2753 -+ __frwr_sendcompletion_flush(wc, "localinv");
2754 -+ }
2755 -+ complete(&frmr->fr_linv_done);
2756 - }
2757 -
2758 - /* Post a REG_MR Work Request to register a memory region
2759 -diff --git a/net/sunrpc/xprtrdma/svc_rdma_backchannel.c b/net/sunrpc/xprtrdma/svc_rdma_backchannel.c
2760 -index a2a7519..cd0c558 100644
2761 ---- a/net/sunrpc/xprtrdma/svc_rdma_backchannel.c
2762 -+++ b/net/sunrpc/xprtrdma/svc_rdma_backchannel.c
2763 -@@ -129,7 +129,7 @@ static int svc_rdma_bc_sendto(struct svcxprt_rdma *rdma,
2764 - ret = -EIO;
2765 - goto out_unmap;
2766 - }
2767 -- atomic_inc(&rdma->sc_dma_used);
2768 -+ svc_rdma_count_mappings(rdma, ctxt);
2769 -
2770 - memset(&send_wr, 0, sizeof(send_wr));
2771 - ctxt->cqe.done = svc_rdma_wc_send;
2772 -diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
2773 -index 2c25606..ad1df97 100644
2774 ---- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
2775 -+++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
2776 -@@ -159,7 +159,7 @@ int rdma_read_chunk_lcl(struct svcxprt_rdma *xprt,
2777 - ctxt->sge[pno].addr);
2778 - if (ret)
2779 - goto err;
2780 -- atomic_inc(&xprt->sc_dma_used);
2781 -+ svc_rdma_count_mappings(xprt, ctxt);
2782 -
2783 - ctxt->sge[pno].lkey = xprt->sc_pd->local_dma_lkey;
2784 - ctxt->sge[pno].length = len;
2785 -diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
2786 -index 54d53330..3b95b19 100644
2787 ---- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
2788 -+++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
2789 -@@ -280,7 +280,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
2790 - if (ib_dma_mapping_error(xprt->sc_cm_id->device,
2791 - sge[sge_no].addr))
2792 - goto err;
2793 -- atomic_inc(&xprt->sc_dma_used);
2794 -+ svc_rdma_count_mappings(xprt, ctxt);
2795 - sge[sge_no].lkey = xprt->sc_pd->local_dma_lkey;
2796 - ctxt->count++;
2797 - sge_off = 0;
2798 -@@ -489,7 +489,7 @@ static int send_reply(struct svcxprt_rdma *rdma,
2799 - ctxt->sge[0].length, DMA_TO_DEVICE);
2800 - if (ib_dma_mapping_error(rdma->sc_cm_id->device, ctxt->sge[0].addr))
2801 - goto err;
2802 -- atomic_inc(&rdma->sc_dma_used);
2803 -+ svc_rdma_count_mappings(rdma, ctxt);
2804 -
2805 - ctxt->direction = DMA_TO_DEVICE;
2806 -
2807 -@@ -505,7 +505,7 @@ static int send_reply(struct svcxprt_rdma *rdma,
2808 - if (ib_dma_mapping_error(rdma->sc_cm_id->device,
2809 - ctxt->sge[sge_no].addr))
2810 - goto err;
2811 -- atomic_inc(&rdma->sc_dma_used);
2812 -+ svc_rdma_count_mappings(rdma, ctxt);
2813 - ctxt->sge[sge_no].lkey = rdma->sc_pd->local_dma_lkey;
2814 - ctxt->sge[sge_no].length = sge_bytes;
2815 - }
2816 -@@ -523,23 +523,9 @@ static int send_reply(struct svcxprt_rdma *rdma,
2817 - ctxt->pages[page_no+1] = rqstp->rq_respages[page_no];
2818 - ctxt->count++;
2819 - rqstp->rq_respages[page_no] = NULL;
2820 -- /*
2821 -- * If there are more pages than SGE, terminate SGE
2822 -- * list so that svc_rdma_unmap_dma doesn't attempt to
2823 -- * unmap garbage.
2824 -- */
2825 -- if (page_no+1 >= sge_no)
2826 -- ctxt->sge[page_no+1].length = 0;
2827 - }
2828 - rqstp->rq_next_page = rqstp->rq_respages + 1;
2829 -
2830 -- /* The loop above bumps sc_dma_used for each sge. The
2831 -- * xdr_buf.tail gets a separate sge, but resides in the
2832 -- * same page as xdr_buf.head. Don't count it twice.
2833 -- */
2834 -- if (sge_no > ctxt->count)
2835 -- atomic_dec(&rdma->sc_dma_used);
2836 --
2837 - if (sge_no > rdma->sc_max_sge) {
2838 - pr_err("svcrdma: Too many sges (%d)\n", sge_no);
2839 - goto err;
2840 -@@ -635,7 +621,7 @@ int svc_rdma_sendto(struct svc_rqst *rqstp)
2841 - ret = send_reply(rdma, rqstp, res_page, rdma_resp, vec,
2842 - inline_bytes);
2843 - if (ret < 0)
2844 -- goto err1;
2845 -+ goto err0;
2846 -
2847 - svc_rdma_put_req_map(rdma, vec);
2848 - dprintk("svcrdma: send_reply returns %d\n", ret);
2849 -@@ -692,7 +678,7 @@ void svc_rdma_send_error(struct svcxprt_rdma *xprt, struct rpcrdma_msg *rmsgp,
2850 - svc_rdma_put_context(ctxt, 1);
2851 - return;
2852 - }
2853 -- atomic_inc(&xprt->sc_dma_used);
2854 -+ svc_rdma_count_mappings(xprt, ctxt);
2855 -
2856 - /* Prepare SEND WR */
2857 - memset(&err_wr, 0, sizeof(err_wr));
2858 -diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
2859 -index dd94401..924271c 100644
2860 ---- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
2861 -+++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
2862 -@@ -198,6 +198,7 @@ struct svc_rdma_op_ctxt *svc_rdma_get_context(struct svcxprt_rdma *xprt)
2863 -
2864 - out:
2865 - ctxt->count = 0;
2866 -+ ctxt->mapped_sges = 0;
2867 - ctxt->frmr = NULL;
2868 - return ctxt;
2869 -
2870 -@@ -221,22 +222,27 @@ struct svc_rdma_op_ctxt *svc_rdma_get_context(struct svcxprt_rdma *xprt)
2871 - void svc_rdma_unmap_dma(struct svc_rdma_op_ctxt *ctxt)
2872 - {
2873 - struct svcxprt_rdma *xprt = ctxt->xprt;
2874 -- int i;
2875 -- for (i = 0; i < ctxt->count && ctxt->sge[i].length; i++) {
2876 -+ struct ib_device *device = xprt->sc_cm_id->device;
2877 -+ u32 lkey = xprt->sc_pd->local_dma_lkey;
2878 -+ unsigned int i, count;
2879 -+
2880 -+ for (count = 0, i = 0; i < ctxt->mapped_sges; i++) {
2881 - /*
2882 - * Unmap the DMA addr in the SGE if the lkey matches
2883 - * the local_dma_lkey, otherwise, ignore it since it is
2884 - * an FRMR lkey and will be unmapped later when the
2885 - * last WR that uses it completes.
2886 - */
2887 -- if (ctxt->sge[i].lkey == xprt->sc_pd->local_dma_lkey) {
2888 -- atomic_dec(&xprt->sc_dma_used);
2889 -- ib_dma_unmap_page(xprt->sc_cm_id->device,
2890 -+ if (ctxt->sge[i].lkey == lkey) {
2891 -+ count++;
2892 -+ ib_dma_unmap_page(device,
2893 - ctxt->sge[i].addr,
2894 - ctxt->sge[i].length,
2895 - ctxt->direction);
2896 - }
2897 - }
2898 -+ ctxt->mapped_sges = 0;
2899 -+ atomic_sub(count, &xprt->sc_dma_used);
2900 - }
2901 -
2902 - void svc_rdma_put_context(struct svc_rdma_op_ctxt *ctxt, int free_pages)
2903 -@@ -600,7 +606,7 @@ int svc_rdma_post_recv(struct svcxprt_rdma *xprt, gfp_t flags)
2904 - DMA_FROM_DEVICE);
2905 - if (ib_dma_mapping_error(xprt->sc_cm_id->device, pa))
2906 - goto err_put_ctxt;
2907 -- atomic_inc(&xprt->sc_dma_used);
2908 -+ svc_rdma_count_mappings(xprt, ctxt);
2909 - ctxt->sge[sge_no].addr = pa;
2910 - ctxt->sge[sge_no].length = PAGE_SIZE;
2911 - ctxt->sge[sge_no].lkey = xprt->sc_pd->local_dma_lkey;
2912 -diff --git a/net/sunrpc/xprtrdma/xprt_rdma.h b/net/sunrpc/xprtrdma/xprt_rdma.h
2913 -index a71b0f5..edc0344 100644
2914 ---- a/net/sunrpc/xprtrdma/xprt_rdma.h
2915 -+++ b/net/sunrpc/xprtrdma/xprt_rdma.h
2916 -@@ -207,7 +207,8 @@ struct rpcrdma_rep {
2917 - enum rpcrdma_frmr_state {
2918 - FRMR_IS_INVALID, /* ready to be used */
2919 - FRMR_IS_VALID, /* in use */
2920 -- FRMR_IS_STALE, /* failed completion */
2921 -+ FRMR_FLUSHED_FR, /* flushed FASTREG WR */
2922 -+ FRMR_FLUSHED_LI, /* flushed LOCALINV WR */
2923 - };
2924 -
2925 - struct rpcrdma_frmr {
2926 -diff --git a/sound/core/info.c b/sound/core/info.c
2927 -index 895362a..8ab72e0 100644
2928 ---- a/sound/core/info.c
2929 -+++ b/sound/core/info.c
2930 -@@ -325,10 +325,15 @@ static ssize_t snd_info_text_entry_write(struct file *file,
2931 - size_t next;
2932 - int err = 0;
2933 -
2934 -+ if (!entry->c.text.write)
2935 -+ return -EIO;
2936 - pos = *offset;
2937 - if (!valid_pos(pos, count))
2938 - return -EIO;
2939 - next = pos + count;
2940 -+ /* don't handle too large text inputs */
2941 -+ if (next > 16 * 1024)
2942 -+ return -EIO;
2943 - mutex_lock(&entry->access);
2944 - buf = data->wbuffer;
2945 - if (!buf) {
2946 -@@ -366,7 +371,9 @@ static int snd_info_seq_show(struct seq_file *seq, void *p)
2947 - struct snd_info_private_data *data = seq->private;
2948 - struct snd_info_entry *entry = data->entry;
2949 -
2950 -- if (entry->c.text.read) {
2951 -+ if (!entry->c.text.read) {
2952 -+ return -EIO;
2953 -+ } else {
2954 - data->rbuffer->buffer = (char *)seq; /* XXX hack! */
2955 - entry->c.text.read(entry, data->rbuffer);
2956 - }
2957 -diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
2958 -index e07807d..3670086b 100644
2959 ---- a/sound/soc/codecs/cs4270.c
2960 -+++ b/sound/soc/codecs/cs4270.c
2961 -@@ -148,11 +148,11 @@ SND_SOC_DAPM_OUTPUT("AOUTR"),
2962 - };
2963 -
2964 - static const struct snd_soc_dapm_route cs4270_dapm_routes[] = {
2965 -- { "Capture", NULL, "AINA" },
2966 -- { "Capture", NULL, "AINB" },
2967 -+ { "Capture", NULL, "AINL" },
2968 -+ { "Capture", NULL, "AINR" },
2969 -
2970 -- { "AOUTA", NULL, "Playback" },
2971 -- { "AOUTB", NULL, "Playback" },
2972 -+ { "AOUTL", NULL, "Playback" },
2973 -+ { "AOUTR", NULL, "Playback" },
2974 - };
2975 -
2976 - /**
2977 -diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c
2978 -index e3e7641..7b7a380 100644
2979 ---- a/sound/soc/intel/skylake/skl.c
2980 -+++ b/sound/soc/intel/skylake/skl.c
2981 -@@ -785,8 +785,7 @@ static void skl_remove(struct pci_dev *pci)
2982 -
2983 - release_firmware(skl->tplg);
2984 -
2985 -- if (pci_dev_run_wake(pci))
2986 -- pm_runtime_get_noresume(&pci->dev);
2987 -+ pm_runtime_get_noresume(&pci->dev);
2988 -
2989 - /* codec removal, invoke bus_device_remove */
2990 - snd_hdac_ext_bus_device_remove(ebus);
2991 -diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
2992 -index 44f170c..03c18db 100644
2993 ---- a/sound/soc/sunxi/sun4i-codec.c
2994 -+++ b/sound/soc/sunxi/sun4i-codec.c
2995 -@@ -738,11 +738,11 @@ static struct snd_soc_card *sun4i_codec_create_card(struct device *dev)
2996 -
2997 - card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
2998 - if (!card)
2999 -- return NULL;
3000 -+ return ERR_PTR(-ENOMEM);
3001 -
3002 - card->dai_link = sun4i_codec_create_link(dev, &card->num_links);
3003 - if (!card->dai_link)
3004 -- return NULL;
3005 -+ return ERR_PTR(-ENOMEM);
3006 -
3007 - card->dev = dev;
3008 - card->name = "sun4i-codec";
3009 -@@ -842,7 +842,8 @@ static int sun4i_codec_probe(struct platform_device *pdev)
3010 - }
3011 -
3012 - card = sun4i_codec_create_card(&pdev->dev);
3013 -- if (!card) {
3014 -+ if (IS_ERR(card)) {
3015 -+ ret = PTR_ERR(card);
3016 - dev_err(&pdev->dev, "Failed to create our card\n");
3017 - goto err_unregister_codec;
3018 - }
3019 -diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
3020 -index 7aee954..4ad1eac 100644
3021 ---- a/tools/perf/ui/browsers/hists.c
3022 -+++ b/tools/perf/ui/browsers/hists.c
3023 -@@ -595,7 +595,8 @@ int hist_browser__run(struct hist_browser *browser, const char *help)
3024 - u64 nr_entries;
3025 - hbt->timer(hbt->arg);
3026 -
3027 -- if (hist_browser__has_filter(browser))
3028 -+ if (hist_browser__has_filter(browser) ||
3029 -+ symbol_conf.report_hierarchy)
3030 - hist_browser__update_nr_entries(browser);
3031 -
3032 - nr_entries = hist_browser__nr_entries(browser);
3033 -diff --git a/tools/power/cpupower/utils/cpufreq-set.c b/tools/power/cpupower/utils/cpufreq-set.c
3034 -index b4bf769..1eef0ae 100644
3035 ---- a/tools/power/cpupower/utils/cpufreq-set.c
3036 -+++ b/tools/power/cpupower/utils/cpufreq-set.c
3037 -@@ -296,7 +296,7 @@ int cmd_freq_set(int argc, char **argv)
3038 - struct cpufreq_affected_cpus *cpus;
3039 -
3040 - if (!bitmask_isbitset(cpus_chosen, cpu) ||
3041 -- cpupower_is_cpu_online(cpu))
3042 -+ cpupower_is_cpu_online(cpu) != 1)
3043 - continue;
3044 -
3045 - cpus = cpufreq_get_related_cpus(cpu);
3046 -@@ -316,10 +316,7 @@ int cmd_freq_set(int argc, char **argv)
3047 - cpu <= bitmask_last(cpus_chosen); cpu++) {
3048 -
3049 - if (!bitmask_isbitset(cpus_chosen, cpu) ||
3050 -- cpupower_is_cpu_online(cpu))
3051 -- continue;
3052 --
3053 -- if (cpupower_is_cpu_online(cpu) != 1)
3054 -+ cpupower_is_cpu_online(cpu) != 1)
3055 - continue;
3056 -
3057 - printf(_("Setting cpu: %d\n"), cpu);
3058 -diff --git a/virt/kvm/arm/vgic/vgic-mmio.c b/virt/kvm/arm/vgic/vgic-mmio.c
3059 -index 3bad3c5..d1b080c 100644
3060 ---- a/virt/kvm/arm/vgic/vgic-mmio.c
3061 -+++ b/virt/kvm/arm/vgic/vgic-mmio.c
3062 -@@ -453,17 +453,33 @@ struct vgic_io_device *kvm_to_vgic_iodev(const struct kvm_io_device *dev)
3063 - return container_of(dev, struct vgic_io_device, dev);
3064 - }
3065 -
3066 --static bool check_region(const struct vgic_register_region *region,
3067 -+static bool check_region(const struct kvm *kvm,
3068 -+ const struct vgic_register_region *region,
3069 - gpa_t addr, int len)
3070 - {
3071 -- if ((region->access_flags & VGIC_ACCESS_8bit) && len == 1)
3072 -- return true;
3073 -- if ((region->access_flags & VGIC_ACCESS_32bit) &&
3074 -- len == sizeof(u32) && !(addr & 3))
3075 -- return true;
3076 -- if ((region->access_flags & VGIC_ACCESS_64bit) &&
3077 -- len == sizeof(u64) && !(addr & 7))
3078 -- return true;
3079 -+ int flags, nr_irqs = kvm->arch.vgic.nr_spis + VGIC_NR_PRIVATE_IRQS;
3080 -+
3081 -+ switch (len) {
3082 -+ case sizeof(u8):
3083 -+ flags = VGIC_ACCESS_8bit;
3084 -+ break;
3085 -+ case sizeof(u32):
3086 -+ flags = VGIC_ACCESS_32bit;
3087 -+ break;
3088 -+ case sizeof(u64):
3089 -+ flags = VGIC_ACCESS_64bit;
3090 -+ break;
3091 -+ default:
3092 -+ return false;
3093 -+ }
3094 -+
3095 -+ if ((region->access_flags & flags) && IS_ALIGNED(addr, len)) {
3096 -+ if (!region->bits_per_irq)
3097 -+ return true;
3098 -+
3099 -+ /* Do we access a non-allocated IRQ? */
3100 -+ return VGIC_ADDR_TO_INTID(addr, region->bits_per_irq) < nr_irqs;
3101 -+ }
3102 -
3103 - return false;
3104 - }
3105 -@@ -477,7 +493,7 @@ static int dispatch_mmio_read(struct kvm_vcpu *vcpu, struct kvm_io_device *dev,
3106 -
3107 - region = vgic_find_mmio_region(iodev->regions, iodev->nr_regions,
3108 - addr - iodev->base_addr);
3109 -- if (!region || !check_region(region, addr, len)) {
3110 -+ if (!region || !check_region(vcpu->kvm, region, addr, len)) {
3111 - memset(val, 0, len);
3112 - return 0;
3113 - }
3114 -@@ -510,10 +526,7 @@ static int dispatch_mmio_write(struct kvm_vcpu *vcpu, struct kvm_io_device *dev,
3115 -
3116 - region = vgic_find_mmio_region(iodev->regions, iodev->nr_regions,
3117 - addr - iodev->base_addr);
3118 -- if (!region)
3119 -- return 0;
3120 --
3121 -- if (!check_region(region, addr, len))
3122 -+ if (!region || !check_region(vcpu->kvm, region, addr, len))
3123 - return 0;
3124 -
3125 - switch (iodev->iodev_type) {
3126 -diff --git a/virt/kvm/arm/vgic/vgic-mmio.h b/virt/kvm/arm/vgic/vgic-mmio.h
3127 -index 0b3ecf9..ba63d91 100644
3128 ---- a/virt/kvm/arm/vgic/vgic-mmio.h
3129 -+++ b/virt/kvm/arm/vgic/vgic-mmio.h
3130 -@@ -50,15 +50,15 @@ extern struct kvm_io_device_ops kvm_io_gic_ops;
3131 - #define VGIC_ADDR_IRQ_MASK(bits) (((bits) * 1024 / 8) - 1)
3132 -
3133 - /*
3134 -- * (addr & mask) gives us the byte offset for the INT ID, so we want to
3135 -- * divide this with 'bytes per irq' to get the INT ID, which is given
3136 -- * by '(bits) / 8'. But we do this with fixed-point-arithmetic and
3137 -- * take advantage of the fact that division by a fraction equals
3138 -- * multiplication with the inverted fraction, and scale up both the
3139 -- * numerator and denominator with 8 to support at most 64 bits per IRQ:
3140 -+ * (addr & mask) gives us the _byte_ offset for the INT ID.
3141 -+ * We multiply this by 8 the get the _bit_ offset, then divide this by
3142 -+ * the number of bits to learn the actual INT ID.
3143 -+ * But instead of a division (which requires a "long long div" implementation),
3144 -+ * we shift by the binary logarithm of <bits>.
3145 -+ * This assumes that <bits> is a power of two.
3146 - */
3147 - #define VGIC_ADDR_TO_INTID(addr, bits) (((addr) & VGIC_ADDR_IRQ_MASK(bits)) * \
3148 -- 64 / (bits) / 8)
3149 -+ 8 >> ilog2(bits))
3150 -
3151 - /*
3152 - * Some VGIC registers store per-IRQ information, with a different number
3153
3154 diff --git a/4.8.11/1009_linux-4.8.10.patch b/4.8.11/1009_linux-4.8.10.patch
3155 deleted file mode 100644
3156 index 1e751e5..0000000
3157 --- a/4.8.11/1009_linux-4.8.10.patch
3158 +++ /dev/null
3159 @@ -1,4759 +0,0 @@
3160 -diff --git a/Makefile b/Makefile
3161 -index c1519ab..7cf2b49 100644
3162 ---- a/Makefile
3163 -+++ b/Makefile
3164 -@@ -1,6 +1,6 @@
3165 - VERSION = 4
3166 - PATCHLEVEL = 8
3167 --SUBLEVEL = 9
3168 -+SUBLEVEL = 10
3169 - EXTRAVERSION =
3170 - NAME = Psychotic Stoned Sheep
3171 -
3172 -diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
3173 -index 37a315d..a6847fc 100644
3174 ---- a/arch/sparc/include/asm/uaccess_64.h
3175 -+++ b/arch/sparc/include/asm/uaccess_64.h
3176 -@@ -98,7 +98,6 @@ struct exception_table_entry {
3177 - unsigned int insn, fixup;
3178 - };
3179 -
3180 --void __ret_efault(void);
3181 - void __retl_efault(void);
3182 -
3183 - /* Uh, these should become the main single-value transfer routines..
3184 -@@ -205,55 +204,34 @@ int __get_user_bad(void);
3185 - unsigned long __must_check ___copy_from_user(void *to,
3186 - const void __user *from,
3187 - unsigned long size);
3188 --unsigned long copy_from_user_fixup(void *to, const void __user *from,
3189 -- unsigned long size);
3190 - static inline unsigned long __must_check
3191 - copy_from_user(void *to, const void __user *from, unsigned long size)
3192 - {
3193 -- unsigned long ret;
3194 --
3195 - check_object_size(to, size, false);
3196 -
3197 -- ret = ___copy_from_user(to, from, size);
3198 -- if (unlikely(ret))
3199 -- ret = copy_from_user_fixup(to, from, size);
3200 --
3201 -- return ret;
3202 -+ return ___copy_from_user(to, from, size);
3203 - }
3204 - #define __copy_from_user copy_from_user
3205 -
3206 - unsigned long __must_check ___copy_to_user(void __user *to,
3207 - const void *from,
3208 - unsigned long size);
3209 --unsigned long copy_to_user_fixup(void __user *to, const void *from,
3210 -- unsigned long size);
3211 - static inline unsigned long __must_check
3212 - copy_to_user(void __user *to, const void *from, unsigned long size)
3213 - {
3214 -- unsigned long ret;
3215 --
3216 - check_object_size(from, size, true);
3217 -
3218 -- ret = ___copy_to_user(to, from, size);
3219 -- if (unlikely(ret))
3220 -- ret = copy_to_user_fixup(to, from, size);
3221 -- return ret;
3222 -+ return ___copy_to_user(to, from, size);
3223 - }
3224 - #define __copy_to_user copy_to_user
3225 -
3226 - unsigned long __must_check ___copy_in_user(void __user *to,
3227 - const void __user *from,
3228 - unsigned long size);
3229 --unsigned long copy_in_user_fixup(void __user *to, void __user *from,
3230 -- unsigned long size);
3231 - static inline unsigned long __must_check
3232 - copy_in_user(void __user *to, void __user *from, unsigned long size)
3233 - {
3234 -- unsigned long ret = ___copy_in_user(to, from, size);
3235 --
3236 -- if (unlikely(ret))
3237 -- ret = copy_in_user_fixup(to, from, size);
3238 -- return ret;
3239 -+ return ___copy_in_user(to, from, size);
3240 - }
3241 - #define __copy_in_user copy_in_user
3242 -
3243 -diff --git a/arch/sparc/kernel/head_64.S b/arch/sparc/kernel/head_64.S
3244 -index a076b42..5f1f3ae 100644
3245 ---- a/arch/sparc/kernel/head_64.S
3246 -+++ b/arch/sparc/kernel/head_64.S
3247 -@@ -922,47 +922,11 @@ prom_tba: .xword 0
3248 - tlb_type: .word 0 /* Must NOT end up in BSS */
3249 - .section ".fixup",#alloc,#execinstr
3250 -
3251 -- .globl __ret_efault, __retl_efault, __ret_one, __retl_one
3252 --ENTRY(__ret_efault)
3253 -- ret
3254 -- restore %g0, -EFAULT, %o0
3255 --ENDPROC(__ret_efault)
3256 --
3257 - ENTRY(__retl_efault)
3258 - retl
3259 - mov -EFAULT, %o0
3260 - ENDPROC(__retl_efault)
3261 -
3262 --ENTRY(__retl_one)
3263 -- retl
3264 -- mov 1, %o0
3265 --ENDPROC(__retl_one)
3266 --
3267 --ENTRY(__retl_one_fp)
3268 -- VISExitHalf
3269 -- retl
3270 -- mov 1, %o0
3271 --ENDPROC(__retl_one_fp)
3272 --
3273 --ENTRY(__ret_one_asi)
3274 -- wr %g0, ASI_AIUS, %asi
3275 -- ret
3276 -- restore %g0, 1, %o0
3277 --ENDPROC(__ret_one_asi)
3278 --
3279 --ENTRY(__retl_one_asi)
3280 -- wr %g0, ASI_AIUS, %asi
3281 -- retl
3282 -- mov 1, %o0
3283 --ENDPROC(__retl_one_asi)
3284 --
3285 --ENTRY(__retl_one_asi_fp)
3286 -- wr %g0, ASI_AIUS, %asi
3287 -- VISExitHalf
3288 -- retl
3289 -- mov 1, %o0
3290 --ENDPROC(__retl_one_asi_fp)
3291 --
3292 - ENTRY(__retl_o1)
3293 - retl
3294 - mov %o1, %o0
3295 -diff --git a/arch/sparc/kernel/jump_label.c b/arch/sparc/kernel/jump_label.c
3296 -index 59bbeff..07933b9 100644
3297 ---- a/arch/sparc/kernel/jump_label.c
3298 -+++ b/arch/sparc/kernel/jump_label.c
3299 -@@ -13,19 +13,30 @@
3300 - void arch_jump_label_transform(struct jump_entry *entry,
3301 - enum jump_label_type type)
3302 - {
3303 -- u32 val;
3304 - u32 *insn = (u32 *) (unsigned long) entry->code;
3305 -+ u32 val;
3306 -
3307 - if (type == JUMP_LABEL_JMP) {
3308 - s32 off = (s32)entry->target - (s32)entry->code;
3309 -+ bool use_v9_branch = false;
3310 -+
3311 -+ BUG_ON(off & 3);
3312 -
3313 - #ifdef CONFIG_SPARC64
3314 -- /* ba,pt %xcc, . + (off << 2) */
3315 -- val = 0x10680000 | ((u32) off >> 2);
3316 --#else
3317 -- /* ba . + (off << 2) */
3318 -- val = 0x10800000 | ((u32) off >> 2);
3319 -+ if (off <= 0xfffff && off >= -0x100000)
3320 -+ use_v9_branch = true;
3321 - #endif
3322 -+ if (use_v9_branch) {
3323 -+ /* WDISP19 - target is . + immed << 2 */
3324 -+ /* ba,pt %xcc, . + off */
3325 -+ val = 0x10680000 | (((u32) off >> 2) & 0x7ffff);
3326 -+ } else {
3327 -+ /* WDISP22 - target is . + immed << 2 */
3328 -+ BUG_ON(off > 0x7fffff);
3329 -+ BUG_ON(off < -0x800000);
3330 -+ /* ba . + off */
3331 -+ val = 0x10800000 | (((u32) off >> 2) & 0x3fffff);
3332 -+ }
3333 - } else {
3334 - val = 0x01000000;
3335 - }
3336 -diff --git a/arch/sparc/kernel/sparc_ksyms_64.c b/arch/sparc/kernel/sparc_ksyms_64.c
3337 -index 9e034f2..20ffb05 100644
3338 ---- a/arch/sparc/kernel/sparc_ksyms_64.c
3339 -+++ b/arch/sparc/kernel/sparc_ksyms_64.c
3340 -@@ -27,7 +27,6 @@ EXPORT_SYMBOL(__flushw_user);
3341 - EXPORT_SYMBOL_GPL(real_hard_smp_processor_id);
3342 -
3343 - /* from head_64.S */
3344 --EXPORT_SYMBOL(__ret_efault);
3345 - EXPORT_SYMBOL(tlb_type);
3346 - EXPORT_SYMBOL(sun4v_chip_type);
3347 - EXPORT_SYMBOL(prom_root_node);
3348 -diff --git a/arch/sparc/lib/GENcopy_from_user.S b/arch/sparc/lib/GENcopy_from_user.S
3349 -index b7d0bd6..69a439f 100644
3350 ---- a/arch/sparc/lib/GENcopy_from_user.S
3351 -+++ b/arch/sparc/lib/GENcopy_from_user.S
3352 -@@ -3,11 +3,11 @@
3353 - * Copyright (C) 2007 David S. Miller (davem@×××××××××.net)
3354 - */
3355 -
3356 --#define EX_LD(x) \
3357 -+#define EX_LD(x,y) \
3358 - 98: x; \
3359 - .section __ex_table,"a";\
3360 - .align 4; \
3361 -- .word 98b, __retl_one; \
3362 -+ .word 98b, y; \
3363 - .text; \
3364 - .align 4;
3365 -
3366 -diff --git a/arch/sparc/lib/GENcopy_to_user.S b/arch/sparc/lib/GENcopy_to_user.S
3367 -index 780550e..9947427 100644
3368 ---- a/arch/sparc/lib/GENcopy_to_user.S
3369 -+++ b/arch/sparc/lib/GENcopy_to_user.S
3370 -@@ -3,11 +3,11 @@
3371 - * Copyright (C) 2007 David S. Miller (davem@×××××××××.net)
3372 - */
3373 -
3374 --#define EX_ST(x) \
3375 -+#define EX_ST(x,y) \
3376 - 98: x; \
3377 - .section __ex_table,"a";\
3378 - .align 4; \
3379 -- .word 98b, __retl_one; \
3380 -+ .word 98b, y; \
3381 - .text; \
3382 - .align 4;
3383 -
3384 -diff --git a/arch/sparc/lib/GENmemcpy.S b/arch/sparc/lib/GENmemcpy.S
3385 -index 89358ee..059ea24 100644
3386 ---- a/arch/sparc/lib/GENmemcpy.S
3387 -+++ b/arch/sparc/lib/GENmemcpy.S
3388 -@@ -4,21 +4,18 @@
3389 - */
3390 -
3391 - #ifdef __KERNEL__
3392 -+#include <linux/linkage.h>
3393 - #define GLOBAL_SPARE %g7
3394 - #else
3395 - #define GLOBAL_SPARE %g5
3396 - #endif
3397 -
3398 - #ifndef EX_LD
3399 --#define EX_LD(x) x
3400 -+#define EX_LD(x,y) x
3401 - #endif
3402 -
3403 - #ifndef EX_ST
3404 --#define EX_ST(x) x
3405 --#endif
3406 --
3407 --#ifndef EX_RETVAL
3408 --#define EX_RETVAL(x) x
3409 -+#define EX_ST(x,y) x
3410 - #endif
3411 -
3412 - #ifndef LOAD
3413 -@@ -45,6 +42,29 @@
3414 - .register %g3,#scratch
3415 -
3416 - .text
3417 -+
3418 -+#ifndef EX_RETVAL
3419 -+#define EX_RETVAL(x) x
3420 -+ENTRY(GEN_retl_o4_1)
3421 -+ add %o4, %o2, %o4
3422 -+ retl
3423 -+ add %o4, 1, %o0
3424 -+ENDPROC(GEN_retl_o4_1)
3425 -+ENTRY(GEN_retl_g1_8)
3426 -+ add %g1, %o2, %g1
3427 -+ retl
3428 -+ add %g1, 8, %o0
3429 -+ENDPROC(GEN_retl_g1_8)
3430 -+ENTRY(GEN_retl_o2_4)
3431 -+ retl
3432 -+ add %o2, 4, %o0
3433 -+ENDPROC(GEN_retl_o2_4)
3434 -+ENTRY(GEN_retl_o2_1)
3435 -+ retl
3436 -+ add %o2, 1, %o0
3437 -+ENDPROC(GEN_retl_o2_1)
3438 -+#endif
3439 -+
3440 - .align 64
3441 -
3442 - .globl FUNC_NAME
3443 -@@ -73,8 +93,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
3444 - sub %g0, %o4, %o4
3445 - sub %o2, %o4, %o2
3446 - 1: subcc %o4, 1, %o4
3447 -- EX_LD(LOAD(ldub, %o1, %g1))
3448 -- EX_ST(STORE(stb, %g1, %o0))
3449 -+ EX_LD(LOAD(ldub, %o1, %g1),GEN_retl_o4_1)
3450 -+ EX_ST(STORE(stb, %g1, %o0),GEN_retl_o4_1)
3451 - add %o1, 1, %o1
3452 - bne,pt %XCC, 1b
3453 - add %o0, 1, %o0
3454 -@@ -82,8 +102,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
3455 - andn %o2, 0x7, %g1
3456 - sub %o2, %g1, %o2
3457 - 1: subcc %g1, 0x8, %g1
3458 -- EX_LD(LOAD(ldx, %o1, %g2))
3459 -- EX_ST(STORE(stx, %g2, %o0))
3460 -+ EX_LD(LOAD(ldx, %o1, %g2),GEN_retl_g1_8)
3461 -+ EX_ST(STORE(stx, %g2, %o0),GEN_retl_g1_8)
3462 - add %o1, 0x8, %o1
3463 - bne,pt %XCC, 1b
3464 - add %o0, 0x8, %o0
3465 -@@ -100,8 +120,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
3466 -
3467 - 1:
3468 - subcc %o2, 4, %o2
3469 -- EX_LD(LOAD(lduw, %o1, %g1))
3470 -- EX_ST(STORE(stw, %g1, %o1 + %o3))
3471 -+ EX_LD(LOAD(lduw, %o1, %g1),GEN_retl_o2_4)
3472 -+ EX_ST(STORE(stw, %g1, %o1 + %o3),GEN_retl_o2_4)
3473 - bgu,pt %XCC, 1b
3474 - add %o1, 4, %o1
3475 -
3476 -@@ -111,8 +131,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
3477 - .align 32
3478 - 90:
3479 - subcc %o2, 1, %o2
3480 -- EX_LD(LOAD(ldub, %o1, %g1))
3481 -- EX_ST(STORE(stb, %g1, %o1 + %o3))
3482 -+ EX_LD(LOAD(ldub, %o1, %g1),GEN_retl_o2_1)
3483 -+ EX_ST(STORE(stb, %g1, %o1 + %o3),GEN_retl_o2_1)
3484 - bgu,pt %XCC, 90b
3485 - add %o1, 1, %o1
3486 - retl
3487 -diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
3488 -index 3269b02..4f2384a 100644
3489 ---- a/arch/sparc/lib/Makefile
3490 -+++ b/arch/sparc/lib/Makefile
3491 -@@ -38,7 +38,7 @@ lib-$(CONFIG_SPARC64) += NG4patch.o NG4copy_page.o NG4clear_page.o NG4memset.o
3492 - lib-$(CONFIG_SPARC64) += GENmemcpy.o GENcopy_from_user.o GENcopy_to_user.o
3493 - lib-$(CONFIG_SPARC64) += GENpatch.o GENpage.o GENbzero.o
3494 -
3495 --lib-$(CONFIG_SPARC64) += copy_in_user.o user_fixup.o memmove.o
3496 -+lib-$(CONFIG_SPARC64) += copy_in_user.o memmove.o
3497 - lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o
3498 -
3499 - obj-$(CONFIG_SPARC64) += iomap.o
3500 -diff --git a/arch/sparc/lib/NG2copy_from_user.S b/arch/sparc/lib/NG2copy_from_user.S
3501 -index d5242b8..b79a699 100644
3502 ---- a/arch/sparc/lib/NG2copy_from_user.S
3503 -+++ b/arch/sparc/lib/NG2copy_from_user.S
3504 -@@ -3,19 +3,19 @@
3505 - * Copyright (C) 2007 David S. Miller (davem@×××××××××.net)
3506 - */
3507 -
3508 --#define EX_LD(x) \
3509 -+#define EX_LD(x,y) \
3510 - 98: x; \
3511 - .section __ex_table,"a";\
3512 - .align 4; \
3513 -- .word 98b, __retl_one_asi;\
3514 -+ .word 98b, y; \
3515 - .text; \
3516 - .align 4;
3517 -
3518 --#define EX_LD_FP(x) \
3519 -+#define EX_LD_FP(x,y) \
3520 - 98: x; \
3521 - .section __ex_table,"a";\
3522 - .align 4; \
3523 -- .word 98b, __retl_one_asi_fp;\
3524 -+ .word 98b, y##_fp; \
3525 - .text; \
3526 - .align 4;
3527 -
3528 -diff --git a/arch/sparc/lib/NG2copy_to_user.S b/arch/sparc/lib/NG2copy_to_user.S
3529 -index 4e962d9..dcec55f 100644
3530 ---- a/arch/sparc/lib/NG2copy_to_user.S
3531 -+++ b/arch/sparc/lib/NG2copy_to_user.S
3532 -@@ -3,19 +3,19 @@
3533 - * Copyright (C) 2007 David S. Miller (davem@×××××××××.net)
3534 - */
3535 -
3536 --#define EX_ST(x) \
3537 -+#define EX_ST(x,y) \
3538 - 98: x; \
3539 - .section __ex_table,"a";\
3540 - .align 4; \
3541 -- .word 98b, __retl_one_asi;\
3542 -+ .word 98b, y; \
3543 - .text; \
3544 - .align 4;
3545 -
3546 --#define EX_ST_FP(x) \
3547 -+#define EX_ST_FP(x,y) \
3548 - 98: x; \
3549 - .section __ex_table,"a";\
3550 - .align 4; \
3551 -- .word 98b, __retl_one_asi_fp;\
3552 -+ .word 98b, y##_fp; \
3553 - .text; \
3554 - .align 4;
3555 -
3556 -diff --git a/arch/sparc/lib/NG2memcpy.S b/arch/sparc/lib/NG2memcpy.S
3557 -index d5f585d..c629dbd 100644
3558 ---- a/arch/sparc/lib/NG2memcpy.S
3559 -+++ b/arch/sparc/lib/NG2memcpy.S
3560 -@@ -4,6 +4,7 @@
3561 - */
3562 -
3563 - #ifdef __KERNEL__
3564 -+#include <linux/linkage.h>
3565 - #include <asm/visasm.h>
3566 - #include <asm/asi.h>
3567 - #define GLOBAL_SPARE %g7
3568 -@@ -32,21 +33,17 @@
3569 - #endif
3570 -
3571 - #ifndef EX_LD
3572 --#define EX_LD(x) x
3573 -+#define EX_LD(x,y) x
3574 - #endif
3575 - #ifndef EX_LD_FP
3576 --#define EX_LD_FP(x) x
3577 -+#define EX_LD_FP(x,y) x
3578 - #endif
3579 -
3580 - #ifndef EX_ST
3581 --#define EX_ST(x) x
3582 -+#define EX_ST(x,y) x
3583 - #endif
3584 - #ifndef EX_ST_FP
3585 --#define EX_ST_FP(x) x
3586 --#endif
3587 --
3588 --#ifndef EX_RETVAL
3589 --#define EX_RETVAL(x) x
3590 -+#define EX_ST_FP(x,y) x
3591 - #endif
3592 -
3593 - #ifndef LOAD
3594 -@@ -140,45 +137,110 @@
3595 - fsrc2 %x6, %f12; \
3596 - fsrc2 %x7, %f14;
3597 - #define FREG_LOAD_1(base, x0) \
3598 -- EX_LD_FP(LOAD(ldd, base + 0x00, %x0))
3599 -+ EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1)
3600 - #define FREG_LOAD_2(base, x0, x1) \
3601 -- EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \
3602 -- EX_LD_FP(LOAD(ldd, base + 0x08, %x1));
3603 -+ EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
3604 -+ EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1);
3605 - #define FREG_LOAD_3(base, x0, x1, x2) \
3606 -- EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \
3607 -- EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); \
3608 -- EX_LD_FP(LOAD(ldd, base + 0x10, %x2));
3609 -+ EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
3610 -+ EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1); \
3611 -+ EX_LD_FP(LOAD(ldd, base + 0x10, %x2), NG2_retl_o2_plus_g1);
3612 - #define FREG_LOAD_4(base, x0, x1, x2, x3) \
3613 -- EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \
3614 -- EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); \
3615 -- EX_LD_FP(LOAD(ldd, base + 0x10, %x2)); \
3616 -- EX_LD_FP(LOAD(ldd, base + 0x18, %x3));
3617 -+ EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
3618 -+ EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1); \
3619 -+ EX_LD_FP(LOAD(ldd, base + 0x10, %x2), NG2_retl_o2_plus_g1); \
3620 -+ EX_LD_FP(LOAD(ldd, base + 0x18, %x3), NG2_retl_o2_plus_g1);
3621 - #define FREG_LOAD_5(base, x0, x1, x2, x3, x4) \
3622 -- EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \
3623 -- EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); \
3624 -- EX_LD_FP(LOAD(ldd, base + 0x10, %x2)); \
3625 -- EX_LD_FP(LOAD(ldd, base + 0x18, %x3)); \
3626 -- EX_LD_FP(LOAD(ldd, base + 0x20, %x4));
3627 -+ EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
3628 -+ EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1); \
3629 -+ EX_LD_FP(LOAD(ldd, base + 0x10, %x2), NG2_retl_o2_plus_g1); \
3630 -+ EX_LD_FP(LOAD(ldd, base + 0x18, %x3), NG2_retl_o2_plus_g1); \
3631 -+ EX_LD_FP(LOAD(ldd, base + 0x20, %x4), NG2_retl_o2_plus_g1);
3632 - #define FREG_LOAD_6(base, x0, x1, x2, x3, x4, x5) \
3633 -- EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \
3634 -- EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); \
3635 -- EX_LD_FP(LOAD(ldd, base + 0x10, %x2)); \
3636 -- EX_LD_FP(LOAD(ldd, base + 0x18, %x3)); \
3637 -- EX_LD_FP(LOAD(ldd, base + 0x20, %x4)); \
3638 -- EX_LD_FP(LOAD(ldd, base + 0x28, %x5));
3639 -+ EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
3640 -+ EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1); \
3641 -+ EX_LD_FP(LOAD(ldd, base + 0x10, %x2), NG2_retl_o2_plus_g1); \
3642 -+ EX_LD_FP(LOAD(ldd, base + 0x18, %x3), NG2_retl_o2_plus_g1); \
3643 -+ EX_LD_FP(LOAD(ldd, base + 0x20, %x4), NG2_retl_o2_plus_g1); \
3644 -+ EX_LD_FP(LOAD(ldd, base + 0x28, %x5), NG2_retl_o2_plus_g1);
3645 - #define FREG_LOAD_7(base, x0, x1, x2, x3, x4, x5, x6) \
3646 -- EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \
3647 -- EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); \
3648 -- EX_LD_FP(LOAD(ldd, base + 0x10, %x2)); \
3649 -- EX_LD_FP(LOAD(ldd, base + 0x18, %x3)); \
3650 -- EX_LD_FP(LOAD(ldd, base + 0x20, %x4)); \
3651 -- EX_LD_FP(LOAD(ldd, base + 0x28, %x5)); \
3652 -- EX_LD_FP(LOAD(ldd, base + 0x30, %x6));
3653 -+ EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
3654 -+ EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1); \
3655 -+ EX_LD_FP(LOAD(ldd, base + 0x10, %x2), NG2_retl_o2_plus_g1); \
3656 -+ EX_LD_FP(LOAD(ldd, base + 0x18, %x3), NG2_retl_o2_plus_g1); \
3657 -+ EX_LD_FP(LOAD(ldd, base + 0x20, %x4), NG2_retl_o2_plus_g1); \
3658 -+ EX_LD_FP(LOAD(ldd, base + 0x28, %x5), NG2_retl_o2_plus_g1); \
3659 -+ EX_LD_FP(LOAD(ldd, base + 0x30, %x6), NG2_retl_o2_plus_g1);
3660 -
3661 - .register %g2,#scratch
3662 - .register %g3,#scratch
3663 -
3664 - .text
3665 -+#ifndef EX_RETVAL
3666 -+#define EX_RETVAL(x) x
3667 -+__restore_fp:
3668 -+ VISExitHalf
3669 -+__restore_asi:
3670 -+ retl
3671 -+ wr %g0, ASI_AIUS, %asi
3672 -+ENTRY(NG2_retl_o2)
3673 -+ ba,pt %xcc, __restore_asi
3674 -+ mov %o2, %o0
3675 -+ENDPROC(NG2_retl_o2)
3676 -+ENTRY(NG2_retl_o2_plus_1)
3677 -+ ba,pt %xcc, __restore_asi
3678 -+ add %o2, 1, %o0
3679 -+ENDPROC(NG2_retl_o2_plus_1)
3680 -+ENTRY(NG2_retl_o2_plus_4)
3681 -+ ba,pt %xcc, __restore_asi
3682 -+ add %o2, 4, %o0
3683 -+ENDPROC(NG2_retl_o2_plus_4)
3684 -+ENTRY(NG2_retl_o2_plus_8)
3685 -+ ba,pt %xcc, __restore_asi
3686 -+ add %o2, 8, %o0
3687 -+ENDPROC(NG2_retl_o2_plus_8)
3688 -+ENTRY(NG2_retl_o2_plus_o4_plus_1)
3689 -+ add %o4, 1, %o4
3690 -+ ba,pt %xcc, __restore_asi
3691 -+ add %o2, %o4, %o0
3692 -+ENDPROC(NG2_retl_o2_plus_o4_plus_1)
3693 -+ENTRY(NG2_retl_o2_plus_o4_plus_8)
3694 -+ add %o4, 8, %o4
3695 -+ ba,pt %xcc, __restore_asi
3696 -+ add %o2, %o4, %o0
3697 -+ENDPROC(NG2_retl_o2_plus_o4_plus_8)
3698 -+ENTRY(NG2_retl_o2_plus_o4_plus_16)
3699 -+ add %o4, 16, %o4
3700 -+ ba,pt %xcc, __restore_asi
3701 -+ add %o2, %o4, %o0
3702 -+ENDPROC(NG2_retl_o2_plus_o4_plus_16)
3703 -+ENTRY(NG2_retl_o2_plus_g1_fp)
3704 -+ ba,pt %xcc, __restore_fp
3705 -+ add %o2, %g1, %o0
3706 -+ENDPROC(NG2_retl_o2_plus_g1_fp)
3707 -+ENTRY(NG2_retl_o2_plus_g1_plus_64_fp)
3708 -+ add %g1, 64, %g1
3709 -+ ba,pt %xcc, __restore_fp
3710 -+ add %o2, %g1, %o0
3711 -+ENDPROC(NG2_retl_o2_plus_g1_plus_64_fp)
3712 -+ENTRY(NG2_retl_o2_plus_g1_plus_1)
3713 -+ add %g1, 1, %g1
3714 -+ ba,pt %xcc, __restore_asi
3715 -+ add %o2, %g1, %o0
3716 -+ENDPROC(NG2_retl_o2_plus_g1_plus_1)
3717 -+ENTRY(NG2_retl_o2_and_7_plus_o4)
3718 -+ and %o2, 7, %o2
3719 -+ ba,pt %xcc, __restore_asi
3720 -+ add %o2, %o4, %o0
3721 -+ENDPROC(NG2_retl_o2_and_7_plus_o4)
3722 -+ENTRY(NG2_retl_o2_and_7_plus_o4_plus_8)
3723 -+ and %o2, 7, %o2
3724 -+ add %o4, 8, %o4
3725 -+ ba,pt %xcc, __restore_asi
3726 -+ add %o2, %o4, %o0
3727 -+ENDPROC(NG2_retl_o2_and_7_plus_o4_plus_8)
3728 -+#endif
3729 -+
3730 - .align 64
3731 -
3732 - .globl FUNC_NAME
3733 -@@ -230,8 +292,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
3734 - sub %g0, %o4, %o4 ! bytes to align dst
3735 - sub %o2, %o4, %o2
3736 - 1: subcc %o4, 1, %o4
3737 -- EX_LD(LOAD(ldub, %o1, %g1))
3738 -- EX_ST(STORE(stb, %g1, %o0))
3739 -+ EX_LD(LOAD(ldub, %o1, %g1), NG2_retl_o2_plus_o4_plus_1)
3740 -+ EX_ST(STORE(stb, %g1, %o0), NG2_retl_o2_plus_o4_plus_1)
3741 - add %o1, 1, %o1
3742 - bne,pt %XCC, 1b
3743 - add %o0, 1, %o0
3744 -@@ -281,11 +343,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
3745 - nop
3746 - /* fall through for 0 < low bits < 8 */
3747 - 110: sub %o4, 64, %g2
3748 -- EX_LD_FP(LOAD_BLK(%g2, %f0))
3749 --1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3))
3750 -- EX_LD_FP(LOAD_BLK(%o4, %f16))
3751 -+ EX_LD_FP(LOAD_BLK(%g2, %f0), NG2_retl_o2_plus_g1)
3752 -+1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
3753 -+ EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
3754 - FREG_FROB(f0, f2, f4, f6, f8, f10, f12, f14, f16)
3755 -- EX_ST_FP(STORE_BLK(%f0, %o4 + %g3))
3756 -+ EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
3757 - FREG_MOVE_8(f16, f18, f20, f22, f24, f26, f28, f30)
3758 - subcc %g1, 64, %g1
3759 - add %o4, 64, %o4
3760 -@@ -296,10 +358,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
3761 -
3762 - 120: sub %o4, 56, %g2
3763 - FREG_LOAD_7(%g2, f0, f2, f4, f6, f8, f10, f12)
3764 --1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3))
3765 -- EX_LD_FP(LOAD_BLK(%o4, %f16))
3766 -+1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
3767 -+ EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
3768 - FREG_FROB(f0, f2, f4, f6, f8, f10, f12, f16, f18)
3769 -- EX_ST_FP(STORE_BLK(%f0, %o4 + %g3))
3770 -+ EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
3771 - FREG_MOVE_7(f18, f20, f22, f24, f26, f28, f30)
3772 - subcc %g1, 64, %g1
3773 - add %o4, 64, %o4
3774 -@@ -310,10 +372,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
3775 -
3776 - 130: sub %o4, 48, %g2
3777 - FREG_LOAD_6(%g2, f0, f2, f4, f6, f8, f10)
3778 --1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3))
3779 -- EX_LD_FP(LOAD_BLK(%o4, %f16))
3780 -+1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
3781 -+ EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
3782 - FREG_FROB(f0, f2, f4, f6, f8, f10, f16, f18, f20)
3783 -- EX_ST_FP(STORE_BLK(%f0, %o4 + %g3))
3784 -+ EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
3785 - FREG_MOVE_6(f20, f22, f24, f26, f28, f30)
3786 - subcc %g1, 64, %g1
3787 - add %o4, 64, %o4
3788 -@@ -324,10 +386,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
3789 -
3790 - 140: sub %o4, 40, %g2
3791 - FREG_LOAD_5(%g2, f0, f2, f4, f6, f8)
3792 --1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3))
3793 -- EX_LD_FP(LOAD_BLK(%o4, %f16))
3794 -+1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
3795 -+ EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
3796 - FREG_FROB(f0, f2, f4, f6, f8, f16, f18, f20, f22)
3797 -- EX_ST_FP(STORE_BLK(%f0, %o4 + %g3))
3798 -+ EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
3799 - FREG_MOVE_5(f22, f24, f26, f28, f30)
3800 - subcc %g1, 64, %g1
3801 - add %o4, 64, %o4
3802 -@@ -338,10 +400,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
3803 -
3804 - 150: sub %o4, 32, %g2
3805 - FREG_LOAD_4(%g2, f0, f2, f4, f6)
3806 --1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3))
3807 -- EX_LD_FP(LOAD_BLK(%o4, %f16))
3808 -+1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
3809 -+ EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
3810 - FREG_FROB(f0, f2, f4, f6, f16, f18, f20, f22, f24)
3811 -- EX_ST_FP(STORE_BLK(%f0, %o4 + %g3))
3812 -+ EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
3813 - FREG_MOVE_4(f24, f26, f28, f30)
3814 - subcc %g1, 64, %g1
3815 - add %o4, 64, %o4
3816 -@@ -352,10 +414,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
3817 -
3818 - 160: sub %o4, 24, %g2
3819 - FREG_LOAD_3(%g2, f0, f2, f4)
3820 --1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3))
3821 -- EX_LD_FP(LOAD_BLK(%o4, %f16))
3822 -+1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
3823 -+ EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
3824 - FREG_FROB(f0, f2, f4, f16, f18, f20, f22, f24, f26)
3825 -- EX_ST_FP(STORE_BLK(%f0, %o4 + %g3))
3826 -+ EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
3827 - FREG_MOVE_3(f26, f28, f30)
3828 - subcc %g1, 64, %g1
3829 - add %o4, 64, %o4
3830 -@@ -366,10 +428,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
3831 -
3832 - 170: sub %o4, 16, %g2
3833 - FREG_LOAD_2(%g2, f0, f2)
3834 --1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3))
3835 -- EX_LD_FP(LOAD_BLK(%o4, %f16))
3836 -+1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
3837 -+ EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
3838 - FREG_FROB(f0, f2, f16, f18, f20, f22, f24, f26, f28)
3839 -- EX_ST_FP(STORE_BLK(%f0, %o4 + %g3))
3840 -+ EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
3841 - FREG_MOVE_2(f28, f30)
3842 - subcc %g1, 64, %g1
3843 - add %o4, 64, %o4
3844 -@@ -380,10 +442,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
3845 -
3846 - 180: sub %o4, 8, %g2
3847 - FREG_LOAD_1(%g2, f0)
3848 --1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3))
3849 -- EX_LD_FP(LOAD_BLK(%o4, %f16))
3850 -+1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
3851 -+ EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
3852 - FREG_FROB(f0, f16, f18, f20, f22, f24, f26, f28, f30)
3853 -- EX_ST_FP(STORE_BLK(%f0, %o4 + %g3))
3854 -+ EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
3855 - FREG_MOVE_1(f30)
3856 - subcc %g1, 64, %g1
3857 - add %o4, 64, %o4
3858 -@@ -393,10 +455,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
3859 - nop
3860 -
3861 - 190:
3862 --1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3))
3863 -+1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
3864 - subcc %g1, 64, %g1
3865 -- EX_LD_FP(LOAD_BLK(%o4, %f0))
3866 -- EX_ST_FP(STORE_BLK(%f0, %o4 + %g3))
3867 -+ EX_LD_FP(LOAD_BLK(%o4, %f0), NG2_retl_o2_plus_g1_plus_64)
3868 -+ EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1_plus_64)
3869 - add %o4, 64, %o4
3870 - bne,pt %xcc, 1b
3871 - LOAD(prefetch, %o4 + 64, #one_read)
3872 -@@ -423,28 +485,28 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
3873 - andn %o2, 0xf, %o4
3874 - and %o2, 0xf, %o2
3875 - 1: subcc %o4, 0x10, %o4
3876 -- EX_LD(LOAD(ldx, %o1, %o5))
3877 -+ EX_LD(LOAD(ldx, %o1, %o5), NG2_retl_o2_plus_o4_plus_16)
3878 - add %o1, 0x08, %o1
3879 -- EX_LD(LOAD(ldx, %o1, %g1))
3880 -+ EX_LD(LOAD(ldx, %o1, %g1), NG2_retl_o2_plus_o4_plus_16)
3881 - sub %o1, 0x08, %o1
3882 -- EX_ST(STORE(stx, %o5, %o1 + GLOBAL_SPARE))
3883 -+ EX_ST(STORE(stx, %o5, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_o4_plus_16)
3884 - add %o1, 0x8, %o1
3885 -- EX_ST(STORE(stx, %g1, %o1 + GLOBAL_SPARE))
3886 -+ EX_ST(STORE(stx, %g1, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_o4_plus_8)
3887 - bgu,pt %XCC, 1b
3888 - add %o1, 0x8, %o1
3889 - 73: andcc %o2, 0x8, %g0
3890 - be,pt %XCC, 1f
3891 - nop
3892 - sub %o2, 0x8, %o2
3893 -- EX_LD(LOAD(ldx, %o1, %o5))
3894 -- EX_ST(STORE(stx, %o5, %o1 + GLOBAL_SPARE))
3895 -+ EX_LD(LOAD(ldx, %o1, %o5), NG2_retl_o2_plus_8)
3896 -+ EX_ST(STORE(stx, %o5, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_8)
3897 - add %o1, 0x8, %o1
3898 - 1: andcc %o2, 0x4, %g0
3899 - be,pt %XCC, 1f
3900 - nop
3901 - sub %o2, 0x4, %o2
3902 -- EX_LD(LOAD(lduw, %o1, %o5))
3903 -- EX_ST(STORE(stw, %o5, %o1 + GLOBAL_SPARE))
3904 -+ EX_LD(LOAD(lduw, %o1, %o5), NG2_retl_o2_plus_4)
3905 -+ EX_ST(STORE(stw, %o5, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_4)
3906 - add %o1, 0x4, %o1
3907 - 1: cmp %o2, 0
3908 - be,pt %XCC, 85f
3909 -@@ -460,8 +522,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
3910 - sub %o2, %g1, %o2
3911 -
3912 - 1: subcc %g1, 1, %g1
3913 -- EX_LD(LOAD(ldub, %o1, %o5))
3914 -- EX_ST(STORE(stb, %o5, %o1 + GLOBAL_SPARE))
3915 -+ EX_LD(LOAD(ldub, %o1, %o5), NG2_retl_o2_plus_g1_plus_1)
3916 -+ EX_ST(STORE(stb, %o5, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_g1_plus_1)
3917 - bgu,pt %icc, 1b
3918 - add %o1, 1, %o1
3919 -
3920 -@@ -477,16 +539,16 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
3921 -
3922 - 8: mov 64, GLOBAL_SPARE
3923 - andn %o1, 0x7, %o1
3924 -- EX_LD(LOAD(ldx, %o1, %g2))
3925 -+ EX_LD(LOAD(ldx, %o1, %g2), NG2_retl_o2)
3926 - sub GLOBAL_SPARE, %g1, GLOBAL_SPARE
3927 - andn %o2, 0x7, %o4
3928 - sllx %g2, %g1, %g2
3929 - 1: add %o1, 0x8, %o1
3930 -- EX_LD(LOAD(ldx, %o1, %g3))
3931 -+ EX_LD(LOAD(ldx, %o1, %g3), NG2_retl_o2_and_7_plus_o4)
3932 - subcc %o4, 0x8, %o4
3933 - srlx %g3, GLOBAL_SPARE, %o5
3934 - or %o5, %g2, %o5
3935 -- EX_ST(STORE(stx, %o5, %o0))
3936 -+ EX_ST(STORE(stx, %o5, %o0), NG2_retl_o2_and_7_plus_o4_plus_8)
3937 - add %o0, 0x8, %o0
3938 - bgu,pt %icc, 1b
3939 - sllx %g3, %g1, %g2
3940 -@@ -506,8 +568,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
3941 -
3942 - 1:
3943 - subcc %o2, 4, %o2
3944 -- EX_LD(LOAD(lduw, %o1, %g1))
3945 -- EX_ST(STORE(stw, %g1, %o1 + GLOBAL_SPARE))
3946 -+ EX_LD(LOAD(lduw, %o1, %g1), NG2_retl_o2_plus_4)
3947 -+ EX_ST(STORE(stw, %g1, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_4)
3948 - bgu,pt %XCC, 1b
3949 - add %o1, 4, %o1
3950 -
3951 -@@ -517,8 +579,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
3952 - .align 32
3953 - 90:
3954 - subcc %o2, 1, %o2
3955 -- EX_LD(LOAD(ldub, %o1, %g1))
3956 -- EX_ST(STORE(stb, %g1, %o1 + GLOBAL_SPARE))
3957 -+ EX_LD(LOAD(ldub, %o1, %g1), NG2_retl_o2_plus_1)
3958 -+ EX_ST(STORE(stb, %g1, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_1)
3959 - bgu,pt %XCC, 90b
3960 - add %o1, 1, %o1
3961 - retl
3962 -diff --git a/arch/sparc/lib/NG4copy_from_user.S b/arch/sparc/lib/NG4copy_from_user.S
3963 -index 2e8ee7a..16a286c 100644
3964 ---- a/arch/sparc/lib/NG4copy_from_user.S
3965 -+++ b/arch/sparc/lib/NG4copy_from_user.S
3966 -@@ -3,19 +3,19 @@
3967 - * Copyright (C) 2012 David S. Miller (davem@×××××××××.net)
3968 - */
3969 -
3970 --#define EX_LD(x) \
3971 -+#define EX_LD(x, y) \
3972 - 98: x; \
3973 - .section __ex_table,"a";\
3974 - .align 4; \
3975 -- .word 98b, __retl_one_asi;\
3976 -+ .word 98b, y; \
3977 - .text; \
3978 - .align 4;
3979 -
3980 --#define EX_LD_FP(x) \
3981 -+#define EX_LD_FP(x,y) \
3982 - 98: x; \
3983 - .section __ex_table,"a";\
3984 - .align 4; \
3985 -- .word 98b, __retl_one_asi_fp;\
3986 -+ .word 98b, y##_fp; \
3987 - .text; \
3988 - .align 4;
3989 -
3990 -diff --git a/arch/sparc/lib/NG4copy_to_user.S b/arch/sparc/lib/NG4copy_to_user.S
3991 -index be0bf45..6b0276f 100644
3992 ---- a/arch/sparc/lib/NG4copy_to_user.S
3993 -+++ b/arch/sparc/lib/NG4copy_to_user.S
3994 -@@ -3,19 +3,19 @@
3995 - * Copyright (C) 2012 David S. Miller (davem@×××××××××.net)
3996 - */
3997 -
3998 --#define EX_ST(x) \
3999 -+#define EX_ST(x,y) \
4000 - 98: x; \
4001 - .section __ex_table,"a";\
4002 - .align 4; \
4003 -- .word 98b, __retl_one_asi;\
4004 -+ .word 98b, y; \
4005 - .text; \
4006 - .align 4;
4007 -
4008 --#define EX_ST_FP(x) \
4009 -+#define EX_ST_FP(x,y) \
4010 - 98: x; \
4011 - .section __ex_table,"a";\
4012 - .align 4; \
4013 -- .word 98b, __retl_one_asi_fp;\
4014 -+ .word 98b, y##_fp; \
4015 - .text; \
4016 - .align 4;
4017 -
4018 -diff --git a/arch/sparc/lib/NG4memcpy.S b/arch/sparc/lib/NG4memcpy.S
4019 -index 8e13ee1..75bb93b 100644
4020 ---- a/arch/sparc/lib/NG4memcpy.S
4021 -+++ b/arch/sparc/lib/NG4memcpy.S
4022 -@@ -4,6 +4,7 @@
4023 - */
4024 -
4025 - #ifdef __KERNEL__
4026 -+#include <linux/linkage.h>
4027 - #include <asm/visasm.h>
4028 - #include <asm/asi.h>
4029 - #define GLOBAL_SPARE %g7
4030 -@@ -46,22 +47,19 @@
4031 - #endif
4032 -
4033 - #ifndef EX_LD
4034 --#define EX_LD(x) x
4035 -+#define EX_LD(x,y) x
4036 - #endif
4037 - #ifndef EX_LD_FP
4038 --#define EX_LD_FP(x) x
4039 -+#define EX_LD_FP(x,y) x
4040 - #endif
4041 -
4042 - #ifndef EX_ST
4043 --#define EX_ST(x) x
4044 -+#define EX_ST(x,y) x
4045 - #endif
4046 - #ifndef EX_ST_FP
4047 --#define EX_ST_FP(x) x
4048 -+#define EX_ST_FP(x,y) x
4049 - #endif
4050 -
4051 --#ifndef EX_RETVAL
4052 --#define EX_RETVAL(x) x
4053 --#endif
4054 -
4055 - #ifndef LOAD
4056 - #define LOAD(type,addr,dest) type [addr], dest
4057 -@@ -94,6 +92,158 @@
4058 - .register %g3,#scratch
4059 -
4060 - .text
4061 -+#ifndef EX_RETVAL
4062 -+#define EX_RETVAL(x) x
4063 -+__restore_asi_fp:
4064 -+ VISExitHalf
4065 -+__restore_asi:
4066 -+ retl
4067 -+ wr %g0, ASI_AIUS, %asi
4068 -+
4069 -+ENTRY(NG4_retl_o2)
4070 -+ ba,pt %xcc, __restore_asi
4071 -+ mov %o2, %o0
4072 -+ENDPROC(NG4_retl_o2)
4073 -+ENTRY(NG4_retl_o2_plus_1)
4074 -+ ba,pt %xcc, __restore_asi
4075 -+ add %o2, 1, %o0
4076 -+ENDPROC(NG4_retl_o2_plus_1)
4077 -+ENTRY(NG4_retl_o2_plus_4)
4078 -+ ba,pt %xcc, __restore_asi
4079 -+ add %o2, 4, %o0
4080 -+ENDPROC(NG4_retl_o2_plus_4)
4081 -+ENTRY(NG4_retl_o2_plus_o5)
4082 -+ ba,pt %xcc, __restore_asi
4083 -+ add %o2, %o5, %o0
4084 -+ENDPROC(NG4_retl_o2_plus_o5)
4085 -+ENTRY(NG4_retl_o2_plus_o5_plus_4)
4086 -+ add %o5, 4, %o5
4087 -+ ba,pt %xcc, __restore_asi
4088 -+ add %o2, %o5, %o0
4089 -+ENDPROC(NG4_retl_o2_plus_o5_plus_4)
4090 -+ENTRY(NG4_retl_o2_plus_o5_plus_8)
4091 -+ add %o5, 8, %o5
4092 -+ ba,pt %xcc, __restore_asi
4093 -+ add %o2, %o5, %o0
4094 -+ENDPROC(NG4_retl_o2_plus_o5_plus_8)
4095 -+ENTRY(NG4_retl_o2_plus_o5_plus_16)
4096 -+ add %o5, 16, %o5
4097 -+ ba,pt %xcc, __restore_asi
4098 -+ add %o2, %o5, %o0
4099 -+ENDPROC(NG4_retl_o2_plus_o5_plus_16)
4100 -+ENTRY(NG4_retl_o2_plus_o5_plus_24)
4101 -+ add %o5, 24, %o5
4102 -+ ba,pt %xcc, __restore_asi
4103 -+ add %o2, %o5, %o0
4104 -+ENDPROC(NG4_retl_o2_plus_o5_plus_24)
4105 -+ENTRY(NG4_retl_o2_plus_o5_plus_32)
4106 -+ add %o5, 32, %o5
4107 -+ ba,pt %xcc, __restore_asi
4108 -+ add %o2, %o5, %o0
4109 -+ENDPROC(NG4_retl_o2_plus_o5_plus_32)
4110 -+ENTRY(NG4_retl_o2_plus_g1)
4111 -+ ba,pt %xcc, __restore_asi
4112 -+ add %o2, %g1, %o0
4113 -+ENDPROC(NG4_retl_o2_plus_g1)
4114 -+ENTRY(NG4_retl_o2_plus_g1_plus_1)
4115 -+ add %g1, 1, %g1
4116 -+ ba,pt %xcc, __restore_asi
4117 -+ add %o2, %g1, %o0
4118 -+ENDPROC(NG4_retl_o2_plus_g1_plus_1)
4119 -+ENTRY(NG4_retl_o2_plus_g1_plus_8)
4120 -+ add %g1, 8, %g1
4121 -+ ba,pt %xcc, __restore_asi
4122 -+ add %o2, %g1, %o0
4123 -+ENDPROC(NG4_retl_o2_plus_g1_plus_8)
4124 -+ENTRY(NG4_retl_o2_plus_o4)
4125 -+ ba,pt %xcc, __restore_asi
4126 -+ add %o2, %o4, %o0
4127 -+ENDPROC(NG4_retl_o2_plus_o4)
4128 -+ENTRY(NG4_retl_o2_plus_o4_plus_8)
4129 -+ add %o4, 8, %o4
4130 -+ ba,pt %xcc, __restore_asi
4131 -+ add %o2, %o4, %o0
4132 -+ENDPROC(NG4_retl_o2_plus_o4_plus_8)
4133 -+ENTRY(NG4_retl_o2_plus_o4_plus_16)
4134 -+ add %o4, 16, %o4
4135 -+ ba,pt %xcc, __restore_asi
4136 -+ add %o2, %o4, %o0
4137 -+ENDPROC(NG4_retl_o2_plus_o4_plus_16)
4138 -+ENTRY(NG4_retl_o2_plus_o4_plus_24)
4139 -+ add %o4, 24, %o4
4140 -+ ba,pt %xcc, __restore_asi
4141 -+ add %o2, %o4, %o0
4142 -+ENDPROC(NG4_retl_o2_plus_o4_plus_24)
4143 -+ENTRY(NG4_retl_o2_plus_o4_plus_32)
4144 -+ add %o4, 32, %o4
4145 -+ ba,pt %xcc, __restore_asi
4146 -+ add %o2, %o4, %o0
4147 -+ENDPROC(NG4_retl_o2_plus_o4_plus_32)
4148 -+ENTRY(NG4_retl_o2_plus_o4_plus_40)
4149 -+ add %o4, 40, %o4
4150 -+ ba,pt %xcc, __restore_asi
4151 -+ add %o2, %o4, %o0
4152 -+ENDPROC(NG4_retl_o2_plus_o4_plus_40)
4153 -+ENTRY(NG4_retl_o2_plus_o4_plus_48)
4154 -+ add %o4, 48, %o4
4155 -+ ba,pt %xcc, __restore_asi
4156 -+ add %o2, %o4, %o0
4157 -+ENDPROC(NG4_retl_o2_plus_o4_plus_48)
4158 -+ENTRY(NG4_retl_o2_plus_o4_plus_56)
4159 -+ add %o4, 56, %o4
4160 -+ ba,pt %xcc, __restore_asi
4161 -+ add %o2, %o4, %o0
4162 -+ENDPROC(NG4_retl_o2_plus_o4_plus_56)
4163 -+ENTRY(NG4_retl_o2_plus_o4_plus_64)
4164 -+ add %o4, 64, %o4
4165 -+ ba,pt %xcc, __restore_asi
4166 -+ add %o2, %o4, %o0
4167 -+ENDPROC(NG4_retl_o2_plus_o4_plus_64)
4168 -+ENTRY(NG4_retl_o2_plus_o4_fp)
4169 -+ ba,pt %xcc, __restore_asi_fp
4170 -+ add %o2, %o4, %o0
4171 -+ENDPROC(NG4_retl_o2_plus_o4_fp)
4172 -+ENTRY(NG4_retl_o2_plus_o4_plus_8_fp)
4173 -+ add %o4, 8, %o4
4174 -+ ba,pt %xcc, __restore_asi_fp
4175 -+ add %o2, %o4, %o0
4176 -+ENDPROC(NG4_retl_o2_plus_o4_plus_8_fp)
4177 -+ENTRY(NG4_retl_o2_plus_o4_plus_16_fp)
4178 -+ add %o4, 16, %o4
4179 -+ ba,pt %xcc, __restore_asi_fp
4180 -+ add %o2, %o4, %o0
4181 -+ENDPROC(NG4_retl_o2_plus_o4_plus_16_fp)
4182 -+ENTRY(NG4_retl_o2_plus_o4_plus_24_fp)
4183 -+ add %o4, 24, %o4
4184 -+ ba,pt %xcc, __restore_asi_fp
4185 -+ add %o2, %o4, %o0
4186 -+ENDPROC(NG4_retl_o2_plus_o4_plus_24_fp)
4187 -+ENTRY(NG4_retl_o2_plus_o4_plus_32_fp)
4188 -+ add %o4, 32, %o4
4189 -+ ba,pt %xcc, __restore_asi_fp
4190 -+ add %o2, %o4, %o0
4191 -+ENDPROC(NG4_retl_o2_plus_o4_plus_32_fp)
4192 -+ENTRY(NG4_retl_o2_plus_o4_plus_40_fp)
4193 -+ add %o4, 40, %o4
4194 -+ ba,pt %xcc, __restore_asi_fp
4195 -+ add %o2, %o4, %o0
4196 -+ENDPROC(NG4_retl_o2_plus_o4_plus_40_fp)
4197 -+ENTRY(NG4_retl_o2_plus_o4_plus_48_fp)
4198 -+ add %o4, 48, %o4
4199 -+ ba,pt %xcc, __restore_asi_fp
4200 -+ add %o2, %o4, %o0
4201 -+ENDPROC(NG4_retl_o2_plus_o4_plus_48_fp)
4202 -+ENTRY(NG4_retl_o2_plus_o4_plus_56_fp)
4203 -+ add %o4, 56, %o4
4204 -+ ba,pt %xcc, __restore_asi_fp
4205 -+ add %o2, %o4, %o0
4206 -+ENDPROC(NG4_retl_o2_plus_o4_plus_56_fp)
4207 -+ENTRY(NG4_retl_o2_plus_o4_plus_64_fp)
4208 -+ add %o4, 64, %o4
4209 -+ ba,pt %xcc, __restore_asi_fp
4210 -+ add %o2, %o4, %o0
4211 -+ENDPROC(NG4_retl_o2_plus_o4_plus_64_fp)
4212 -+#endif
4213 - .align 64
4214 -
4215 - .globl FUNC_NAME
4216 -@@ -124,12 +274,13 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
4217 - brz,pt %g1, 51f
4218 - sub %o2, %g1, %o2
4219 -
4220 --1: EX_LD(LOAD(ldub, %o1 + 0x00, %g2))
4221 -+
4222 -+1: EX_LD(LOAD(ldub, %o1 + 0x00, %g2), NG4_retl_o2_plus_g1)
4223 - add %o1, 1, %o1
4224 - subcc %g1, 1, %g1
4225 - add %o0, 1, %o0
4226 - bne,pt %icc, 1b
4227 -- EX_ST(STORE(stb, %g2, %o0 - 0x01))
4228 -+ EX_ST(STORE(stb, %g2, %o0 - 0x01), NG4_retl_o2_plus_g1_plus_1)
4229 -
4230 - 51: LOAD(prefetch, %o1 + 0x040, #n_reads_strong)
4231 - LOAD(prefetch, %o1 + 0x080, #n_reads_strong)
4232 -@@ -154,43 +305,43 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
4233 - brz,pt %g1, .Llarge_aligned
4234 - sub %o2, %g1, %o2
4235 -
4236 --1: EX_LD(LOAD(ldx, %o1 + 0x00, %g2))
4237 -+1: EX_LD(LOAD(ldx, %o1 + 0x00, %g2), NG4_retl_o2_plus_g1)
4238 - add %o1, 8, %o1
4239 - subcc %g1, 8, %g1
4240 - add %o0, 8, %o0
4241 - bne,pt %icc, 1b
4242 -- EX_ST(STORE(stx, %g2, %o0 - 0x08))
4243 -+ EX_ST(STORE(stx, %g2, %o0 - 0x08), NG4_retl_o2_plus_g1_plus_8)
4244 -
4245 - .Llarge_aligned:
4246 - /* len >= 0x80 && src 8-byte aligned && dest 8-byte aligned */
4247 - andn %o2, 0x3f, %o4
4248 - sub %o2, %o4, %o2
4249 -
4250 --1: EX_LD(LOAD(ldx, %o1 + 0x00, %g1))
4251 -+1: EX_LD(LOAD(ldx, %o1 + 0x00, %g1), NG4_retl_o2_plus_o4)
4252 - add %o1, 0x40, %o1
4253 -- EX_LD(LOAD(ldx, %o1 - 0x38, %g2))
4254 -+ EX_LD(LOAD(ldx, %o1 - 0x38, %g2), NG4_retl_o2_plus_o4)
4255 - subcc %o4, 0x40, %o4
4256 -- EX_LD(LOAD(ldx, %o1 - 0x30, %g3))
4257 -- EX_LD(LOAD(ldx, %o1 - 0x28, GLOBAL_SPARE))
4258 -- EX_LD(LOAD(ldx, %o1 - 0x20, %o5))
4259 -- EX_ST(STORE_INIT(%g1, %o0))
4260 -+ EX_LD(LOAD(ldx, %o1 - 0x30, %g3), NG4_retl_o2_plus_o4_plus_64)
4261 -+ EX_LD(LOAD(ldx, %o1 - 0x28, GLOBAL_SPARE), NG4_retl_o2_plus_o4_plus_64)
4262 -+ EX_LD(LOAD(ldx, %o1 - 0x20, %o5), NG4_retl_o2_plus_o4_plus_64)
4263 -+ EX_ST(STORE_INIT(%g1, %o0), NG4_retl_o2_plus_o4_plus_64)
4264 - add %o0, 0x08, %o0
4265 -- EX_ST(STORE_INIT(%g2, %o0))
4266 -+ EX_ST(STORE_INIT(%g2, %o0), NG4_retl_o2_plus_o4_plus_56)
4267 - add %o0, 0x08, %o0
4268 -- EX_LD(LOAD(ldx, %o1 - 0x18, %g2))
4269 -- EX_ST(STORE_INIT(%g3, %o0))
4270 -+ EX_LD(LOAD(ldx, %o1 - 0x18, %g2), NG4_retl_o2_plus_o4_plus_48)
4271 -+ EX_ST(STORE_INIT(%g3, %o0), NG4_retl_o2_plus_o4_plus_48)
4272 - add %o0, 0x08, %o0
4273 -- EX_LD(LOAD(ldx, %o1 - 0x10, %g3))
4274 -- EX_ST(STORE_INIT(GLOBAL_SPARE, %o0))
4275 -+ EX_LD(LOAD(ldx, %o1 - 0x10, %g3), NG4_retl_o2_plus_o4_plus_40)
4276 -+ EX_ST(STORE_INIT(GLOBAL_SPARE, %o0), NG4_retl_o2_plus_o4_plus_40)
4277 - add %o0, 0x08, %o0
4278 -- EX_LD(LOAD(ldx, %o1 - 0x08, GLOBAL_SPARE))
4279 -- EX_ST(STORE_INIT(%o5, %o0))
4280 -+ EX_LD(LOAD(ldx, %o1 - 0x08, GLOBAL_SPARE), NG4_retl_o2_plus_o4_plus_32)
4281 -+ EX_ST(STORE_INIT(%o5, %o0), NG4_retl_o2_plus_o4_plus_32)
4282 - add %o0, 0x08, %o0
4283 -- EX_ST(STORE_INIT(%g2, %o0))
4284 -+ EX_ST(STORE_INIT(%g2, %o0), NG4_retl_o2_plus_o4_plus_24)
4285 - add %o0, 0x08, %o0
4286 -- EX_ST(STORE_INIT(%g3, %o0))
4287 -+ EX_ST(STORE_INIT(%g3, %o0), NG4_retl_o2_plus_o4_plus_16)
4288 - add %o0, 0x08, %o0
4289 -- EX_ST(STORE_INIT(GLOBAL_SPARE, %o0))
4290 -+ EX_ST(STORE_INIT(GLOBAL_SPARE, %o0), NG4_retl_o2_plus_o4_plus_8)
4291 - add %o0, 0x08, %o0
4292 - bne,pt %icc, 1b
4293 - LOAD(prefetch, %o1 + 0x200, #n_reads_strong)
4294 -@@ -216,17 +367,17 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
4295 - sub %o2, %o4, %o2
4296 - alignaddr %o1, %g0, %g1
4297 - add %o1, %o4, %o1
4298 -- EX_LD_FP(LOAD(ldd, %g1 + 0x00, %f0))
4299 --1: EX_LD_FP(LOAD(ldd, %g1 + 0x08, %f2))
4300 -+ EX_LD_FP(LOAD(ldd, %g1 + 0x00, %f0), NG4_retl_o2_plus_o4)
4301 -+1: EX_LD_FP(LOAD(ldd, %g1 + 0x08, %f2), NG4_retl_o2_plus_o4)
4302 - subcc %o4, 0x40, %o4
4303 -- EX_LD_FP(LOAD(ldd, %g1 + 0x10, %f4))
4304 -- EX_LD_FP(LOAD(ldd, %g1 + 0x18, %f6))
4305 -- EX_LD_FP(LOAD(ldd, %g1 + 0x20, %f8))
4306 -- EX_LD_FP(LOAD(ldd, %g1 + 0x28, %f10))
4307 -- EX_LD_FP(LOAD(ldd, %g1 + 0x30, %f12))
4308 -- EX_LD_FP(LOAD(ldd, %g1 + 0x38, %f14))
4309 -+ EX_LD_FP(LOAD(ldd, %g1 + 0x10, %f4), NG4_retl_o2_plus_o4_plus_64)
4310 -+ EX_LD_FP(LOAD(ldd, %g1 + 0x18, %f6), NG4_retl_o2_plus_o4_plus_64)
4311 -+ EX_LD_FP(LOAD(ldd, %g1 + 0x20, %f8), NG4_retl_o2_plus_o4_plus_64)
4312 -+ EX_LD_FP(LOAD(ldd, %g1 + 0x28, %f10), NG4_retl_o2_plus_o4_plus_64)
4313 -+ EX_LD_FP(LOAD(ldd, %g1 + 0x30, %f12), NG4_retl_o2_plus_o4_plus_64)
4314 -+ EX_LD_FP(LOAD(ldd, %g1 + 0x38, %f14), NG4_retl_o2_plus_o4_plus_64)
4315 - faligndata %f0, %f2, %f16
4316 -- EX_LD_FP(LOAD(ldd, %g1 + 0x40, %f0))
4317 -+ EX_LD_FP(LOAD(ldd, %g1 + 0x40, %f0), NG4_retl_o2_plus_o4_plus_64)
4318 - faligndata %f2, %f4, %f18
4319 - add %g1, 0x40, %g1
4320 - faligndata %f4, %f6, %f20
4321 -@@ -235,14 +386,14 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
4322 - faligndata %f10, %f12, %f26
4323 - faligndata %f12, %f14, %f28
4324 - faligndata %f14, %f0, %f30
4325 -- EX_ST_FP(STORE(std, %f16, %o0 + 0x00))
4326 -- EX_ST_FP(STORE(std, %f18, %o0 + 0x08))
4327 -- EX_ST_FP(STORE(std, %f20, %o0 + 0x10))
4328 -- EX_ST_FP(STORE(std, %f22, %o0 + 0x18))
4329 -- EX_ST_FP(STORE(std, %f24, %o0 + 0x20))
4330 -- EX_ST_FP(STORE(std, %f26, %o0 + 0x28))
4331 -- EX_ST_FP(STORE(std, %f28, %o0 + 0x30))
4332 -- EX_ST_FP(STORE(std, %f30, %o0 + 0x38))
4333 -+ EX_ST_FP(STORE(std, %f16, %o0 + 0x00), NG4_retl_o2_plus_o4_plus_64)
4334 -+ EX_ST_FP(STORE(std, %f18, %o0 + 0x08), NG4_retl_o2_plus_o4_plus_56)
4335 -+ EX_ST_FP(STORE(std, %f20, %o0 + 0x10), NG4_retl_o2_plus_o4_plus_48)
4336 -+ EX_ST_FP(STORE(std, %f22, %o0 + 0x18), NG4_retl_o2_plus_o4_plus_40)
4337 -+ EX_ST_FP(STORE(std, %f24, %o0 + 0x20), NG4_retl_o2_plus_o4_plus_32)
4338 -+ EX_ST_FP(STORE(std, %f26, %o0 + 0x28), NG4_retl_o2_plus_o4_plus_24)
4339 -+ EX_ST_FP(STORE(std, %f28, %o0 + 0x30), NG4_retl_o2_plus_o4_plus_16)
4340 -+ EX_ST_FP(STORE(std, %f30, %o0 + 0x38), NG4_retl_o2_plus_o4_plus_8)
4341 - add %o0, 0x40, %o0
4342 - bne,pt %icc, 1b
4343 - LOAD(prefetch, %g1 + 0x200, #n_reads_strong)
4344 -@@ -270,37 +421,38 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
4345 - andncc %o2, 0x20 - 1, %o5
4346 - be,pn %icc, 2f
4347 - sub %o2, %o5, %o2
4348 --1: EX_LD(LOAD(ldx, %o1 + 0x00, %g1))
4349 -- EX_LD(LOAD(ldx, %o1 + 0x08, %g2))
4350 -- EX_LD(LOAD(ldx, %o1 + 0x10, GLOBAL_SPARE))
4351 -- EX_LD(LOAD(ldx, %o1 + 0x18, %o4))
4352 -+1: EX_LD(LOAD(ldx, %o1 + 0x00, %g1), NG4_retl_o2_plus_o5)
4353 -+ EX_LD(LOAD(ldx, %o1 + 0x08, %g2), NG4_retl_o2_plus_o5)
4354 -+ EX_LD(LOAD(ldx, %o1 + 0x10, GLOBAL_SPARE), NG4_retl_o2_plus_o5)
4355 -+ EX_LD(LOAD(ldx, %o1 + 0x18, %o4), NG4_retl_o2_plus_o5)
4356 - add %o1, 0x20, %o1
4357 - subcc %o5, 0x20, %o5
4358 -- EX_ST(STORE(stx, %g1, %o0 + 0x00))
4359 -- EX_ST(STORE(stx, %g2, %o0 + 0x08))
4360 -- EX_ST(STORE(stx, GLOBAL_SPARE, %o0 + 0x10))
4361 -- EX_ST(STORE(stx, %o4, %o0 + 0x18))
4362 -+ EX_ST(STORE(stx, %g1, %o0 + 0x00), NG4_retl_o2_plus_o5_plus_32)
4363 -+ EX_ST(STORE(stx, %g2, %o0 + 0x08), NG4_retl_o2_plus_o5_plus_24)
4364 -+ EX_ST(STORE(stx, GLOBAL_SPARE, %o0 + 0x10), NG4_retl_o2_plus_o5_plus_24)
4365 -+ EX_ST(STORE(stx, %o4, %o0 + 0x18), NG4_retl_o2_plus_o5_plus_8)
4366 - bne,pt %icc, 1b
4367 - add %o0, 0x20, %o0
4368 - 2: andcc %o2, 0x18, %o5
4369 - be,pt %icc, 3f
4370 - sub %o2, %o5, %o2
4371 --1: EX_LD(LOAD(ldx, %o1 + 0x00, %g1))
4372 -+
4373 -+1: EX_LD(LOAD(ldx, %o1 + 0x00, %g1), NG4_retl_o2_plus_o5)
4374 - add %o1, 0x08, %o1
4375 - add %o0, 0x08, %o0
4376 - subcc %o5, 0x08, %o5
4377 - bne,pt %icc, 1b
4378 -- EX_ST(STORE(stx, %g1, %o0 - 0x08))
4379 -+ EX_ST(STORE(stx, %g1, %o0 - 0x08), NG4_retl_o2_plus_o5_plus_8)
4380 - 3: brz,pt %o2, .Lexit
4381 - cmp %o2, 0x04
4382 - bl,pn %icc, .Ltiny
4383 - nop
4384 -- EX_LD(LOAD(lduw, %o1 + 0x00, %g1))
4385 -+ EX_LD(LOAD(lduw, %o1 + 0x00, %g1), NG4_retl_o2)
4386 - add %o1, 0x04, %o1
4387 - add %o0, 0x04, %o0
4388 - subcc %o2, 0x04, %o2
4389 - bne,pn %icc, .Ltiny
4390 -- EX_ST(STORE(stw, %g1, %o0 - 0x04))
4391 -+ EX_ST(STORE(stw, %g1, %o0 - 0x04), NG4_retl_o2_plus_4)
4392 - ba,a,pt %icc, .Lexit
4393 - .Lmedium_unaligned:
4394 - /* First get dest 8 byte aligned. */
4395 -@@ -309,12 +461,12 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
4396 - brz,pt %g1, 2f
4397 - sub %o2, %g1, %o2
4398 -
4399 --1: EX_LD(LOAD(ldub, %o1 + 0x00, %g2))
4400 -+1: EX_LD(LOAD(ldub, %o1 + 0x00, %g2), NG4_retl_o2_plus_g1)
4401 - add %o1, 1, %o1
4402 - subcc %g1, 1, %g1
4403 - add %o0, 1, %o0
4404 - bne,pt %icc, 1b
4405 -- EX_ST(STORE(stb, %g2, %o0 - 0x01))
4406 -+ EX_ST(STORE(stb, %g2, %o0 - 0x01), NG4_retl_o2_plus_g1_plus_1)
4407 - 2:
4408 - and %o1, 0x7, %g1
4409 - brz,pn %g1, .Lmedium_noprefetch
4410 -@@ -322,16 +474,16 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
4411 - mov 64, %g2
4412 - sub %g2, %g1, %g2
4413 - andn %o1, 0x7, %o1
4414 -- EX_LD(LOAD(ldx, %o1 + 0x00, %o4))
4415 -+ EX_LD(LOAD(ldx, %o1 + 0x00, %o4), NG4_retl_o2)
4416 - sllx %o4, %g1, %o4
4417 - andn %o2, 0x08 - 1, %o5
4418 - sub %o2, %o5, %o2
4419 --1: EX_LD(LOAD(ldx, %o1 + 0x08, %g3))
4420 -+1: EX_LD(LOAD(ldx, %o1 + 0x08, %g3), NG4_retl_o2_plus_o5)
4421 - add %o1, 0x08, %o1
4422 - subcc %o5, 0x08, %o5
4423 - srlx %g3, %g2, GLOBAL_SPARE
4424 - or GLOBAL_SPARE, %o4, GLOBAL_SPARE
4425 -- EX_ST(STORE(stx, GLOBAL_SPARE, %o0 + 0x00))
4426 -+ EX_ST(STORE(stx, GLOBAL_SPARE, %o0 + 0x00), NG4_retl_o2_plus_o5_plus_8)
4427 - add %o0, 0x08, %o0
4428 - bne,pt %icc, 1b
4429 - sllx %g3, %g1, %o4
4430 -@@ -342,17 +494,17 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
4431 - ba,pt %icc, .Lsmall_unaligned
4432 -
4433 - .Ltiny:
4434 -- EX_LD(LOAD(ldub, %o1 + 0x00, %g1))
4435 -+ EX_LD(LOAD(ldub, %o1 + 0x00, %g1), NG4_retl_o2)
4436 - subcc %o2, 1, %o2
4437 - be,pn %icc, .Lexit
4438 -- EX_ST(STORE(stb, %g1, %o0 + 0x00))
4439 -- EX_LD(LOAD(ldub, %o1 + 0x01, %g1))
4440 -+ EX_ST(STORE(stb, %g1, %o0 + 0x00), NG4_retl_o2_plus_1)
4441 -+ EX_LD(LOAD(ldub, %o1 + 0x01, %g1), NG4_retl_o2)
4442 - subcc %o2, 1, %o2
4443 - be,pn %icc, .Lexit
4444 -- EX_ST(STORE(stb, %g1, %o0 + 0x01))
4445 -- EX_LD(LOAD(ldub, %o1 + 0x02, %g1))
4446 -+ EX_ST(STORE(stb, %g1, %o0 + 0x01), NG4_retl_o2_plus_1)
4447 -+ EX_LD(LOAD(ldub, %o1 + 0x02, %g1), NG4_retl_o2)
4448 - ba,pt %icc, .Lexit
4449 -- EX_ST(STORE(stb, %g1, %o0 + 0x02))
4450 -+ EX_ST(STORE(stb, %g1, %o0 + 0x02), NG4_retl_o2)
4451 -
4452 - .Lsmall:
4453 - andcc %g2, 0x3, %g0
4454 -@@ -360,22 +512,22 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
4455 - andn %o2, 0x4 - 1, %o5
4456 - sub %o2, %o5, %o2
4457 - 1:
4458 -- EX_LD(LOAD(lduw, %o1 + 0x00, %g1))
4459 -+ EX_LD(LOAD(lduw, %o1 + 0x00, %g1), NG4_retl_o2_plus_o5)
4460 - add %o1, 0x04, %o1
4461 - subcc %o5, 0x04, %o5
4462 - add %o0, 0x04, %o0
4463 - bne,pt %icc, 1b
4464 -- EX_ST(STORE(stw, %g1, %o0 - 0x04))
4465 -+ EX_ST(STORE(stw, %g1, %o0 - 0x04), NG4_retl_o2_plus_o5_plus_4)
4466 - brz,pt %o2, .Lexit
4467 - nop
4468 - ba,a,pt %icc, .Ltiny
4469 -
4470 - .Lsmall_unaligned:
4471 --1: EX_LD(LOAD(ldub, %o1 + 0x00, %g1))
4472 -+1: EX_LD(LOAD(ldub, %o1 + 0x00, %g1), NG4_retl_o2)
4473 - add %o1, 1, %o1
4474 - add %o0, 1, %o0
4475 - subcc %o2, 1, %o2
4476 - bne,pt %icc, 1b
4477 -- EX_ST(STORE(stb, %g1, %o0 - 0x01))
4478 -+ EX_ST(STORE(stb, %g1, %o0 - 0x01), NG4_retl_o2_plus_1)
4479 - ba,a,pt %icc, .Lexit
4480 - .size FUNC_NAME, .-FUNC_NAME
4481 -diff --git a/arch/sparc/lib/NGcopy_from_user.S b/arch/sparc/lib/NGcopy_from_user.S
4482 -index 5d1e4d1..9cd42fc 100644
4483 ---- a/arch/sparc/lib/NGcopy_from_user.S
4484 -+++ b/arch/sparc/lib/NGcopy_from_user.S
4485 -@@ -3,11 +3,11 @@
4486 - * Copyright (C) 2006, 2007 David S. Miller (davem@×××××××××.net)
4487 - */
4488 -
4489 --#define EX_LD(x) \
4490 -+#define EX_LD(x,y) \
4491 - 98: x; \
4492 - .section __ex_table,"a";\
4493 - .align 4; \
4494 -- .word 98b, __ret_one_asi;\
4495 -+ .word 98b, y; \
4496 - .text; \
4497 - .align 4;
4498 -
4499 -diff --git a/arch/sparc/lib/NGcopy_to_user.S b/arch/sparc/lib/NGcopy_to_user.S
4500 -index ff630dc..5c358af 100644
4501 ---- a/arch/sparc/lib/NGcopy_to_user.S
4502 -+++ b/arch/sparc/lib/NGcopy_to_user.S
4503 -@@ -3,11 +3,11 @@
4504 - * Copyright (C) 2006, 2007 David S. Miller (davem@×××××××××.net)
4505 - */
4506 -
4507 --#define EX_ST(x) \
4508 -+#define EX_ST(x,y) \
4509 - 98: x; \
4510 - .section __ex_table,"a";\
4511 - .align 4; \
4512 -- .word 98b, __ret_one_asi;\
4513 -+ .word 98b, y; \
4514 - .text; \
4515 - .align 4;
4516 -
4517 -diff --git a/arch/sparc/lib/NGmemcpy.S b/arch/sparc/lib/NGmemcpy.S
4518 -index 96a14ca..d88c4ed 100644
4519 ---- a/arch/sparc/lib/NGmemcpy.S
4520 -+++ b/arch/sparc/lib/NGmemcpy.S
4521 -@@ -4,6 +4,7 @@
4522 - */
4523 -
4524 - #ifdef __KERNEL__
4525 -+#include <linux/linkage.h>
4526 - #include <asm/asi.h>
4527 - #include <asm/thread_info.h>
4528 - #define GLOBAL_SPARE %g7
4529 -@@ -27,15 +28,11 @@
4530 - #endif
4531 -
4532 - #ifndef EX_LD
4533 --#define EX_LD(x) x
4534 -+#define EX_LD(x,y) x
4535 - #endif
4536 -
4537 - #ifndef EX_ST
4538 --#define EX_ST(x) x
4539 --#endif
4540 --
4541 --#ifndef EX_RETVAL
4542 --#define EX_RETVAL(x) x
4543 -+#define EX_ST(x,y) x
4544 - #endif
4545 -
4546 - #ifndef LOAD
4547 -@@ -79,6 +76,92 @@
4548 - .register %g3,#scratch
4549 -
4550 - .text
4551 -+#ifndef EX_RETVAL
4552 -+#define EX_RETVAL(x) x
4553 -+__restore_asi:
4554 -+ ret
4555 -+ wr %g0, ASI_AIUS, %asi
4556 -+ restore
4557 -+ENTRY(NG_ret_i2_plus_i4_plus_1)
4558 -+ ba,pt %xcc, __restore_asi
4559 -+ add %i2, %i5, %i0
4560 -+ENDPROC(NG_ret_i2_plus_i4_plus_1)
4561 -+ENTRY(NG_ret_i2_plus_g1)
4562 -+ ba,pt %xcc, __restore_asi
4563 -+ add %i2, %g1, %i0
4564 -+ENDPROC(NG_ret_i2_plus_g1)
4565 -+ENTRY(NG_ret_i2_plus_g1_minus_8)
4566 -+ sub %g1, 8, %g1
4567 -+ ba,pt %xcc, __restore_asi
4568 -+ add %i2, %g1, %i0
4569 -+ENDPROC(NG_ret_i2_plus_g1_minus_8)
4570 -+ENTRY(NG_ret_i2_plus_g1_minus_16)
4571 -+ sub %g1, 16, %g1
4572 -+ ba,pt %xcc, __restore_asi
4573 -+ add %i2, %g1, %i0
4574 -+ENDPROC(NG_ret_i2_plus_g1_minus_16)
4575 -+ENTRY(NG_ret_i2_plus_g1_minus_24)
4576 -+ sub %g1, 24, %g1
4577 -+ ba,pt %xcc, __restore_asi
4578 -+ add %i2, %g1, %i0
4579 -+ENDPROC(NG_ret_i2_plus_g1_minus_24)
4580 -+ENTRY(NG_ret_i2_plus_g1_minus_32)
4581 -+ sub %g1, 32, %g1
4582 -+ ba,pt %xcc, __restore_asi
4583 -+ add %i2, %g1, %i0
4584 -+ENDPROC(NG_ret_i2_plus_g1_minus_32)
4585 -+ENTRY(NG_ret_i2_plus_g1_minus_40)
4586 -+ sub %g1, 40, %g1
4587 -+ ba,pt %xcc, __restore_asi
4588 -+ add %i2, %g1, %i0
4589 -+ENDPROC(NG_ret_i2_plus_g1_minus_40)
4590 -+ENTRY(NG_ret_i2_plus_g1_minus_48)
4591 -+ sub %g1, 48, %g1
4592 -+ ba,pt %xcc, __restore_asi
4593 -+ add %i2, %g1, %i0
4594 -+ENDPROC(NG_ret_i2_plus_g1_minus_48)
4595 -+ENTRY(NG_ret_i2_plus_g1_minus_56)
4596 -+ sub %g1, 56, %g1
4597 -+ ba,pt %xcc, __restore_asi
4598 -+ add %i2, %g1, %i0
4599 -+ENDPROC(NG_ret_i2_plus_g1_minus_56)
4600 -+ENTRY(NG_ret_i2_plus_i4)
4601 -+ ba,pt %xcc, __restore_asi
4602 -+ add %i2, %i4, %i0
4603 -+ENDPROC(NG_ret_i2_plus_i4)
4604 -+ENTRY(NG_ret_i2_plus_i4_minus_8)
4605 -+ sub %i4, 8, %i4
4606 -+ ba,pt %xcc, __restore_asi
4607 -+ add %i2, %i4, %i0
4608 -+ENDPROC(NG_ret_i2_plus_i4_minus_8)
4609 -+ENTRY(NG_ret_i2_plus_8)
4610 -+ ba,pt %xcc, __restore_asi
4611 -+ add %i2, 8, %i0
4612 -+ENDPROC(NG_ret_i2_plus_8)
4613 -+ENTRY(NG_ret_i2_plus_4)
4614 -+ ba,pt %xcc, __restore_asi
4615 -+ add %i2, 4, %i0
4616 -+ENDPROC(NG_ret_i2_plus_4)
4617 -+ENTRY(NG_ret_i2_plus_1)
4618 -+ ba,pt %xcc, __restore_asi
4619 -+ add %i2, 1, %i0
4620 -+ENDPROC(NG_ret_i2_plus_1)
4621 -+ENTRY(NG_ret_i2_plus_g1_plus_1)
4622 -+ add %g1, 1, %g1
4623 -+ ba,pt %xcc, __restore_asi
4624 -+ add %i2, %g1, %i0
4625 -+ENDPROC(NG_ret_i2_plus_g1_plus_1)
4626 -+ENTRY(NG_ret_i2)
4627 -+ ba,pt %xcc, __restore_asi
4628 -+ mov %i2, %i0
4629 -+ENDPROC(NG_ret_i2)
4630 -+ENTRY(NG_ret_i2_and_7_plus_i4)
4631 -+ and %i2, 7, %i2
4632 -+ ba,pt %xcc, __restore_asi
4633 -+ add %i2, %i4, %i0
4634 -+ENDPROC(NG_ret_i2_and_7_plus_i4)
4635 -+#endif
4636 -+
4637 - .align 64
4638 -
4639 - .globl FUNC_NAME
4640 -@@ -126,8 +209,8 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
4641 - sub %g0, %i4, %i4 ! bytes to align dst
4642 - sub %i2, %i4, %i2
4643 - 1: subcc %i4, 1, %i4
4644 -- EX_LD(LOAD(ldub, %i1, %g1))
4645 -- EX_ST(STORE(stb, %g1, %o0))
4646 -+ EX_LD(LOAD(ldub, %i1, %g1), NG_ret_i2_plus_i4_plus_1)
4647 -+ EX_ST(STORE(stb, %g1, %o0), NG_ret_i2_plus_i4_plus_1)
4648 - add %i1, 1, %i1
4649 - bne,pt %XCC, 1b
4650 - add %o0, 1, %o0
4651 -@@ -160,7 +243,7 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
4652 - and %i4, 0x7, GLOBAL_SPARE
4653 - sll GLOBAL_SPARE, 3, GLOBAL_SPARE
4654 - mov 64, %i5
4655 -- EX_LD(LOAD_TWIN(%i1, %g2, %g3))
4656 -+ EX_LD(LOAD_TWIN(%i1, %g2, %g3), NG_ret_i2_plus_g1)
4657 - sub %i5, GLOBAL_SPARE, %i5
4658 - mov 16, %o4
4659 - mov 32, %o5
4660 -@@ -178,31 +261,31 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
4661 - srlx WORD3, PRE_SHIFT, TMP; \
4662 - or WORD2, TMP, WORD2;
4663 -
4664 --8: EX_LD(LOAD_TWIN(%i1 + %o4, %o2, %o3))
4665 -+8: EX_LD(LOAD_TWIN(%i1 + %o4, %o2, %o3), NG_ret_i2_plus_g1)
4666 - MIX_THREE_WORDS(%g2, %g3, %o2, %i5, GLOBAL_SPARE, %o1)
4667 - LOAD(prefetch, %i1 + %i3, #one_read)
4668 -
4669 -- EX_ST(STORE_INIT(%g2, %o0 + 0x00))
4670 -- EX_ST(STORE_INIT(%g3, %o0 + 0x08))
4671 -+ EX_ST(STORE_INIT(%g2, %o0 + 0x00), NG_ret_i2_plus_g1)
4672 -+ EX_ST(STORE_INIT(%g3, %o0 + 0x08), NG_ret_i2_plus_g1_minus_8)
4673 -
4674 -- EX_LD(LOAD_TWIN(%i1 + %o5, %g2, %g3))
4675 -+ EX_LD(LOAD_TWIN(%i1 + %o5, %g2, %g3), NG_ret_i2_plus_g1_minus_16)
4676 - MIX_THREE_WORDS(%o2, %o3, %g2, %i5, GLOBAL_SPARE, %o1)
4677 -
4678 -- EX_ST(STORE_INIT(%o2, %o0 + 0x10))
4679 -- EX_ST(STORE_INIT(%o3, %o0 + 0x18))
4680 -+ EX_ST(STORE_INIT(%o2, %o0 + 0x10), NG_ret_i2_plus_g1_minus_16)
4681 -+ EX_ST(STORE_INIT(%o3, %o0 + 0x18), NG_ret_i2_plus_g1_minus_24)
4682 -
4683 -- EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3))
4684 -+ EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3), NG_ret_i2_plus_g1_minus_32)
4685 - MIX_THREE_WORDS(%g2, %g3, %o2, %i5, GLOBAL_SPARE, %o1)
4686 -
4687 -- EX_ST(STORE_INIT(%g2, %o0 + 0x20))
4688 -- EX_ST(STORE_INIT(%g3, %o0 + 0x28))
4689 -+ EX_ST(STORE_INIT(%g2, %o0 + 0x20), NG_ret_i2_plus_g1_minus_32)
4690 -+ EX_ST(STORE_INIT(%g3, %o0 + 0x28), NG_ret_i2_plus_g1_minus_40)
4691 -
4692 -- EX_LD(LOAD_TWIN(%i1 + %i3, %g2, %g3))
4693 -+ EX_LD(LOAD_TWIN(%i1 + %i3, %g2, %g3), NG_ret_i2_plus_g1_minus_48)
4694 - add %i1, 64, %i1
4695 - MIX_THREE_WORDS(%o2, %o3, %g2, %i5, GLOBAL_SPARE, %o1)
4696 -
4697 -- EX_ST(STORE_INIT(%o2, %o0 + 0x30))
4698 -- EX_ST(STORE_INIT(%o3, %o0 + 0x38))
4699 -+ EX_ST(STORE_INIT(%o2, %o0 + 0x30), NG_ret_i2_plus_g1_minus_48)
4700 -+ EX_ST(STORE_INIT(%o3, %o0 + 0x38), NG_ret_i2_plus_g1_minus_56)
4701 -
4702 - subcc %g1, 64, %g1
4703 - bne,pt %XCC, 8b
4704 -@@ -211,31 +294,31 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
4705 - ba,pt %XCC, 60f
4706 - add %i1, %i4, %i1
4707 -
4708 --9: EX_LD(LOAD_TWIN(%i1 + %o4, %o2, %o3))
4709 -+9: EX_LD(LOAD_TWIN(%i1 + %o4, %o2, %o3), NG_ret_i2_plus_g1)
4710 - MIX_THREE_WORDS(%g3, %o2, %o3, %i5, GLOBAL_SPARE, %o1)
4711 - LOAD(prefetch, %i1 + %i3, #one_read)
4712 -
4713 -- EX_ST(STORE_INIT(%g3, %o0 + 0x00))
4714 -- EX_ST(STORE_INIT(%o2, %o0 + 0x08))
4715 -+ EX_ST(STORE_INIT(%g3, %o0 + 0x00), NG_ret_i2_plus_g1)
4716 -+ EX_ST(STORE_INIT(%o2, %o0 + 0x08), NG_ret_i2_plus_g1_minus_8)
4717 -
4718 -- EX_LD(LOAD_TWIN(%i1 + %o5, %g2, %g3))
4719 -+ EX_LD(LOAD_TWIN(%i1 + %o5, %g2, %g3), NG_ret_i2_plus_g1_minus_16)
4720 - MIX_THREE_WORDS(%o3, %g2, %g3, %i5, GLOBAL_SPARE, %o1)
4721 -
4722 -- EX_ST(STORE_INIT(%o3, %o0 + 0x10))
4723 -- EX_ST(STORE_INIT(%g2, %o0 + 0x18))
4724 -+ EX_ST(STORE_INIT(%o3, %o0 + 0x10), NG_ret_i2_plus_g1_minus_16)
4725 -+ EX_ST(STORE_INIT(%g2, %o0 + 0x18), NG_ret_i2_plus_g1_minus_24)
4726 -
4727 -- EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3))
4728 -+ EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3), NG_ret_i2_plus_g1_minus_32)
4729 - MIX_THREE_WORDS(%g3, %o2, %o3, %i5, GLOBAL_SPARE, %o1)
4730 -
4731 -- EX_ST(STORE_INIT(%g3, %o0 + 0x20))
4732 -- EX_ST(STORE_INIT(%o2, %o0 + 0x28))
4733 -+ EX_ST(STORE_INIT(%g3, %o0 + 0x20), NG_ret_i2_plus_g1_minus_32)
4734 -+ EX_ST(STORE_INIT(%o2, %o0 + 0x28), NG_ret_i2_plus_g1_minus_40)
4735 -
4736 -- EX_LD(LOAD_TWIN(%i1 + %i3, %g2, %g3))
4737 -+ EX_LD(LOAD_TWIN(%i1 + %i3, %g2, %g3), NG_ret_i2_plus_g1_minus_48)
4738 - add %i1, 64, %i1
4739 - MIX_THREE_WORDS(%o3, %g2, %g3, %i5, GLOBAL_SPARE, %o1)
4740 -
4741 -- EX_ST(STORE_INIT(%o3, %o0 + 0x30))
4742 -- EX_ST(STORE_INIT(%g2, %o0 + 0x38))
4743 -+ EX_ST(STORE_INIT(%o3, %o0 + 0x30), NG_ret_i2_plus_g1_minus_48)
4744 -+ EX_ST(STORE_INIT(%g2, %o0 + 0x38), NG_ret_i2_plus_g1_minus_56)
4745 -
4746 - subcc %g1, 64, %g1
4747 - bne,pt %XCC, 9b
4748 -@@ -249,25 +332,25 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
4749 - * one twin load ahead, then add 8 back into source when
4750 - * we finish the loop.
4751 - */
4752 -- EX_LD(LOAD_TWIN(%i1, %o4, %o5))
4753 -+ EX_LD(LOAD_TWIN(%i1, %o4, %o5), NG_ret_i2_plus_g1)
4754 - mov 16, %o7
4755 - mov 32, %g2
4756 - mov 48, %g3
4757 - mov 64, %o1
4758 --1: EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3))
4759 -+1: EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3), NG_ret_i2_plus_g1)
4760 - LOAD(prefetch, %i1 + %o1, #one_read)
4761 -- EX_ST(STORE_INIT(%o5, %o0 + 0x00)) ! initializes cache line
4762 -- EX_ST(STORE_INIT(%o2, %o0 + 0x08))
4763 -- EX_LD(LOAD_TWIN(%i1 + %g2, %o4, %o5))
4764 -- EX_ST(STORE_INIT(%o3, %o0 + 0x10))
4765 -- EX_ST(STORE_INIT(%o4, %o0 + 0x18))
4766 -- EX_LD(LOAD_TWIN(%i1 + %g3, %o2, %o3))
4767 -- EX_ST(STORE_INIT(%o5, %o0 + 0x20))
4768 -- EX_ST(STORE_INIT(%o2, %o0 + 0x28))
4769 -- EX_LD(LOAD_TWIN(%i1 + %o1, %o4, %o5))
4770 -+ EX_ST(STORE_INIT(%o5, %o0 + 0x00), NG_ret_i2_plus_g1) ! initializes cache line
4771 -+ EX_ST(STORE_INIT(%o2, %o0 + 0x08), NG_ret_i2_plus_g1_minus_8)
4772 -+ EX_LD(LOAD_TWIN(%i1 + %g2, %o4, %o5), NG_ret_i2_plus_g1_minus_16)
4773 -+ EX_ST(STORE_INIT(%o3, %o0 + 0x10), NG_ret_i2_plus_g1_minus_16)
4774 -+ EX_ST(STORE_INIT(%o4, %o0 + 0x18), NG_ret_i2_plus_g1_minus_24)
4775 -+ EX_LD(LOAD_TWIN(%i1 + %g3, %o2, %o3), NG_ret_i2_plus_g1_minus_32)
4776 -+ EX_ST(STORE_INIT(%o5, %o0 + 0x20), NG_ret_i2_plus_g1_minus_32)
4777 -+ EX_ST(STORE_INIT(%o2, %o0 + 0x28), NG_ret_i2_plus_g1_minus_40)
4778 -+ EX_LD(LOAD_TWIN(%i1 + %o1, %o4, %o5), NG_ret_i2_plus_g1_minus_48)
4779 - add %i1, 64, %i1
4780 -- EX_ST(STORE_INIT(%o3, %o0 + 0x30))
4781 -- EX_ST(STORE_INIT(%o4, %o0 + 0x38))
4782 -+ EX_ST(STORE_INIT(%o3, %o0 + 0x30), NG_ret_i2_plus_g1_minus_48)
4783 -+ EX_ST(STORE_INIT(%o4, %o0 + 0x38), NG_ret_i2_plus_g1_minus_56)
4784 - subcc %g1, 64, %g1
4785 - bne,pt %XCC, 1b
4786 - add %o0, 64, %o0
4787 -@@ -282,20 +365,20 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
4788 - mov 32, %g2
4789 - mov 48, %g3
4790 - mov 64, %o1
4791 --1: EX_LD(LOAD_TWIN(%i1 + %g0, %o4, %o5))
4792 -- EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3))
4793 -+1: EX_LD(LOAD_TWIN(%i1 + %g0, %o4, %o5), NG_ret_i2_plus_g1)
4794 -+ EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3), NG_ret_i2_plus_g1)
4795 - LOAD(prefetch, %i1 + %o1, #one_read)
4796 -- EX_ST(STORE_INIT(%o4, %o0 + 0x00)) ! initializes cache line
4797 -- EX_ST(STORE_INIT(%o5, %o0 + 0x08))
4798 -- EX_LD(LOAD_TWIN(%i1 + %g2, %o4, %o5))
4799 -- EX_ST(STORE_INIT(%o2, %o0 + 0x10))
4800 -- EX_ST(STORE_INIT(%o3, %o0 + 0x18))
4801 -- EX_LD(LOAD_TWIN(%i1 + %g3, %o2, %o3))
4802 -+ EX_ST(STORE_INIT(%o4, %o0 + 0x00), NG_ret_i2_plus_g1) ! initializes cache line
4803 -+ EX_ST(STORE_INIT(%o5, %o0 + 0x08), NG_ret_i2_plus_g1_minus_8)
4804 -+ EX_LD(LOAD_TWIN(%i1 + %g2, %o4, %o5), NG_ret_i2_plus_g1_minus_16)
4805 -+ EX_ST(STORE_INIT(%o2, %o0 + 0x10), NG_ret_i2_plus_g1_minus_16)
4806 -+ EX_ST(STORE_INIT(%o3, %o0 + 0x18), NG_ret_i2_plus_g1_minus_24)
4807 -+ EX_LD(LOAD_TWIN(%i1 + %g3, %o2, %o3), NG_ret_i2_plus_g1_minus_32)
4808 - add %i1, 64, %i1
4809 -- EX_ST(STORE_INIT(%o4, %o0 + 0x20))
4810 -- EX_ST(STORE_INIT(%o5, %o0 + 0x28))
4811 -- EX_ST(STORE_INIT(%o2, %o0 + 0x30))
4812 -- EX_ST(STORE_INIT(%o3, %o0 + 0x38))
4813 -+ EX_ST(STORE_INIT(%o4, %o0 + 0x20), NG_ret_i2_plus_g1_minus_32)
4814 -+ EX_ST(STORE_INIT(%o5, %o0 + 0x28), NG_ret_i2_plus_g1_minus_40)
4815 -+ EX_ST(STORE_INIT(%o2, %o0 + 0x30), NG_ret_i2_plus_g1_minus_48)
4816 -+ EX_ST(STORE_INIT(%o3, %o0 + 0x38), NG_ret_i2_plus_g1_minus_56)
4817 - subcc %g1, 64, %g1
4818 - bne,pt %XCC, 1b
4819 - add %o0, 64, %o0
4820 -@@ -321,28 +404,28 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
4821 - andn %i2, 0xf, %i4
4822 - and %i2, 0xf, %i2
4823 - 1: subcc %i4, 0x10, %i4
4824 -- EX_LD(LOAD(ldx, %i1, %o4))
4825 -+ EX_LD(LOAD(ldx, %i1, %o4), NG_ret_i2_plus_i4)
4826 - add %i1, 0x08, %i1
4827 -- EX_LD(LOAD(ldx, %i1, %g1))
4828 -+ EX_LD(LOAD(ldx, %i1, %g1), NG_ret_i2_plus_i4)
4829 - sub %i1, 0x08, %i1
4830 -- EX_ST(STORE(stx, %o4, %i1 + %i3))
4831 -+ EX_ST(STORE(stx, %o4, %i1 + %i3), NG_ret_i2_plus_i4)
4832 - add %i1, 0x8, %i1
4833 -- EX_ST(STORE(stx, %g1, %i1 + %i3))
4834 -+ EX_ST(STORE(stx, %g1, %i1 + %i3), NG_ret_i2_plus_i4_minus_8)
4835 - bgu,pt %XCC, 1b
4836 - add %i1, 0x8, %i1
4837 - 73: andcc %i2, 0x8, %g0
4838 - be,pt %XCC, 1f
4839 - nop
4840 - sub %i2, 0x8, %i2
4841 -- EX_LD(LOAD(ldx, %i1, %o4))
4842 -- EX_ST(STORE(stx, %o4, %i1 + %i3))
4843 -+ EX_LD(LOAD(ldx, %i1, %o4), NG_ret_i2_plus_8)
4844 -+ EX_ST(STORE(stx, %o4, %i1 + %i3), NG_ret_i2_plus_8)
4845 - add %i1, 0x8, %i1
4846 - 1: andcc %i2, 0x4, %g0
4847 - be,pt %XCC, 1f
4848 - nop
4849 - sub %i2, 0x4, %i2
4850 -- EX_LD(LOAD(lduw, %i1, %i5))
4851 -- EX_ST(STORE(stw, %i5, %i1 + %i3))
4852 -+ EX_LD(LOAD(lduw, %i1, %i5), NG_ret_i2_plus_4)
4853 -+ EX_ST(STORE(stw, %i5, %i1 + %i3), NG_ret_i2_plus_4)
4854 - add %i1, 0x4, %i1
4855 - 1: cmp %i2, 0
4856 - be,pt %XCC, 85f
4857 -@@ -358,8 +441,8 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
4858 - sub %i2, %g1, %i2
4859 -
4860 - 1: subcc %g1, 1, %g1
4861 -- EX_LD(LOAD(ldub, %i1, %i5))
4862 -- EX_ST(STORE(stb, %i5, %i1 + %i3))
4863 -+ EX_LD(LOAD(ldub, %i1, %i5), NG_ret_i2_plus_g1_plus_1)
4864 -+ EX_ST(STORE(stb, %i5, %i1 + %i3), NG_ret_i2_plus_g1_plus_1)
4865 - bgu,pt %icc, 1b
4866 - add %i1, 1, %i1
4867 -
4868 -@@ -375,16 +458,16 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
4869 -
4870 - 8: mov 64, %i3
4871 - andn %i1, 0x7, %i1
4872 -- EX_LD(LOAD(ldx, %i1, %g2))
4873 -+ EX_LD(LOAD(ldx, %i1, %g2), NG_ret_i2)
4874 - sub %i3, %g1, %i3
4875 - andn %i2, 0x7, %i4
4876 - sllx %g2, %g1, %g2
4877 - 1: add %i1, 0x8, %i1
4878 -- EX_LD(LOAD(ldx, %i1, %g3))
4879 -+ EX_LD(LOAD(ldx, %i1, %g3), NG_ret_i2_and_7_plus_i4)
4880 - subcc %i4, 0x8, %i4
4881 - srlx %g3, %i3, %i5
4882 - or %i5, %g2, %i5
4883 -- EX_ST(STORE(stx, %i5, %o0))
4884 -+ EX_ST(STORE(stx, %i5, %o0), NG_ret_i2_and_7_plus_i4)
4885 - add %o0, 0x8, %o0
4886 - bgu,pt %icc, 1b
4887 - sllx %g3, %g1, %g2
4888 -@@ -404,8 +487,8 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
4889 -
4890 - 1:
4891 - subcc %i2, 4, %i2
4892 -- EX_LD(LOAD(lduw, %i1, %g1))
4893 -- EX_ST(STORE(stw, %g1, %i1 + %i3))
4894 -+ EX_LD(LOAD(lduw, %i1, %g1), NG_ret_i2_plus_4)
4895 -+ EX_ST(STORE(stw, %g1, %i1 + %i3), NG_ret_i2_plus_4)
4896 - bgu,pt %XCC, 1b
4897 - add %i1, 4, %i1
4898 -
4899 -@@ -415,8 +498,8 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
4900 - .align 32
4901 - 90:
4902 - subcc %i2, 1, %i2
4903 -- EX_LD(LOAD(ldub, %i1, %g1))
4904 -- EX_ST(STORE(stb, %g1, %i1 + %i3))
4905 -+ EX_LD(LOAD(ldub, %i1, %g1), NG_ret_i2_plus_1)
4906 -+ EX_ST(STORE(stb, %g1, %i1 + %i3), NG_ret_i2_plus_1)
4907 - bgu,pt %XCC, 90b
4908 - add %i1, 1, %i1
4909 - ret
4910 -diff --git a/arch/sparc/lib/U1copy_from_user.S b/arch/sparc/lib/U1copy_from_user.S
4911 -index ecc5692..bb6ff73 100644
4912 ---- a/arch/sparc/lib/U1copy_from_user.S
4913 -+++ b/arch/sparc/lib/U1copy_from_user.S
4914 -@@ -3,19 +3,19 @@
4915 - * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@××××××.com)
4916 - */
4917 -
4918 --#define EX_LD(x) \
4919 -+#define EX_LD(x,y) \
4920 - 98: x; \
4921 - .section __ex_table,"a";\
4922 - .align 4; \
4923 -- .word 98b, __retl_one; \
4924 -+ .word 98b, y; \
4925 - .text; \
4926 - .align 4;
4927 -
4928 --#define EX_LD_FP(x) \
4929 -+#define EX_LD_FP(x,y) \
4930 - 98: x; \
4931 - .section __ex_table,"a";\
4932 - .align 4; \
4933 -- .word 98b, __retl_one_fp;\
4934 -+ .word 98b, y; \
4935 - .text; \
4936 - .align 4;
4937 -
4938 -diff --git a/arch/sparc/lib/U1copy_to_user.S b/arch/sparc/lib/U1copy_to_user.S
4939 -index 9eea392..ed92ce73 100644
4940 ---- a/arch/sparc/lib/U1copy_to_user.S
4941 -+++ b/arch/sparc/lib/U1copy_to_user.S
4942 -@@ -3,19 +3,19 @@
4943 - * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@××××××.com)
4944 - */
4945 -
4946 --#define EX_ST(x) \
4947 -+#define EX_ST(x,y) \
4948 - 98: x; \
4949 - .section __ex_table,"a";\
4950 - .align 4; \
4951 -- .word 98b, __retl_one; \
4952 -+ .word 98b, y; \
4953 - .text; \
4954 - .align 4;
4955 -
4956 --#define EX_ST_FP(x) \
4957 -+#define EX_ST_FP(x,y) \
4958 - 98: x; \
4959 - .section __ex_table,"a";\
4960 - .align 4; \
4961 -- .word 98b, __retl_one_fp;\
4962 -+ .word 98b, y; \
4963 - .text; \
4964 - .align 4;
4965 -
4966 -diff --git a/arch/sparc/lib/U1memcpy.S b/arch/sparc/lib/U1memcpy.S
4967 -index 3e6209e..f30d2ab 100644
4968 ---- a/arch/sparc/lib/U1memcpy.S
4969 -+++ b/arch/sparc/lib/U1memcpy.S
4970 -@@ -5,6 +5,7 @@
4971 - */
4972 -
4973 - #ifdef __KERNEL__
4974 -+#include <linux/linkage.h>
4975 - #include <asm/visasm.h>
4976 - #include <asm/asi.h>
4977 - #define GLOBAL_SPARE g7
4978 -@@ -23,21 +24,17 @@
4979 - #endif
4980 -
4981 - #ifndef EX_LD
4982 --#define EX_LD(x) x
4983 -+#define EX_LD(x,y) x
4984 - #endif
4985 - #ifndef EX_LD_FP
4986 --#define EX_LD_FP(x) x
4987 -+#define EX_LD_FP(x,y) x
4988 - #endif
4989 -
4990 - #ifndef EX_ST
4991 --#define EX_ST(x) x
4992 -+#define EX_ST(x,y) x
4993 - #endif
4994 - #ifndef EX_ST_FP
4995 --#define EX_ST_FP(x) x
4996 --#endif
4997 --
4998 --#ifndef EX_RETVAL
4999 --#define EX_RETVAL(x) x
5000 -+#define EX_ST_FP(x,y) x
5001 - #endif
5002 -
5003 - #ifndef LOAD
5004 -@@ -78,53 +75,169 @@
5005 - faligndata %f7, %f8, %f60; \
5006 - faligndata %f8, %f9, %f62;
5007 -
5008 --#define MAIN_LOOP_CHUNK(src, dest, fdest, fsrc, len, jmptgt) \
5009 -- EX_LD_FP(LOAD_BLK(%src, %fdest)); \
5010 -- EX_ST_FP(STORE_BLK(%fsrc, %dest)); \
5011 -- add %src, 0x40, %src; \
5012 -- subcc %len, 0x40, %len; \
5013 -- be,pn %xcc, jmptgt; \
5014 -- add %dest, 0x40, %dest; \
5015 --
5016 --#define LOOP_CHUNK1(src, dest, len, branch_dest) \
5017 -- MAIN_LOOP_CHUNK(src, dest, f0, f48, len, branch_dest)
5018 --#define LOOP_CHUNK2(src, dest, len, branch_dest) \
5019 -- MAIN_LOOP_CHUNK(src, dest, f16, f48, len, branch_dest)
5020 --#define LOOP_CHUNK3(src, dest, len, branch_dest) \
5021 -- MAIN_LOOP_CHUNK(src, dest, f32, f48, len, branch_dest)
5022 -+#define MAIN_LOOP_CHUNK(src, dest, fdest, fsrc, jmptgt) \
5023 -+ EX_LD_FP(LOAD_BLK(%src, %fdest), U1_gs_80_fp); \
5024 -+ EX_ST_FP(STORE_BLK(%fsrc, %dest), U1_gs_80_fp); \
5025 -+ add %src, 0x40, %src; \
5026 -+ subcc %GLOBAL_SPARE, 0x40, %GLOBAL_SPARE; \
5027 -+ be,pn %xcc, jmptgt; \
5028 -+ add %dest, 0x40, %dest; \
5029 -+
5030 -+#define LOOP_CHUNK1(src, dest, branch_dest) \
5031 -+ MAIN_LOOP_CHUNK(src, dest, f0, f48, branch_dest)
5032 -+#define LOOP_CHUNK2(src, dest, branch_dest) \
5033 -+ MAIN_LOOP_CHUNK(src, dest, f16, f48, branch_dest)
5034 -+#define LOOP_CHUNK3(src, dest, branch_dest) \
5035 -+ MAIN_LOOP_CHUNK(src, dest, f32, f48, branch_dest)
5036 -
5037 - #define DO_SYNC membar #Sync;
5038 - #define STORE_SYNC(dest, fsrc) \
5039 -- EX_ST_FP(STORE_BLK(%fsrc, %dest)); \
5040 -+ EX_ST_FP(STORE_BLK(%fsrc, %dest), U1_gs_80_fp); \
5041 - add %dest, 0x40, %dest; \
5042 - DO_SYNC
5043 -
5044 - #define STORE_JUMP(dest, fsrc, target) \
5045 -- EX_ST_FP(STORE_BLK(%fsrc, %dest)); \
5046 -+ EX_ST_FP(STORE_BLK(%fsrc, %dest), U1_gs_40_fp); \
5047 - add %dest, 0x40, %dest; \
5048 - ba,pt %xcc, target; \
5049 - nop;
5050 -
5051 --#define FINISH_VISCHUNK(dest, f0, f1, left) \
5052 -- subcc %left, 8, %left;\
5053 -- bl,pn %xcc, 95f; \
5054 -- faligndata %f0, %f1, %f48; \
5055 -- EX_ST_FP(STORE(std, %f48, %dest)); \
5056 -+#define FINISH_VISCHUNK(dest, f0, f1) \
5057 -+ subcc %g3, 8, %g3; \
5058 -+ bl,pn %xcc, 95f; \
5059 -+ faligndata %f0, %f1, %f48; \
5060 -+ EX_ST_FP(STORE(std, %f48, %dest), U1_g3_8_fp); \
5061 - add %dest, 8, %dest;
5062 -
5063 --#define UNEVEN_VISCHUNK_LAST(dest, f0, f1, left) \
5064 -- subcc %left, 8, %left; \
5065 -- bl,pn %xcc, 95f; \
5066 -+#define UNEVEN_VISCHUNK_LAST(dest, f0, f1) \
5067 -+ subcc %g3, 8, %g3; \
5068 -+ bl,pn %xcc, 95f; \
5069 - fsrc2 %f0, %f1;
5070 -
5071 --#define UNEVEN_VISCHUNK(dest, f0, f1, left) \
5072 -- UNEVEN_VISCHUNK_LAST(dest, f0, f1, left) \
5073 -+#define UNEVEN_VISCHUNK(dest, f0, f1) \
5074 -+ UNEVEN_VISCHUNK_LAST(dest, f0, f1) \
5075 - ba,a,pt %xcc, 93f;
5076 -
5077 - .register %g2,#scratch
5078 - .register %g3,#scratch
5079 -
5080 - .text
5081 -+#ifndef EX_RETVAL
5082 -+#define EX_RETVAL(x) x
5083 -+ENTRY(U1_g1_1_fp)
5084 -+ VISExitHalf
5085 -+ add %g1, 1, %g1
5086 -+ add %g1, %g2, %g1
5087 -+ retl
5088 -+ add %g1, %o2, %o0
5089 -+ENDPROC(U1_g1_1_fp)
5090 -+ENTRY(U1_g2_0_fp)
5091 -+ VISExitHalf
5092 -+ retl
5093 -+ add %g2, %o2, %o0
5094 -+ENDPROC(U1_g2_0_fp)
5095 -+ENTRY(U1_g2_8_fp)
5096 -+ VISExitHalf
5097 -+ add %g2, 8, %g2
5098 -+ retl
5099 -+ add %g2, %o2, %o0
5100 -+ENDPROC(U1_g2_8_fp)
5101 -+ENTRY(U1_gs_0_fp)
5102 -+ VISExitHalf
5103 -+ add %GLOBAL_SPARE, %g3, %o0
5104 -+ retl
5105 -+ add %o0, %o2, %o0
5106 -+ENDPROC(U1_gs_0_fp)
5107 -+ENTRY(U1_gs_80_fp)
5108 -+ VISExitHalf
5109 -+ add %GLOBAL_SPARE, 0x80, %GLOBAL_SPARE
5110 -+ add %GLOBAL_SPARE, %g3, %o0
5111 -+ retl
5112 -+ add %o0, %o2, %o0
5113 -+ENDPROC(U1_gs_80_fp)
5114 -+ENTRY(U1_gs_40_fp)
5115 -+ VISExitHalf
5116 -+ add %GLOBAL_SPARE, 0x40, %GLOBAL_SPARE
5117 -+ add %GLOBAL_SPARE, %g3, %o0
5118 -+ retl
5119 -+ add %o0, %o2, %o0
5120 -+ENDPROC(U1_gs_40_fp)
5121 -+ENTRY(U1_g3_0_fp)
5122 -+ VISExitHalf
5123 -+ retl
5124 -+ add %g3, %o2, %o0
5125 -+ENDPROC(U1_g3_0_fp)
5126 -+ENTRY(U1_g3_8_fp)
5127 -+ VISExitHalf
5128 -+ add %g3, 8, %g3
5129 -+ retl
5130 -+ add %g3, %o2, %o0
5131 -+ENDPROC(U1_g3_8_fp)
5132 -+ENTRY(U1_o2_0_fp)
5133 -+ VISExitHalf
5134 -+ retl
5135 -+ mov %o2, %o0
5136 -+ENDPROC(U1_o2_0_fp)
5137 -+ENTRY(U1_o2_1_fp)
5138 -+ VISExitHalf
5139 -+ retl
5140 -+ add %o2, 1, %o0
5141 -+ENDPROC(U1_o2_1_fp)
5142 -+ENTRY(U1_gs_0)
5143 -+ VISExitHalf
5144 -+ retl
5145 -+ add %GLOBAL_SPARE, %o2, %o0
5146 -+ENDPROC(U1_gs_0)
5147 -+ENTRY(U1_gs_8)
5148 -+ VISExitHalf
5149 -+ add %GLOBAL_SPARE, %o2, %GLOBAL_SPARE
5150 -+ retl
5151 -+ add %GLOBAL_SPARE, 0x8, %o0
5152 -+ENDPROC(U1_gs_8)
5153 -+ENTRY(U1_gs_10)
5154 -+ VISExitHalf
5155 -+ add %GLOBAL_SPARE, %o2, %GLOBAL_SPARE
5156 -+ retl
5157 -+ add %GLOBAL_SPARE, 0x10, %o0
5158 -+ENDPROC(U1_gs_10)
5159 -+ENTRY(U1_o2_0)
5160 -+ retl
5161 -+ mov %o2, %o0
5162 -+ENDPROC(U1_o2_0)
5163 -+ENTRY(U1_o2_8)
5164 -+ retl
5165 -+ add %o2, 8, %o0
5166 -+ENDPROC(U1_o2_8)
5167 -+ENTRY(U1_o2_4)
5168 -+ retl
5169 -+ add %o2, 4, %o0
5170 -+ENDPROC(U1_o2_4)
5171 -+ENTRY(U1_o2_1)
5172 -+ retl
5173 -+ add %o2, 1, %o0
5174 -+ENDPROC(U1_o2_1)
5175 -+ENTRY(U1_g1_0)
5176 -+ retl
5177 -+ add %g1, %o2, %o0
5178 -+ENDPROC(U1_g1_0)
5179 -+ENTRY(U1_g1_1)
5180 -+ add %g1, 1, %g1
5181 -+ retl
5182 -+ add %g1, %o2, %o0
5183 -+ENDPROC(U1_g1_1)
5184 -+ENTRY(U1_gs_0_o2_adj)
5185 -+ and %o2, 7, %o2
5186 -+ retl
5187 -+ add %GLOBAL_SPARE, %o2, %o0
5188 -+ENDPROC(U1_gs_0_o2_adj)
5189 -+ENTRY(U1_gs_8_o2_adj)
5190 -+ and %o2, 7, %o2
5191 -+ add %GLOBAL_SPARE, 8, %GLOBAL_SPARE
5192 -+ retl
5193 -+ add %GLOBAL_SPARE, %o2, %o0
5194 -+ENDPROC(U1_gs_8_o2_adj)
5195 -+#endif
5196 -+
5197 - .align 64
5198 -
5199 - .globl FUNC_NAME
5200 -@@ -166,8 +279,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5201 - and %g2, 0x38, %g2
5202 -
5203 - 1: subcc %g1, 0x1, %g1
5204 -- EX_LD_FP(LOAD(ldub, %o1 + 0x00, %o3))
5205 -- EX_ST_FP(STORE(stb, %o3, %o1 + %GLOBAL_SPARE))
5206 -+ EX_LD_FP(LOAD(ldub, %o1 + 0x00, %o3), U1_g1_1_fp)
5207 -+ EX_ST_FP(STORE(stb, %o3, %o1 + %GLOBAL_SPARE), U1_g1_1_fp)
5208 - bgu,pt %XCC, 1b
5209 - add %o1, 0x1, %o1
5210 -
5211 -@@ -178,20 +291,20 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5212 - be,pt %icc, 3f
5213 - alignaddr %o1, %g0, %o1
5214 -
5215 -- EX_LD_FP(LOAD(ldd, %o1, %f4))
5216 --1: EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f6))
5217 -+ EX_LD_FP(LOAD(ldd, %o1, %f4), U1_g2_0_fp)
5218 -+1: EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f6), U1_g2_0_fp)
5219 - add %o1, 0x8, %o1
5220 - subcc %g2, 0x8, %g2
5221 - faligndata %f4, %f6, %f0
5222 -- EX_ST_FP(STORE(std, %f0, %o0))
5223 -+ EX_ST_FP(STORE(std, %f0, %o0), U1_g2_8_fp)
5224 - be,pn %icc, 3f
5225 - add %o0, 0x8, %o0
5226 -
5227 -- EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f4))
5228 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f4), U1_g2_0_fp)
5229 - add %o1, 0x8, %o1
5230 - subcc %g2, 0x8, %g2
5231 - faligndata %f6, %f4, %f0
5232 -- EX_ST_FP(STORE(std, %f0, %o0))
5233 -+ EX_ST_FP(STORE(std, %f0, %o0), U1_g2_8_fp)
5234 - bne,pt %icc, 1b
5235 - add %o0, 0x8, %o0
5236 -
5237 -@@ -214,13 +327,13 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5238 - add %g1, %GLOBAL_SPARE, %g1
5239 - subcc %o2, %g3, %o2
5240 -
5241 -- EX_LD_FP(LOAD_BLK(%o1, %f0))
5242 -+ EX_LD_FP(LOAD_BLK(%o1, %f0), U1_gs_0_fp)
5243 - add %o1, 0x40, %o1
5244 - add %g1, %g3, %g1
5245 -- EX_LD_FP(LOAD_BLK(%o1, %f16))
5246 -+ EX_LD_FP(LOAD_BLK(%o1, %f16), U1_gs_0_fp)
5247 - add %o1, 0x40, %o1
5248 - sub %GLOBAL_SPARE, 0x80, %GLOBAL_SPARE
5249 -- EX_LD_FP(LOAD_BLK(%o1, %f32))
5250 -+ EX_LD_FP(LOAD_BLK(%o1, %f32), U1_gs_80_fp)
5251 - add %o1, 0x40, %o1
5252 -
5253 - /* There are 8 instances of the unrolled loop,
5254 -@@ -240,11 +353,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5255 -
5256 - .align 64
5257 - 1: FREG_FROB(f0, f2, f4, f6, f8, f10,f12,f14,f16)
5258 -- LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f)
5259 -+ LOOP_CHUNK1(o1, o0, 1f)
5260 - FREG_FROB(f16,f18,f20,f22,f24,f26,f28,f30,f32)
5261 -- LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f)
5262 -+ LOOP_CHUNK2(o1, o0, 2f)
5263 - FREG_FROB(f32,f34,f36,f38,f40,f42,f44,f46,f0)
5264 -- LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f)
5265 -+ LOOP_CHUNK3(o1, o0, 3f)
5266 - ba,pt %xcc, 1b+4
5267 - faligndata %f0, %f2, %f48
5268 - 1: FREG_FROB(f16,f18,f20,f22,f24,f26,f28,f30,f32)
5269 -@@ -261,11 +374,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5270 - STORE_JUMP(o0, f48, 56f)
5271 -
5272 - 1: FREG_FROB(f2, f4, f6, f8, f10,f12,f14,f16,f18)
5273 -- LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f)
5274 -+ LOOP_CHUNK1(o1, o0, 1f)
5275 - FREG_FROB(f18,f20,f22,f24,f26,f28,f30,f32,f34)
5276 -- LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f)
5277 -+ LOOP_CHUNK2(o1, o0, 2f)
5278 - FREG_FROB(f34,f36,f38,f40,f42,f44,f46,f0, f2)
5279 -- LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f)
5280 -+ LOOP_CHUNK3(o1, o0, 3f)
5281 - ba,pt %xcc, 1b+4
5282 - faligndata %f2, %f4, %f48
5283 - 1: FREG_FROB(f18,f20,f22,f24,f26,f28,f30,f32,f34)
5284 -@@ -282,11 +395,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5285 - STORE_JUMP(o0, f48, 57f)
5286 -
5287 - 1: FREG_FROB(f4, f6, f8, f10,f12,f14,f16,f18,f20)
5288 -- LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f)
5289 -+ LOOP_CHUNK1(o1, o0, 1f)
5290 - FREG_FROB(f20,f22,f24,f26,f28,f30,f32,f34,f36)
5291 -- LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f)
5292 -+ LOOP_CHUNK2(o1, o0, 2f)
5293 - FREG_FROB(f36,f38,f40,f42,f44,f46,f0, f2, f4)
5294 -- LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f)
5295 -+ LOOP_CHUNK3(o1, o0, 3f)
5296 - ba,pt %xcc, 1b+4
5297 - faligndata %f4, %f6, %f48
5298 - 1: FREG_FROB(f20,f22,f24,f26,f28,f30,f32,f34,f36)
5299 -@@ -303,11 +416,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5300 - STORE_JUMP(o0, f48, 58f)
5301 -
5302 - 1: FREG_FROB(f6, f8, f10,f12,f14,f16,f18,f20,f22)
5303 -- LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f)
5304 -+ LOOP_CHUNK1(o1, o0, 1f)
5305 - FREG_FROB(f22,f24,f26,f28,f30,f32,f34,f36,f38)
5306 -- LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f)
5307 -+ LOOP_CHUNK2(o1, o0, 2f)
5308 - FREG_FROB(f38,f40,f42,f44,f46,f0, f2, f4, f6)
5309 -- LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f)
5310 -+ LOOP_CHUNK3(o1, o0, 3f)
5311 - ba,pt %xcc, 1b+4
5312 - faligndata %f6, %f8, %f48
5313 - 1: FREG_FROB(f22,f24,f26,f28,f30,f32,f34,f36,f38)
5314 -@@ -324,11 +437,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5315 - STORE_JUMP(o0, f48, 59f)
5316 -
5317 - 1: FREG_FROB(f8, f10,f12,f14,f16,f18,f20,f22,f24)
5318 -- LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f)
5319 -+ LOOP_CHUNK1(o1, o0, 1f)
5320 - FREG_FROB(f24,f26,f28,f30,f32,f34,f36,f38,f40)
5321 -- LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f)
5322 -+ LOOP_CHUNK2(o1, o0, 2f)
5323 - FREG_FROB(f40,f42,f44,f46,f0, f2, f4, f6, f8)
5324 -- LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f)
5325 -+ LOOP_CHUNK3(o1, o0, 3f)
5326 - ba,pt %xcc, 1b+4
5327 - faligndata %f8, %f10, %f48
5328 - 1: FREG_FROB(f24,f26,f28,f30,f32,f34,f36,f38,f40)
5329 -@@ -345,11 +458,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5330 - STORE_JUMP(o0, f48, 60f)
5331 -
5332 - 1: FREG_FROB(f10,f12,f14,f16,f18,f20,f22,f24,f26)
5333 -- LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f)
5334 -+ LOOP_CHUNK1(o1, o0, 1f)
5335 - FREG_FROB(f26,f28,f30,f32,f34,f36,f38,f40,f42)
5336 -- LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f)
5337 -+ LOOP_CHUNK2(o1, o0, 2f)
5338 - FREG_FROB(f42,f44,f46,f0, f2, f4, f6, f8, f10)
5339 -- LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f)
5340 -+ LOOP_CHUNK3(o1, o0, 3f)
5341 - ba,pt %xcc, 1b+4
5342 - faligndata %f10, %f12, %f48
5343 - 1: FREG_FROB(f26,f28,f30,f32,f34,f36,f38,f40,f42)
5344 -@@ -366,11 +479,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5345 - STORE_JUMP(o0, f48, 61f)
5346 -
5347 - 1: FREG_FROB(f12,f14,f16,f18,f20,f22,f24,f26,f28)
5348 -- LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f)
5349 -+ LOOP_CHUNK1(o1, o0, 1f)
5350 - FREG_FROB(f28,f30,f32,f34,f36,f38,f40,f42,f44)
5351 -- LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f)
5352 -+ LOOP_CHUNK2(o1, o0, 2f)
5353 - FREG_FROB(f44,f46,f0, f2, f4, f6, f8, f10,f12)
5354 -- LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f)
5355 -+ LOOP_CHUNK3(o1, o0, 3f)
5356 - ba,pt %xcc, 1b+4
5357 - faligndata %f12, %f14, %f48
5358 - 1: FREG_FROB(f28,f30,f32,f34,f36,f38,f40,f42,f44)
5359 -@@ -387,11 +500,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5360 - STORE_JUMP(o0, f48, 62f)
5361 -
5362 - 1: FREG_FROB(f14,f16,f18,f20,f22,f24,f26,f28,f30)
5363 -- LOOP_CHUNK1(o1, o0, GLOBAL_SPARE, 1f)
5364 -+ LOOP_CHUNK1(o1, o0, 1f)
5365 - FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46)
5366 -- LOOP_CHUNK2(o1, o0, GLOBAL_SPARE, 2f)
5367 -+ LOOP_CHUNK2(o1, o0, 2f)
5368 - FREG_FROB(f46,f0, f2, f4, f6, f8, f10,f12,f14)
5369 -- LOOP_CHUNK3(o1, o0, GLOBAL_SPARE, 3f)
5370 -+ LOOP_CHUNK3(o1, o0, 3f)
5371 - ba,pt %xcc, 1b+4
5372 - faligndata %f14, %f16, %f48
5373 - 1: FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46)
5374 -@@ -407,53 +520,53 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5375 - FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46)
5376 - STORE_JUMP(o0, f48, 63f)
5377 -
5378 --40: FINISH_VISCHUNK(o0, f0, f2, g3)
5379 --41: FINISH_VISCHUNK(o0, f2, f4, g3)
5380 --42: FINISH_VISCHUNK(o0, f4, f6, g3)
5381 --43: FINISH_VISCHUNK(o0, f6, f8, g3)
5382 --44: FINISH_VISCHUNK(o0, f8, f10, g3)
5383 --45: FINISH_VISCHUNK(o0, f10, f12, g3)
5384 --46: FINISH_VISCHUNK(o0, f12, f14, g3)
5385 --47: UNEVEN_VISCHUNK(o0, f14, f0, g3)
5386 --48: FINISH_VISCHUNK(o0, f16, f18, g3)
5387 --49: FINISH_VISCHUNK(o0, f18, f20, g3)
5388 --50: FINISH_VISCHUNK(o0, f20, f22, g3)
5389 --51: FINISH_VISCHUNK(o0, f22, f24, g3)
5390 --52: FINISH_VISCHUNK(o0, f24, f26, g3)
5391 --53: FINISH_VISCHUNK(o0, f26, f28, g3)
5392 --54: FINISH_VISCHUNK(o0, f28, f30, g3)
5393 --55: UNEVEN_VISCHUNK(o0, f30, f0, g3)
5394 --56: FINISH_VISCHUNK(o0, f32, f34, g3)
5395 --57: FINISH_VISCHUNK(o0, f34, f36, g3)
5396 --58: FINISH_VISCHUNK(o0, f36, f38, g3)
5397 --59: FINISH_VISCHUNK(o0, f38, f40, g3)
5398 --60: FINISH_VISCHUNK(o0, f40, f42, g3)
5399 --61: FINISH_VISCHUNK(o0, f42, f44, g3)
5400 --62: FINISH_VISCHUNK(o0, f44, f46, g3)
5401 --63: UNEVEN_VISCHUNK_LAST(o0, f46, f0, g3)
5402 --
5403 --93: EX_LD_FP(LOAD(ldd, %o1, %f2))
5404 -+40: FINISH_VISCHUNK(o0, f0, f2)
5405 -+41: FINISH_VISCHUNK(o0, f2, f4)
5406 -+42: FINISH_VISCHUNK(o0, f4, f6)
5407 -+43: FINISH_VISCHUNK(o0, f6, f8)
5408 -+44: FINISH_VISCHUNK(o0, f8, f10)
5409 -+45: FINISH_VISCHUNK(o0, f10, f12)
5410 -+46: FINISH_VISCHUNK(o0, f12, f14)
5411 -+47: UNEVEN_VISCHUNK(o0, f14, f0)
5412 -+48: FINISH_VISCHUNK(o0, f16, f18)
5413 -+49: FINISH_VISCHUNK(o0, f18, f20)
5414 -+50: FINISH_VISCHUNK(o0, f20, f22)
5415 -+51: FINISH_VISCHUNK(o0, f22, f24)
5416 -+52: FINISH_VISCHUNK(o0, f24, f26)
5417 -+53: FINISH_VISCHUNK(o0, f26, f28)
5418 -+54: FINISH_VISCHUNK(o0, f28, f30)
5419 -+55: UNEVEN_VISCHUNK(o0, f30, f0)
5420 -+56: FINISH_VISCHUNK(o0, f32, f34)
5421 -+57: FINISH_VISCHUNK(o0, f34, f36)
5422 -+58: FINISH_VISCHUNK(o0, f36, f38)
5423 -+59: FINISH_VISCHUNK(o0, f38, f40)
5424 -+60: FINISH_VISCHUNK(o0, f40, f42)
5425 -+61: FINISH_VISCHUNK(o0, f42, f44)
5426 -+62: FINISH_VISCHUNK(o0, f44, f46)
5427 -+63: UNEVEN_VISCHUNK_LAST(o0, f46, f0)
5428 -+
5429 -+93: EX_LD_FP(LOAD(ldd, %o1, %f2), U1_g3_0_fp)
5430 - add %o1, 8, %o1
5431 - subcc %g3, 8, %g3
5432 - faligndata %f0, %f2, %f8
5433 -- EX_ST_FP(STORE(std, %f8, %o0))
5434 -+ EX_ST_FP(STORE(std, %f8, %o0), U1_g3_8_fp)
5435 - bl,pn %xcc, 95f
5436 - add %o0, 8, %o0
5437 -- EX_LD_FP(LOAD(ldd, %o1, %f0))
5438 -+ EX_LD_FP(LOAD(ldd, %o1, %f0), U1_g3_0_fp)
5439 - add %o1, 8, %o1
5440 - subcc %g3, 8, %g3
5441 - faligndata %f2, %f0, %f8
5442 -- EX_ST_FP(STORE(std, %f8, %o0))
5443 -+ EX_ST_FP(STORE(std, %f8, %o0), U1_g3_8_fp)
5444 - bge,pt %xcc, 93b
5445 - add %o0, 8, %o0
5446 -
5447 - 95: brz,pt %o2, 2f
5448 - mov %g1, %o1
5449 -
5450 --1: EX_LD_FP(LOAD(ldub, %o1, %o3))
5451 -+1: EX_LD_FP(LOAD(ldub, %o1, %o3), U1_o2_0_fp)
5452 - add %o1, 1, %o1
5453 - subcc %o2, 1, %o2
5454 -- EX_ST_FP(STORE(stb, %o3, %o0))
5455 -+ EX_ST_FP(STORE(stb, %o3, %o0), U1_o2_1_fp)
5456 - bne,pt %xcc, 1b
5457 - add %o0, 1, %o0
5458 -
5459 -@@ -469,27 +582,27 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5460 -
5461 - 72: andn %o2, 0xf, %GLOBAL_SPARE
5462 - and %o2, 0xf, %o2
5463 --1: EX_LD(LOAD(ldx, %o1 + 0x00, %o5))
5464 -- EX_LD(LOAD(ldx, %o1 + 0x08, %g1))
5465 -+1: EX_LD(LOAD(ldx, %o1 + 0x00, %o5), U1_gs_0)
5466 -+ EX_LD(LOAD(ldx, %o1 + 0x08, %g1), U1_gs_0)
5467 - subcc %GLOBAL_SPARE, 0x10, %GLOBAL_SPARE
5468 -- EX_ST(STORE(stx, %o5, %o1 + %o3))
5469 -+ EX_ST(STORE(stx, %o5, %o1 + %o3), U1_gs_10)
5470 - add %o1, 0x8, %o1
5471 -- EX_ST(STORE(stx, %g1, %o1 + %o3))
5472 -+ EX_ST(STORE(stx, %g1, %o1 + %o3), U1_gs_8)
5473 - bgu,pt %XCC, 1b
5474 - add %o1, 0x8, %o1
5475 - 73: andcc %o2, 0x8, %g0
5476 - be,pt %XCC, 1f
5477 - nop
5478 -- EX_LD(LOAD(ldx, %o1, %o5))
5479 -+ EX_LD(LOAD(ldx, %o1, %o5), U1_o2_0)
5480 - sub %o2, 0x8, %o2
5481 -- EX_ST(STORE(stx, %o5, %o1 + %o3))
5482 -+ EX_ST(STORE(stx, %o5, %o1 + %o3), U1_o2_8)
5483 - add %o1, 0x8, %o1
5484 - 1: andcc %o2, 0x4, %g0
5485 - be,pt %XCC, 1f
5486 - nop
5487 -- EX_LD(LOAD(lduw, %o1, %o5))
5488 -+ EX_LD(LOAD(lduw, %o1, %o5), U1_o2_0)
5489 - sub %o2, 0x4, %o2
5490 -- EX_ST(STORE(stw, %o5, %o1 + %o3))
5491 -+ EX_ST(STORE(stw, %o5, %o1 + %o3), U1_o2_4)
5492 - add %o1, 0x4, %o1
5493 - 1: cmp %o2, 0
5494 - be,pt %XCC, 85f
5495 -@@ -503,9 +616,9 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5496 - sub %g0, %g1, %g1
5497 - sub %o2, %g1, %o2
5498 -
5499 --1: EX_LD(LOAD(ldub, %o1, %o5))
5500 -+1: EX_LD(LOAD(ldub, %o1, %o5), U1_g1_0)
5501 - subcc %g1, 1, %g1
5502 -- EX_ST(STORE(stb, %o5, %o1 + %o3))
5503 -+ EX_ST(STORE(stb, %o5, %o1 + %o3), U1_g1_1)
5504 - bgu,pt %icc, 1b
5505 - add %o1, 1, %o1
5506 -
5507 -@@ -521,16 +634,16 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5508 -
5509 - 8: mov 64, %o3
5510 - andn %o1, 0x7, %o1
5511 -- EX_LD(LOAD(ldx, %o1, %g2))
5512 -+ EX_LD(LOAD(ldx, %o1, %g2), U1_o2_0)
5513 - sub %o3, %g1, %o3
5514 - andn %o2, 0x7, %GLOBAL_SPARE
5515 - sllx %g2, %g1, %g2
5516 --1: EX_LD(LOAD(ldx, %o1 + 0x8, %g3))
5517 -+1: EX_LD(LOAD(ldx, %o1 + 0x8, %g3), U1_gs_0_o2_adj)
5518 - subcc %GLOBAL_SPARE, 0x8, %GLOBAL_SPARE
5519 - add %o1, 0x8, %o1
5520 - srlx %g3, %o3, %o5
5521 - or %o5, %g2, %o5
5522 -- EX_ST(STORE(stx, %o5, %o0))
5523 -+ EX_ST(STORE(stx, %o5, %o0), U1_gs_8_o2_adj)
5524 - add %o0, 0x8, %o0
5525 - bgu,pt %icc, 1b
5526 - sllx %g3, %g1, %g2
5527 -@@ -548,9 +661,9 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5528 - bne,pn %XCC, 90f
5529 - sub %o0, %o1, %o3
5530 -
5531 --1: EX_LD(LOAD(lduw, %o1, %g1))
5532 -+1: EX_LD(LOAD(lduw, %o1, %g1), U1_o2_0)
5533 - subcc %o2, 4, %o2
5534 -- EX_ST(STORE(stw, %g1, %o1 + %o3))
5535 -+ EX_ST(STORE(stw, %g1, %o1 + %o3), U1_o2_4)
5536 - bgu,pt %XCC, 1b
5537 - add %o1, 4, %o1
5538 -
5539 -@@ -558,9 +671,9 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5540 - mov EX_RETVAL(%o4), %o0
5541 -
5542 - .align 32
5543 --90: EX_LD(LOAD(ldub, %o1, %g1))
5544 -+90: EX_LD(LOAD(ldub, %o1, %g1), U1_o2_0)
5545 - subcc %o2, 1, %o2
5546 -- EX_ST(STORE(stb, %g1, %o1 + %o3))
5547 -+ EX_ST(STORE(stb, %g1, %o1 + %o3), U1_o2_1)
5548 - bgu,pt %XCC, 90b
5549 - add %o1, 1, %o1
5550 - retl
5551 -diff --git a/arch/sparc/lib/U3copy_from_user.S b/arch/sparc/lib/U3copy_from_user.S
5552 -index 88ad73d..db73010 100644
5553 ---- a/arch/sparc/lib/U3copy_from_user.S
5554 -+++ b/arch/sparc/lib/U3copy_from_user.S
5555 -@@ -3,19 +3,19 @@
5556 - * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@××××××.com)
5557 - */
5558 -
5559 --#define EX_LD(x) \
5560 -+#define EX_LD(x,y) \
5561 - 98: x; \
5562 - .section __ex_table,"a";\
5563 - .align 4; \
5564 -- .word 98b, __retl_one; \
5565 -+ .word 98b, y; \
5566 - .text; \
5567 - .align 4;
5568 -
5569 --#define EX_LD_FP(x) \
5570 -+#define EX_LD_FP(x,y) \
5571 - 98: x; \
5572 - .section __ex_table,"a";\
5573 - .align 4; \
5574 -- .word 98b, __retl_one_fp;\
5575 -+ .word 98b, y##_fp; \
5576 - .text; \
5577 - .align 4;
5578 -
5579 -diff --git a/arch/sparc/lib/U3copy_to_user.S b/arch/sparc/lib/U3copy_to_user.S
5580 -index 845139d..c4ee858 100644
5581 ---- a/arch/sparc/lib/U3copy_to_user.S
5582 -+++ b/arch/sparc/lib/U3copy_to_user.S
5583 -@@ -3,19 +3,19 @@
5584 - * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@××××××.com)
5585 - */
5586 -
5587 --#define EX_ST(x) \
5588 -+#define EX_ST(x,y) \
5589 - 98: x; \
5590 - .section __ex_table,"a";\
5591 - .align 4; \
5592 -- .word 98b, __retl_one; \
5593 -+ .word 98b, y; \
5594 - .text; \
5595 - .align 4;
5596 -
5597 --#define EX_ST_FP(x) \
5598 -+#define EX_ST_FP(x,y) \
5599 - 98: x; \
5600 - .section __ex_table,"a";\
5601 - .align 4; \
5602 -- .word 98b, __retl_one_fp;\
5603 -+ .word 98b, y##_fp; \
5604 - .text; \
5605 - .align 4;
5606 -
5607 -diff --git a/arch/sparc/lib/U3memcpy.S b/arch/sparc/lib/U3memcpy.S
5608 -index 491ee69..54f9870 100644
5609 ---- a/arch/sparc/lib/U3memcpy.S
5610 -+++ b/arch/sparc/lib/U3memcpy.S
5611 -@@ -4,6 +4,7 @@
5612 - */
5613 -
5614 - #ifdef __KERNEL__
5615 -+#include <linux/linkage.h>
5616 - #include <asm/visasm.h>
5617 - #include <asm/asi.h>
5618 - #define GLOBAL_SPARE %g7
5619 -@@ -22,21 +23,17 @@
5620 - #endif
5621 -
5622 - #ifndef EX_LD
5623 --#define EX_LD(x) x
5624 -+#define EX_LD(x,y) x
5625 - #endif
5626 - #ifndef EX_LD_FP
5627 --#define EX_LD_FP(x) x
5628 -+#define EX_LD_FP(x,y) x
5629 - #endif
5630 -
5631 - #ifndef EX_ST
5632 --#define EX_ST(x) x
5633 -+#define EX_ST(x,y) x
5634 - #endif
5635 - #ifndef EX_ST_FP
5636 --#define EX_ST_FP(x) x
5637 --#endif
5638 --
5639 --#ifndef EX_RETVAL
5640 --#define EX_RETVAL(x) x
5641 -+#define EX_ST_FP(x,y) x
5642 - #endif
5643 -
5644 - #ifndef LOAD
5645 -@@ -77,6 +74,87 @@
5646 - */
5647 -
5648 - .text
5649 -+#ifndef EX_RETVAL
5650 -+#define EX_RETVAL(x) x
5651 -+__restore_fp:
5652 -+ VISExitHalf
5653 -+ retl
5654 -+ nop
5655 -+ENTRY(U3_retl_o2_plus_g2_plus_g1_plus_1_fp)
5656 -+ add %g1, 1, %g1
5657 -+ add %g2, %g1, %g2
5658 -+ ba,pt %xcc, __restore_fp
5659 -+ add %o2, %g2, %o0
5660 -+ENDPROC(U3_retl_o2_plus_g2_plus_g1_plus_1_fp)
5661 -+ENTRY(U3_retl_o2_plus_g2_fp)
5662 -+ ba,pt %xcc, __restore_fp
5663 -+ add %o2, %g2, %o0
5664 -+ENDPROC(U3_retl_o2_plus_g2_fp)
5665 -+ENTRY(U3_retl_o2_plus_g2_plus_8_fp)
5666 -+ add %g2, 8, %g2
5667 -+ ba,pt %xcc, __restore_fp
5668 -+ add %o2, %g2, %o0
5669 -+ENDPROC(U3_retl_o2_plus_g2_plus_8_fp)
5670 -+ENTRY(U3_retl_o2)
5671 -+ retl
5672 -+ mov %o2, %o0
5673 -+ENDPROC(U3_retl_o2)
5674 -+ENTRY(U3_retl_o2_plus_1)
5675 -+ retl
5676 -+ add %o2, 1, %o0
5677 -+ENDPROC(U3_retl_o2_plus_1)
5678 -+ENTRY(U3_retl_o2_plus_4)
5679 -+ retl
5680 -+ add %o2, 4, %o0
5681 -+ENDPROC(U3_retl_o2_plus_4)
5682 -+ENTRY(U3_retl_o2_plus_8)
5683 -+ retl
5684 -+ add %o2, 8, %o0
5685 -+ENDPROC(U3_retl_o2_plus_8)
5686 -+ENTRY(U3_retl_o2_plus_g1_plus_1)
5687 -+ add %g1, 1, %g1
5688 -+ retl
5689 -+ add %o2, %g1, %o0
5690 -+ENDPROC(U3_retl_o2_plus_g1_plus_1)
5691 -+ENTRY(U3_retl_o2_fp)
5692 -+ ba,pt %xcc, __restore_fp
5693 -+ mov %o2, %o0
5694 -+ENDPROC(U3_retl_o2_fp)
5695 -+ENTRY(U3_retl_o2_plus_o3_sll_6_plus_0x80_fp)
5696 -+ sll %o3, 6, %o3
5697 -+ add %o3, 0x80, %o3
5698 -+ ba,pt %xcc, __restore_fp
5699 -+ add %o2, %o3, %o0
5700 -+ENDPROC(U3_retl_o2_plus_o3_sll_6_plus_0x80_fp)
5701 -+ENTRY(U3_retl_o2_plus_o3_sll_6_plus_0x40_fp)
5702 -+ sll %o3, 6, %o3
5703 -+ add %o3, 0x40, %o3
5704 -+ ba,pt %xcc, __restore_fp
5705 -+ add %o2, %o3, %o0
5706 -+ENDPROC(U3_retl_o2_plus_o3_sll_6_plus_0x40_fp)
5707 -+ENTRY(U3_retl_o2_plus_GS_plus_0x10)
5708 -+ add GLOBAL_SPARE, 0x10, GLOBAL_SPARE
5709 -+ retl
5710 -+ add %o2, GLOBAL_SPARE, %o0
5711 -+ENDPROC(U3_retl_o2_plus_GS_plus_0x10)
5712 -+ENTRY(U3_retl_o2_plus_GS_plus_0x08)
5713 -+ add GLOBAL_SPARE, 0x08, GLOBAL_SPARE
5714 -+ retl
5715 -+ add %o2, GLOBAL_SPARE, %o0
5716 -+ENDPROC(U3_retl_o2_plus_GS_plus_0x08)
5717 -+ENTRY(U3_retl_o2_and_7_plus_GS)
5718 -+ and %o2, 7, %o2
5719 -+ retl
5720 -+ add %o2, GLOBAL_SPARE, %o2
5721 -+ENDPROC(U3_retl_o2_and_7_plus_GS)
5722 -+ENTRY(U3_retl_o2_and_7_plus_GS_plus_8)
5723 -+ add GLOBAL_SPARE, 8, GLOBAL_SPARE
5724 -+ and %o2, 7, %o2
5725 -+ retl
5726 -+ add %o2, GLOBAL_SPARE, %o2
5727 -+ENDPROC(U3_retl_o2_and_7_plus_GS_plus_8)
5728 -+#endif
5729 -+
5730 - .align 64
5731 -
5732 - /* The cheetah's flexible spine, oversized liver, enlarged heart,
5733 -@@ -126,8 +204,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5734 - and %g2, 0x38, %g2
5735 -
5736 - 1: subcc %g1, 0x1, %g1
5737 -- EX_LD_FP(LOAD(ldub, %o1 + 0x00, %o3))
5738 -- EX_ST_FP(STORE(stb, %o3, %o1 + GLOBAL_SPARE))
5739 -+ EX_LD_FP(LOAD(ldub, %o1 + 0x00, %o3), U3_retl_o2_plus_g2_plus_g1_plus_1)
5740 -+ EX_ST_FP(STORE(stb, %o3, %o1 + GLOBAL_SPARE), U3_retl_o2_plus_g2_plus_g1_plus_1)
5741 - bgu,pt %XCC, 1b
5742 - add %o1, 0x1, %o1
5743 -
5744 -@@ -138,20 +216,20 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5745 - be,pt %icc, 3f
5746 - alignaddr %o1, %g0, %o1
5747 -
5748 -- EX_LD_FP(LOAD(ldd, %o1, %f4))
5749 --1: EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f6))
5750 -+ EX_LD_FP(LOAD(ldd, %o1, %f4), U3_retl_o2_plus_g2)
5751 -+1: EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f6), U3_retl_o2_plus_g2)
5752 - add %o1, 0x8, %o1
5753 - subcc %g2, 0x8, %g2
5754 - faligndata %f4, %f6, %f0
5755 -- EX_ST_FP(STORE(std, %f0, %o0))
5756 -+ EX_ST_FP(STORE(std, %f0, %o0), U3_retl_o2_plus_g2_plus_8)
5757 - be,pn %icc, 3f
5758 - add %o0, 0x8, %o0
5759 -
5760 -- EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f4))
5761 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f4), U3_retl_o2_plus_g2)
5762 - add %o1, 0x8, %o1
5763 - subcc %g2, 0x8, %g2
5764 - faligndata %f6, %f4, %f2
5765 -- EX_ST_FP(STORE(std, %f2, %o0))
5766 -+ EX_ST_FP(STORE(std, %f2, %o0), U3_retl_o2_plus_g2_plus_8)
5767 - bne,pt %icc, 1b
5768 - add %o0, 0x8, %o0
5769 -
5770 -@@ -161,25 +239,25 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5771 - LOAD(prefetch, %o1 + 0x080, #one_read)
5772 - LOAD(prefetch, %o1 + 0x0c0, #one_read)
5773 - LOAD(prefetch, %o1 + 0x100, #one_read)
5774 -- EX_LD_FP(LOAD(ldd, %o1 + 0x000, %f0))
5775 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x000, %f0), U3_retl_o2)
5776 - LOAD(prefetch, %o1 + 0x140, #one_read)
5777 -- EX_LD_FP(LOAD(ldd, %o1 + 0x008, %f2))
5778 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x008, %f2), U3_retl_o2)
5779 - LOAD(prefetch, %o1 + 0x180, #one_read)
5780 -- EX_LD_FP(LOAD(ldd, %o1 + 0x010, %f4))
5781 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x010, %f4), U3_retl_o2)
5782 - LOAD(prefetch, %o1 + 0x1c0, #one_read)
5783 - faligndata %f0, %f2, %f16
5784 -- EX_LD_FP(LOAD(ldd, %o1 + 0x018, %f6))
5785 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x018, %f6), U3_retl_o2)
5786 - faligndata %f2, %f4, %f18
5787 -- EX_LD_FP(LOAD(ldd, %o1 + 0x020, %f8))
5788 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x020, %f8), U3_retl_o2)
5789 - faligndata %f4, %f6, %f20
5790 -- EX_LD_FP(LOAD(ldd, %o1 + 0x028, %f10))
5791 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x028, %f10), U3_retl_o2)
5792 - faligndata %f6, %f8, %f22
5793 -
5794 -- EX_LD_FP(LOAD(ldd, %o1 + 0x030, %f12))
5795 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x030, %f12), U3_retl_o2)
5796 - faligndata %f8, %f10, %f24
5797 -- EX_LD_FP(LOAD(ldd, %o1 + 0x038, %f14))
5798 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x038, %f14), U3_retl_o2)
5799 - faligndata %f10, %f12, %f26
5800 -- EX_LD_FP(LOAD(ldd, %o1 + 0x040, %f0))
5801 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x040, %f0), U3_retl_o2)
5802 -
5803 - subcc GLOBAL_SPARE, 0x80, GLOBAL_SPARE
5804 - add %o1, 0x40, %o1
5805 -@@ -190,26 +268,26 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5806 -
5807 - .align 64
5808 - 1:
5809 -- EX_LD_FP(LOAD(ldd, %o1 + 0x008, %f2))
5810 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x008, %f2), U3_retl_o2_plus_o3_sll_6_plus_0x80)
5811 - faligndata %f12, %f14, %f28
5812 -- EX_LD_FP(LOAD(ldd, %o1 + 0x010, %f4))
5813 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x010, %f4), U3_retl_o2_plus_o3_sll_6_plus_0x80)
5814 - faligndata %f14, %f0, %f30
5815 -- EX_ST_FP(STORE_BLK(%f16, %o0))
5816 -- EX_LD_FP(LOAD(ldd, %o1 + 0x018, %f6))
5817 -+ EX_ST_FP(STORE_BLK(%f16, %o0), U3_retl_o2_plus_o3_sll_6_plus_0x80)
5818 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x018, %f6), U3_retl_o2_plus_o3_sll_6_plus_0x40)
5819 - faligndata %f0, %f2, %f16
5820 - add %o0, 0x40, %o0
5821 -
5822 -- EX_LD_FP(LOAD(ldd, %o1 + 0x020, %f8))
5823 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x020, %f8), U3_retl_o2_plus_o3_sll_6_plus_0x40)
5824 - faligndata %f2, %f4, %f18
5825 -- EX_LD_FP(LOAD(ldd, %o1 + 0x028, %f10))
5826 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x028, %f10), U3_retl_o2_plus_o3_sll_6_plus_0x40)
5827 - faligndata %f4, %f6, %f20
5828 -- EX_LD_FP(LOAD(ldd, %o1 + 0x030, %f12))
5829 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x030, %f12), U3_retl_o2_plus_o3_sll_6_plus_0x40)
5830 - subcc %o3, 0x01, %o3
5831 - faligndata %f6, %f8, %f22
5832 -- EX_LD_FP(LOAD(ldd, %o1 + 0x038, %f14))
5833 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x038, %f14), U3_retl_o2_plus_o3_sll_6_plus_0x80)
5834 -
5835 - faligndata %f8, %f10, %f24
5836 -- EX_LD_FP(LOAD(ldd, %o1 + 0x040, %f0))
5837 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x040, %f0), U3_retl_o2_plus_o3_sll_6_plus_0x80)
5838 - LOAD(prefetch, %o1 + 0x1c0, #one_read)
5839 - faligndata %f10, %f12, %f26
5840 - bg,pt %XCC, 1b
5841 -@@ -217,29 +295,29 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5842 -
5843 - /* Finally we copy the last full 64-byte block. */
5844 - 2:
5845 -- EX_LD_FP(LOAD(ldd, %o1 + 0x008, %f2))
5846 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x008, %f2), U3_retl_o2_plus_o3_sll_6_plus_0x80)
5847 - faligndata %f12, %f14, %f28
5848 -- EX_LD_FP(LOAD(ldd, %o1 + 0x010, %f4))
5849 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x010, %f4), U3_retl_o2_plus_o3_sll_6_plus_0x80)
5850 - faligndata %f14, %f0, %f30
5851 -- EX_ST_FP(STORE_BLK(%f16, %o0))
5852 -- EX_LD_FP(LOAD(ldd, %o1 + 0x018, %f6))
5853 -+ EX_ST_FP(STORE_BLK(%f16, %o0), U3_retl_o2_plus_o3_sll_6_plus_0x80)
5854 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x018, %f6), U3_retl_o2_plus_o3_sll_6_plus_0x40)
5855 - faligndata %f0, %f2, %f16
5856 -- EX_LD_FP(LOAD(ldd, %o1 + 0x020, %f8))
5857 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x020, %f8), U3_retl_o2_plus_o3_sll_6_plus_0x40)
5858 - faligndata %f2, %f4, %f18
5859 -- EX_LD_FP(LOAD(ldd, %o1 + 0x028, %f10))
5860 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x028, %f10), U3_retl_o2_plus_o3_sll_6_plus_0x40)
5861 - faligndata %f4, %f6, %f20
5862 -- EX_LD_FP(LOAD(ldd, %o1 + 0x030, %f12))
5863 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x030, %f12), U3_retl_o2_plus_o3_sll_6_plus_0x40)
5864 - faligndata %f6, %f8, %f22
5865 -- EX_LD_FP(LOAD(ldd, %o1 + 0x038, %f14))
5866 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x038, %f14), U3_retl_o2_plus_o3_sll_6_plus_0x40)
5867 - faligndata %f8, %f10, %f24
5868 - cmp %g1, 0
5869 - be,pt %XCC, 1f
5870 - add %o0, 0x40, %o0
5871 -- EX_LD_FP(LOAD(ldd, %o1 + 0x040, %f0))
5872 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x040, %f0), U3_retl_o2_plus_o3_sll_6_plus_0x40)
5873 - 1: faligndata %f10, %f12, %f26
5874 - faligndata %f12, %f14, %f28
5875 - faligndata %f14, %f0, %f30
5876 -- EX_ST_FP(STORE_BLK(%f16, %o0))
5877 -+ EX_ST_FP(STORE_BLK(%f16, %o0), U3_retl_o2_plus_o3_sll_6_plus_0x40)
5878 - add %o0, 0x40, %o0
5879 - add %o1, 0x40, %o1
5880 - membar #Sync
5881 -@@ -259,20 +337,20 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5882 -
5883 - sub %o2, %g2, %o2
5884 - be,a,pt %XCC, 1f
5885 -- EX_LD_FP(LOAD(ldd, %o1 + 0x00, %f0))
5886 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x00, %f0), U3_retl_o2_plus_g2)
5887 -
5888 --1: EX_LD_FP(LOAD(ldd, %o1 + 0x08, %f2))
5889 -+1: EX_LD_FP(LOAD(ldd, %o1 + 0x08, %f2), U3_retl_o2_plus_g2)
5890 - add %o1, 0x8, %o1
5891 - subcc %g2, 0x8, %g2
5892 - faligndata %f0, %f2, %f8
5893 -- EX_ST_FP(STORE(std, %f8, %o0))
5894 -+ EX_ST_FP(STORE(std, %f8, %o0), U3_retl_o2_plus_g2_plus_8)
5895 - be,pn %XCC, 2f
5896 - add %o0, 0x8, %o0
5897 -- EX_LD_FP(LOAD(ldd, %o1 + 0x08, %f0))
5898 -+ EX_LD_FP(LOAD(ldd, %o1 + 0x08, %f0), U3_retl_o2_plus_g2)
5899 - add %o1, 0x8, %o1
5900 - subcc %g2, 0x8, %g2
5901 - faligndata %f2, %f0, %f8
5902 -- EX_ST_FP(STORE(std, %f8, %o0))
5903 -+ EX_ST_FP(STORE(std, %f8, %o0), U3_retl_o2_plus_g2_plus_8)
5904 - bne,pn %XCC, 1b
5905 - add %o0, 0x8, %o0
5906 -
5907 -@@ -292,30 +370,33 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5908 - andcc %o2, 0x8, %g0
5909 - be,pt %icc, 1f
5910 - nop
5911 -- EX_LD(LOAD(ldx, %o1, %o5))
5912 -- EX_ST(STORE(stx, %o5, %o1 + %o3))
5913 -+ EX_LD(LOAD(ldx, %o1, %o5), U3_retl_o2)
5914 -+ EX_ST(STORE(stx, %o5, %o1 + %o3), U3_retl_o2)
5915 - add %o1, 0x8, %o1
5916 -+ sub %o2, 8, %o2
5917 -
5918 - 1: andcc %o2, 0x4, %g0
5919 - be,pt %icc, 1f
5920 - nop
5921 -- EX_LD(LOAD(lduw, %o1, %o5))
5922 -- EX_ST(STORE(stw, %o5, %o1 + %o3))
5923 -+ EX_LD(LOAD(lduw, %o1, %o5), U3_retl_o2)
5924 -+ EX_ST(STORE(stw, %o5, %o1 + %o3), U3_retl_o2)
5925 - add %o1, 0x4, %o1
5926 -+ sub %o2, 4, %o2
5927 -
5928 - 1: andcc %o2, 0x2, %g0
5929 - be,pt %icc, 1f
5930 - nop
5931 -- EX_LD(LOAD(lduh, %o1, %o5))
5932 -- EX_ST(STORE(sth, %o5, %o1 + %o3))
5933 -+ EX_LD(LOAD(lduh, %o1, %o5), U3_retl_o2)
5934 -+ EX_ST(STORE(sth, %o5, %o1 + %o3), U3_retl_o2)
5935 - add %o1, 0x2, %o1
5936 -+ sub %o2, 2, %o2
5937 -
5938 - 1: andcc %o2, 0x1, %g0
5939 - be,pt %icc, 85f
5940 - nop
5941 -- EX_LD(LOAD(ldub, %o1, %o5))
5942 -+ EX_LD(LOAD(ldub, %o1, %o5), U3_retl_o2)
5943 - ba,pt %xcc, 85f
5944 -- EX_ST(STORE(stb, %o5, %o1 + %o3))
5945 -+ EX_ST(STORE(stb, %o5, %o1 + %o3), U3_retl_o2)
5946 -
5947 - .align 64
5948 - 70: /* 16 < len <= 64 */
5949 -@@ -326,26 +407,26 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5950 - andn %o2, 0xf, GLOBAL_SPARE
5951 - and %o2, 0xf, %o2
5952 - 1: subcc GLOBAL_SPARE, 0x10, GLOBAL_SPARE
5953 -- EX_LD(LOAD(ldx, %o1 + 0x00, %o5))
5954 -- EX_LD(LOAD(ldx, %o1 + 0x08, %g1))
5955 -- EX_ST(STORE(stx, %o5, %o1 + %o3))
5956 -+ EX_LD(LOAD(ldx, %o1 + 0x00, %o5), U3_retl_o2_plus_GS_plus_0x10)
5957 -+ EX_LD(LOAD(ldx, %o1 + 0x08, %g1), U3_retl_o2_plus_GS_plus_0x10)
5958 -+ EX_ST(STORE(stx, %o5, %o1 + %o3), U3_retl_o2_plus_GS_plus_0x10)
5959 - add %o1, 0x8, %o1
5960 -- EX_ST(STORE(stx, %g1, %o1 + %o3))
5961 -+ EX_ST(STORE(stx, %g1, %o1 + %o3), U3_retl_o2_plus_GS_plus_0x08)
5962 - bgu,pt %XCC, 1b
5963 - add %o1, 0x8, %o1
5964 - 73: andcc %o2, 0x8, %g0
5965 - be,pt %XCC, 1f
5966 - nop
5967 - sub %o2, 0x8, %o2
5968 -- EX_LD(LOAD(ldx, %o1, %o5))
5969 -- EX_ST(STORE(stx, %o5, %o1 + %o3))
5970 -+ EX_LD(LOAD(ldx, %o1, %o5), U3_retl_o2_plus_8)
5971 -+ EX_ST(STORE(stx, %o5, %o1 + %o3), U3_retl_o2_plus_8)
5972 - add %o1, 0x8, %o1
5973 - 1: andcc %o2, 0x4, %g0
5974 - be,pt %XCC, 1f
5975 - nop
5976 - sub %o2, 0x4, %o2
5977 -- EX_LD(LOAD(lduw, %o1, %o5))
5978 -- EX_ST(STORE(stw, %o5, %o1 + %o3))
5979 -+ EX_LD(LOAD(lduw, %o1, %o5), U3_retl_o2_plus_4)
5980 -+ EX_ST(STORE(stw, %o5, %o1 + %o3), U3_retl_o2_plus_4)
5981 - add %o1, 0x4, %o1
5982 - 1: cmp %o2, 0
5983 - be,pt %XCC, 85f
5984 -@@ -361,8 +442,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5985 - sub %o2, %g1, %o2
5986 -
5987 - 1: subcc %g1, 1, %g1
5988 -- EX_LD(LOAD(ldub, %o1, %o5))
5989 -- EX_ST(STORE(stb, %o5, %o1 + %o3))
5990 -+ EX_LD(LOAD(ldub, %o1, %o5), U3_retl_o2_plus_g1_plus_1)
5991 -+ EX_ST(STORE(stb, %o5, %o1 + %o3), U3_retl_o2_plus_g1_plus_1)
5992 - bgu,pt %icc, 1b
5993 - add %o1, 1, %o1
5994 -
5995 -@@ -378,16 +459,16 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
5996 -
5997 - 8: mov 64, %o3
5998 - andn %o1, 0x7, %o1
5999 -- EX_LD(LOAD(ldx, %o1, %g2))
6000 -+ EX_LD(LOAD(ldx, %o1, %g2), U3_retl_o2)
6001 - sub %o3, %g1, %o3
6002 - andn %o2, 0x7, GLOBAL_SPARE
6003 - sllx %g2, %g1, %g2
6004 --1: EX_LD(LOAD(ldx, %o1 + 0x8, %g3))
6005 -+1: EX_LD(LOAD(ldx, %o1 + 0x8, %g3), U3_retl_o2_and_7_plus_GS)
6006 - subcc GLOBAL_SPARE, 0x8, GLOBAL_SPARE
6007 - add %o1, 0x8, %o1
6008 - srlx %g3, %o3, %o5
6009 - or %o5, %g2, %o5
6010 -- EX_ST(STORE(stx, %o5, %o0))
6011 -+ EX_ST(STORE(stx, %o5, %o0), U3_retl_o2_and_7_plus_GS_plus_8)
6012 - add %o0, 0x8, %o0
6013 - bgu,pt %icc, 1b
6014 - sllx %g3, %g1, %g2
6015 -@@ -407,8 +488,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
6016 -
6017 - 1:
6018 - subcc %o2, 4, %o2
6019 -- EX_LD(LOAD(lduw, %o1, %g1))
6020 -- EX_ST(STORE(stw, %g1, %o1 + %o3))
6021 -+ EX_LD(LOAD(lduw, %o1, %g1), U3_retl_o2_plus_4)
6022 -+ EX_ST(STORE(stw, %g1, %o1 + %o3), U3_retl_o2_plus_4)
6023 - bgu,pt %XCC, 1b
6024 - add %o1, 4, %o1
6025 -
6026 -@@ -418,8 +499,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
6027 - .align 32
6028 - 90:
6029 - subcc %o2, 1, %o2
6030 -- EX_LD(LOAD(ldub, %o1, %g1))
6031 -- EX_ST(STORE(stb, %g1, %o1 + %o3))
6032 -+ EX_LD(LOAD(ldub, %o1, %g1), U3_retl_o2_plus_1)
6033 -+ EX_ST(STORE(stb, %g1, %o1 + %o3), U3_retl_o2_plus_1)
6034 - bgu,pt %XCC, 90b
6035 - add %o1, 1, %o1
6036 - retl
6037 -diff --git a/arch/sparc/lib/copy_in_user.S b/arch/sparc/lib/copy_in_user.S
6038 -index 302c0e6..4c89b48 100644
6039 ---- a/arch/sparc/lib/copy_in_user.S
6040 -+++ b/arch/sparc/lib/copy_in_user.S
6041 -@@ -8,18 +8,33 @@
6042 -
6043 - #define XCC xcc
6044 -
6045 --#define EX(x,y) \
6046 -+#define EX(x,y,z) \
6047 - 98: x,y; \
6048 - .section __ex_table,"a";\
6049 - .align 4; \
6050 -- .word 98b, __retl_one; \
6051 -+ .word 98b, z; \
6052 - .text; \
6053 - .align 4;
6054 -
6055 -+#define EX_O4(x,y) EX(x,y,__retl_o4_plus_8)
6056 -+#define EX_O2_4(x,y) EX(x,y,__retl_o2_plus_4)
6057 -+#define EX_O2_1(x,y) EX(x,y,__retl_o2_plus_1)
6058 -+
6059 - .register %g2,#scratch
6060 - .register %g3,#scratch
6061 -
6062 - .text
6063 -+__retl_o4_plus_8:
6064 -+ add %o4, %o2, %o4
6065 -+ retl
6066 -+ add %o4, 8, %o0
6067 -+__retl_o2_plus_4:
6068 -+ retl
6069 -+ add %o2, 4, %o0
6070 -+__retl_o2_plus_1:
6071 -+ retl
6072 -+ add %o2, 1, %o0
6073 -+
6074 - .align 32
6075 -
6076 - /* Don't try to get too fancy here, just nice and
6077 -@@ -44,8 +59,8 @@ ENTRY(___copy_in_user) /* %o0=dst, %o1=src, %o2=len */
6078 - andn %o2, 0x7, %o4
6079 - and %o2, 0x7, %o2
6080 - 1: subcc %o4, 0x8, %o4
6081 -- EX(ldxa [%o1] %asi, %o5)
6082 -- EX(stxa %o5, [%o0] %asi)
6083 -+ EX_O4(ldxa [%o1] %asi, %o5)
6084 -+ EX_O4(stxa %o5, [%o0] %asi)
6085 - add %o1, 0x8, %o1
6086 - bgu,pt %XCC, 1b
6087 - add %o0, 0x8, %o0
6088 -@@ -53,8 +68,8 @@ ENTRY(___copy_in_user) /* %o0=dst, %o1=src, %o2=len */
6089 - be,pt %XCC, 1f
6090 - nop
6091 - sub %o2, 0x4, %o2
6092 -- EX(lduwa [%o1] %asi, %o5)
6093 -- EX(stwa %o5, [%o0] %asi)
6094 -+ EX_O2_4(lduwa [%o1] %asi, %o5)
6095 -+ EX_O2_4(stwa %o5, [%o0] %asi)
6096 - add %o1, 0x4, %o1
6097 - add %o0, 0x4, %o0
6098 - 1: cmp %o2, 0
6099 -@@ -70,8 +85,8 @@ ENTRY(___copy_in_user) /* %o0=dst, %o1=src, %o2=len */
6100 -
6101 - 82:
6102 - subcc %o2, 4, %o2
6103 -- EX(lduwa [%o1] %asi, %g1)
6104 -- EX(stwa %g1, [%o0] %asi)
6105 -+ EX_O2_4(lduwa [%o1] %asi, %g1)
6106 -+ EX_O2_4(stwa %g1, [%o0] %asi)
6107 - add %o1, 4, %o1
6108 - bgu,pt %XCC, 82b
6109 - add %o0, 4, %o0
6110 -@@ -82,8 +97,8 @@ ENTRY(___copy_in_user) /* %o0=dst, %o1=src, %o2=len */
6111 - .align 32
6112 - 90:
6113 - subcc %o2, 1, %o2
6114 -- EX(lduba [%o1] %asi, %g1)
6115 -- EX(stba %g1, [%o0] %asi)
6116 -+ EX_O2_1(lduba [%o1] %asi, %g1)
6117 -+ EX_O2_1(stba %g1, [%o0] %asi)
6118 - add %o1, 1, %o1
6119 - bgu,pt %XCC, 90b
6120 - add %o0, 1, %o0
6121 -diff --git a/arch/sparc/lib/user_fixup.c b/arch/sparc/lib/user_fixup.c
6122 -deleted file mode 100644
6123 -index ac96ae2..0000000
6124 ---- a/arch/sparc/lib/user_fixup.c
6125 -+++ /dev/null
6126 -@@ -1,71 +0,0 @@
6127 --/* user_fixup.c: Fix up user copy faults.
6128 -- *
6129 -- * Copyright (C) 2004 David S. Miller <davem@××××××.com>
6130 -- */
6131 --
6132 --#include <linux/compiler.h>
6133 --#include <linux/kernel.h>
6134 --#include <linux/string.h>
6135 --#include <linux/errno.h>
6136 --#include <linux/module.h>
6137 --
6138 --#include <asm/uaccess.h>
6139 --
6140 --/* Calculating the exact fault address when using
6141 -- * block loads and stores can be very complicated.
6142 -- *
6143 -- * Instead of trying to be clever and handling all
6144 -- * of the cases, just fix things up simply here.
6145 -- */
6146 --
6147 --static unsigned long compute_size(unsigned long start, unsigned long size, unsigned long *offset)
6148 --{
6149 -- unsigned long fault_addr = current_thread_info()->fault_address;
6150 -- unsigned long end = start + size;
6151 --
6152 -- if (fault_addr < start || fault_addr >= end) {
6153 -- *offset = 0;
6154 -- } else {
6155 -- *offset = fault_addr - start;
6156 -- size = end - fault_addr;
6157 -- }
6158 -- return size;
6159 --}
6160 --
6161 --unsigned long copy_from_user_fixup(void *to, const void __user *from, unsigned long size)
6162 --{
6163 -- unsigned long offset;
6164 --
6165 -- size = compute_size((unsigned long) from, size, &offset);
6166 -- if (likely(size))
6167 -- memset(to + offset, 0, size);
6168 --
6169 -- return size;
6170 --}
6171 --EXPORT_SYMBOL(copy_from_user_fixup);
6172 --
6173 --unsigned long copy_to_user_fixup(void __user *to, const void *from, unsigned long size)
6174 --{
6175 -- unsigned long offset;
6176 --
6177 -- return compute_size((unsigned long) to, size, &offset);
6178 --}
6179 --EXPORT_SYMBOL(copy_to_user_fixup);
6180 --
6181 --unsigned long copy_in_user_fixup(void __user *to, void __user *from, unsigned long size)
6182 --{
6183 -- unsigned long fault_addr = current_thread_info()->fault_address;
6184 -- unsigned long start = (unsigned long) to;
6185 -- unsigned long end = start + size;
6186 --
6187 -- if (fault_addr >= start && fault_addr < end)
6188 -- return end - fault_addr;
6189 --
6190 -- start = (unsigned long) from;
6191 -- end = start + size;
6192 -- if (fault_addr >= start && fault_addr < end)
6193 -- return end - fault_addr;
6194 --
6195 -- return size;
6196 --}
6197 --EXPORT_SYMBOL(copy_in_user_fixup);
6198 -diff --git a/arch/sparc/mm/tsb.c b/arch/sparc/mm/tsb.c
6199 -index f2b7711..e20fbba 100644
6200 ---- a/arch/sparc/mm/tsb.c
6201 -+++ b/arch/sparc/mm/tsb.c
6202 -@@ -27,6 +27,20 @@ static inline int tag_compare(unsigned long tag, unsigned long vaddr)
6203 - return (tag == (vaddr >> 22));
6204 - }
6205 -
6206 -+static void flush_tsb_kernel_range_scan(unsigned long start, unsigned long end)
6207 -+{
6208 -+ unsigned long idx;
6209 -+
6210 -+ for (idx = 0; idx < KERNEL_TSB_NENTRIES; idx++) {
6211 -+ struct tsb *ent = &swapper_tsb[idx];
6212 -+ unsigned long match = idx << 13;
6213 -+
6214 -+ match |= (ent->tag << 22);
6215 -+ if (match >= start && match < end)
6216 -+ ent->tag = (1UL << TSB_TAG_INVALID_BIT);
6217 -+ }
6218 -+}
6219 -+
6220 - /* TSB flushes need only occur on the processor initiating the address
6221 - * space modification, not on each cpu the address space has run on.
6222 - * Only the TLB flush needs that treatment.
6223 -@@ -36,6 +50,9 @@ void flush_tsb_kernel_range(unsigned long start, unsigned long end)
6224 - {
6225 - unsigned long v;
6226 -
6227 -+ if ((end - start) >> PAGE_SHIFT >= 2 * KERNEL_TSB_NENTRIES)
6228 -+ return flush_tsb_kernel_range_scan(start, end);
6229 -+
6230 - for (v = start; v < end; v += PAGE_SIZE) {
6231 - unsigned long hash = tsb_hash(v, PAGE_SHIFT,
6232 - KERNEL_TSB_NENTRIES);
6233 -diff --git a/arch/sparc/mm/ultra.S b/arch/sparc/mm/ultra.S
6234 -index b4f4733..5d2fd6c 100644
6235 ---- a/arch/sparc/mm/ultra.S
6236 -+++ b/arch/sparc/mm/ultra.S
6237 -@@ -30,7 +30,7 @@
6238 - .text
6239 - .align 32
6240 - .globl __flush_tlb_mm
6241 --__flush_tlb_mm: /* 18 insns */
6242 -+__flush_tlb_mm: /* 19 insns */
6243 - /* %o0=(ctx & TAG_CONTEXT_BITS), %o1=SECONDARY_CONTEXT */
6244 - ldxa [%o1] ASI_DMMU, %g2
6245 - cmp %g2, %o0
6246 -@@ -81,7 +81,7 @@ __flush_tlb_page: /* 22 insns */
6247 -
6248 - .align 32
6249 - .globl __flush_tlb_pending
6250 --__flush_tlb_pending: /* 26 insns */
6251 -+__flush_tlb_pending: /* 27 insns */
6252 - /* %o0 = context, %o1 = nr, %o2 = vaddrs[] */
6253 - rdpr %pstate, %g7
6254 - sllx %o1, 3, %o1
6255 -@@ -113,12 +113,14 @@ __flush_tlb_pending: /* 26 insns */
6256 -
6257 - .align 32
6258 - .globl __flush_tlb_kernel_range
6259 --__flush_tlb_kernel_range: /* 16 insns */
6260 -+__flush_tlb_kernel_range: /* 31 insns */
6261 - /* %o0=start, %o1=end */
6262 - cmp %o0, %o1
6263 - be,pn %xcc, 2f
6264 -+ sub %o1, %o0, %o3
6265 -+ srlx %o3, 18, %o4
6266 -+ brnz,pn %o4, __spitfire_flush_tlb_kernel_range_slow
6267 - sethi %hi(PAGE_SIZE), %o4
6268 -- sub %o1, %o0, %o3
6269 - sub %o3, %o4, %o3
6270 - or %o0, 0x20, %o0 ! Nucleus
6271 - 1: stxa %g0, [%o0 + %o3] ASI_DMMU_DEMAP
6272 -@@ -131,6 +133,41 @@ __flush_tlb_kernel_range: /* 16 insns */
6273 - retl
6274 - nop
6275 - nop
6276 -+ nop
6277 -+ nop
6278 -+ nop
6279 -+ nop
6280 -+ nop
6281 -+ nop
6282 -+ nop
6283 -+ nop
6284 -+ nop
6285 -+ nop
6286 -+ nop
6287 -+ nop
6288 -+ nop
6289 -+
6290 -+__spitfire_flush_tlb_kernel_range_slow:
6291 -+ mov 63 * 8, %o4
6292 -+1: ldxa [%o4] ASI_ITLB_DATA_ACCESS, %o3
6293 -+ andcc %o3, 0x40, %g0 /* _PAGE_L_4U */
6294 -+ bne,pn %xcc, 2f
6295 -+ mov TLB_TAG_ACCESS, %o3
6296 -+ stxa %g0, [%o3] ASI_IMMU
6297 -+ stxa %g0, [%o4] ASI_ITLB_DATA_ACCESS
6298 -+ membar #Sync
6299 -+2: ldxa [%o4] ASI_DTLB_DATA_ACCESS, %o3
6300 -+ andcc %o3, 0x40, %g0
6301 -+ bne,pn %xcc, 2f
6302 -+ mov TLB_TAG_ACCESS, %o3
6303 -+ stxa %g0, [%o3] ASI_DMMU
6304 -+ stxa %g0, [%o4] ASI_DTLB_DATA_ACCESS
6305 -+ membar #Sync
6306 -+2: sub %o4, 8, %o4
6307 -+ brgez,pt %o4, 1b
6308 -+ nop
6309 -+ retl
6310 -+ nop
6311 -
6312 - __spitfire_flush_tlb_mm_slow:
6313 - rdpr %pstate, %g1
6314 -@@ -285,6 +322,40 @@ __cheetah_flush_tlb_pending: /* 27 insns */
6315 - retl
6316 - wrpr %g7, 0x0, %pstate
6317 -
6318 -+__cheetah_flush_tlb_kernel_range: /* 31 insns */
6319 -+ /* %o0=start, %o1=end */
6320 -+ cmp %o0, %o1
6321 -+ be,pn %xcc, 2f
6322 -+ sub %o1, %o0, %o3
6323 -+ srlx %o3, 18, %o4
6324 -+ brnz,pn %o4, 3f
6325 -+ sethi %hi(PAGE_SIZE), %o4
6326 -+ sub %o3, %o4, %o3
6327 -+ or %o0, 0x20, %o0 ! Nucleus
6328 -+1: stxa %g0, [%o0 + %o3] ASI_DMMU_DEMAP
6329 -+ stxa %g0, [%o0 + %o3] ASI_IMMU_DEMAP
6330 -+ membar #Sync
6331 -+ brnz,pt %o3, 1b
6332 -+ sub %o3, %o4, %o3
6333 -+2: sethi %hi(KERNBASE), %o3
6334 -+ flush %o3
6335 -+ retl
6336 -+ nop
6337 -+3: mov 0x80, %o4
6338 -+ stxa %g0, [%o4] ASI_DMMU_DEMAP
6339 -+ membar #Sync
6340 -+ stxa %g0, [%o4] ASI_IMMU_DEMAP
6341 -+ membar #Sync
6342 -+ retl
6343 -+ nop
6344 -+ nop
6345 -+ nop
6346 -+ nop
6347 -+ nop
6348 -+ nop
6349 -+ nop
6350 -+ nop
6351 -+
6352 - #ifdef DCACHE_ALIASING_POSSIBLE
6353 - __cheetah_flush_dcache_page: /* 11 insns */
6354 - sethi %hi(PAGE_OFFSET), %g1
6355 -@@ -309,19 +380,28 @@ __hypervisor_tlb_tl0_error:
6356 - ret
6357 - restore
6358 -
6359 --__hypervisor_flush_tlb_mm: /* 10 insns */
6360 -+__hypervisor_flush_tlb_mm: /* 19 insns */
6361 - mov %o0, %o2 /* ARG2: mmu context */
6362 - mov 0, %o0 /* ARG0: CPU lists unimplemented */
6363 - mov 0, %o1 /* ARG1: CPU lists unimplemented */
6364 - mov HV_MMU_ALL, %o3 /* ARG3: flags */
6365 - mov HV_FAST_MMU_DEMAP_CTX, %o5
6366 - ta HV_FAST_TRAP
6367 -- brnz,pn %o0, __hypervisor_tlb_tl0_error
6368 -+ brnz,pn %o0, 1f
6369 - mov HV_FAST_MMU_DEMAP_CTX, %o1
6370 - retl
6371 - nop
6372 -+1: sethi %hi(__hypervisor_tlb_tl0_error), %o5
6373 -+ jmpl %o5 + %lo(__hypervisor_tlb_tl0_error), %g0
6374 -+ nop
6375 -+ nop
6376 -+ nop
6377 -+ nop
6378 -+ nop
6379 -+ nop
6380 -+ nop
6381 -
6382 --__hypervisor_flush_tlb_page: /* 11 insns */
6383 -+__hypervisor_flush_tlb_page: /* 22 insns */
6384 - /* %o0 = context, %o1 = vaddr */
6385 - mov %o0, %g2
6386 - mov %o1, %o0 /* ARG0: vaddr + IMMU-bit */
6387 -@@ -330,12 +410,23 @@ __hypervisor_flush_tlb_page: /* 11 insns */
6388 - srlx %o0, PAGE_SHIFT, %o0
6389 - sllx %o0, PAGE_SHIFT, %o0
6390 - ta HV_MMU_UNMAP_ADDR_TRAP
6391 -- brnz,pn %o0, __hypervisor_tlb_tl0_error
6392 -+ brnz,pn %o0, 1f
6393 - mov HV_MMU_UNMAP_ADDR_TRAP, %o1
6394 - retl
6395 - nop
6396 -+1: sethi %hi(__hypervisor_tlb_tl0_error), %o2
6397 -+ jmpl %o2 + %lo(__hypervisor_tlb_tl0_error), %g0
6398 -+ nop
6399 -+ nop
6400 -+ nop
6401 -+ nop
6402 -+ nop
6403 -+ nop
6404 -+ nop
6405 -+ nop
6406 -+ nop
6407 -
6408 --__hypervisor_flush_tlb_pending: /* 16 insns */
6409 -+__hypervisor_flush_tlb_pending: /* 27 insns */
6410 - /* %o0 = context, %o1 = nr, %o2 = vaddrs[] */
6411 - sllx %o1, 3, %g1
6412 - mov %o2, %g2
6413 -@@ -347,31 +438,57 @@ __hypervisor_flush_tlb_pending: /* 16 insns */
6414 - srlx %o0, PAGE_SHIFT, %o0
6415 - sllx %o0, PAGE_SHIFT, %o0
6416 - ta HV_MMU_UNMAP_ADDR_TRAP
6417 -- brnz,pn %o0, __hypervisor_tlb_tl0_error
6418 -+ brnz,pn %o0, 1f
6419 - mov HV_MMU_UNMAP_ADDR_TRAP, %o1
6420 - brnz,pt %g1, 1b
6421 - nop
6422 - retl
6423 - nop
6424 -+1: sethi %hi(__hypervisor_tlb_tl0_error), %o2
6425 -+ jmpl %o2 + %lo(__hypervisor_tlb_tl0_error), %g0
6426 -+ nop
6427 -+ nop
6428 -+ nop
6429 -+ nop
6430 -+ nop
6431 -+ nop
6432 -+ nop
6433 -+ nop
6434 -+ nop
6435 -
6436 --__hypervisor_flush_tlb_kernel_range: /* 16 insns */
6437 -+__hypervisor_flush_tlb_kernel_range: /* 31 insns */
6438 - /* %o0=start, %o1=end */
6439 - cmp %o0, %o1
6440 - be,pn %xcc, 2f
6441 -- sethi %hi(PAGE_SIZE), %g3
6442 -- mov %o0, %g1
6443 -- sub %o1, %g1, %g2
6444 -+ sub %o1, %o0, %g2
6445 -+ srlx %g2, 18, %g3
6446 -+ brnz,pn %g3, 4f
6447 -+ mov %o0, %g1
6448 -+ sethi %hi(PAGE_SIZE), %g3
6449 - sub %g2, %g3, %g2
6450 - 1: add %g1, %g2, %o0 /* ARG0: virtual address */
6451 - mov 0, %o1 /* ARG1: mmu context */
6452 - mov HV_MMU_ALL, %o2 /* ARG2: flags */
6453 - ta HV_MMU_UNMAP_ADDR_TRAP
6454 -- brnz,pn %o0, __hypervisor_tlb_tl0_error
6455 -+ brnz,pn %o0, 3f
6456 - mov HV_MMU_UNMAP_ADDR_TRAP, %o1
6457 - brnz,pt %g2, 1b
6458 - sub %g2, %g3, %g2
6459 - 2: retl
6460 - nop
6461 -+3: sethi %hi(__hypervisor_tlb_tl0_error), %o2
6462 -+ jmpl %o2 + %lo(__hypervisor_tlb_tl0_error), %g0
6463 -+ nop
6464 -+4: mov 0, %o0 /* ARG0: CPU lists unimplemented */
6465 -+ mov 0, %o1 /* ARG1: CPU lists unimplemented */
6466 -+ mov 0, %o2 /* ARG2: mmu context == nucleus */
6467 -+ mov HV_MMU_ALL, %o3 /* ARG3: flags */
6468 -+ mov HV_FAST_MMU_DEMAP_CTX, %o5
6469 -+ ta HV_FAST_TRAP
6470 -+ brnz,pn %o0, 3b
6471 -+ mov HV_FAST_MMU_DEMAP_CTX, %o1
6472 -+ retl
6473 -+ nop
6474 -
6475 - #ifdef DCACHE_ALIASING_POSSIBLE
6476 - /* XXX Niagara and friends have an 8K cache, so no aliasing is
6477 -@@ -394,43 +511,6 @@ tlb_patch_one:
6478 - retl
6479 - nop
6480 -
6481 -- .globl cheetah_patch_cachetlbops
6482 --cheetah_patch_cachetlbops:
6483 -- save %sp, -128, %sp
6484 --
6485 -- sethi %hi(__flush_tlb_mm), %o0
6486 -- or %o0, %lo(__flush_tlb_mm), %o0
6487 -- sethi %hi(__cheetah_flush_tlb_mm), %o1
6488 -- or %o1, %lo(__cheetah_flush_tlb_mm), %o1
6489 -- call tlb_patch_one
6490 -- mov 19, %o2
6491 --
6492 -- sethi %hi(__flush_tlb_page), %o0
6493 -- or %o0, %lo(__flush_tlb_page), %o0
6494 -- sethi %hi(__cheetah_flush_tlb_page), %o1
6495 -- or %o1, %lo(__cheetah_flush_tlb_page), %o1
6496 -- call tlb_patch_one
6497 -- mov 22, %o2
6498 --
6499 -- sethi %hi(__flush_tlb_pending), %o0
6500 -- or %o0, %lo(__flush_tlb_pending), %o0
6501 -- sethi %hi(__cheetah_flush_tlb_pending), %o1
6502 -- or %o1, %lo(__cheetah_flush_tlb_pending), %o1
6503 -- call tlb_patch_one
6504 -- mov 27, %o2
6505 --
6506 --#ifdef DCACHE_ALIASING_POSSIBLE
6507 -- sethi %hi(__flush_dcache_page), %o0
6508 -- or %o0, %lo(__flush_dcache_page), %o0
6509 -- sethi %hi(__cheetah_flush_dcache_page), %o1
6510 -- or %o1, %lo(__cheetah_flush_dcache_page), %o1
6511 -- call tlb_patch_one
6512 -- mov 11, %o2
6513 --#endif /* DCACHE_ALIASING_POSSIBLE */
6514 --
6515 -- ret
6516 -- restore
6517 --
6518 - #ifdef CONFIG_SMP
6519 - /* These are all called by the slaves of a cross call, at
6520 - * trap level 1, with interrupts fully disabled.
6521 -@@ -447,7 +527,7 @@ cheetah_patch_cachetlbops:
6522 - */
6523 - .align 32
6524 - .globl xcall_flush_tlb_mm
6525 --xcall_flush_tlb_mm: /* 21 insns */
6526 -+xcall_flush_tlb_mm: /* 24 insns */
6527 - mov PRIMARY_CONTEXT, %g2
6528 - ldxa [%g2] ASI_DMMU, %g3
6529 - srlx %g3, CTX_PGSZ1_NUC_SHIFT, %g4
6530 -@@ -469,9 +549,12 @@ xcall_flush_tlb_mm: /* 21 insns */
6531 - nop
6532 - nop
6533 - nop
6534 -+ nop
6535 -+ nop
6536 -+ nop
6537 -
6538 - .globl xcall_flush_tlb_page
6539 --xcall_flush_tlb_page: /* 17 insns */
6540 -+xcall_flush_tlb_page: /* 20 insns */
6541 - /* %g5=context, %g1=vaddr */
6542 - mov PRIMARY_CONTEXT, %g4
6543 - ldxa [%g4] ASI_DMMU, %g2
6544 -@@ -490,15 +573,20 @@ xcall_flush_tlb_page: /* 17 insns */
6545 - retry
6546 - nop
6547 - nop
6548 -+ nop
6549 -+ nop
6550 -+ nop
6551 -
6552 - .globl xcall_flush_tlb_kernel_range
6553 --xcall_flush_tlb_kernel_range: /* 25 insns */
6554 -+xcall_flush_tlb_kernel_range: /* 44 insns */
6555 - sethi %hi(PAGE_SIZE - 1), %g2
6556 - or %g2, %lo(PAGE_SIZE - 1), %g2
6557 - andn %g1, %g2, %g1
6558 - andn %g7, %g2, %g7
6559 - sub %g7, %g1, %g3
6560 -- add %g2, 1, %g2
6561 -+ srlx %g3, 18, %g2
6562 -+ brnz,pn %g2, 2f
6563 -+ add %g2, 1, %g2
6564 - sub %g3, %g2, %g3
6565 - or %g1, 0x20, %g1 ! Nucleus
6566 - 1: stxa %g0, [%g1 + %g3] ASI_DMMU_DEMAP
6567 -@@ -507,8 +595,25 @@ xcall_flush_tlb_kernel_range: /* 25 insns */
6568 - brnz,pt %g3, 1b
6569 - sub %g3, %g2, %g3
6570 - retry
6571 -- nop
6572 -- nop
6573 -+2: mov 63 * 8, %g1
6574 -+1: ldxa [%g1] ASI_ITLB_DATA_ACCESS, %g2
6575 -+ andcc %g2, 0x40, %g0 /* _PAGE_L_4U */
6576 -+ bne,pn %xcc, 2f
6577 -+ mov TLB_TAG_ACCESS, %g2
6578 -+ stxa %g0, [%g2] ASI_IMMU
6579 -+ stxa %g0, [%g1] ASI_ITLB_DATA_ACCESS
6580 -+ membar #Sync
6581 -+2: ldxa [%g1] ASI_DTLB_DATA_ACCESS, %g2
6582 -+ andcc %g2, 0x40, %g0
6583 -+ bne,pn %xcc, 2f
6584 -+ mov TLB_TAG_ACCESS, %g2
6585 -+ stxa %g0, [%g2] ASI_DMMU
6586 -+ stxa %g0, [%g1] ASI_DTLB_DATA_ACCESS
6587 -+ membar #Sync
6588 -+2: sub %g1, 8, %g1
6589 -+ brgez,pt %g1, 1b
6590 -+ nop
6591 -+ retry
6592 - nop
6593 - nop
6594 - nop
6595 -@@ -637,6 +742,52 @@ xcall_fetch_glob_pmu_n4:
6596 -
6597 - retry
6598 -
6599 -+__cheetah_xcall_flush_tlb_kernel_range: /* 44 insns */
6600 -+ sethi %hi(PAGE_SIZE - 1), %g2
6601 -+ or %g2, %lo(PAGE_SIZE - 1), %g2
6602 -+ andn %g1, %g2, %g1
6603 -+ andn %g7, %g2, %g7
6604 -+ sub %g7, %g1, %g3
6605 -+ srlx %g3, 18, %g2
6606 -+ brnz,pn %g2, 2f
6607 -+ add %g2, 1, %g2
6608 -+ sub %g3, %g2, %g3
6609 -+ or %g1, 0x20, %g1 ! Nucleus
6610 -+1: stxa %g0, [%g1 + %g3] ASI_DMMU_DEMAP
6611 -+ stxa %g0, [%g1 + %g3] ASI_IMMU_DEMAP
6612 -+ membar #Sync
6613 -+ brnz,pt %g3, 1b
6614 -+ sub %g3, %g2, %g3
6615 -+ retry
6616 -+2: mov 0x80, %g2
6617 -+ stxa %g0, [%g2] ASI_DMMU_DEMAP
6618 -+ membar #Sync
6619 -+ stxa %g0, [%g2] ASI_IMMU_DEMAP
6620 -+ membar #Sync
6621 -+ retry
6622 -+ nop
6623 -+ nop
6624 -+ nop
6625 -+ nop
6626 -+ nop
6627 -+ nop
6628 -+ nop
6629 -+ nop
6630 -+ nop
6631 -+ nop
6632 -+ nop
6633 -+ nop
6634 -+ nop
6635 -+ nop
6636 -+ nop
6637 -+ nop
6638 -+ nop
6639 -+ nop
6640 -+ nop
6641 -+ nop
6642 -+ nop
6643 -+ nop
6644 -+
6645 - #ifdef DCACHE_ALIASING_POSSIBLE
6646 - .align 32
6647 - .globl xcall_flush_dcache_page_cheetah
6648 -@@ -700,7 +851,7 @@ __hypervisor_tlb_xcall_error:
6649 - ba,a,pt %xcc, rtrap
6650 -
6651 - .globl __hypervisor_xcall_flush_tlb_mm
6652 --__hypervisor_xcall_flush_tlb_mm: /* 21 insns */
6653 -+__hypervisor_xcall_flush_tlb_mm: /* 24 insns */
6654 - /* %g5=ctx, g1,g2,g3,g4,g7=scratch, %g6=unusable */
6655 - mov %o0, %g2
6656 - mov %o1, %g3
6657 -@@ -714,7 +865,7 @@ __hypervisor_xcall_flush_tlb_mm: /* 21 insns */
6658 - mov HV_FAST_MMU_DEMAP_CTX, %o5
6659 - ta HV_FAST_TRAP
6660 - mov HV_FAST_MMU_DEMAP_CTX, %g6
6661 -- brnz,pn %o0, __hypervisor_tlb_xcall_error
6662 -+ brnz,pn %o0, 1f
6663 - mov %o0, %g5
6664 - mov %g2, %o0
6665 - mov %g3, %o1
6666 -@@ -723,9 +874,12 @@ __hypervisor_xcall_flush_tlb_mm: /* 21 insns */
6667 - mov %g7, %o5
6668 - membar #Sync
6669 - retry
6670 -+1: sethi %hi(__hypervisor_tlb_xcall_error), %g4
6671 -+ jmpl %g4 + %lo(__hypervisor_tlb_xcall_error), %g0
6672 -+ nop
6673 -
6674 - .globl __hypervisor_xcall_flush_tlb_page
6675 --__hypervisor_xcall_flush_tlb_page: /* 17 insns */
6676 -+__hypervisor_xcall_flush_tlb_page: /* 20 insns */
6677 - /* %g5=ctx, %g1=vaddr */
6678 - mov %o0, %g2
6679 - mov %o1, %g3
6680 -@@ -737,42 +891,64 @@ __hypervisor_xcall_flush_tlb_page: /* 17 insns */
6681 - sllx %o0, PAGE_SHIFT, %o0
6682 - ta HV_MMU_UNMAP_ADDR_TRAP
6683 - mov HV_MMU_UNMAP_ADDR_TRAP, %g6
6684 -- brnz,a,pn %o0, __hypervisor_tlb_xcall_error
6685 -+ brnz,a,pn %o0, 1f
6686 - mov %o0, %g5
6687 - mov %g2, %o0
6688 - mov %g3, %o1
6689 - mov %g4, %o2
6690 - membar #Sync
6691 - retry
6692 -+1: sethi %hi(__hypervisor_tlb_xcall_error), %g4
6693 -+ jmpl %g4 + %lo(__hypervisor_tlb_xcall_error), %g0
6694 -+ nop
6695 -
6696 - .globl __hypervisor_xcall_flush_tlb_kernel_range
6697 --__hypervisor_xcall_flush_tlb_kernel_range: /* 25 insns */
6698 -+__hypervisor_xcall_flush_tlb_kernel_range: /* 44 insns */
6699 - /* %g1=start, %g7=end, g2,g3,g4,g5,g6=scratch */
6700 - sethi %hi(PAGE_SIZE - 1), %g2
6701 - or %g2, %lo(PAGE_SIZE - 1), %g2
6702 - andn %g1, %g2, %g1
6703 - andn %g7, %g2, %g7
6704 - sub %g7, %g1, %g3
6705 -+ srlx %g3, 18, %g7
6706 - add %g2, 1, %g2
6707 - sub %g3, %g2, %g3
6708 - mov %o0, %g2
6709 - mov %o1, %g4
6710 -- mov %o2, %g7
6711 -+ brnz,pn %g7, 2f
6712 -+ mov %o2, %g7
6713 - 1: add %g1, %g3, %o0 /* ARG0: virtual address */
6714 - mov 0, %o1 /* ARG1: mmu context */
6715 - mov HV_MMU_ALL, %o2 /* ARG2: flags */
6716 - ta HV_MMU_UNMAP_ADDR_TRAP
6717 - mov HV_MMU_UNMAP_ADDR_TRAP, %g6
6718 -- brnz,pn %o0, __hypervisor_tlb_xcall_error
6719 -+ brnz,pn %o0, 1f
6720 - mov %o0, %g5
6721 - sethi %hi(PAGE_SIZE), %o2
6722 - brnz,pt %g3, 1b
6723 - sub %g3, %o2, %g3
6724 -- mov %g2, %o0
6725 -+5: mov %g2, %o0
6726 - mov %g4, %o1
6727 - mov %g7, %o2
6728 - membar #Sync
6729 - retry
6730 -+1: sethi %hi(__hypervisor_tlb_xcall_error), %g4
6731 -+ jmpl %g4 + %lo(__hypervisor_tlb_xcall_error), %g0
6732 -+ nop
6733 -+2: mov %o3, %g1
6734 -+ mov %o5, %g3
6735 -+ mov 0, %o0 /* ARG0: CPU lists unimplemented */
6736 -+ mov 0, %o1 /* ARG1: CPU lists unimplemented */
6737 -+ mov 0, %o2 /* ARG2: mmu context == nucleus */
6738 -+ mov HV_MMU_ALL, %o3 /* ARG3: flags */
6739 -+ mov HV_FAST_MMU_DEMAP_CTX, %o5
6740 -+ ta HV_FAST_TRAP
6741 -+ mov %g1, %o3
6742 -+ brz,pt %o0, 5b
6743 -+ mov %g3, %o5
6744 -+ mov HV_FAST_MMU_DEMAP_CTX, %g6
6745 -+ ba,pt %xcc, 1b
6746 -+ clr %g5
6747 -
6748 - /* These just get rescheduled to PIL vectors. */
6749 - .globl xcall_call_function
6750 -@@ -809,6 +985,58 @@ xcall_kgdb_capture:
6751 -
6752 - #endif /* CONFIG_SMP */
6753 -
6754 -+ .globl cheetah_patch_cachetlbops
6755 -+cheetah_patch_cachetlbops:
6756 -+ save %sp, -128, %sp
6757 -+
6758 -+ sethi %hi(__flush_tlb_mm), %o0
6759 -+ or %o0, %lo(__flush_tlb_mm), %o0
6760 -+ sethi %hi(__cheetah_flush_tlb_mm), %o1
6761 -+ or %o1, %lo(__cheetah_flush_tlb_mm), %o1
6762 -+ call tlb_patch_one
6763 -+ mov 19, %o2
6764 -+
6765 -+ sethi %hi(__flush_tlb_page), %o0
6766 -+ or %o0, %lo(__flush_tlb_page), %o0
6767 -+ sethi %hi(__cheetah_flush_tlb_page), %o1
6768 -+ or %o1, %lo(__cheetah_flush_tlb_page), %o1
6769 -+ call tlb_patch_one
6770 -+ mov 22, %o2
6771 -+
6772 -+ sethi %hi(__flush_tlb_pending), %o0
6773 -+ or %o0, %lo(__flush_tlb_pending), %o0
6774 -+ sethi %hi(__cheetah_flush_tlb_pending), %o1
6775 -+ or %o1, %lo(__cheetah_flush_tlb_pending), %o1
6776 -+ call tlb_patch_one
6777 -+ mov 27, %o2
6778 -+
6779 -+ sethi %hi(__flush_tlb_kernel_range), %o0
6780 -+ or %o0, %lo(__flush_tlb_kernel_range), %o0
6781 -+ sethi %hi(__cheetah_flush_tlb_kernel_range), %o1
6782 -+ or %o1, %lo(__cheetah_flush_tlb_kernel_range), %o1
6783 -+ call tlb_patch_one
6784 -+ mov 31, %o2
6785 -+
6786 -+#ifdef DCACHE_ALIASING_POSSIBLE
6787 -+ sethi %hi(__flush_dcache_page), %o0
6788 -+ or %o0, %lo(__flush_dcache_page), %o0
6789 -+ sethi %hi(__cheetah_flush_dcache_page), %o1
6790 -+ or %o1, %lo(__cheetah_flush_dcache_page), %o1
6791 -+ call tlb_patch_one
6792 -+ mov 11, %o2
6793 -+#endif /* DCACHE_ALIASING_POSSIBLE */
6794 -+
6795 -+#ifdef CONFIG_SMP
6796 -+ sethi %hi(xcall_flush_tlb_kernel_range), %o0
6797 -+ or %o0, %lo(xcall_flush_tlb_kernel_range), %o0
6798 -+ sethi %hi(__cheetah_xcall_flush_tlb_kernel_range), %o1
6799 -+ or %o1, %lo(__cheetah_xcall_flush_tlb_kernel_range), %o1
6800 -+ call tlb_patch_one
6801 -+ mov 44, %o2
6802 -+#endif /* CONFIG_SMP */
6803 -+
6804 -+ ret
6805 -+ restore
6806 -
6807 - .globl hypervisor_patch_cachetlbops
6808 - hypervisor_patch_cachetlbops:
6809 -@@ -819,28 +1047,28 @@ hypervisor_patch_cachetlbops:
6810 - sethi %hi(__hypervisor_flush_tlb_mm), %o1
6811 - or %o1, %lo(__hypervisor_flush_tlb_mm), %o1
6812 - call tlb_patch_one
6813 -- mov 10, %o2
6814 -+ mov 19, %o2
6815 -
6816 - sethi %hi(__flush_tlb_page), %o0
6817 - or %o0, %lo(__flush_tlb_page), %o0
6818 - sethi %hi(__hypervisor_flush_tlb_page), %o1
6819 - or %o1, %lo(__hypervisor_flush_tlb_page), %o1
6820 - call tlb_patch_one
6821 -- mov 11, %o2
6822 -+ mov 22, %o2
6823 -
6824 - sethi %hi(__flush_tlb_pending), %o0
6825 - or %o0, %lo(__flush_tlb_pending), %o0
6826 - sethi %hi(__hypervisor_flush_tlb_pending), %o1
6827 - or %o1, %lo(__hypervisor_flush_tlb_pending), %o1
6828 - call tlb_patch_one
6829 -- mov 16, %o2
6830 -+ mov 27, %o2
6831 -
6832 - sethi %hi(__flush_tlb_kernel_range), %o0
6833 - or %o0, %lo(__flush_tlb_kernel_range), %o0
6834 - sethi %hi(__hypervisor_flush_tlb_kernel_range), %o1
6835 - or %o1, %lo(__hypervisor_flush_tlb_kernel_range), %o1
6836 - call tlb_patch_one
6837 -- mov 16, %o2
6838 -+ mov 31, %o2
6839 -
6840 - #ifdef DCACHE_ALIASING_POSSIBLE
6841 - sethi %hi(__flush_dcache_page), %o0
6842 -@@ -857,21 +1085,21 @@ hypervisor_patch_cachetlbops:
6843 - sethi %hi(__hypervisor_xcall_flush_tlb_mm), %o1
6844 - or %o1, %lo(__hypervisor_xcall_flush_tlb_mm), %o1
6845 - call tlb_patch_one
6846 -- mov 21, %o2
6847 -+ mov 24, %o2
6848 -
6849 - sethi %hi(xcall_flush_tlb_page), %o0
6850 - or %o0, %lo(xcall_flush_tlb_page), %o0
6851 - sethi %hi(__hypervisor_xcall_flush_tlb_page), %o1
6852 - or %o1, %lo(__hypervisor_xcall_flush_tlb_page), %o1
6853 - call tlb_patch_one
6854 -- mov 17, %o2
6855 -+ mov 20, %o2
6856 -
6857 - sethi %hi(xcall_flush_tlb_kernel_range), %o0
6858 - or %o0, %lo(xcall_flush_tlb_kernel_range), %o0
6859 - sethi %hi(__hypervisor_xcall_flush_tlb_kernel_range), %o1
6860 - or %o1, %lo(__hypervisor_xcall_flush_tlb_kernel_range), %o1
6861 - call tlb_patch_one
6862 -- mov 25, %o2
6863 -+ mov 44, %o2
6864 - #endif /* CONFIG_SMP */
6865 -
6866 - ret
6867 -diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
6868 -index c4751ec..45e87c9 100644
6869 ---- a/drivers/net/ethernet/broadcom/bgmac.c
6870 -+++ b/drivers/net/ethernet/broadcom/bgmac.c
6871 -@@ -307,6 +307,10 @@ static void bgmac_dma_rx_enable(struct bgmac *bgmac,
6872 - u32 ctl;
6873 -
6874 - ctl = bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_RX_CTL);
6875 -+
6876 -+ /* preserve ONLY bits 16-17 from current hardware value */
6877 -+ ctl &= BGMAC_DMA_RX_ADDREXT_MASK;
6878 -+
6879 - if (bgmac->feature_flags & BGMAC_FEAT_RX_MASK_SETUP) {
6880 - ctl &= ~BGMAC_DMA_RX_BL_MASK;
6881 - ctl |= BGMAC_DMA_RX_BL_128 << BGMAC_DMA_RX_BL_SHIFT;
6882 -@@ -317,7 +321,6 @@ static void bgmac_dma_rx_enable(struct bgmac *bgmac,
6883 - ctl &= ~BGMAC_DMA_RX_PT_MASK;
6884 - ctl |= BGMAC_DMA_RX_PT_1 << BGMAC_DMA_RX_PT_SHIFT;
6885 - }
6886 -- ctl &= BGMAC_DMA_RX_ADDREXT_MASK;
6887 - ctl |= BGMAC_DMA_RX_ENABLE;
6888 - ctl |= BGMAC_DMA_RX_PARITY_DISABLE;
6889 - ctl |= BGMAC_DMA_RX_OVERFLOW_CONT;
6890 -diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
6891 -index 505ceaf..2c850a9 100644
6892 ---- a/drivers/net/ethernet/broadcom/bnx2.c
6893 -+++ b/drivers/net/ethernet/broadcom/bnx2.c
6894 -@@ -49,6 +49,7 @@
6895 - #include <linux/firmware.h>
6896 - #include <linux/log2.h>
6897 - #include <linux/aer.h>
6898 -+#include <linux/crash_dump.h>
6899 -
6900 - #if defined(CONFIG_CNIC) || defined(CONFIG_CNIC_MODULE)
6901 - #define BCM_CNIC 1
6902 -@@ -4759,15 +4760,16 @@ bnx2_setup_msix_tbl(struct bnx2 *bp)
6903 - BNX2_WR(bp, BNX2_PCI_GRC_WINDOW3_ADDR, BNX2_MSIX_PBA_ADDR);
6904 - }
6905 -
6906 --static int
6907 --bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
6908 -+static void
6909 -+bnx2_wait_dma_complete(struct bnx2 *bp)
6910 - {
6911 - u32 val;
6912 -- int i, rc = 0;
6913 -- u8 old_port;
6914 -+ int i;
6915 -
6916 -- /* Wait for the current PCI transaction to complete before
6917 -- * issuing a reset. */
6918 -+ /*
6919 -+ * Wait for the current PCI transaction to complete before
6920 -+ * issuing a reset.
6921 -+ */
6922 - if ((BNX2_CHIP(bp) == BNX2_CHIP_5706) ||
6923 - (BNX2_CHIP(bp) == BNX2_CHIP_5708)) {
6924 - BNX2_WR(bp, BNX2_MISC_ENABLE_CLR_BITS,
6925 -@@ -4791,6 +4793,21 @@ bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
6926 - }
6927 - }
6928 -
6929 -+ return;
6930 -+}
6931 -+
6932 -+
6933 -+static int
6934 -+bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
6935 -+{
6936 -+ u32 val;
6937 -+ int i, rc = 0;
6938 -+ u8 old_port;
6939 -+
6940 -+ /* Wait for the current PCI transaction to complete before
6941 -+ * issuing a reset. */
6942 -+ bnx2_wait_dma_complete(bp);
6943 -+
6944 - /* Wait for the firmware to tell us it is ok to issue a reset. */
6945 - bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT0 | reset_code, 1, 1);
6946 -
6947 -@@ -6356,6 +6373,10 @@ bnx2_open(struct net_device *dev)
6948 - struct bnx2 *bp = netdev_priv(dev);
6949 - int rc;
6950 -
6951 -+ rc = bnx2_request_firmware(bp);
6952 -+ if (rc < 0)
6953 -+ goto out;
6954 -+
6955 - netif_carrier_off(dev);
6956 -
6957 - bnx2_disable_int(bp);
6958 -@@ -6424,6 +6445,7 @@ bnx2_open(struct net_device *dev)
6959 - bnx2_free_irq(bp);
6960 - bnx2_free_mem(bp);
6961 - bnx2_del_napi(bp);
6962 -+ bnx2_release_firmware(bp);
6963 - goto out;
6964 - }
6965 -
6966 -@@ -8570,12 +8592,15 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
6967 -
6968 - pci_set_drvdata(pdev, dev);
6969 -
6970 -- rc = bnx2_request_firmware(bp);
6971 -- if (rc < 0)
6972 -- goto error;
6973 --
6974 -+ /*
6975 -+ * In-flight DMA from 1st kernel could continue going in kdump kernel.
6976 -+ * New io-page table has been created before bnx2 does reset at open stage.
6977 -+ * We have to wait for the in-flight DMA to complete to avoid it look up
6978 -+ * into the newly created io-page table.
6979 -+ */
6980 -+ if (is_kdump_kernel())
6981 -+ bnx2_wait_dma_complete(bp);
6982 -
6983 -- bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET);
6984 - memcpy(dev->dev_addr, bp->mac_addr, ETH_ALEN);
6985 -
6986 - dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG |
6987 -@@ -8608,7 +8633,6 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
6988 - return 0;
6989 -
6990 - error:
6991 -- bnx2_release_firmware(bp);
6992 - pci_iounmap(pdev, bp->regview);
6993 - pci_release_regions(pdev);
6994 - pci_disable_device(pdev);
6995 -diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
6996 -index d48873b..5cdc96b 100644
6997 ---- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
6998 -+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
6999 -@@ -231,7 +231,7 @@ mlxsw_sp_span_entry_create(struct mlxsw_sp_port *port)
7000 -
7001 - span_entry->used = true;
7002 - span_entry->id = index;
7003 -- span_entry->ref_count = 0;
7004 -+ span_entry->ref_count = 1;
7005 - span_entry->local_port = local_port;
7006 - return span_entry;
7007 - }
7008 -@@ -268,6 +268,7 @@ struct mlxsw_sp_span_entry *mlxsw_sp_span_entry_get(struct mlxsw_sp_port *port)
7009 -
7010 - span_entry = mlxsw_sp_span_entry_find(port);
7011 - if (span_entry) {
7012 -+ /* Already exists, just take a reference */
7013 - span_entry->ref_count++;
7014 - return span_entry;
7015 - }
7016 -@@ -278,6 +279,7 @@ struct mlxsw_sp_span_entry *mlxsw_sp_span_entry_get(struct mlxsw_sp_port *port)
7017 - static int mlxsw_sp_span_entry_put(struct mlxsw_sp *mlxsw_sp,
7018 - struct mlxsw_sp_span_entry *span_entry)
7019 - {
7020 -+ WARN_ON(!span_entry->ref_count);
7021 - if (--span_entry->ref_count == 0)
7022 - mlxsw_sp_span_entry_destroy(mlxsw_sp, span_entry);
7023 - return 0;
7024 -diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
7025 -index 3f5c51d..62514b9 100644
7026 ---- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
7027 -+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
7028 -@@ -777,6 +777,26 @@ static void mlxsw_sp_router_neigh_rec_process(struct mlxsw_sp *mlxsw_sp,
7029 - }
7030 - }
7031 -
7032 -+static bool mlxsw_sp_router_rauhtd_is_full(char *rauhtd_pl)
7033 -+{
7034 -+ u8 num_rec, last_rec_index, num_entries;
7035 -+
7036 -+ num_rec = mlxsw_reg_rauhtd_num_rec_get(rauhtd_pl);
7037 -+ last_rec_index = num_rec - 1;
7038 -+
7039 -+ if (num_rec < MLXSW_REG_RAUHTD_REC_MAX_NUM)
7040 -+ return false;
7041 -+ if (mlxsw_reg_rauhtd_rec_type_get(rauhtd_pl, last_rec_index) ==
7042 -+ MLXSW_REG_RAUHTD_TYPE_IPV6)
7043 -+ return true;
7044 -+
7045 -+ num_entries = mlxsw_reg_rauhtd_ipv4_rec_num_entries_get(rauhtd_pl,
7046 -+ last_rec_index);
7047 -+ if (++num_entries == MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC)
7048 -+ return true;
7049 -+ return false;
7050 -+}
7051 -+
7052 - static int mlxsw_sp_router_neighs_update_rauhtd(struct mlxsw_sp *mlxsw_sp)
7053 - {
7054 - char *rauhtd_pl;
7055 -@@ -803,7 +823,7 @@ static int mlxsw_sp_router_neighs_update_rauhtd(struct mlxsw_sp *mlxsw_sp)
7056 - for (i = 0; i < num_rec; i++)
7057 - mlxsw_sp_router_neigh_rec_process(mlxsw_sp, rauhtd_pl,
7058 - i);
7059 -- } while (num_rec);
7060 -+ } while (mlxsw_sp_router_rauhtd_is_full(rauhtd_pl));
7061 - rtnl_unlock();
7062 -
7063 - kfree(rauhtd_pl);
7064 -diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
7065 -index 4c8c60a..fe9e7b1 100644
7066 ---- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
7067 -+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
7068 -@@ -871,6 +871,13 @@ static int stmmac_init_phy(struct net_device *dev)
7069 - return -ENODEV;
7070 - }
7071 -
7072 -+ /* stmmac_adjust_link will change this to PHY_IGNORE_INTERRUPT to avoid
7073 -+ * subsequent PHY polling, make sure we force a link transition if
7074 -+ * we have a UP/DOWN/UP transition
7075 -+ */
7076 -+ if (phydev->is_pseudo_fixed_link)
7077 -+ phydev->irq = PHY_POLL;
7078 -+
7079 - pr_debug("stmmac_init_phy: %s: attached to PHY (UID 0x%x)"
7080 - " Link = %d\n", dev->name, phydev->phy_id, phydev->link);
7081 -
7082 -diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
7083 -index 5c8429f..3a5530d 100644
7084 ---- a/drivers/usb/gadget/function/f_fs.c
7085 -+++ b/drivers/usb/gadget/function/f_fs.c
7086 -@@ -133,8 +133,60 @@ struct ffs_epfile {
7087 - /*
7088 - * Buffer for holding data from partial reads which may happen since
7089 - * we’re rounding user read requests to a multiple of a max packet size.
7090 -+ *
7091 -+ * The pointer is initialised with NULL value and may be set by
7092 -+ * __ffs_epfile_read_data function to point to a temporary buffer.
7093 -+ *
7094 -+ * In normal operation, calls to __ffs_epfile_read_buffered will consume
7095 -+ * data from said buffer and eventually free it. Importantly, while the
7096 -+ * function is using the buffer, it sets the pointer to NULL. This is
7097 -+ * all right since __ffs_epfile_read_data and __ffs_epfile_read_buffered
7098 -+ * can never run concurrently (they are synchronised by epfile->mutex)
7099 -+ * so the latter will not assign a new value to the pointer.
7100 -+ *
7101 -+ * Meanwhile ffs_func_eps_disable frees the buffer (if the pointer is
7102 -+ * valid) and sets the pointer to READ_BUFFER_DROP value. This special
7103 -+ * value is crux of the synchronisation between ffs_func_eps_disable and
7104 -+ * __ffs_epfile_read_data.
7105 -+ *
7106 -+ * Once __ffs_epfile_read_data is about to finish it will try to set the
7107 -+ * pointer back to its old value (as described above), but seeing as the
7108 -+ * pointer is not-NULL (namely READ_BUFFER_DROP) it will instead free
7109 -+ * the buffer.
7110 -+ *
7111 -+ * == State transitions ==
7112 -+ *
7113 -+ * • ptr == NULL: (initial state)
7114 -+ * â—¦ __ffs_epfile_read_buffer_free: go to ptr == DROP
7115 -+ * â—¦ __ffs_epfile_read_buffered: nop
7116 -+ * â—¦ __ffs_epfile_read_data allocates temp buffer: go to ptr == buf
7117 -+ * ◦ reading finishes: n/a, not in ‘and reading’ state
7118 -+ * • ptr == DROP:
7119 -+ * â—¦ __ffs_epfile_read_buffer_free: nop
7120 -+ * â—¦ __ffs_epfile_read_buffered: go to ptr == NULL
7121 -+ * â—¦ __ffs_epfile_read_data allocates temp buffer: free buf, nop
7122 -+ * ◦ reading finishes: n/a, not in ‘and reading’ state
7123 -+ * • ptr == buf:
7124 -+ * â—¦ __ffs_epfile_read_buffer_free: free buf, go to ptr == DROP
7125 -+ * â—¦ __ffs_epfile_read_buffered: go to ptr == NULL and reading
7126 -+ * â—¦ __ffs_epfile_read_data: n/a, __ffs_epfile_read_buffered
7127 -+ * is always called first
7128 -+ * ◦ reading finishes: n/a, not in ‘and reading’ state
7129 -+ * • ptr == NULL and reading:
7130 -+ * â—¦ __ffs_epfile_read_buffer_free: go to ptr == DROP and reading
7131 -+ * â—¦ __ffs_epfile_read_buffered: n/a, mutex is held
7132 -+ * â—¦ __ffs_epfile_read_data: n/a, mutex is held
7133 -+ * ◦ reading finishes and …
7134 -+ * … all data read: free buf, go to ptr == NULL
7135 -+ * … otherwise: go to ptr == buf and reading
7136 -+ * • ptr == DROP and reading:
7137 -+ * â—¦ __ffs_epfile_read_buffer_free: nop
7138 -+ * â—¦ __ffs_epfile_read_buffered: n/a, mutex is held
7139 -+ * â—¦ __ffs_epfile_read_data: n/a, mutex is held
7140 -+ * â—¦ reading finishes: free buf, go to ptr == DROP
7141 - */
7142 -- struct ffs_buffer *read_buffer; /* P: epfile->mutex */
7143 -+ struct ffs_buffer *read_buffer;
7144 -+#define READ_BUFFER_DROP ((struct ffs_buffer *)ERR_PTR(-ESHUTDOWN))
7145 -
7146 - char name[5];
7147 -
7148 -@@ -733,25 +785,47 @@ static void ffs_epfile_async_io_complete(struct usb_ep *_ep,
7149 - schedule_work(&io_data->work);
7150 - }
7151 -
7152 -+static void __ffs_epfile_read_buffer_free(struct ffs_epfile *epfile)
7153 -+{
7154 -+ /*
7155 -+ * See comment in struct ffs_epfile for full read_buffer pointer
7156 -+ * synchronisation story.
7157 -+ */
7158 -+ struct ffs_buffer *buf = xchg(&epfile->read_buffer, READ_BUFFER_DROP);
7159 -+ if (buf && buf != READ_BUFFER_DROP)
7160 -+ kfree(buf);
7161 -+}
7162 -+
7163 - /* Assumes epfile->mutex is held. */
7164 - static ssize_t __ffs_epfile_read_buffered(struct ffs_epfile *epfile,
7165 - struct iov_iter *iter)
7166 - {
7167 -- struct ffs_buffer *buf = epfile->read_buffer;
7168 -+ /*
7169 -+ * Null out epfile->read_buffer so ffs_func_eps_disable does not free
7170 -+ * the buffer while we are using it. See comment in struct ffs_epfile
7171 -+ * for full read_buffer pointer synchronisation story.
7172 -+ */
7173 -+ struct ffs_buffer *buf = xchg(&epfile->read_buffer, NULL);
7174 - ssize_t ret;
7175 -- if (!buf)
7176 -+ if (!buf || buf == READ_BUFFER_DROP)
7177 - return 0;
7178 -
7179 - ret = copy_to_iter(buf->data, buf->length, iter);
7180 - if (buf->length == ret) {
7181 - kfree(buf);
7182 -- epfile->read_buffer = NULL;
7183 -- } else if (unlikely(iov_iter_count(iter))) {
7184 -+ return ret;
7185 -+ }
7186 -+
7187 -+ if (unlikely(iov_iter_count(iter))) {
7188 - ret = -EFAULT;
7189 - } else {
7190 - buf->length -= ret;
7191 - buf->data += ret;
7192 - }
7193 -+
7194 -+ if (cmpxchg(&epfile->read_buffer, NULL, buf))
7195 -+ kfree(buf);
7196 -+
7197 - return ret;
7198 - }
7199 -
7200 -@@ -780,7 +854,15 @@ static ssize_t __ffs_epfile_read_data(struct ffs_epfile *epfile,
7201 - buf->length = data_len;
7202 - buf->data = buf->storage;
7203 - memcpy(buf->storage, data + ret, data_len);
7204 -- epfile->read_buffer = buf;
7205 -+
7206 -+ /*
7207 -+ * At this point read_buffer is NULL or READ_BUFFER_DROP (if
7208 -+ * ffs_func_eps_disable has been called in the meanwhile). See comment
7209 -+ * in struct ffs_epfile for full read_buffer pointer synchronisation
7210 -+ * story.
7211 -+ */
7212 -+ if (unlikely(cmpxchg(&epfile->read_buffer, NULL, buf)))
7213 -+ kfree(buf);
7214 -
7215 - return ret;
7216 - }
7217 -@@ -1094,8 +1176,7 @@ ffs_epfile_release(struct inode *inode, struct file *file)
7218 -
7219 - ENTER();
7220 -
7221 -- kfree(epfile->read_buffer);
7222 -- epfile->read_buffer = NULL;
7223 -+ __ffs_epfile_read_buffer_free(epfile);
7224 - ffs_data_closed(epfile->ffs);
7225 -
7226 - return 0;
7227 -@@ -1721,24 +1802,20 @@ static void ffs_func_eps_disable(struct ffs_function *func)
7228 - unsigned count = func->ffs->eps_count;
7229 - unsigned long flags;
7230 -
7231 -+ spin_lock_irqsave(&func->ffs->eps_lock, flags);
7232 - do {
7233 -- if (epfile)
7234 -- mutex_lock(&epfile->mutex);
7235 -- spin_lock_irqsave(&func->ffs->eps_lock, flags);
7236 - /* pending requests get nuked */
7237 - if (likely(ep->ep))
7238 - usb_ep_disable(ep->ep);
7239 - ++ep;
7240 -- spin_unlock_irqrestore(&func->ffs->eps_lock, flags);
7241 -
7242 - if (epfile) {
7243 - epfile->ep = NULL;
7244 -- kfree(epfile->read_buffer);
7245 -- epfile->read_buffer = NULL;
7246 -- mutex_unlock(&epfile->mutex);
7247 -+ __ffs_epfile_read_buffer_free(epfile);
7248 - ++epfile;
7249 - }
7250 - } while (--count);
7251 -+ spin_unlock_irqrestore(&func->ffs->eps_lock, flags);
7252 - }
7253 -
7254 - static int ffs_func_eps_enable(struct ffs_function *func)
7255 -diff --git a/include/net/ip.h b/include/net/ip.h
7256 -index 156b0c1..0ccf6da 100644
7257 ---- a/include/net/ip.h
7258 -+++ b/include/net/ip.h
7259 -@@ -47,7 +47,6 @@ struct inet_skb_parm {
7260 - #define IPSKB_REROUTED BIT(4)
7261 - #define IPSKB_DOREDIRECT BIT(5)
7262 - #define IPSKB_FRAG_PMTU BIT(6)
7263 --#define IPSKB_FRAG_SEGS BIT(7)
7264 -
7265 - u16 frag_max_size;
7266 - };
7267 -diff --git a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h
7268 -index 43a5a0e..b01d5d1 100644
7269 ---- a/include/net/ip6_tunnel.h
7270 -+++ b/include/net/ip6_tunnel.h
7271 -@@ -145,6 +145,7 @@ static inline void ip6tunnel_xmit(struct sock *sk, struct sk_buff *skb,
7272 - {
7273 - int pkt_len, err;
7274 -
7275 -+ memset(skb->cb, 0, sizeof(struct inet6_skb_parm));
7276 - pkt_len = skb->len - skb_inner_network_offset(skb);
7277 - err = ip6_local_out(dev_net(skb_dst(skb)->dev), sk, skb);
7278 - if (unlikely(net_xmit_eval(err)))
7279 -diff --git a/include/net/sock.h b/include/net/sock.h
7280 -index 8741988..c26eab9 100644
7281 ---- a/include/net/sock.h
7282 -+++ b/include/net/sock.h
7283 -@@ -1587,11 +1587,11 @@ static inline void sock_put(struct sock *sk)
7284 - void sock_gen_put(struct sock *sk);
7285 -
7286 - int __sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested,
7287 -- unsigned int trim_cap);
7288 -+ unsigned int trim_cap, bool refcounted);
7289 - static inline int sk_receive_skb(struct sock *sk, struct sk_buff *skb,
7290 - const int nested)
7291 - {
7292 -- return __sk_receive_skb(sk, skb, nested, 1);
7293 -+ return __sk_receive_skb(sk, skb, nested, 1, true);
7294 - }
7295 -
7296 - static inline void sk_tx_queue_set(struct sock *sk, int tx_queue)
7297 -diff --git a/include/net/tcp.h b/include/net/tcp.h
7298 -index 7717302..0de6989 100644
7299 ---- a/include/net/tcp.h
7300 -+++ b/include/net/tcp.h
7301 -@@ -1164,6 +1164,7 @@ static inline void tcp_prequeue_init(struct tcp_sock *tp)
7302 - }
7303 -
7304 - bool tcp_prequeue(struct sock *sk, struct sk_buff *skb);
7305 -+int tcp_filter(struct sock *sk, struct sk_buff *skb);
7306 -
7307 - #undef STATE_TRACE
7308 -
7309 -diff --git a/include/uapi/linux/atm_zatm.h b/include/uapi/linux/atm_zatm.h
7310 -index 5cd4d4d..9c9c6ad 100644
7311 ---- a/include/uapi/linux/atm_zatm.h
7312 -+++ b/include/uapi/linux/atm_zatm.h
7313 -@@ -14,7 +14,6 @@
7314 -
7315 - #include <linux/atmapi.h>
7316 - #include <linux/atmioc.h>
7317 --#include <linux/time.h>
7318 -
7319 - #define ZATM_GETPOOL _IOW('a',ATMIOC_SARPRV+1,struct atmif_sioc)
7320 - /* get pool statistics */
7321 -diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
7322 -index 570eeca..ad1bc67 100644
7323 ---- a/kernel/bpf/hashtab.c
7324 -+++ b/kernel/bpf/hashtab.c
7325 -@@ -687,7 +687,8 @@ static void delete_all_elements(struct bpf_htab *htab)
7326 -
7327 - hlist_for_each_entry_safe(l, n, head, hash_node) {
7328 - hlist_del_rcu(&l->hash_node);
7329 -- htab_elem_free(htab, l);
7330 -+ if (l->state != HTAB_EXTRA_ELEM_USED)
7331 -+ htab_elem_free(htab, l);
7332 - }
7333 - }
7334 - }
7335 -diff --git a/net/core/dev.c b/net/core/dev.c
7336 -index 44b3ba4..9ce9d72 100644
7337 ---- a/net/core/dev.c
7338 -+++ b/net/core/dev.c
7339 -@@ -2484,7 +2484,7 @@ int skb_checksum_help(struct sk_buff *skb)
7340 - goto out;
7341 - }
7342 -
7343 -- *(__sum16 *)(skb->data + offset) = csum_fold(csum);
7344 -+ *(__sum16 *)(skb->data + offset) = csum_fold(csum) ?: CSUM_MANGLED_0;
7345 - out_set_summed:
7346 - skb->ip_summed = CHECKSUM_NONE;
7347 - out:
7348 -diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
7349 -index 52742a0..5550a86 100644
7350 ---- a/net/core/flow_dissector.c
7351 -+++ b/net/core/flow_dissector.c
7352 -@@ -118,7 +118,7 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
7353 - struct flow_dissector_key_tags *key_tags;
7354 - struct flow_dissector_key_keyid *key_keyid;
7355 - u8 ip_proto = 0;
7356 -- bool ret = false;
7357 -+ bool ret;
7358 -
7359 - if (!data) {
7360 - data = skb->data;
7361 -@@ -481,12 +481,17 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
7362 - out_good:
7363 - ret = true;
7364 -
7365 --out_bad:
7366 -+ key_control->thoff = (u16)nhoff;
7367 -+out:
7368 - key_basic->n_proto = proto;
7369 - key_basic->ip_proto = ip_proto;
7370 -- key_control->thoff = (u16)nhoff;
7371 -
7372 - return ret;
7373 -+
7374 -+out_bad:
7375 -+ ret = false;
7376 -+ key_control->thoff = min_t(u16, nhoff, skb ? skb->len : hlen);
7377 -+ goto out;
7378 - }
7379 - EXPORT_SYMBOL(__skb_flow_dissect);
7380 -
7381 -diff --git a/net/core/sock.c b/net/core/sock.c
7382 -index fd7b41e..10acacc 100644
7383 ---- a/net/core/sock.c
7384 -+++ b/net/core/sock.c
7385 -@@ -453,7 +453,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
7386 - EXPORT_SYMBOL(sock_queue_rcv_skb);
7387 -
7388 - int __sk_receive_skb(struct sock *sk, struct sk_buff *skb,
7389 -- const int nested, unsigned int trim_cap)
7390 -+ const int nested, unsigned int trim_cap, bool refcounted)
7391 - {
7392 - int rc = NET_RX_SUCCESS;
7393 -
7394 -@@ -487,7 +487,8 @@ int __sk_receive_skb(struct sock *sk, struct sk_buff *skb,
7395 -
7396 - bh_unlock_sock(sk);
7397 - out:
7398 -- sock_put(sk);
7399 -+ if (refcounted)
7400 -+ sock_put(sk);
7401 - return rc;
7402 - discard_and_relse:
7403 - kfree_skb(skb);
7404 -@@ -1563,6 +1564,7 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
7405 - RCU_INIT_POINTER(newsk->sk_reuseport_cb, NULL);
7406 -
7407 - newsk->sk_err = 0;
7408 -+ newsk->sk_err_soft = 0;
7409 - newsk->sk_priority = 0;
7410 - newsk->sk_incoming_cpu = raw_smp_processor_id();
7411 - atomic64_set(&newsk->sk_cookie, 0);
7412 -diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
7413 -index 345a3ae..b567c87 100644
7414 ---- a/net/dccp/ipv4.c
7415 -+++ b/net/dccp/ipv4.c
7416 -@@ -235,7 +235,7 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info)
7417 - {
7418 - const struct iphdr *iph = (struct iphdr *)skb->data;
7419 - const u8 offset = iph->ihl << 2;
7420 -- const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data + offset);
7421 -+ const struct dccp_hdr *dh;
7422 - struct dccp_sock *dp;
7423 - struct inet_sock *inet;
7424 - const int type = icmp_hdr(skb)->type;
7425 -@@ -245,11 +245,13 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info)
7426 - int err;
7427 - struct net *net = dev_net(skb->dev);
7428 -
7429 -- if (skb->len < offset + sizeof(*dh) ||
7430 -- skb->len < offset + __dccp_basic_hdr_len(dh)) {
7431 -- __ICMP_INC_STATS(net, ICMP_MIB_INERRORS);
7432 -- return;
7433 -- }
7434 -+ /* Only need dccph_dport & dccph_sport which are the first
7435 -+ * 4 bytes in dccp header.
7436 -+ * Our caller (icmp_socket_deliver()) already pulled 8 bytes for us.
7437 -+ */
7438 -+ BUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_sport) > 8);
7439 -+ BUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_dport) > 8);
7440 -+ dh = (struct dccp_hdr *)(skb->data + offset);
7441 -
7442 - sk = __inet_lookup_established(net, &dccp_hashinfo,
7443 - iph->daddr, dh->dccph_dport,
7444 -@@ -868,7 +870,7 @@ static int dccp_v4_rcv(struct sk_buff *skb)
7445 - goto discard_and_relse;
7446 - nf_reset(skb);
7447 -
7448 -- return __sk_receive_skb(sk, skb, 1, dh->dccph_doff * 4);
7449 -+ return __sk_receive_skb(sk, skb, 1, dh->dccph_doff * 4, refcounted);
7450 -
7451 - no_dccp_socket:
7452 - if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
7453 -diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
7454 -index 3828f94..715e5d1 100644
7455 ---- a/net/dccp/ipv6.c
7456 -+++ b/net/dccp/ipv6.c
7457 -@@ -70,7 +70,7 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
7458 - u8 type, u8 code, int offset, __be32 info)
7459 - {
7460 - const struct ipv6hdr *hdr = (const struct ipv6hdr *)skb->data;
7461 -- const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data + offset);
7462 -+ const struct dccp_hdr *dh;
7463 - struct dccp_sock *dp;
7464 - struct ipv6_pinfo *np;
7465 - struct sock *sk;
7466 -@@ -78,12 +78,13 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
7467 - __u64 seq;
7468 - struct net *net = dev_net(skb->dev);
7469 -
7470 -- if (skb->len < offset + sizeof(*dh) ||
7471 -- skb->len < offset + __dccp_basic_hdr_len(dh)) {
7472 -- __ICMP6_INC_STATS(net, __in6_dev_get(skb->dev),
7473 -- ICMP6_MIB_INERRORS);
7474 -- return;
7475 -- }
7476 -+ /* Only need dccph_dport & dccph_sport which are the first
7477 -+ * 4 bytes in dccp header.
7478 -+ * Our caller (icmpv6_notify()) already pulled 8 bytes for us.
7479 -+ */
7480 -+ BUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_sport) > 8);
7481 -+ BUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_dport) > 8);
7482 -+ dh = (struct dccp_hdr *)(skb->data + offset);
7483 -
7484 - sk = __inet6_lookup_established(net, &dccp_hashinfo,
7485 - &hdr->daddr, dh->dccph_dport,
7486 -@@ -738,7 +739,8 @@ static int dccp_v6_rcv(struct sk_buff *skb)
7487 - if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
7488 - goto discard_and_relse;
7489 -
7490 -- return __sk_receive_skb(sk, skb, 1, dh->dccph_doff * 4) ? -1 : 0;
7491 -+ return __sk_receive_skb(sk, skb, 1, dh->dccph_doff * 4,
7492 -+ refcounted) ? -1 : 0;
7493 -
7494 - no_dccp_socket:
7495 - if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
7496 -@@ -956,6 +958,7 @@ static const struct inet_connection_sock_af_ops dccp_ipv6_mapped = {
7497 - .getsockopt = ipv6_getsockopt,
7498 - .addr2sockaddr = inet6_csk_addr2sockaddr,
7499 - .sockaddr_len = sizeof(struct sockaddr_in6),
7500 -+ .bind_conflict = inet6_csk_bind_conflict,
7501 - #ifdef CONFIG_COMPAT
7502 - .compat_setsockopt = compat_ipv6_setsockopt,
7503 - .compat_getsockopt = compat_ipv6_getsockopt,
7504 -diff --git a/net/dccp/proto.c b/net/dccp/proto.c
7505 -index 41e6580..9fe25bf 100644
7506 ---- a/net/dccp/proto.c
7507 -+++ b/net/dccp/proto.c
7508 -@@ -1009,6 +1009,10 @@ void dccp_close(struct sock *sk, long timeout)
7509 - __kfree_skb(skb);
7510 - }
7511 -
7512 -+ /* If socket has been already reset kill it. */
7513 -+ if (sk->sk_state == DCCP_CLOSED)
7514 -+ goto adjudge_to_death;
7515 -+
7516 - if (data_was_unread) {
7517 - /* Unread data was tossed, send an appropriate Reset Code */
7518 - DCCP_WARN("ABORT with %u bytes unread\n", data_was_unread);
7519 -diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
7520 -index e2ffc2a..7ef7031 100644
7521 ---- a/net/ipv4/fib_trie.c
7522 -+++ b/net/ipv4/fib_trie.c
7523 -@@ -2455,22 +2455,19 @@ static struct key_vector *fib_route_get_idx(struct fib_route_iter *iter,
7524 - struct key_vector *l, **tp = &iter->tnode;
7525 - t_key key;
7526 -
7527 -- /* use cache location of next-to-find key */
7528 -+ /* use cached location of previously found key */
7529 - if (iter->pos > 0 && pos >= iter->pos) {
7530 -- pos -= iter->pos;
7531 - key = iter->key;
7532 - } else {
7533 -- iter->pos = 0;
7534 -+ iter->pos = 1;
7535 - key = 0;
7536 - }
7537 -
7538 -- while ((l = leaf_walk_rcu(tp, key)) != NULL) {
7539 -+ pos -= iter->pos;
7540 -+
7541 -+ while ((l = leaf_walk_rcu(tp, key)) && (pos-- > 0)) {
7542 - key = l->key + 1;
7543 - iter->pos++;
7544 --
7545 -- if (--pos <= 0)
7546 -- break;
7547 --
7548 - l = NULL;
7549 -
7550 - /* handle unlikely case of a key wrap */
7551 -@@ -2479,7 +2476,7 @@ static struct key_vector *fib_route_get_idx(struct fib_route_iter *iter,
7552 - }
7553 -
7554 - if (l)
7555 -- iter->key = key; /* remember it */
7556 -+ iter->key = l->key; /* remember it */
7557 - else
7558 - iter->pos = 0; /* forget it */
7559 -
7560 -@@ -2507,7 +2504,7 @@ static void *fib_route_seq_start(struct seq_file *seq, loff_t *pos)
7561 - return fib_route_get_idx(iter, *pos);
7562 -
7563 - iter->pos = 0;
7564 -- iter->key = 0;
7565 -+ iter->key = KEY_MAX;
7566 -
7567 - return SEQ_START_TOKEN;
7568 - }
7569 -@@ -2516,7 +2513,7 @@ static void *fib_route_seq_next(struct seq_file *seq, void *v, loff_t *pos)
7570 - {
7571 - struct fib_route_iter *iter = seq->private;
7572 - struct key_vector *l = NULL;
7573 -- t_key key = iter->key;
7574 -+ t_key key = iter->key + 1;
7575 -
7576 - ++*pos;
7577 -
7578 -@@ -2525,7 +2522,7 @@ static void *fib_route_seq_next(struct seq_file *seq, void *v, loff_t *pos)
7579 - l = leaf_walk_rcu(&iter->tnode, key);
7580 -
7581 - if (l) {
7582 -- iter->key = l->key + 1;
7583 -+ iter->key = l->key;
7584 - iter->pos++;
7585 - } else {
7586 - iter->pos = 0;
7587 -diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
7588 -index 38abe70..48734ee 100644
7589 ---- a/net/ipv4/icmp.c
7590 -+++ b/net/ipv4/icmp.c
7591 -@@ -477,7 +477,7 @@ static struct rtable *icmp_route_lookup(struct net *net,
7592 - fl4->flowi4_proto = IPPROTO_ICMP;
7593 - fl4->fl4_icmp_type = type;
7594 - fl4->fl4_icmp_code = code;
7595 -- fl4->flowi4_oif = l3mdev_master_ifindex(skb_in->dev);
7596 -+ fl4->flowi4_oif = l3mdev_master_ifindex(skb_dst(skb_in)->dev);
7597 -
7598 - security_skb_classify_flow(skb_in, flowi4_to_flowi(fl4));
7599 - rt = __ip_route_output_key_hash(net, fl4,
7600 -@@ -502,7 +502,7 @@ static struct rtable *icmp_route_lookup(struct net *net,
7601 - if (err)
7602 - goto relookup_failed;
7603 -
7604 -- if (inet_addr_type_dev_table(net, skb_in->dev,
7605 -+ if (inet_addr_type_dev_table(net, skb_dst(skb_in)->dev,
7606 - fl4_dec.saddr) == RTN_LOCAL) {
7607 - rt2 = __ip_route_output_key(net, &fl4_dec);
7608 - if (IS_ERR(rt2))
7609 -diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c
7610 -index 8b4ffd2..9f0a7b9 100644
7611 ---- a/net/ipv4/ip_forward.c
7612 -+++ b/net/ipv4/ip_forward.c
7613 -@@ -117,7 +117,7 @@ int ip_forward(struct sk_buff *skb)
7614 - if (opt->is_strictroute && rt->rt_uses_gateway)
7615 - goto sr_failed;
7616 -
7617 -- IPCB(skb)->flags |= IPSKB_FORWARDED | IPSKB_FRAG_SEGS;
7618 -+ IPCB(skb)->flags |= IPSKB_FORWARDED;
7619 - mtu = ip_dst_mtu_maybe_forward(&rt->dst, true);
7620 - if (ip_exceeds_mtu(skb, mtu)) {
7621 - IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS);
7622 -diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
7623 -index dde37fb..307daed 100644
7624 ---- a/net/ipv4/ip_output.c
7625 -+++ b/net/ipv4/ip_output.c
7626 -@@ -223,11 +223,9 @@ static int ip_finish_output_gso(struct net *net, struct sock *sk,
7627 - struct sk_buff *segs;
7628 - int ret = 0;
7629 -
7630 -- /* common case: fragmentation of segments is not allowed,
7631 -- * or seglen is <= mtu
7632 -+ /* common case: seglen is <= mtu
7633 - */
7634 -- if (((IPCB(skb)->flags & IPSKB_FRAG_SEGS) == 0) ||
7635 -- skb_gso_validate_mtu(skb, mtu))
7636 -+ if (skb_gso_validate_mtu(skb, mtu))
7637 - return ip_finish_output2(net, sk, skb);
7638 -
7639 - /* Slowpath - GSO segment length is exceeding the dst MTU.
7640 -diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
7641 -index 0f227db..afd6b59 100644
7642 ---- a/net/ipv4/ip_tunnel_core.c
7643 -+++ b/net/ipv4/ip_tunnel_core.c
7644 -@@ -63,7 +63,6 @@ void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
7645 - int pkt_len = skb->len - skb_inner_network_offset(skb);
7646 - struct net *net = dev_net(rt->dst.dev);
7647 - struct net_device *dev = skb->dev;
7648 -- int skb_iif = skb->skb_iif;
7649 - struct iphdr *iph;
7650 - int err;
7651 -
7652 -@@ -73,16 +72,6 @@ void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
7653 - skb_dst_set(skb, &rt->dst);
7654 - memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
7655 -
7656 -- if (skb_iif && !(df & htons(IP_DF))) {
7657 -- /* Arrived from an ingress interface, got encapsulated, with
7658 -- * fragmentation of encapulating frames allowed.
7659 -- * If skb is gso, the resulting encapsulated network segments
7660 -- * may exceed dst mtu.
7661 -- * Allow IP Fragmentation of segments.
7662 -- */
7663 -- IPCB(skb)->flags |= IPSKB_FRAG_SEGS;
7664 -- }
7665 --
7666 - /* Push down and install the IP header. */
7667 - skb_push(skb, sizeof(struct iphdr));
7668 - skb_reset_network_header(skb);
7669 -diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
7670 -index 5f006e1..27089f5 100644
7671 ---- a/net/ipv4/ipmr.c
7672 -+++ b/net/ipv4/ipmr.c
7673 -@@ -1749,7 +1749,7 @@ static void ipmr_queue_xmit(struct net *net, struct mr_table *mrt,
7674 - vif->dev->stats.tx_bytes += skb->len;
7675 - }
7676 -
7677 -- IPCB(skb)->flags |= IPSKB_FORWARDED | IPSKB_FRAG_SEGS;
7678 -+ IPCB(skb)->flags |= IPSKB_FORWARDED;
7679 -
7680 - /* RFC1584 teaches, that DVMRP/PIM router must deliver packets locally
7681 - * not only before forwarding, but after forwarding on all output
7682 -diff --git a/net/ipv4/route.c b/net/ipv4/route.c
7683 -index 62c3ed0..2f23ef1 100644
7684 ---- a/net/ipv4/route.c
7685 -+++ b/net/ipv4/route.c
7686 -@@ -753,7 +753,9 @@ static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flow
7687 - goto reject_redirect;
7688 - }
7689 -
7690 -- n = ipv4_neigh_lookup(&rt->dst, NULL, &new_gw);
7691 -+ n = __ipv4_neigh_lookup(rt->dst.dev, new_gw);
7692 -+ if (!n)
7693 -+ n = neigh_create(&arp_tbl, &new_gw, rt->dst.dev);
7694 - if (!IS_ERR(n)) {
7695 - if (!(n->nud_state & NUD_VALID)) {
7696 - neigh_event_send(n, NULL);
7697 -diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
7698 -index ffbb218..c876f5d 100644
7699 ---- a/net/ipv4/tcp.c
7700 -+++ b/net/ipv4/tcp.c
7701 -@@ -1145,7 +1145,7 @@ int tcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
7702 -
7703 - err = -EPIPE;
7704 - if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))
7705 -- goto out_err;
7706 -+ goto do_error;
7707 -
7708 - sg = !!(sk->sk_route_caps & NETIF_F_SG);
7709 -
7710 -@@ -1219,7 +1219,7 @@ int tcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
7711 -
7712 - if (!skb_can_coalesce(skb, i, pfrag->page,
7713 - pfrag->offset)) {
7714 -- if (i == sysctl_max_skb_frags || !sg) {
7715 -+ if (i >= sysctl_max_skb_frags || !sg) {
7716 - tcp_mark_push(tp, skb);
7717 - goto new_segment;
7718 - }
7719 -diff --git a/net/ipv4/tcp_dctcp.c b/net/ipv4/tcp_dctcp.c
7720 -index 10d728b..ab37c67 100644
7721 ---- a/net/ipv4/tcp_dctcp.c
7722 -+++ b/net/ipv4/tcp_dctcp.c
7723 -@@ -56,6 +56,7 @@ struct dctcp {
7724 - u32 next_seq;
7725 - u32 ce_state;
7726 - u32 delayed_ack_reserved;
7727 -+ u32 loss_cwnd;
7728 - };
7729 -
7730 - static unsigned int dctcp_shift_g __read_mostly = 4; /* g = 1/2^4 */
7731 -@@ -96,6 +97,7 @@ static void dctcp_init(struct sock *sk)
7732 - ca->dctcp_alpha = min(dctcp_alpha_on_init, DCTCP_MAX_ALPHA);
7733 -
7734 - ca->delayed_ack_reserved = 0;
7735 -+ ca->loss_cwnd = 0;
7736 - ca->ce_state = 0;
7737 -
7738 - dctcp_reset(tp, ca);
7739 -@@ -111,9 +113,10 @@ static void dctcp_init(struct sock *sk)
7740 -
7741 - static u32 dctcp_ssthresh(struct sock *sk)
7742 - {
7743 -- const struct dctcp *ca = inet_csk_ca(sk);
7744 -+ struct dctcp *ca = inet_csk_ca(sk);
7745 - struct tcp_sock *tp = tcp_sk(sk);
7746 -
7747 -+ ca->loss_cwnd = tp->snd_cwnd;
7748 - return max(tp->snd_cwnd - ((tp->snd_cwnd * ca->dctcp_alpha) >> 11U), 2U);
7749 - }
7750 -
7751 -@@ -308,12 +311,20 @@ static size_t dctcp_get_info(struct sock *sk, u32 ext, int *attr,
7752 - return 0;
7753 - }
7754 -
7755 -+static u32 dctcp_cwnd_undo(struct sock *sk)
7756 -+{
7757 -+ const struct dctcp *ca = inet_csk_ca(sk);
7758 -+
7759 -+ return max(tcp_sk(sk)->snd_cwnd, ca->loss_cwnd);
7760 -+}
7761 -+
7762 - static struct tcp_congestion_ops dctcp __read_mostly = {
7763 - .init = dctcp_init,
7764 - .in_ack_event = dctcp_update_alpha,
7765 - .cwnd_event = dctcp_cwnd_event,
7766 - .ssthresh = dctcp_ssthresh,
7767 - .cong_avoid = tcp_reno_cong_avoid,
7768 -+ .undo_cwnd = dctcp_cwnd_undo,
7769 - .set_state = dctcp_state,
7770 - .get_info = dctcp_get_info,
7771 - .flags = TCP_CONG_NEEDS_ECN,
7772 -diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
7773 -index 7158d4f..7b235fa 100644
7774 ---- a/net/ipv4/tcp_ipv4.c
7775 -+++ b/net/ipv4/tcp_ipv4.c
7776 -@@ -1537,6 +1537,21 @@ bool tcp_prequeue(struct sock *sk, struct sk_buff *skb)
7777 - }
7778 - EXPORT_SYMBOL(tcp_prequeue);
7779 -
7780 -+int tcp_filter(struct sock *sk, struct sk_buff *skb)
7781 -+{
7782 -+ struct tcphdr *th = (struct tcphdr *)skb->data;
7783 -+ unsigned int eaten = skb->len;
7784 -+ int err;
7785 -+
7786 -+ err = sk_filter_trim_cap(sk, skb, th->doff * 4);
7787 -+ if (!err) {
7788 -+ eaten -= skb->len;
7789 -+ TCP_SKB_CB(skb)->end_seq -= eaten;
7790 -+ }
7791 -+ return err;
7792 -+}
7793 -+EXPORT_SYMBOL(tcp_filter);
7794 -+
7795 - /*
7796 - * From tcp_input.c
7797 - */
7798 -@@ -1648,8 +1663,10 @@ int tcp_v4_rcv(struct sk_buff *skb)
7799 -
7800 - nf_reset(skb);
7801 -
7802 -- if (sk_filter(sk, skb))
7803 -+ if (tcp_filter(sk, skb))
7804 - goto discard_and_relse;
7805 -+ th = (const struct tcphdr *)skb->data;
7806 -+ iph = ip_hdr(skb);
7807 -
7808 - skb->dev = NULL;
7809 -
7810 -diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
7811 -index bd59c34..7370ad2 100644
7812 ---- a/net/ipv6/icmp.c
7813 -+++ b/net/ipv6/icmp.c
7814 -@@ -448,7 +448,7 @@ static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
7815 - if (__ipv6_addr_needs_scope_id(addr_type))
7816 - iif = skb->dev->ifindex;
7817 - else
7818 -- iif = l3mdev_master_ifindex(skb->dev);
7819 -+ iif = l3mdev_master_ifindex(skb_dst(skb)->dev);
7820 -
7821 - /*
7822 - * Must not send error if the source does not uniquely
7823 -diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
7824 -index fc67822..af6a09e 100644
7825 ---- a/net/ipv6/tcp_ipv6.c
7826 -+++ b/net/ipv6/tcp_ipv6.c
7827 -@@ -1228,7 +1228,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
7828 - if (skb->protocol == htons(ETH_P_IP))
7829 - return tcp_v4_do_rcv(sk, skb);
7830 -
7831 -- if (sk_filter(sk, skb))
7832 -+ if (tcp_filter(sk, skb))
7833 - goto discard;
7834 -
7835 - /*
7836 -@@ -1455,8 +1455,10 @@ static int tcp_v6_rcv(struct sk_buff *skb)
7837 - if (tcp_v6_inbound_md5_hash(sk, skb))
7838 - goto discard_and_relse;
7839 -
7840 -- if (sk_filter(sk, skb))
7841 -+ if (tcp_filter(sk, skb))
7842 - goto discard_and_relse;
7843 -+ th = (const struct tcphdr *)skb->data;
7844 -+ hdr = ipv6_hdr(skb);
7845 -
7846 - skb->dev = NULL;
7847 -
7848 -diff --git a/net/sctp/socket.c b/net/sctp/socket.c
7849 -index baccbf3..7b0e059 100644
7850 ---- a/net/sctp/socket.c
7851 -+++ b/net/sctp/socket.c
7852 -@@ -1214,9 +1214,12 @@ static int __sctp_connect(struct sock *sk,
7853 -
7854 - timeo = sock_sndtimeo(sk, f_flags & O_NONBLOCK);
7855 -
7856 -- err = sctp_wait_for_connect(asoc, &timeo);
7857 -- if ((err == 0 || err == -EINPROGRESS) && assoc_id)
7858 -+ if (assoc_id)
7859 - *assoc_id = asoc->assoc_id;
7860 -+ err = sctp_wait_for_connect(asoc, &timeo);
7861 -+ /* Note: the asoc may be freed after the return of
7862 -+ * sctp_wait_for_connect.
7863 -+ */
7864 -
7865 - /* Don't free association on exit. */
7866 - asoc = NULL;
7867 -@@ -4278,19 +4281,18 @@ static void sctp_shutdown(struct sock *sk, int how)
7868 - {
7869 - struct net *net = sock_net(sk);
7870 - struct sctp_endpoint *ep;
7871 -- struct sctp_association *asoc;
7872 -
7873 - if (!sctp_style(sk, TCP))
7874 - return;
7875 -
7876 -- if (how & SEND_SHUTDOWN) {
7877 -+ ep = sctp_sk(sk)->ep;
7878 -+ if (how & SEND_SHUTDOWN && !list_empty(&ep->asocs)) {
7879 -+ struct sctp_association *asoc;
7880 -+
7881 - sk->sk_state = SCTP_SS_CLOSING;
7882 -- ep = sctp_sk(sk)->ep;
7883 -- if (!list_empty(&ep->asocs)) {
7884 -- asoc = list_entry(ep->asocs.next,
7885 -- struct sctp_association, asocs);
7886 -- sctp_primitive_SHUTDOWN(net, asoc, NULL);
7887 -- }
7888 -+ asoc = list_entry(ep->asocs.next,
7889 -+ struct sctp_association, asocs);
7890 -+ sctp_primitive_SHUTDOWN(net, asoc, NULL);
7891 - }
7892 - }
7893 -
7894 -diff --git a/net/socket.c b/net/socket.c
7895 -index a1bd161..03bc2c2 100644
7896 ---- a/net/socket.c
7897 -+++ b/net/socket.c
7898 -@@ -2041,6 +2041,8 @@ int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
7899 - if (err)
7900 - break;
7901 - ++datagrams;
7902 -+ if (msg_data_left(&msg_sys))
7903 -+ break;
7904 - cond_resched();
7905 - }
7906 -
7907 -diff --git a/tools/spi/spidev_test.c b/tools/spi/spidev_test.c
7908 -index f3825b6..f046b77 100644
7909 ---- a/tools/spi/spidev_test.c
7910 -+++ b/tools/spi/spidev_test.c
7911 -@@ -19,6 +19,7 @@
7912 - #include <getopt.h>
7913 - #include <fcntl.h>
7914 - #include <sys/ioctl.h>
7915 -+#include <linux/ioctl.h>
7916 - #include <sys/stat.h>
7917 - #include <linux/types.h>
7918 - #include <linux/spi/spidev.h>
7919
7920 diff --git a/4.8.11/0000_README b/4.8.12/0000_README
7921 similarity index 90%
7922 rename from 4.8.11/0000_README
7923 rename to 4.8.12/0000_README
7924 index a5a0953..e80d57a 100644
7925 --- a/4.8.11/0000_README
7926 +++ b/4.8.12/0000_README
7927 @@ -2,19 +2,15 @@ README
7928 -----------------------------------------------------------------------------
7929 Individual Patch Descriptions:
7930 -----------------------------------------------------------------------------
7931 -Patch: 1008_linux-4.8.9.patch
7932 -From: http://www.kernel.org
7933 -Desc: Linux 4.8.9
7934 -
7935 -Patch: 1009_linux-4.8.10.patch
7936 -From: http://www.kernel.org
7937 -Desc: Linux 4.8.10
7938 -
7939 Patch: 1010_linux-4.8.11.patch
7940 From: http://www.kernel.org
7941 Desc: Linux 4.8.11
7942
7943 -Patch: 4420_grsecurity-3.1-4.8.11-201611271225.patch
7944 +Patch: 1011_linux-4.8.12.patch
7945 +From: http://www.kernel.org
7946 +Desc: Linux 4.8.12
7947 +
7948 +Patch: 4420_grsecurity-3.1-4.8.12-201612031658.patch
7949 From: http://www.grsecurity.net
7950 Desc: hardened-sources base patch from upstream grsecurity
7951
7952
7953 diff --git a/4.8.11/1010_linux-4.8.11.patch b/4.8.12/1010_linux-4.8.11.patch
7954 similarity index 100%
7955 rename from 4.8.11/1010_linux-4.8.11.patch
7956 rename to 4.8.12/1010_linux-4.8.11.patch
7957
7958 diff --git a/4.8.12/1011_linux-4.8.12.patch b/4.8.12/1011_linux-4.8.12.patch
7959 new file mode 100644
7960 index 0000000..6e460f1
7961 --- /dev/null
7962 +++ b/4.8.12/1011_linux-4.8.12.patch
7963 @@ -0,0 +1,1563 @@
7964 +diff --git a/Makefile b/Makefile
7965 +index 2b1bcba..7b0c92f 100644
7966 +--- a/Makefile
7967 ++++ b/Makefile
7968 +@@ -1,6 +1,6 @@
7969 + VERSION = 4
7970 + PATCHLEVEL = 8
7971 +-SUBLEVEL = 11
7972 ++SUBLEVEL = 12
7973 + EXTRAVERSION =
7974 + NAME = Psychotic Stoned Sheep
7975 +
7976 +diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
7977 +index af12c2d..81c11a6 100644
7978 +--- a/arch/parisc/Kconfig
7979 ++++ b/arch/parisc/Kconfig
7980 +@@ -33,7 +33,9 @@ config PARISC
7981 + select HAVE_ARCH_HASH
7982 + select HAVE_ARCH_SECCOMP_FILTER
7983 + select HAVE_ARCH_TRACEHOOK
7984 +- select HAVE_UNSTABLE_SCHED_CLOCK if (SMP || !64BIT)
7985 ++ select GENERIC_SCHED_CLOCK
7986 ++ select HAVE_UNSTABLE_SCHED_CLOCK if SMP
7987 ++ select GENERIC_CLOCKEVENTS
7988 + select ARCH_NO_COHERENT_DMA_MMAP
7989 + select CPU_NO_EFFICIENT_FFS
7990 +
7991 +diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
7992 +index 6700127..c2259d4 100644
7993 +--- a/arch/parisc/kernel/cache.c
7994 ++++ b/arch/parisc/kernel/cache.c
7995 +@@ -369,6 +369,7 @@ void __init parisc_setup_cache_timing(void)
7996 + {
7997 + unsigned long rangetime, alltime;
7998 + unsigned long size, start;
7999 ++ unsigned long threshold;
8000 +
8001 + alltime = mfctl(16);
8002 + flush_data_cache();
8003 +@@ -382,17 +383,12 @@ void __init parisc_setup_cache_timing(void)
8004 + printk(KERN_DEBUG "Whole cache flush %lu cycles, flushing %lu bytes %lu cycles\n",
8005 + alltime, size, rangetime);
8006 +
8007 +- /* Racy, but if we see an intermediate value, it's ok too... */
8008 +- parisc_cache_flush_threshold = size * alltime / rangetime;
8009 +-
8010 +- parisc_cache_flush_threshold = L1_CACHE_ALIGN(parisc_cache_flush_threshold);
8011 +- if (!parisc_cache_flush_threshold)
8012 +- parisc_cache_flush_threshold = FLUSH_THRESHOLD;
8013 +-
8014 +- if (parisc_cache_flush_threshold > cache_info.dc_size)
8015 +- parisc_cache_flush_threshold = cache_info.dc_size;
8016 +-
8017 +- printk(KERN_INFO "Setting cache flush threshold to %lu kB\n",
8018 ++ threshold = L1_CACHE_ALIGN(size * alltime / rangetime);
8019 ++ if (threshold > cache_info.dc_size)
8020 ++ threshold = cache_info.dc_size;
8021 ++ if (threshold)
8022 ++ parisc_cache_flush_threshold = threshold;
8023 ++ printk(KERN_INFO "Cache flush threshold set to %lu KiB\n",
8024 + parisc_cache_flush_threshold/1024);
8025 +
8026 + /* calculate TLB flush threshold */
8027 +@@ -401,7 +397,7 @@ void __init parisc_setup_cache_timing(void)
8028 + flush_tlb_all();
8029 + alltime = mfctl(16) - alltime;
8030 +
8031 +- size = PAGE_SIZE;
8032 ++ size = 0;
8033 + start = (unsigned long) _text;
8034 + rangetime = mfctl(16);
8035 + while (start < (unsigned long) _end) {
8036 +@@ -414,13 +410,10 @@ void __init parisc_setup_cache_timing(void)
8037 + printk(KERN_DEBUG "Whole TLB flush %lu cycles, flushing %lu bytes %lu cycles\n",
8038 + alltime, size, rangetime);
8039 +
8040 +- parisc_tlb_flush_threshold = size * alltime / rangetime;
8041 +- parisc_tlb_flush_threshold *= num_online_cpus();
8042 +- parisc_tlb_flush_threshold = PAGE_ALIGN(parisc_tlb_flush_threshold);
8043 +- if (!parisc_tlb_flush_threshold)
8044 +- parisc_tlb_flush_threshold = FLUSH_TLB_THRESHOLD;
8045 +-
8046 +- printk(KERN_INFO "Setting TLB flush threshold to %lu kB\n",
8047 ++ threshold = PAGE_ALIGN(num_online_cpus() * size * alltime / rangetime);
8048 ++ if (threshold)
8049 ++ parisc_tlb_flush_threshold = threshold;
8050 ++ printk(KERN_INFO "TLB flush threshold set to %lu KiB\n",
8051 + parisc_tlb_flush_threshold/1024);
8052 + }
8053 +
8054 +diff --git a/arch/parisc/kernel/pacache.S b/arch/parisc/kernel/pacache.S
8055 +index b743a80..6755219 100644
8056 +--- a/arch/parisc/kernel/pacache.S
8057 ++++ b/arch/parisc/kernel/pacache.S
8058 +@@ -96,7 +96,7 @@ fitmanyloop: /* Loop if LOOP >= 2 */
8059 +
8060 + fitmanymiddle: /* Loop if LOOP >= 2 */
8061 + addib,COND(>) -1, %r31, fitmanymiddle /* Adjusted inner loop decr */
8062 +- pitlbe 0(%sr1, %r28)
8063 ++ pitlbe %r0(%sr1, %r28)
8064 + pitlbe,m %arg1(%sr1, %r28) /* Last pitlbe and addr adjust */
8065 + addib,COND(>) -1, %r29, fitmanymiddle /* Middle loop decr */
8066 + copy %arg3, %r31 /* Re-init inner loop count */
8067 +@@ -139,7 +139,7 @@ fdtmanyloop: /* Loop if LOOP >= 2 */
8068 +
8069 + fdtmanymiddle: /* Loop if LOOP >= 2 */
8070 + addib,COND(>) -1, %r31, fdtmanymiddle /* Adjusted inner loop decr */
8071 +- pdtlbe 0(%sr1, %r28)
8072 ++ pdtlbe %r0(%sr1, %r28)
8073 + pdtlbe,m %arg1(%sr1, %r28) /* Last pdtlbe and addr adjust */
8074 + addib,COND(>) -1, %r29, fdtmanymiddle /* Middle loop decr */
8075 + copy %arg3, %r31 /* Re-init inner loop count */
8076 +@@ -620,12 +620,12 @@ ENTRY(copy_user_page_asm)
8077 + /* Purge any old translations */
8078 +
8079 + #ifdef CONFIG_PA20
8080 +- pdtlb,l 0(%r28)
8081 +- pdtlb,l 0(%r29)
8082 ++ pdtlb,l %r0(%r28)
8083 ++ pdtlb,l %r0(%r29)
8084 + #else
8085 + tlb_lock %r20,%r21,%r22
8086 +- pdtlb 0(%r28)
8087 +- pdtlb 0(%r29)
8088 ++ pdtlb %r0(%r28)
8089 ++ pdtlb %r0(%r29)
8090 + tlb_unlock %r20,%r21,%r22
8091 + #endif
8092 +
8093 +@@ -768,10 +768,10 @@ ENTRY(clear_user_page_asm)
8094 + /* Purge any old translation */
8095 +
8096 + #ifdef CONFIG_PA20
8097 +- pdtlb,l 0(%r28)
8098 ++ pdtlb,l %r0(%r28)
8099 + #else
8100 + tlb_lock %r20,%r21,%r22
8101 +- pdtlb 0(%r28)
8102 ++ pdtlb %r0(%r28)
8103 + tlb_unlock %r20,%r21,%r22
8104 + #endif
8105 +
8106 +@@ -852,10 +852,10 @@ ENTRY(flush_dcache_page_asm)
8107 + /* Purge any old translation */
8108 +
8109 + #ifdef CONFIG_PA20
8110 +- pdtlb,l 0(%r28)
8111 ++ pdtlb,l %r0(%r28)
8112 + #else
8113 + tlb_lock %r20,%r21,%r22
8114 +- pdtlb 0(%r28)
8115 ++ pdtlb %r0(%r28)
8116 + tlb_unlock %r20,%r21,%r22
8117 + #endif
8118 +
8119 +@@ -892,10 +892,10 @@ ENTRY(flush_dcache_page_asm)
8120 + sync
8121 +
8122 + #ifdef CONFIG_PA20
8123 +- pdtlb,l 0(%r25)
8124 ++ pdtlb,l %r0(%r25)
8125 + #else
8126 + tlb_lock %r20,%r21,%r22
8127 +- pdtlb 0(%r25)
8128 ++ pdtlb %r0(%r25)
8129 + tlb_unlock %r20,%r21,%r22
8130 + #endif
8131 +
8132 +@@ -925,13 +925,18 @@ ENTRY(flush_icache_page_asm)
8133 + depwi 0, 31,PAGE_SHIFT, %r28 /* Clear any offset bits */
8134 + #endif
8135 +
8136 +- /* Purge any old translation */
8137 ++ /* Purge any old translation. Note that the FIC instruction
8138 ++ * may use either the instruction or data TLB. Given that we
8139 ++ * have a flat address space, it's not clear which TLB will be
8140 ++ * used. So, we purge both entries. */
8141 +
8142 + #ifdef CONFIG_PA20
8143 ++ pdtlb,l %r0(%r28)
8144 + pitlb,l %r0(%sr4,%r28)
8145 + #else
8146 + tlb_lock %r20,%r21,%r22
8147 +- pitlb (%sr4,%r28)
8148 ++ pdtlb %r0(%r28)
8149 ++ pitlb %r0(%sr4,%r28)
8150 + tlb_unlock %r20,%r21,%r22
8151 + #endif
8152 +
8153 +@@ -970,10 +975,12 @@ ENTRY(flush_icache_page_asm)
8154 + sync
8155 +
8156 + #ifdef CONFIG_PA20
8157 ++ pdtlb,l %r0(%r28)
8158 + pitlb,l %r0(%sr4,%r25)
8159 + #else
8160 + tlb_lock %r20,%r21,%r22
8161 +- pitlb (%sr4,%r25)
8162 ++ pdtlb %r0(%r28)
8163 ++ pitlb %r0(%sr4,%r25)
8164 + tlb_unlock %r20,%r21,%r22
8165 + #endif
8166 +
8167 +diff --git a/arch/parisc/kernel/pci-dma.c b/arch/parisc/kernel/pci-dma.c
8168 +index 02d9ed0..494ff6e 100644
8169 +--- a/arch/parisc/kernel/pci-dma.c
8170 ++++ b/arch/parisc/kernel/pci-dma.c
8171 +@@ -95,8 +95,8 @@ static inline int map_pte_uncached(pte_t * pte,
8172 +
8173 + if (!pte_none(*pte))
8174 + printk(KERN_ERR "map_pte_uncached: page already exists\n");
8175 +- set_pte(pte, __mk_pte(*paddr_ptr, PAGE_KERNEL_UNC));
8176 + purge_tlb_start(flags);
8177 ++ set_pte(pte, __mk_pte(*paddr_ptr, PAGE_KERNEL_UNC));
8178 + pdtlb_kernel(orig_vaddr);
8179 + purge_tlb_end(flags);
8180 + vaddr += PAGE_SIZE;
8181 +diff --git a/arch/parisc/kernel/setup.c b/arch/parisc/kernel/setup.c
8182 +index 81d6f63..2e66a88 100644
8183 +--- a/arch/parisc/kernel/setup.c
8184 ++++ b/arch/parisc/kernel/setup.c
8185 +@@ -334,6 +334,10 @@ static int __init parisc_init(void)
8186 + /* tell PDC we're Linux. Nevermind failure. */
8187 + pdc_stable_write(0x40, &osid, sizeof(osid));
8188 +
8189 ++ /* start with known state */
8190 ++ flush_cache_all_local();
8191 ++ flush_tlb_all_local(NULL);
8192 ++
8193 + processor_init();
8194 + #ifdef CONFIG_SMP
8195 + pr_info("CPU(s): %d out of %d %s at %d.%06d MHz online\n",
8196 +diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c
8197 +index 9b63b87..325f30d 100644
8198 +--- a/arch/parisc/kernel/time.c
8199 ++++ b/arch/parisc/kernel/time.c
8200 +@@ -14,6 +14,7 @@
8201 + #include <linux/module.h>
8202 + #include <linux/rtc.h>
8203 + #include <linux/sched.h>
8204 ++#include <linux/sched_clock.h>
8205 + #include <linux/kernel.h>
8206 + #include <linux/param.h>
8207 + #include <linux/string.h>
8208 +@@ -39,18 +40,6 @@
8209 +
8210 + static unsigned long clocktick __read_mostly; /* timer cycles per tick */
8211 +
8212 +-#ifndef CONFIG_64BIT
8213 +-/*
8214 +- * The processor-internal cycle counter (Control Register 16) is used as time
8215 +- * source for the sched_clock() function. This register is 64bit wide on a
8216 +- * 64-bit kernel and 32bit on a 32-bit kernel. Since sched_clock() always
8217 +- * requires a 64bit counter we emulate on the 32-bit kernel the higher 32bits
8218 +- * with a per-cpu variable which we increase every time the counter
8219 +- * wraps-around (which happens every ~4 secounds).
8220 +- */
8221 +-static DEFINE_PER_CPU(unsigned long, cr16_high_32_bits);
8222 +-#endif
8223 +-
8224 + /*
8225 + * We keep time on PA-RISC Linux by using the Interval Timer which is
8226 + * a pair of registers; one is read-only and one is write-only; both
8227 +@@ -121,12 +110,6 @@ irqreturn_t __irq_entry timer_interrupt(int irq, void *dev_id)
8228 + */
8229 + mtctl(next_tick, 16);
8230 +
8231 +-#if !defined(CONFIG_64BIT)
8232 +- /* check for overflow on a 32bit kernel (every ~4 seconds). */
8233 +- if (unlikely(next_tick < now))
8234 +- this_cpu_inc(cr16_high_32_bits);
8235 +-#endif
8236 +-
8237 + /* Skip one clocktick on purpose if we missed next_tick.
8238 + * The new CR16 must be "later" than current CR16 otherwise
8239 + * itimer would not fire until CR16 wrapped - e.g 4 seconds
8240 +@@ -208,7 +191,7 @@ EXPORT_SYMBOL(profile_pc);
8241 +
8242 + /* clock source code */
8243 +
8244 +-static cycle_t read_cr16(struct clocksource *cs)
8245 ++static cycle_t notrace read_cr16(struct clocksource *cs)
8246 + {
8247 + return get_cycles();
8248 + }
8249 +@@ -287,26 +270,9 @@ void read_persistent_clock(struct timespec *ts)
8250 + }
8251 +
8252 +
8253 +-/*
8254 +- * sched_clock() framework
8255 +- */
8256 +-
8257 +-static u32 cyc2ns_mul __read_mostly;
8258 +-static u32 cyc2ns_shift __read_mostly;
8259 +-
8260 +-u64 sched_clock(void)
8261 ++static u64 notrace read_cr16_sched_clock(void)
8262 + {
8263 +- u64 now;
8264 +-
8265 +- /* Get current cycle counter (Control Register 16). */
8266 +-#ifdef CONFIG_64BIT
8267 +- now = mfctl(16);
8268 +-#else
8269 +- now = mfctl(16) + (((u64) this_cpu_read(cr16_high_32_bits)) << 32);
8270 +-#endif
8271 +-
8272 +- /* return the value in ns (cycles_2_ns) */
8273 +- return mul_u64_u32_shr(now, cyc2ns_mul, cyc2ns_shift);
8274 ++ return get_cycles();
8275 + }
8276 +
8277 +
8278 +@@ -316,17 +282,16 @@ u64 sched_clock(void)
8279 +
8280 + void __init time_init(void)
8281 + {
8282 +- unsigned long current_cr16_khz;
8283 ++ unsigned long cr16_hz;
8284 +
8285 +- current_cr16_khz = PAGE0->mem_10msec/10; /* kHz */
8286 + clocktick = (100 * PAGE0->mem_10msec) / HZ;
8287 +-
8288 +- /* calculate mult/shift values for cr16 */
8289 +- clocks_calc_mult_shift(&cyc2ns_mul, &cyc2ns_shift, current_cr16_khz,
8290 +- NSEC_PER_MSEC, 0);
8291 +-
8292 + start_cpu_itimer(); /* get CPU 0 started */
8293 +
8294 ++ cr16_hz = 100 * PAGE0->mem_10msec; /* Hz */
8295 ++
8296 + /* register at clocksource framework */
8297 +- clocksource_register_khz(&clocksource_cr16, current_cr16_khz);
8298 ++ clocksource_register_hz(&clocksource_cr16, cr16_hz);
8299 ++
8300 ++ /* register as sched_clock source */
8301 ++ sched_clock_register(read_cr16_sched_clock, BITS_PER_LONG, cr16_hz);
8302 + }
8303 +diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
8304 +index d80161b..60522d2 100644
8305 +--- a/arch/powerpc/boot/main.c
8306 ++++ b/arch/powerpc/boot/main.c
8307 +@@ -217,8 +217,12 @@ void start(void)
8308 + console_ops.close();
8309 +
8310 + kentry = (kernel_entry_t) vmlinux.addr;
8311 +- if (ft_addr)
8312 +- kentry(ft_addr, 0, NULL);
8313 ++ if (ft_addr) {
8314 ++ if(platform_ops.kentry)
8315 ++ platform_ops.kentry(ft_addr, vmlinux.addr);
8316 ++ else
8317 ++ kentry(ft_addr, 0, NULL);
8318 ++ }
8319 + else
8320 + kentry((unsigned long)initrd.addr, initrd.size,
8321 + loader_info.promptr);
8322 +diff --git a/arch/powerpc/boot/opal-calls.S b/arch/powerpc/boot/opal-calls.S
8323 +index ff2f1b9..2a99fc9 100644
8324 +--- a/arch/powerpc/boot/opal-calls.S
8325 ++++ b/arch/powerpc/boot/opal-calls.S
8326 +@@ -12,6 +12,19 @@
8327 +
8328 + .text
8329 +
8330 ++ .globl opal_kentry
8331 ++opal_kentry:
8332 ++ /* r3 is the fdt ptr */
8333 ++ mtctr r4
8334 ++ li r4, 0
8335 ++ li r5, 0
8336 ++ li r6, 0
8337 ++ li r7, 0
8338 ++ ld r11,opal@got(r2)
8339 ++ ld r8,0(r11)
8340 ++ ld r9,8(r11)
8341 ++ bctr
8342 ++
8343 + #define OPAL_CALL(name, token) \
8344 + .globl name; \
8345 + name: \
8346 +diff --git a/arch/powerpc/boot/opal.c b/arch/powerpc/boot/opal.c
8347 +index 1f37e1c..d7b4fd4 100644
8348 +--- a/arch/powerpc/boot/opal.c
8349 ++++ b/arch/powerpc/boot/opal.c
8350 +@@ -23,14 +23,25 @@ struct opal {
8351 +
8352 + static u32 opal_con_id;
8353 +
8354 ++/* see opal-wrappers.S */
8355 + int64_t opal_console_write(int64_t term_number, u64 *length, const u8 *buffer);
8356 + int64_t opal_console_read(int64_t term_number, uint64_t *length, u8 *buffer);
8357 + int64_t opal_console_write_buffer_space(uint64_t term_number, uint64_t *length);
8358 + int64_t opal_console_flush(uint64_t term_number);
8359 + int64_t opal_poll_events(uint64_t *outstanding_event_mask);
8360 +
8361 ++void opal_kentry(unsigned long fdt_addr, void *vmlinux_addr);
8362 ++
8363 + static int opal_con_open(void)
8364 + {
8365 ++ /*
8366 ++ * When OPAL loads the boot kernel it stashes the OPAL base and entry
8367 ++ * address in r8 and r9 so the kernel can use the OPAL console
8368 ++ * before unflattening the devicetree. While executing the wrapper will
8369 ++ * probably trash r8 and r9 so this kentry hook restores them before
8370 ++ * entering the decompressed kernel.
8371 ++ */
8372 ++ platform_ops.kentry = opal_kentry;
8373 + return 0;
8374 + }
8375 +
8376 +diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
8377 +index e19b64e..deeae6f 100644
8378 +--- a/arch/powerpc/boot/ops.h
8379 ++++ b/arch/powerpc/boot/ops.h
8380 +@@ -30,6 +30,7 @@ struct platform_ops {
8381 + void * (*realloc)(void *ptr, unsigned long size);
8382 + void (*exit)(void);
8383 + void * (*vmlinux_alloc)(unsigned long size);
8384 ++ void (*kentry)(unsigned long fdt_addr, void *vmlinux_addr);
8385 + };
8386 + extern struct platform_ops platform_ops;
8387 +
8388 +diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
8389 +index e2fb408..fd10b58 100644
8390 +--- a/arch/powerpc/include/asm/mmu.h
8391 ++++ b/arch/powerpc/include/asm/mmu.h
8392 +@@ -29,6 +29,12 @@
8393 + */
8394 +
8395 + /*
8396 ++ * Kernel read only support.
8397 ++ * We added the ppp value 0b110 in ISA 2.04.
8398 ++ */
8399 ++#define MMU_FTR_KERNEL_RO ASM_CONST(0x00004000)
8400 ++
8401 ++/*
8402 + * We need to clear top 16bits of va (from the remaining 64 bits )in
8403 + * tlbie* instructions
8404 + */
8405 +@@ -103,10 +109,10 @@
8406 + #define MMU_FTRS_POWER4 MMU_FTRS_DEFAULT_HPTE_ARCH_V2
8407 + #define MMU_FTRS_PPC970 MMU_FTRS_POWER4 | MMU_FTR_TLBIE_CROP_VA
8408 + #define MMU_FTRS_POWER5 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE
8409 +-#define MMU_FTRS_POWER6 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE
8410 +-#define MMU_FTRS_POWER7 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE
8411 +-#define MMU_FTRS_POWER8 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE
8412 +-#define MMU_FTRS_POWER9 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE
8413 ++#define MMU_FTRS_POWER6 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_KERNEL_RO
8414 ++#define MMU_FTRS_POWER7 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_KERNEL_RO
8415 ++#define MMU_FTRS_POWER8 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_KERNEL_RO
8416 ++#define MMU_FTRS_POWER9 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_KERNEL_RO
8417 + #define MMU_FTRS_CELL MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \
8418 + MMU_FTR_CI_LARGE_PAGE
8419 + #define MMU_FTRS_PA6T MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \
8420 +diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
8421 +index 978dada..52cbf04 100644
8422 +--- a/arch/powerpc/include/asm/reg.h
8423 ++++ b/arch/powerpc/include/asm/reg.h
8424 +@@ -355,6 +355,7 @@
8425 + #define LPCR_PECE0 ASM_CONST(0x0000000000004000) /* ext. exceptions can cause exit */
8426 + #define LPCR_PECE1 ASM_CONST(0x0000000000002000) /* decrementer can cause exit */
8427 + #define LPCR_PECE2 ASM_CONST(0x0000000000001000) /* machine check etc can cause exit */
8428 ++#define LPCR_PECE_HVEE ASM_CONST(0x0000400000000000) /* P9 Wakeup on HV interrupts */
8429 + #define LPCR_MER ASM_CONST(0x0000000000000800) /* Mediated External Exception */
8430 + #define LPCR_MER_SH 11
8431 + #define LPCR_TC ASM_CONST(0x0000000000000200) /* Translation control */
8432 +diff --git a/arch/powerpc/kernel/cpu_setup_power.S b/arch/powerpc/kernel/cpu_setup_power.S
8433 +index 52ff3f0..37c027c 100644
8434 +--- a/arch/powerpc/kernel/cpu_setup_power.S
8435 ++++ b/arch/powerpc/kernel/cpu_setup_power.S
8436 +@@ -98,8 +98,8 @@ _GLOBAL(__setup_cpu_power9)
8437 + li r0,0
8438 + mtspr SPRN_LPID,r0
8439 + mfspr r3,SPRN_LPCR
8440 +- ori r3, r3, LPCR_PECEDH
8441 +- ori r3, r3, LPCR_HVICE
8442 ++ LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE)
8443 ++ or r3, r3, r4
8444 + bl __init_LPCR
8445 + bl __init_HFSCR
8446 + bl __init_tlb_power9
8447 +@@ -118,8 +118,8 @@ _GLOBAL(__restore_cpu_power9)
8448 + li r0,0
8449 + mtspr SPRN_LPID,r0
8450 + mfspr r3,SPRN_LPCR
8451 +- ori r3, r3, LPCR_PECEDH
8452 +- ori r3, r3, LPCR_HVICE
8453 ++ LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE)
8454 ++ or r3, r3, r4
8455 + bl __init_LPCR
8456 + bl __init_HFSCR
8457 + bl __init_tlb_power9
8458 +diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
8459 +index 28923b2..8dff9ce 100644
8460 +--- a/arch/powerpc/mm/hash_utils_64.c
8461 ++++ b/arch/powerpc/mm/hash_utils_64.c
8462 +@@ -190,8 +190,12 @@ unsigned long htab_convert_pte_flags(unsigned long pteflags)
8463 + /*
8464 + * Kernel read only mapped with ppp bits 0b110
8465 + */
8466 +- if (!(pteflags & _PAGE_WRITE))
8467 +- rflags |= (HPTE_R_PP0 | 0x2);
8468 ++ if (!(pteflags & _PAGE_WRITE)) {
8469 ++ if (mmu_has_feature(MMU_FTR_KERNEL_RO))
8470 ++ rflags |= (HPTE_R_PP0 | 0x2);
8471 ++ else
8472 ++ rflags |= 0x3;
8473 ++ }
8474 + } else {
8475 + if (pteflags & _PAGE_RWX)
8476 + rflags |= 0x2;
8477 +diff --git a/arch/tile/kernel/time.c b/arch/tile/kernel/time.c
8478 +index 178989e..ea960d6 100644
8479 +--- a/arch/tile/kernel/time.c
8480 ++++ b/arch/tile/kernel/time.c
8481 +@@ -218,8 +218,8 @@ void do_timer_interrupt(struct pt_regs *regs, int fault_num)
8482 + */
8483 + unsigned long long sched_clock(void)
8484 + {
8485 +- return clocksource_cyc2ns(get_cycles(),
8486 +- sched_clock_mult, SCHED_CLOCK_SHIFT);
8487 ++ return mult_frac(get_cycles(),
8488 ++ sched_clock_mult, 1ULL << SCHED_CLOCK_SHIFT);
8489 + }
8490 +
8491 + int setup_profiling_timer(unsigned int multiplier)
8492 +diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c
8493 +index 9b983a4..8fc714b 100644
8494 +--- a/arch/x86/events/intel/ds.c
8495 ++++ b/arch/x86/events/intel/ds.c
8496 +@@ -1070,20 +1070,20 @@ static void setup_pebs_sample_data(struct perf_event *event,
8497 + }
8498 +
8499 + /*
8500 +- * We use the interrupt regs as a base because the PEBS record
8501 +- * does not contain a full regs set, specifically it seems to
8502 +- * lack segment descriptors, which get used by things like
8503 +- * user_mode().
8504 ++ * We use the interrupt regs as a base because the PEBS record does not
8505 ++ * contain a full regs set, specifically it seems to lack segment
8506 ++ * descriptors, which get used by things like user_mode().
8507 + *
8508 +- * In the simple case fix up only the IP and BP,SP regs, for
8509 +- * PERF_SAMPLE_IP and PERF_SAMPLE_CALLCHAIN to function properly.
8510 +- * A possible PERF_SAMPLE_REGS will have to transfer all regs.
8511 ++ * In the simple case fix up only the IP for PERF_SAMPLE_IP.
8512 ++ *
8513 ++ * We must however always use BP,SP from iregs for the unwinder to stay
8514 ++ * sane; the record BP,SP can point into thin air when the record is
8515 ++ * from a previous PMI context or an (I)RET happend between the record
8516 ++ * and PMI.
8517 + */
8518 + *regs = *iregs;
8519 + regs->flags = pebs->flags;
8520 + set_linear_ip(regs, pebs->ip);
8521 +- regs->bp = pebs->bp;
8522 +- regs->sp = pebs->sp;
8523 +
8524 + if (sample_type & PERF_SAMPLE_REGS_INTR) {
8525 + regs->ax = pebs->ax;
8526 +@@ -1092,10 +1092,21 @@ static void setup_pebs_sample_data(struct perf_event *event,
8527 + regs->dx = pebs->dx;
8528 + regs->si = pebs->si;
8529 + regs->di = pebs->di;
8530 +- regs->bp = pebs->bp;
8531 +- regs->sp = pebs->sp;
8532 +
8533 +- regs->flags = pebs->flags;
8534 ++ /*
8535 ++ * Per the above; only set BP,SP if we don't need callchains.
8536 ++ *
8537 ++ * XXX: does this make sense?
8538 ++ */
8539 ++ if (!(sample_type & PERF_SAMPLE_CALLCHAIN)) {
8540 ++ regs->bp = pebs->bp;
8541 ++ regs->sp = pebs->sp;
8542 ++ }
8543 ++
8544 ++ /*
8545 ++ * Preserve PERF_EFLAGS_VM from set_linear_ip().
8546 ++ */
8547 ++ regs->flags = pebs->flags | (regs->flags & PERF_EFLAGS_VM);
8548 + #ifndef CONFIG_X86_32
8549 + regs->r8 = pebs->r8;
8550 + regs->r9 = pebs->r9;
8551 +diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h
8552 +index 8c4a477..181c238 100644
8553 +--- a/arch/x86/events/perf_event.h
8554 ++++ b/arch/x86/events/perf_event.h
8555 +@@ -113,7 +113,7 @@ struct debug_store {
8556 + * Per register state.
8557 + */
8558 + struct er_account {
8559 +- raw_spinlock_t lock; /* per-core: protect structure */
8560 ++ raw_spinlock_t lock; /* per-core: protect structure */
8561 + u64 config; /* extra MSR config */
8562 + u64 reg; /* extra MSR number */
8563 + atomic_t ref; /* reference count */
8564 +diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
8565 +index 3fc03a0..c289e2f 100644
8566 +--- a/arch/x86/kernel/fpu/core.c
8567 ++++ b/arch/x86/kernel/fpu/core.c
8568 +@@ -517,14 +517,14 @@ void fpu__clear(struct fpu *fpu)
8569 + {
8570 + WARN_ON_FPU(fpu != &current->thread.fpu); /* Almost certainly an anomaly */
8571 +
8572 +- if (!use_eager_fpu() || !static_cpu_has(X86_FEATURE_FPU)) {
8573 +- /* FPU state will be reallocated lazily at the first use. */
8574 +- fpu__drop(fpu);
8575 +- } else {
8576 +- if (!fpu->fpstate_active) {
8577 +- fpu__activate_curr(fpu);
8578 +- user_fpu_begin();
8579 +- }
8580 ++ fpu__drop(fpu);
8581 ++
8582 ++ /*
8583 ++ * Make sure fpstate is cleared and initialized.
8584 ++ */
8585 ++ if (static_cpu_has(X86_FEATURE_FPU)) {
8586 ++ fpu__activate_curr(fpu);
8587 ++ user_fpu_begin();
8588 + copy_init_fpstate_to_fpregs();
8589 + }
8590 + }
8591 +diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
8592 +index cbd7b92..a3ce9d2 100644
8593 +--- a/arch/x86/kvm/emulate.c
8594 ++++ b/arch/x86/kvm/emulate.c
8595 +@@ -2105,16 +2105,10 @@ static int em_iret(struct x86_emulate_ctxt *ctxt)
8596 + static int em_jmp_far(struct x86_emulate_ctxt *ctxt)
8597 + {
8598 + int rc;
8599 +- unsigned short sel, old_sel;
8600 +- struct desc_struct old_desc, new_desc;
8601 +- const struct x86_emulate_ops *ops = ctxt->ops;
8602 ++ unsigned short sel;
8603 ++ struct desc_struct new_desc;
8604 + u8 cpl = ctxt->ops->cpl(ctxt);
8605 +
8606 +- /* Assignment of RIP may only fail in 64-bit mode */
8607 +- if (ctxt->mode == X86EMUL_MODE_PROT64)
8608 +- ops->get_segment(ctxt, &old_sel, &old_desc, NULL,
8609 +- VCPU_SREG_CS);
8610 +-
8611 + memcpy(&sel, ctxt->src.valptr + ctxt->op_bytes, 2);
8612 +
8613 + rc = __load_segment_descriptor(ctxt, sel, VCPU_SREG_CS, cpl,
8614 +@@ -2124,12 +2118,10 @@ static int em_jmp_far(struct x86_emulate_ctxt *ctxt)
8615 + return rc;
8616 +
8617 + rc = assign_eip_far(ctxt, ctxt->src.val, &new_desc);
8618 +- if (rc != X86EMUL_CONTINUE) {
8619 +- WARN_ON(ctxt->mode != X86EMUL_MODE_PROT64);
8620 +- /* assigning eip failed; restore the old cs */
8621 +- ops->set_segment(ctxt, old_sel, &old_desc, 0, VCPU_SREG_CS);
8622 +- return rc;
8623 +- }
8624 ++ /* Error handling is not implemented. */
8625 ++ if (rc != X86EMUL_CONTINUE)
8626 ++ return X86EMUL_UNHANDLEABLE;
8627 ++
8628 + return rc;
8629 + }
8630 +
8631 +@@ -2189,14 +2181,8 @@ static int em_ret_far(struct x86_emulate_ctxt *ctxt)
8632 + {
8633 + int rc;
8634 + unsigned long eip, cs;
8635 +- u16 old_cs;
8636 + int cpl = ctxt->ops->cpl(ctxt);
8637 +- struct desc_struct old_desc, new_desc;
8638 +- const struct x86_emulate_ops *ops = ctxt->ops;
8639 +-
8640 +- if (ctxt->mode == X86EMUL_MODE_PROT64)
8641 +- ops->get_segment(ctxt, &old_cs, &old_desc, NULL,
8642 +- VCPU_SREG_CS);
8643 ++ struct desc_struct new_desc;
8644 +
8645 + rc = emulate_pop(ctxt, &eip, ctxt->op_bytes);
8646 + if (rc != X86EMUL_CONTINUE)
8647 +@@ -2213,10 +2199,10 @@ static int em_ret_far(struct x86_emulate_ctxt *ctxt)
8648 + if (rc != X86EMUL_CONTINUE)
8649 + return rc;
8650 + rc = assign_eip_far(ctxt, eip, &new_desc);
8651 +- if (rc != X86EMUL_CONTINUE) {
8652 +- WARN_ON(ctxt->mode != X86EMUL_MODE_PROT64);
8653 +- ops->set_segment(ctxt, old_cs, &old_desc, 0, VCPU_SREG_CS);
8654 +- }
8655 ++ /* Error handling is not implemented. */
8656 ++ if (rc != X86EMUL_CONTINUE)
8657 ++ return X86EMUL_UNHANDLEABLE;
8658 ++
8659 + return rc;
8660 + }
8661 +
8662 +diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c
8663 +index 1a22de7..6e219e5 100644
8664 +--- a/arch/x86/kvm/ioapic.c
8665 ++++ b/arch/x86/kvm/ioapic.c
8666 +@@ -94,7 +94,7 @@ static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,
8667 + static void rtc_irq_eoi_tracking_reset(struct kvm_ioapic *ioapic)
8668 + {
8669 + ioapic->rtc_status.pending_eoi = 0;
8670 +- bitmap_zero(ioapic->rtc_status.dest_map.map, KVM_MAX_VCPUS);
8671 ++ bitmap_zero(ioapic->rtc_status.dest_map.map, KVM_MAX_VCPU_ID);
8672 + }
8673 +
8674 + static void kvm_rtc_eoi_tracking_restore_all(struct kvm_ioapic *ioapic);
8675 +diff --git a/arch/x86/kvm/ioapic.h b/arch/x86/kvm/ioapic.h
8676 +index 7d2692a..1cc6e54 100644
8677 +--- a/arch/x86/kvm/ioapic.h
8678 ++++ b/arch/x86/kvm/ioapic.h
8679 +@@ -42,13 +42,13 @@ struct kvm_vcpu;
8680 +
8681 + struct dest_map {
8682 + /* vcpu bitmap where IRQ has been sent */
8683 +- DECLARE_BITMAP(map, KVM_MAX_VCPUS);
8684 ++ DECLARE_BITMAP(map, KVM_MAX_VCPU_ID);
8685 +
8686 + /*
8687 + * Vector sent to a given vcpu, only valid when
8688 + * the vcpu's bit in map is set
8689 + */
8690 +- u8 vectors[KVM_MAX_VCPUS];
8691 ++ u8 vectors[KVM_MAX_VCPU_ID];
8692 + };
8693 +
8694 +
8695 +diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c
8696 +index 25810b1..e7a112a 100644
8697 +--- a/arch/x86/kvm/irq_comm.c
8698 ++++ b/arch/x86/kvm/irq_comm.c
8699 +@@ -41,6 +41,15 @@ static int kvm_set_pic_irq(struct kvm_kernel_irq_routing_entry *e,
8700 + bool line_status)
8701 + {
8702 + struct kvm_pic *pic = pic_irqchip(kvm);
8703 ++
8704 ++ /*
8705 ++ * XXX: rejecting pic routes when pic isn't in use would be better,
8706 ++ * but the default routing table is installed while kvm->arch.vpic is
8707 ++ * NULL and KVM_CREATE_IRQCHIP can race with KVM_IRQ_LINE.
8708 ++ */
8709 ++ if (!pic)
8710 ++ return -1;
8711 ++
8712 + return kvm_pic_set_irq(pic, e->irqchip.pin, irq_source_id, level);
8713 + }
8714 +
8715 +@@ -49,6 +58,10 @@ static int kvm_set_ioapic_irq(struct kvm_kernel_irq_routing_entry *e,
8716 + bool line_status)
8717 + {
8718 + struct kvm_ioapic *ioapic = kvm->arch.vioapic;
8719 ++
8720 ++ if (!ioapic)
8721 ++ return -1;
8722 ++
8723 + return kvm_ioapic_set_irq(ioapic, e->irqchip.pin, irq_source_id, level,
8724 + line_status);
8725 + }
8726 +diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
8727 +index b62c852..d2255e4 100644
8728 +--- a/arch/x86/kvm/lapic.c
8729 ++++ b/arch/x86/kvm/lapic.c
8730 +@@ -138,7 +138,7 @@ static inline bool kvm_apic_map_get_logical_dest(struct kvm_apic_map *map,
8731 + *mask = dest_id & 0xff;
8732 + return true;
8733 + case KVM_APIC_MODE_XAPIC_CLUSTER:
8734 +- *cluster = map->xapic_cluster_map[dest_id >> 4];
8735 ++ *cluster = map->xapic_cluster_map[(dest_id >> 4) & 0xf];
8736 + *mask = dest_id & 0xf;
8737 + return true;
8738 + default:
8739 +diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
8740 +index 832b98f..a3a983f 100644
8741 +--- a/arch/x86/mm/extable.c
8742 ++++ b/arch/x86/mm/extable.c
8743 +@@ -135,7 +135,12 @@ void __init early_fixup_exception(struct pt_regs *regs, int trapnr)
8744 + if (early_recursion_flag > 2)
8745 + goto halt_loop;
8746 +
8747 +- if (regs->cs != __KERNEL_CS)
8748 ++ /*
8749 ++ * Old CPUs leave the high bits of CS on the stack
8750 ++ * undefined. I'm not sure which CPUs do this, but at least
8751 ++ * the 486 DX works this way.
8752 ++ */
8753 ++ if ((regs->cs & 0xFFFF) != __KERNEL_CS)
8754 + goto fail;
8755 +
8756 + /*
8757 +diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
8758 +index 865f46e..c80765b 100644
8759 +--- a/crypto/asymmetric_keys/x509_cert_parser.c
8760 ++++ b/crypto/asymmetric_keys/x509_cert_parser.c
8761 +@@ -133,7 +133,6 @@ struct x509_certificate *x509_cert_parse(const void *data, size_t datalen)
8762 + return cert;
8763 +
8764 + error_decode:
8765 +- kfree(cert->pub->key);
8766 + kfree(ctx);
8767 + error_no_ctx:
8768 + x509_free_certificate(cert);
8769 +diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c
8770 +index 29f600f..ff64313 100644
8771 +--- a/drivers/dax/dax.c
8772 ++++ b/drivers/dax/dax.c
8773 +@@ -323,8 +323,8 @@ static int check_vma(struct dax_dev *dax_dev, struct vm_area_struct *vma,
8774 + if (!dax_dev->alive)
8775 + return -ENXIO;
8776 +
8777 +- /* prevent private / writable mappings from being established */
8778 +- if ((vma->vm_flags & (VM_NORESERVE|VM_SHARED|VM_WRITE)) == VM_WRITE) {
8779 ++ /* prevent private mappings from being established */
8780 ++ if ((vma->vm_flags & VM_SHARED) != VM_SHARED) {
8781 + dev_info(dev, "%s: %s: fail, attempted private mapping\n",
8782 + current->comm, func);
8783 + return -EINVAL;
8784 +diff --git a/drivers/dax/pmem.c b/drivers/dax/pmem.c
8785 +index 73ae849..76dd42d 100644
8786 +--- a/drivers/dax/pmem.c
8787 ++++ b/drivers/dax/pmem.c
8788 +@@ -77,7 +77,9 @@ static int dax_pmem_probe(struct device *dev)
8789 + nsio = to_nd_namespace_io(&ndns->dev);
8790 +
8791 + /* parse the 'pfn' info block via ->rw_bytes */
8792 +- devm_nsio_enable(dev, nsio);
8793 ++ rc = devm_nsio_enable(dev, nsio);
8794 ++ if (rc)
8795 ++ return rc;
8796 + altmap = nvdimm_setup_pfn(nd_pfn, &res, &__altmap);
8797 + if (IS_ERR(altmap))
8798 + return PTR_ERR(altmap);
8799 +diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
8800 +index 58470f5..8c53748 100644
8801 +--- a/drivers/iommu/dmar.c
8802 ++++ b/drivers/iommu/dmar.c
8803 +@@ -338,7 +338,9 @@ static int dmar_pci_bus_notifier(struct notifier_block *nb,
8804 + struct pci_dev *pdev = to_pci_dev(data);
8805 + struct dmar_pci_notify_info *info;
8806 +
8807 +- /* Only care about add/remove events for physical functions */
8808 ++ /* Only care about add/remove events for physical functions.
8809 ++ * For VFs we actually do the lookup based on the corresponding
8810 ++ * PF in device_to_iommu() anyway. */
8811 + if (pdev->is_virtfn)
8812 + return NOTIFY_DONE;
8813 + if (action != BUS_NOTIFY_ADD_DEVICE &&
8814 +diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
8815 +index 1257b0b..7fb5387 100644
8816 +--- a/drivers/iommu/intel-iommu.c
8817 ++++ b/drivers/iommu/intel-iommu.c
8818 +@@ -892,7 +892,13 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf
8819 + return NULL;
8820 +
8821 + if (dev_is_pci(dev)) {
8822 ++ struct pci_dev *pf_pdev;
8823 ++
8824 + pdev = to_pci_dev(dev);
8825 ++ /* VFs aren't listed in scope tables; we need to look up
8826 ++ * the PF instead to find the IOMMU. */
8827 ++ pf_pdev = pci_physfn(pdev);
8828 ++ dev = &pf_pdev->dev;
8829 + segment = pci_domain_nr(pdev->bus);
8830 + } else if (has_acpi_companion(dev))
8831 + dev = &ACPI_COMPANION(dev)->dev;
8832 +@@ -905,6 +911,13 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf
8833 + for_each_active_dev_scope(drhd->devices,
8834 + drhd->devices_cnt, i, tmp) {
8835 + if (tmp == dev) {
8836 ++ /* For a VF use its original BDF# not that of the PF
8837 ++ * which we used for the IOMMU lookup. Strictly speaking
8838 ++ * we could do this for all PCI devices; we only need to
8839 ++ * get the BDF# from the scope table for ACPI matches. */
8840 ++ if (pdev->is_virtfn)
8841 ++ goto got_pdev;
8842 ++
8843 + *bus = drhd->devices[i].bus;
8844 + *devfn = drhd->devices[i].devfn;
8845 + goto out;
8846 +diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c
8847 +index 8ebb353..cb72e00 100644
8848 +--- a/drivers/iommu/intel-svm.c
8849 ++++ b/drivers/iommu/intel-svm.c
8850 +@@ -39,10 +39,18 @@ int intel_svm_alloc_pasid_tables(struct intel_iommu *iommu)
8851 + struct page *pages;
8852 + int order;
8853 +
8854 +- order = ecap_pss(iommu->ecap) + 7 - PAGE_SHIFT;
8855 +- if (order < 0)
8856 +- order = 0;
8857 +-
8858 ++ /* Start at 2 because it's defined as 2^(1+PSS) */
8859 ++ iommu->pasid_max = 2 << ecap_pss(iommu->ecap);
8860 ++
8861 ++ /* Eventually I'm promised we will get a multi-level PASID table
8862 ++ * and it won't have to be physically contiguous. Until then,
8863 ++ * limit the size because 8MiB contiguous allocations can be hard
8864 ++ * to come by. The limit of 0x20000, which is 1MiB for each of
8865 ++ * the PASID and PASID-state tables, is somewhat arbitrary. */
8866 ++ if (iommu->pasid_max > 0x20000)
8867 ++ iommu->pasid_max = 0x20000;
8868 ++
8869 ++ order = get_order(sizeof(struct pasid_entry) * iommu->pasid_max);
8870 + pages = alloc_pages(GFP_KERNEL | __GFP_ZERO, order);
8871 + if (!pages) {
8872 + pr_warn("IOMMU: %s: Failed to allocate PASID table\n",
8873 +@@ -53,6 +61,8 @@ int intel_svm_alloc_pasid_tables(struct intel_iommu *iommu)
8874 + pr_info("%s: Allocated order %d PASID table.\n", iommu->name, order);
8875 +
8876 + if (ecap_dis(iommu->ecap)) {
8877 ++ /* Just making it explicit... */
8878 ++ BUILD_BUG_ON(sizeof(struct pasid_entry) != sizeof(struct pasid_state_entry));
8879 + pages = alloc_pages(GFP_KERNEL | __GFP_ZERO, order);
8880 + if (pages)
8881 + iommu->pasid_state_table = page_address(pages);
8882 +@@ -68,11 +78,7 @@ int intel_svm_alloc_pasid_tables(struct intel_iommu *iommu)
8883 +
8884 + int intel_svm_free_pasid_tables(struct intel_iommu *iommu)
8885 + {
8886 +- int order;
8887 +-
8888 +- order = ecap_pss(iommu->ecap) + 7 - PAGE_SHIFT;
8889 +- if (order < 0)
8890 +- order = 0;
8891 ++ int order = get_order(sizeof(struct pasid_entry) * iommu->pasid_max);
8892 +
8893 + if (iommu->pasid_table) {
8894 + free_pages((unsigned long)iommu->pasid_table, order);
8895 +@@ -371,8 +377,8 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_
8896 + }
8897 + svm->iommu = iommu;
8898 +
8899 +- if (pasid_max > 2 << ecap_pss(iommu->ecap))
8900 +- pasid_max = 2 << ecap_pss(iommu->ecap);
8901 ++ if (pasid_max > iommu->pasid_max)
8902 ++ pasid_max = iommu->pasid_max;
8903 +
8904 + /* Do not use PASID 0 in caching mode (virtualised IOMMU) */
8905 + ret = idr_alloc(&iommu->pasid_idr, svm,
8906 +diff --git a/drivers/media/tuners/tuner-xc2028.c b/drivers/media/tuners/tuner-xc2028.c
8907 +index 317ef63..8d96a22 100644
8908 +--- a/drivers/media/tuners/tuner-xc2028.c
8909 ++++ b/drivers/media/tuners/tuner-xc2028.c
8910 +@@ -281,6 +281,14 @@ static void free_firmware(struct xc2028_data *priv)
8911 + int i;
8912 + tuner_dbg("%s called\n", __func__);
8913 +
8914 ++ /* free allocated f/w string */
8915 ++ if (priv->fname != firmware_name)
8916 ++ kfree(priv->fname);
8917 ++ priv->fname = NULL;
8918 ++
8919 ++ priv->state = XC2028_NO_FIRMWARE;
8920 ++ memset(&priv->cur_fw, 0, sizeof(priv->cur_fw));
8921 ++
8922 + if (!priv->firm)
8923 + return;
8924 +
8925 +@@ -291,9 +299,6 @@ static void free_firmware(struct xc2028_data *priv)
8926 +
8927 + priv->firm = NULL;
8928 + priv->firm_size = 0;
8929 +- priv->state = XC2028_NO_FIRMWARE;
8930 +-
8931 +- memset(&priv->cur_fw, 0, sizeof(priv->cur_fw));
8932 + }
8933 +
8934 + static int load_all_firmwares(struct dvb_frontend *fe,
8935 +@@ -884,9 +889,8 @@ static int check_firmware(struct dvb_frontend *fe, unsigned int type,
8936 + return 0;
8937 +
8938 + fail:
8939 +- priv->state = XC2028_NO_FIRMWARE;
8940 ++ free_firmware(priv);
8941 +
8942 +- memset(&priv->cur_fw, 0, sizeof(priv->cur_fw));
8943 + if (retry_count < 8) {
8944 + msleep(50);
8945 + retry_count++;
8946 +@@ -1332,11 +1336,8 @@ static int xc2028_dvb_release(struct dvb_frontend *fe)
8947 + mutex_lock(&xc2028_list_mutex);
8948 +
8949 + /* only perform final cleanup if this is the last instance */
8950 +- if (hybrid_tuner_report_instance_count(priv) == 1) {
8951 ++ if (hybrid_tuner_report_instance_count(priv) == 1)
8952 + free_firmware(priv);
8953 +- kfree(priv->ctrl.fname);
8954 +- priv->ctrl.fname = NULL;
8955 +- }
8956 +
8957 + if (priv)
8958 + hybrid_tuner_release_state(priv);
8959 +@@ -1399,19 +1400,8 @@ static int xc2028_set_config(struct dvb_frontend *fe, void *priv_cfg)
8960 +
8961 + /*
8962 + * Copy the config data.
8963 +- * For the firmware name, keep a local copy of the string,
8964 +- * in order to avoid troubles during device release.
8965 + */
8966 +- kfree(priv->ctrl.fname);
8967 +- priv->ctrl.fname = NULL;
8968 + memcpy(&priv->ctrl, p, sizeof(priv->ctrl));
8969 +- if (p->fname) {
8970 +- priv->ctrl.fname = kstrdup(p->fname, GFP_KERNEL);
8971 +- if (priv->ctrl.fname == NULL) {
8972 +- rc = -ENOMEM;
8973 +- goto unlock;
8974 +- }
8975 +- }
8976 +
8977 + /*
8978 + * If firmware name changed, frees firmware. As free_firmware will
8979 +@@ -1426,10 +1416,15 @@ static int xc2028_set_config(struct dvb_frontend *fe, void *priv_cfg)
8980 +
8981 + if (priv->state == XC2028_NO_FIRMWARE) {
8982 + if (!firmware_name[0])
8983 +- priv->fname = priv->ctrl.fname;
8984 ++ priv->fname = kstrdup(p->fname, GFP_KERNEL);
8985 + else
8986 + priv->fname = firmware_name;
8987 +
8988 ++ if (!priv->fname) {
8989 ++ rc = -ENOMEM;
8990 ++ goto unlock;
8991 ++ }
8992 ++
8993 + rc = request_firmware_nowait(THIS_MODULE, 1,
8994 + priv->fname,
8995 + priv->i2c_props.adap->dev.parent,
8996 +diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
8997 +index 239be2f..2267601 100644
8998 +--- a/drivers/mmc/host/sdhci-of-esdhc.c
8999 ++++ b/drivers/mmc/host/sdhci-of-esdhc.c
9000 +@@ -66,6 +66,20 @@ static u32 esdhc_readl_fixup(struct sdhci_host *host,
9001 + return ret;
9002 + }
9003 + }
9004 ++ /*
9005 ++ * The DAT[3:0] line signal levels and the CMD line signal level are
9006 ++ * not compatible with standard SDHC register. The line signal levels
9007 ++ * DAT[7:0] are at bits 31:24 and the command line signal level is at
9008 ++ * bit 23. All other bits are the same as in the standard SDHC
9009 ++ * register.
9010 ++ */
9011 ++ if (spec_reg == SDHCI_PRESENT_STATE) {
9012 ++ ret = value & 0x000fffff;
9013 ++ ret |= (value >> 4) & SDHCI_DATA_LVL_MASK;
9014 ++ ret |= (value << 1) & SDHCI_CMD_LVL;
9015 ++ return ret;
9016 ++ }
9017 ++
9018 + ret = value;
9019 + return ret;
9020 + }
9021 +diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
9022 +index 0411c9f..1b3bd1c 100644
9023 +--- a/drivers/mmc/host/sdhci.h
9024 ++++ b/drivers/mmc/host/sdhci.h
9025 +@@ -73,6 +73,7 @@
9026 + #define SDHCI_DATA_LVL_MASK 0x00F00000
9027 + #define SDHCI_DATA_LVL_SHIFT 20
9028 + #define SDHCI_DATA_0_LVL_MASK 0x00100000
9029 ++#define SDHCI_CMD_LVL 0x01000000
9030 +
9031 + #define SDHCI_HOST_CONTROL 0x28
9032 + #define SDHCI_CTRL_LED 0x01
9033 +diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
9034 +index 46c0f5e..58e6029 100644
9035 +--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
9036 ++++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
9037 +@@ -3894,6 +3894,11 @@ _scsih_temp_threshold_events(struct MPT3SAS_ADAPTER *ioc,
9038 + }
9039 + }
9040 +
9041 ++static inline bool ata_12_16_cmd(struct scsi_cmnd *scmd)
9042 ++{
9043 ++ return (scmd->cmnd[0] == ATA_12 || scmd->cmnd[0] == ATA_16);
9044 ++}
9045 ++
9046 + /**
9047 + * _scsih_flush_running_cmds - completing outstanding commands.
9048 + * @ioc: per adapter object
9049 +@@ -3915,6 +3920,9 @@ _scsih_flush_running_cmds(struct MPT3SAS_ADAPTER *ioc)
9050 + if (!scmd)
9051 + continue;
9052 + count++;
9053 ++ if (ata_12_16_cmd(scmd))
9054 ++ scsi_internal_device_unblock(scmd->device,
9055 ++ SDEV_RUNNING);
9056 + mpt3sas_base_free_smid(ioc, smid);
9057 + scsi_dma_unmap(scmd);
9058 + if (ioc->pci_error_recovery)
9059 +@@ -4019,8 +4027,6 @@ _scsih_eedp_error_handling(struct scsi_cmnd *scmd, u16 ioc_status)
9060 + SAM_STAT_CHECK_CONDITION;
9061 + }
9062 +
9063 +-
9064 +-
9065 + /**
9066 + * scsih_qcmd - main scsi request entry point
9067 + * @scmd: pointer to scsi command object
9068 +@@ -4047,6 +4053,13 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
9069 + if (ioc->logging_level & MPT_DEBUG_SCSI)
9070 + scsi_print_command(scmd);
9071 +
9072 ++ /*
9073 ++ * Lock the device for any subsequent command until command is
9074 ++ * done.
9075 ++ */
9076 ++ if (ata_12_16_cmd(scmd))
9077 ++ scsi_internal_device_block(scmd->device);
9078 ++
9079 + sas_device_priv_data = scmd->device->hostdata;
9080 + if (!sas_device_priv_data || !sas_device_priv_data->sas_target) {
9081 + scmd->result = DID_NO_CONNECT << 16;
9082 +@@ -4622,6 +4635,9 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
9083 + if (scmd == NULL)
9084 + return 1;
9085 +
9086 ++ if (ata_12_16_cmd(scmd))
9087 ++ scsi_internal_device_unblock(scmd->device, SDEV_RUNNING);
9088 ++
9089 + mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
9090 +
9091 + if (mpi_reply == NULL) {
9092 +diff --git a/drivers/thermal/intel_powerclamp.c b/drivers/thermal/intel_powerclamp.c
9093 +index 7a22307..afada65 100644
9094 +--- a/drivers/thermal/intel_powerclamp.c
9095 ++++ b/drivers/thermal/intel_powerclamp.c
9096 +@@ -669,9 +669,16 @@ static struct thermal_cooling_device_ops powerclamp_cooling_ops = {
9097 + .set_cur_state = powerclamp_set_cur_state,
9098 + };
9099 +
9100 ++static const struct x86_cpu_id __initconst intel_powerclamp_ids[] = {
9101 ++ { X86_VENDOR_INTEL, X86_FAMILY_ANY, X86_MODEL_ANY, X86_FEATURE_MWAIT },
9102 ++ {}
9103 ++};
9104 ++MODULE_DEVICE_TABLE(x86cpu, intel_powerclamp_ids);
9105 ++
9106 + static int __init powerclamp_probe(void)
9107 + {
9108 +- if (!boot_cpu_has(X86_FEATURE_MWAIT)) {
9109 ++
9110 ++ if (!x86_match_cpu(intel_powerclamp_ids)) {
9111 + pr_err("CPU does not support MWAIT");
9112 + return -ENODEV;
9113 + }
9114 +diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
9115 +index 69426e6..3dbb4a2 100644
9116 +--- a/drivers/usb/chipidea/core.c
9117 ++++ b/drivers/usb/chipidea/core.c
9118 +@@ -914,6 +914,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
9119 + if (!ci)
9120 + return -ENOMEM;
9121 +
9122 ++ spin_lock_init(&ci->lock);
9123 + ci->dev = dev;
9124 + ci->platdata = dev_get_platdata(dev);
9125 + ci->imx28_write_fix = !!(ci->platdata->flags &
9126 +diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
9127 +index b933568..bced28f 100644
9128 +--- a/drivers/usb/chipidea/udc.c
9129 ++++ b/drivers/usb/chipidea/udc.c
9130 +@@ -1895,8 +1895,6 @@ static int udc_start(struct ci_hdrc *ci)
9131 + struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps;
9132 + int retval = 0;
9133 +
9134 +- spin_lock_init(&ci->lock);
9135 +-
9136 + ci->gadget.ops = &usb_gadget_ops;
9137 + ci->gadget.speed = USB_SPEED_UNKNOWN;
9138 + ci->gadget.max_speed = USB_SPEED_HIGH;
9139 +diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
9140 +index f61477b..243ac5e 100644
9141 +--- a/drivers/usb/serial/cp210x.c
9142 ++++ b/drivers/usb/serial/cp210x.c
9143 +@@ -131,6 +131,7 @@ static const struct usb_device_id id_table[] = {
9144 + { USB_DEVICE(0x10C4, 0x88A4) }, /* MMB Networks ZigBee USB Device */
9145 + { USB_DEVICE(0x10C4, 0x88A5) }, /* Planet Innovation Ingeni ZigBee USB Device */
9146 + { USB_DEVICE(0x10C4, 0x8946) }, /* Ketra N1 Wireless Interface */
9147 ++ { USB_DEVICE(0x10C4, 0x8962) }, /* Brim Brothers charging dock */
9148 + { USB_DEVICE(0x10C4, 0x8977) }, /* CEL MeshWorks DevKit Device */
9149 + { USB_DEVICE(0x10C4, 0x8998) }, /* KCF Technologies PRN */
9150 + { USB_DEVICE(0x10C4, 0x8A2A) }, /* HubZ dual ZigBee and Z-Wave dongle */
9151 +diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
9152 +index 0ff7f38..6e9fc8b 100644
9153 +--- a/drivers/usb/serial/ftdi_sio.c
9154 ++++ b/drivers/usb/serial/ftdi_sio.c
9155 +@@ -1012,6 +1012,8 @@ static const struct usb_device_id id_table_combined[] = {
9156 + { USB_DEVICE(ICPDAS_VID, ICPDAS_I7561U_PID) },
9157 + { USB_DEVICE(ICPDAS_VID, ICPDAS_I7563U_PID) },
9158 + { USB_DEVICE(WICED_VID, WICED_USB20706V2_PID) },
9159 ++ { USB_DEVICE(TI_VID, TI_CC3200_LAUNCHPAD_PID),
9160 ++ .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
9161 + { } /* Terminating entry */
9162 + };
9163 +
9164 +diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
9165 +index 21011c0..48ee04c 100644
9166 +--- a/drivers/usb/serial/ftdi_sio_ids.h
9167 ++++ b/drivers/usb/serial/ftdi_sio_ids.h
9168 +@@ -596,6 +596,12 @@
9169 + #define STK541_PID 0x2109 /* Zigbee Controller */
9170 +
9171 + /*
9172 ++ * Texas Instruments
9173 ++ */
9174 ++#define TI_VID 0x0451
9175 ++#define TI_CC3200_LAUNCHPAD_PID 0xC32A /* SimpleLink Wi-Fi CC3200 LaunchPad */
9176 ++
9177 ++/*
9178 + * Blackfin gnICE JTAG
9179 + * http://docs.blackfin.uclinux.org/doku.php?id=hw:jtag:gnice
9180 + */
9181 +diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
9182 +index ffd0867..1a59f33 100644
9183 +--- a/drivers/usb/storage/transport.c
9184 ++++ b/drivers/usb/storage/transport.c
9185 +@@ -954,10 +954,15 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
9186 +
9187 + /* COMMAND STAGE */
9188 + /* let's send the command via the control pipe */
9189 ++ /*
9190 ++ * Command is sometime (f.e. after scsi_eh_prep_cmnd) on the stack.
9191 ++ * Stack may be vmallocated. So no DMA for us. Make a copy.
9192 ++ */
9193 ++ memcpy(us->iobuf, srb->cmnd, srb->cmd_len);
9194 + result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
9195 + US_CBI_ADSC,
9196 + USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0,
9197 +- us->ifnum, srb->cmnd, srb->cmd_len);
9198 ++ us->ifnum, us->iobuf, srb->cmd_len);
9199 +
9200 + /* check the return code for the command */
9201 + usb_stor_dbg(us, "Call to usb_stor_ctrl_transfer() returned %d\n",
9202 +diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
9203 +index 52a2831..48efe62 100644
9204 +--- a/fs/nfs/callback.c
9205 ++++ b/fs/nfs/callback.c
9206 +@@ -261,7 +261,7 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv,
9207 + }
9208 +
9209 + ret = -EPROTONOSUPPORT;
9210 +- if (minorversion == 0)
9211 ++ if (!IS_ENABLED(CONFIG_NFS_V4_1) || minorversion == 0)
9212 + ret = nfs4_callback_up_net(serv, net);
9213 + else if (xprt->ops->bc_up)
9214 + ret = xprt->ops->bc_up(serv, net);
9215 +diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
9216 +index 2d9b6500..d49e26c 100644
9217 +--- a/include/linux/intel-iommu.h
9218 ++++ b/include/linux/intel-iommu.h
9219 +@@ -429,6 +429,7 @@ struct intel_iommu {
9220 + struct page_req_dsc *prq;
9221 + unsigned char prq_name[16]; /* Name for PRQ interrupt */
9222 + struct idr pasid_idr;
9223 ++ u32 pasid_max;
9224 + #endif
9225 + struct q_inval *qi; /* Queued invalidation info */
9226 + u32 *iommu_state; /* Store iommu states between suspend and resume.*/
9227 +diff --git a/kernel/events/core.c b/kernel/events/core.c
9228 +index fc9bb22..f8c5f5e 100644
9229 +--- a/kernel/events/core.c
9230 ++++ b/kernel/events/core.c
9231 +@@ -7908,6 +7908,7 @@ static void perf_event_addr_filters_apply(struct perf_event *event)
9232 + * if <size> is not specified, the range is treated as a single address.
9233 + */
9234 + enum {
9235 ++ IF_ACT_NONE = -1,
9236 + IF_ACT_FILTER,
9237 + IF_ACT_START,
9238 + IF_ACT_STOP,
9239 +@@ -7931,6 +7932,7 @@ static const match_table_t if_tokens = {
9240 + { IF_SRC_KERNEL, "%u/%u" },
9241 + { IF_SRC_FILEADDR, "%u@%s" },
9242 + { IF_SRC_KERNELADDR, "%u" },
9243 ++ { IF_ACT_NONE, NULL },
9244 + };
9245 +
9246 + /*
9247 +diff --git a/lib/mpi/mpi-pow.c b/lib/mpi/mpi-pow.c
9248 +index 5464c87..e24388a 100644
9249 +--- a/lib/mpi/mpi-pow.c
9250 ++++ b/lib/mpi/mpi-pow.c
9251 +@@ -64,8 +64,13 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod)
9252 + if (!esize) {
9253 + /* Exponent is zero, result is 1 mod MOD, i.e., 1 or 0
9254 + * depending on if MOD equals 1. */
9255 +- rp[0] = 1;
9256 + res->nlimbs = (msize == 1 && mod->d[0] == 1) ? 0 : 1;
9257 ++ if (res->nlimbs) {
9258 ++ if (mpi_resize(res, 1) < 0)
9259 ++ goto enomem;
9260 ++ rp = res->d;
9261 ++ rp[0] = 1;
9262 ++ }
9263 + res->sign = 0;
9264 + goto leave;
9265 + }
9266 +diff --git a/mm/page_alloc.c b/mm/page_alloc.c
9267 +index a2214c6..7401e99 100644
9268 +--- a/mm/page_alloc.c
9269 ++++ b/mm/page_alloc.c
9270 +@@ -3161,6 +3161,16 @@ should_compact_retry(struct alloc_context *ac, unsigned int order, int alloc_fla
9271 + if (!order || order > PAGE_ALLOC_COSTLY_ORDER)
9272 + return false;
9273 +
9274 ++#ifdef CONFIG_COMPACTION
9275 ++ /*
9276 ++ * This is a gross workaround to compensate a lack of reliable compaction
9277 ++ * operation. We cannot simply go OOM with the current state of the compaction
9278 ++ * code because this can lead to pre mature OOM declaration.
9279 ++ */
9280 ++ if (order <= PAGE_ALLOC_COSTLY_ORDER)
9281 ++ return true;
9282 ++#endif
9283 ++
9284 + /*
9285 + * There are setups with compaction disabled which would prefer to loop
9286 + * inside the allocator rather than hit the oom killer prematurely.
9287 +diff --git a/net/can/bcm.c b/net/can/bcm.c
9288 +index 8af9d25..436a753 100644
9289 +--- a/net/can/bcm.c
9290 ++++ b/net/can/bcm.c
9291 +@@ -77,7 +77,7 @@
9292 + (CAN_EFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG) : \
9293 + (CAN_SFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG))
9294 +
9295 +-#define CAN_BCM_VERSION "20160617"
9296 ++#define CAN_BCM_VERSION "20161123"
9297 +
9298 + MODULE_DESCRIPTION("PF_CAN broadcast manager protocol");
9299 + MODULE_LICENSE("Dual BSD/GPL");
9300 +@@ -109,8 +109,9 @@ struct bcm_op {
9301 + u32 count;
9302 + u32 nframes;
9303 + u32 currframe;
9304 +- struct canfd_frame *frames;
9305 +- struct canfd_frame *last_frames;
9306 ++ /* void pointers to arrays of struct can[fd]_frame */
9307 ++ void *frames;
9308 ++ void *last_frames;
9309 + struct canfd_frame sframe;
9310 + struct canfd_frame last_sframe;
9311 + struct sock *sk;
9312 +@@ -681,7 +682,7 @@ static void bcm_rx_handler(struct sk_buff *skb, void *data)
9313 +
9314 + if (op->flags & RX_FILTER_ID) {
9315 + /* the easiest case */
9316 +- bcm_rx_update_and_send(op, &op->last_frames[0], rxframe);
9317 ++ bcm_rx_update_and_send(op, op->last_frames, rxframe);
9318 + goto rx_starttimer;
9319 + }
9320 +
9321 +@@ -1068,7 +1069,7 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
9322 +
9323 + if (msg_head->nframes) {
9324 + /* update CAN frames content */
9325 +- err = memcpy_from_msg((u8 *)op->frames, msg,
9326 ++ err = memcpy_from_msg(op->frames, msg,
9327 + msg_head->nframes * op->cfsiz);
9328 + if (err < 0)
9329 + return err;
9330 +@@ -1118,7 +1119,7 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
9331 + }
9332 +
9333 + if (msg_head->nframes) {
9334 +- err = memcpy_from_msg((u8 *)op->frames, msg,
9335 ++ err = memcpy_from_msg(op->frames, msg,
9336 + msg_head->nframes * op->cfsiz);
9337 + if (err < 0) {
9338 + if (op->frames != &op->sframe)
9339 +@@ -1163,6 +1164,7 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
9340 + /* check flags */
9341 +
9342 + if (op->flags & RX_RTR_FRAME) {
9343 ++ struct canfd_frame *frame0 = op->frames;
9344 +
9345 + /* no timers in RTR-mode */
9346 + hrtimer_cancel(&op->thrtimer);
9347 +@@ -1174,8 +1176,8 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
9348 + * prevent a full-load-loopback-test ... ;-]
9349 + */
9350 + if ((op->flags & TX_CP_CAN_ID) ||
9351 +- (op->frames[0].can_id == op->can_id))
9352 +- op->frames[0].can_id = op->can_id & ~CAN_RTR_FLAG;
9353 ++ (frame0->can_id == op->can_id))
9354 ++ frame0->can_id = op->can_id & ~CAN_RTR_FLAG;
9355 +
9356 + } else {
9357 + if (op->flags & SETTIMER) {
9358 +diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
9359 +index 5550a86..396aac7 100644
9360 +--- a/net/core/flow_dissector.c
9361 ++++ b/net/core/flow_dissector.c
9362 +@@ -945,4 +945,4 @@ static int __init init_default_flow_dissectors(void)
9363 + return 0;
9364 + }
9365 +
9366 +-late_initcall_sync(init_default_flow_dissectors);
9367 ++core_initcall(init_default_flow_dissectors);
9368 +diff --git a/net/wireless/core.h b/net/wireless/core.h
9369 +index eee9144..66f2a11 100644
9370 +--- a/net/wireless/core.h
9371 ++++ b/net/wireless/core.h
9372 +@@ -71,6 +71,7 @@ struct cfg80211_registered_device {
9373 + struct list_head bss_list;
9374 + struct rb_root bss_tree;
9375 + u32 bss_generation;
9376 ++ u32 bss_entries;
9377 + struct cfg80211_scan_request *scan_req; /* protected by RTNL */
9378 + struct sk_buff *scan_msg;
9379 + struct cfg80211_sched_scan_request __rcu *sched_scan_req;
9380 +diff --git a/net/wireless/scan.c b/net/wireless/scan.c
9381 +index 0358e12..438143a 100644
9382 +--- a/net/wireless/scan.c
9383 ++++ b/net/wireless/scan.c
9384 +@@ -57,6 +57,19 @@
9385 + * also linked into the probe response struct.
9386 + */
9387 +
9388 ++/*
9389 ++ * Limit the number of BSS entries stored in mac80211. Each one is
9390 ++ * a bit over 4k at most, so this limits to roughly 4-5M of memory.
9391 ++ * If somebody wants to really attack this though, they'd likely
9392 ++ * use small beacons, and only one type of frame, limiting each of
9393 ++ * the entries to a much smaller size (in order to generate more
9394 ++ * entries in total, so overhead is bigger.)
9395 ++ */
9396 ++static int bss_entries_limit = 1000;
9397 ++module_param(bss_entries_limit, int, 0644);
9398 ++MODULE_PARM_DESC(bss_entries_limit,
9399 ++ "limit to number of scan BSS entries (per wiphy, default 1000)");
9400 ++
9401 + #define IEEE80211_SCAN_RESULT_EXPIRE (30 * HZ)
9402 +
9403 + static void bss_free(struct cfg80211_internal_bss *bss)
9404 +@@ -137,6 +150,10 @@ static bool __cfg80211_unlink_bss(struct cfg80211_registered_device *rdev,
9405 +
9406 + list_del_init(&bss->list);
9407 + rb_erase(&bss->rbn, &rdev->bss_tree);
9408 ++ rdev->bss_entries--;
9409 ++ WARN_ONCE((rdev->bss_entries == 0) ^ list_empty(&rdev->bss_list),
9410 ++ "rdev bss entries[%d]/list[empty:%d] corruption\n",
9411 ++ rdev->bss_entries, list_empty(&rdev->bss_list));
9412 + bss_ref_put(rdev, bss);
9413 + return true;
9414 + }
9415 +@@ -163,6 +180,40 @@ static void __cfg80211_bss_expire(struct cfg80211_registered_device *rdev,
9416 + rdev->bss_generation++;
9417 + }
9418 +
9419 ++static bool cfg80211_bss_expire_oldest(struct cfg80211_registered_device *rdev)
9420 ++{
9421 ++ struct cfg80211_internal_bss *bss, *oldest = NULL;
9422 ++ bool ret;
9423 ++
9424 ++ lockdep_assert_held(&rdev->bss_lock);
9425 ++
9426 ++ list_for_each_entry(bss, &rdev->bss_list, list) {
9427 ++ if (atomic_read(&bss->hold))
9428 ++ continue;
9429 ++
9430 ++ if (!list_empty(&bss->hidden_list) &&
9431 ++ !bss->pub.hidden_beacon_bss)
9432 ++ continue;
9433 ++
9434 ++ if (oldest && time_before(oldest->ts, bss->ts))
9435 ++ continue;
9436 ++ oldest = bss;
9437 ++ }
9438 ++
9439 ++ if (WARN_ON(!oldest))
9440 ++ return false;
9441 ++
9442 ++ /*
9443 ++ * The callers make sure to increase rdev->bss_generation if anything
9444 ++ * gets removed (and a new entry added), so there's no need to also do
9445 ++ * it here.
9446 ++ */
9447 ++
9448 ++ ret = __cfg80211_unlink_bss(rdev, oldest);
9449 ++ WARN_ON(!ret);
9450 ++ return ret;
9451 ++}
9452 ++
9453 + void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,
9454 + bool send_message)
9455 + {
9456 +@@ -693,6 +744,7 @@ static bool cfg80211_combine_bsses(struct cfg80211_registered_device *rdev,
9457 + const u8 *ie;
9458 + int i, ssidlen;
9459 + u8 fold = 0;
9460 ++ u32 n_entries = 0;
9461 +
9462 + ies = rcu_access_pointer(new->pub.beacon_ies);
9463 + if (WARN_ON(!ies))
9464 +@@ -716,6 +768,12 @@ static bool cfg80211_combine_bsses(struct cfg80211_registered_device *rdev,
9465 + /* This is the bad part ... */
9466 +
9467 + list_for_each_entry(bss, &rdev->bss_list, list) {
9468 ++ /*
9469 ++ * we're iterating all the entries anyway, so take the
9470 ++ * opportunity to validate the list length accounting
9471 ++ */
9472 ++ n_entries++;
9473 ++
9474 + if (!ether_addr_equal(bss->pub.bssid, new->pub.bssid))
9475 + continue;
9476 + if (bss->pub.channel != new->pub.channel)
9477 +@@ -744,6 +802,10 @@ static bool cfg80211_combine_bsses(struct cfg80211_registered_device *rdev,
9478 + new->pub.beacon_ies);
9479 + }
9480 +
9481 ++ WARN_ONCE(n_entries != rdev->bss_entries,
9482 ++ "rdev bss entries[%d]/list[len:%d] corruption\n",
9483 ++ rdev->bss_entries, n_entries);
9484 ++
9485 + return true;
9486 + }
9487 +
9488 +@@ -898,7 +960,14 @@ cfg80211_bss_update(struct cfg80211_registered_device *rdev,
9489 + }
9490 + }
9491 +
9492 ++ if (rdev->bss_entries >= bss_entries_limit &&
9493 ++ !cfg80211_bss_expire_oldest(rdev)) {
9494 ++ kfree(new);
9495 ++ goto drop;
9496 ++ }
9497 ++
9498 + list_add_tail(&new->list, &rdev->bss_list);
9499 ++ rdev->bss_entries++;
9500 + rb_insert_bss(rdev, new);
9501 + found = new;
9502 + }
9503 +diff --git a/security/apparmor/domain.c b/security/apparmor/domain.c
9504 +index fc3036b..a4d90aa 100644
9505 +--- a/security/apparmor/domain.c
9506 ++++ b/security/apparmor/domain.c
9507 +@@ -621,8 +621,8 @@ int aa_change_hat(const char *hats[], int count, u64 token, bool permtest)
9508 + /* released below */
9509 + cred = get_current_cred();
9510 + cxt = cred_cxt(cred);
9511 +- profile = aa_cred_profile(cred);
9512 +- previous_profile = cxt->previous;
9513 ++ profile = aa_get_newest_profile(aa_cred_profile(cred));
9514 ++ previous_profile = aa_get_newest_profile(cxt->previous);
9515 +
9516 + if (unconfined(profile)) {
9517 + info = "unconfined";
9518 +@@ -718,6 +718,8 @@ int aa_change_hat(const char *hats[], int count, u64 token, bool permtest)
9519 + out:
9520 + aa_put_profile(hat);
9521 + kfree(name);
9522 ++ aa_put_profile(profile);
9523 ++ aa_put_profile(previous_profile);
9524 + put_cred(cred);
9525 +
9526 + return error;
9527
9528 diff --git a/4.8.11/4420_grsecurity-3.1-4.8.11-201611271225.patch b/4.8.12/4420_grsecurity-3.1-4.8.12-201612031658.patch
9529 similarity index 99%
9530 rename from 4.8.11/4420_grsecurity-3.1-4.8.11-201611271225.patch
9531 rename to 4.8.12/4420_grsecurity-3.1-4.8.12-201612031658.patch
9532 index ec53570..4ae7f33 100644
9533 --- a/4.8.11/4420_grsecurity-3.1-4.8.11-201611271225.patch
9534 +++ b/4.8.12/4420_grsecurity-3.1-4.8.12-201612031658.patch
9535 @@ -407,7 +407,7 @@ index ffab8b5..b8fcd61 100644
9536
9537 A toggle value indicating if modules are allowed to be loaded
9538 diff --git a/Makefile b/Makefile
9539 -index 2b1bcba..e6f635b 100644
9540 +index 7b0c92f..8fa3c72 100644
9541 --- a/Makefile
9542 +++ b/Makefile
9543 @@ -302,7 +302,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
9544 @@ -9160,7 +9160,7 @@ index 4ba26dd..2d1137d 100644
9545 #define PAGE_KERNEL_RO __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO)
9546 #define PAGE_KERNEL_ROX __pgprot(_PAGE_BASE | _PAGE_KERNEL_ROX)
9547 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
9548 -index 978dada..5d29335 100644
9549 +index 52cbf04..c41eb7e 100644
9550 --- a/arch/powerpc/include/asm/reg.h
9551 +++ b/arch/powerpc/include/asm/reg.h
9552 @@ -270,6 +270,7 @@
9553 @@ -19264,7 +19264,7 @@ index 3ca87b5..207a386 100644
9554
9555 static ssize_t cstate_get_attr_cpumask(struct device *dev,
9556 diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c
9557 -index 9b983a4..b31c136 100644
9558 +index 8fc714b..0ce11c3 100644
9559 --- a/arch/x86/events/intel/ds.c
9560 +++ b/arch/x86/events/intel/ds.c
9561 @@ -601,7 +601,7 @@ unlock:
9562 @@ -19293,7 +19293,7 @@ index 9b983a4..b31c136 100644
9563
9564 do {
9565 struct insn insn;
9566 -@@ -1109,7 +1110,7 @@ static void setup_pebs_sample_data(struct perf_event *event,
9567 +@@ -1120,7 +1121,7 @@ static void setup_pebs_sample_data(struct perf_event *event,
9568 }
9569
9570 if (event->attr.precise_ip > 1 && x86_pmu.intel_cap.pebs_format >= 2) {
9571 @@ -19500,7 +19500,7 @@ index 78b9c23..2f5c61e 100644
9572
9573 static inline unsigned uncore_pci_box_ctl(struct intel_uncore_box *box)
9574 diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h
9575 -index 8c4a477..bd8370d 100644
9576 +index 181c238..5634d77 100644
9577 --- a/arch/x86/events/perf_event.h
9578 +++ b/arch/x86/events/perf_event.h
9579 @@ -801,7 +801,7 @@ static inline void set_linear_ip(struct pt_regs *regs, unsigned long ip)
9580 @@ -27760,7 +27760,7 @@ index 04f89ca..43ad7de 100644
9581 unlock_done:
9582 mutex_unlock(&espfix_init_mutex);
9583 diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
9584 -index 3fc03a0..37177e4 100644
9585 +index c289e2f..e2d3af1a 100644
9586 --- a/arch/x86/kernel/fpu/core.c
9587 +++ b/arch/x86/kernel/fpu/core.c
9588 @@ -135,7 +135,7 @@ void __kernel_fpu_end(void)
9589 @@ -32767,7 +32767,7 @@ index 3235e0f..60b5e71 100644
9590
9591 out:
9592 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
9593 -index cbd7b92..d7ea4b9 100644
9594 +index a3ce9d2..0c0ef16 100644
9595 --- a/arch/x86/kvm/emulate.c
9596 +++ b/arch/x86/kvm/emulate.c
9597 @@ -971,7 +971,7 @@ static int em_bsr_c(struct x86_emulate_ctxt *ctxt)
9598 @@ -32797,7 +32797,7 @@ index cbd7b92..d7ea4b9 100644
9599 return rc;
9600 }
9601
9602 -@@ -3882,7 +3882,7 @@ static int check_cr_write(struct x86_emulate_ctxt *ctxt)
9603 +@@ -3868,7 +3868,7 @@ static int check_cr_write(struct x86_emulate_ctxt *ctxt)
9604 int cr = ctxt->modrm_reg;
9605 u64 efer = 0;
9606
9607 @@ -32806,7 +32806,7 @@ index cbd7b92..d7ea4b9 100644
9608 0xffffffff00000000ULL,
9609 0, 0, 0, /* CR3 checked later */
9610 CR4_RESERVED_BITS,
9611 -@@ -4968,7 +4968,10 @@ done_prefixes:
9612 +@@ -4954,7 +4954,10 @@ done_prefixes:
9613 if (ctxt->d == 0)
9614 return EMULATION_FAILED;
9615
9616 @@ -32818,7 +32818,7 @@ index cbd7b92..d7ea4b9 100644
9617
9618 if (unlikely(ctxt->ud) && likely(!(ctxt->d & EmulateOnUD)))
9619 return EMULATION_FAILED;
9620 -@@ -5283,15 +5286,14 @@ special_insn:
9621 +@@ -5269,15 +5272,14 @@ special_insn:
9622 else
9623 ctxt->eflags &= ~X86_EFLAGS_RF;
9624
9625 @@ -32907,7 +32907,7 @@ index 7cc2360..6ae1236 100644
9626 {
9627 struct kvm_kpic_state *s = opaque;
9628 diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c
9629 -index 1a22de7..699421c 100644
9630 +index 6e219e5..ccaf115 100644
9631 --- a/arch/x86/kvm/ioapic.c
9632 +++ b/arch/x86/kvm/ioapic.c
9633 @@ -415,6 +415,8 @@ static void kvm_ioapic_eoi_inject_work(struct work_struct *work)
9634 @@ -32920,7 +32920,7 @@ index 1a22de7..699421c 100644
9635 {
9636 struct dest_map *dest_map = &ioapic->rtc_status.dest_map;
9637 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
9638 -index b62c852..bbf49f2 100644
9639 +index d2255e4..65d458a 100644
9640 --- a/arch/x86/kvm/lapic.c
9641 +++ b/arch/x86/kvm/lapic.c
9642 @@ -57,7 +57,7 @@
9643 @@ -36144,7 +36144,7 @@ index ea9c49a..7ab033a 100644
9644 } else {
9645 walk_pud_level(m, &st, *start,
9646 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
9647 -index 832b98f..f107868 100644
9648 +index a3a983f..69f6099 100644
9649 --- a/arch/x86/mm/extable.c
9650 +++ b/arch/x86/mm/extable.c
9651 @@ -102,7 +102,7 @@ int fixup_exception(struct pt_regs *regs, int trapnr)
9652 @@ -40906,18 +40906,6 @@ index 0774799..a0012ea 100644
9653 {
9654 return jiffies_to_clock_t(q->sg_timeout);
9655 }
9656 -diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
9657 -index 865f46e..c80765b 100644
9658 ---- a/crypto/asymmetric_keys/x509_cert_parser.c
9659 -+++ b/crypto/asymmetric_keys/x509_cert_parser.c
9660 -@@ -133,7 +133,6 @@ struct x509_certificate *x509_cert_parse(const void *data, size_t datalen)
9661 - return cert;
9662 -
9663 - error_decode:
9664 -- kfree(cert->pub->key);
9665 - kfree(ctx);
9666 - error_no_ctx:
9667 - x509_free_certificate(cert);
9668 diff --git a/crypto/cast6_generic.c b/crypto/cast6_generic.c
9669 index 058c8d7..55229dd 100644
9670 --- a/crypto/cast6_generic.c
9671 @@ -75192,7 +75180,7 @@ index 750f82c..956cdf0 100644
9672 int ret = param_set_int(val, kp);
9673 struct MPT3SAS_ADAPTER *ioc;
9674 diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
9675 -index 46c0f5e..f3228ca 100644
9676 +index 58e6029..03e41fa 100644
9677 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
9678 +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
9679 @@ -280,7 +280,7 @@ struct _scsi_io_transfer {
9680 @@ -75204,7 +75192,7 @@ index 46c0f5e..f3228ca 100644
9681 {
9682 int ret = param_set_int(val, kp);
9683 struct MPT3SAS_ADAPTER *ioc;
9684 -@@ -8934,7 +8934,7 @@ scsih_resume(struct pci_dev *pdev)
9685 +@@ -8950,7 +8950,7 @@ scsih_resume(struct pci_dev *pdev)
9686 * PCI_ERS_RESULT_NEED_RESET or PCI_ERS_RESULT_DISCONNECT
9687 */
9688 pci_ers_result_t
9689 @@ -82849,7 +82837,7 @@ index 8967715..4a3791b 100644
9690 struct usb_serial *serial;
9691 int retval = -ENODEV;
9692 diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
9693 -index ffd0867..eb28464 100644
9694 +index 1a59f33..35f4c56 100644
9695 --- a/drivers/usb/storage/transport.c
9696 +++ b/drivers/usb/storage/transport.c
9697 @@ -709,7 +709,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
9698 @@ -144062,7 +144050,7 @@ index e9fdb52..cfb547d 100644
9699 new_table.data = &new_value;
9700 ret = proc_dointvec_minmax(&new_table, write, buffer, lenp, ppos);
9701 diff --git a/kernel/events/core.c b/kernel/events/core.c
9702 -index fc9bb22..bedc98b 100644
9703 +index f8c5f5e..00671d2 100644
9704 --- a/kernel/events/core.c
9705 +++ b/kernel/events/core.c
9706 @@ -389,8 +389,15 @@ static struct srcu_struct pmus_srcu;
9707 @@ -144174,7 +144162,7 @@ index fc9bb22..bedc98b 100644
9708 }
9709 if (read_format & PERF_FORMAT_ID)
9710 values[n++] = primary_event_id(event);
9711 -@@ -8562,8 +8570,7 @@ perf_event_mux_interval_ms_store(struct device *dev,
9712 +@@ -8564,8 +8572,7 @@ perf_event_mux_interval_ms_store(struct device *dev,
9713 cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu);
9714 cpuctx->hrtimer_interval = ns_to_ktime(NSEC_PER_MSEC * timer);
9715
9716 @@ -144184,7 +144172,7 @@ index fc9bb22..bedc98b 100644
9717 }
9718 put_online_cpus();
9719 mutex_unlock(&mux_interval_mutex);
9720 -@@ -9004,7 +9011,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
9721 +@@ -9006,7 +9013,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
9722 event->parent = parent_event;
9723
9724 event->ns = get_pid_ns(task_active_pid_ns(current));
9725 @@ -144193,7 +144181,7 @@ index fc9bb22..bedc98b 100644
9726
9727 event->state = PERF_EVENT_STATE_INACTIVE;
9728
9729 -@@ -9395,6 +9402,11 @@ SYSCALL_DEFINE5(perf_event_open,
9730 +@@ -9397,6 +9404,11 @@ SYSCALL_DEFINE5(perf_event_open,
9731 if (flags & ~PERF_FLAG_ALL)
9732 return -EINVAL;
9733
9734 @@ -144205,7 +144193,7 @@ index fc9bb22..bedc98b 100644
9735 err = perf_copy_attr(attr_uptr, &attr);
9736 if (err)
9737 return err;
9738 -@@ -9912,10 +9924,10 @@ static void sync_child_event(struct perf_event *child_event,
9739 +@@ -9914,10 +9926,10 @@ static void sync_child_event(struct perf_event *child_event,
9740 /*
9741 * Add back the child's count to the parent's count:
9742 */
9743 @@ -151544,25 +151532,6 @@ index 5a92189..d77978d 100644
9744 retval = 1;
9745 }
9746 spin_unlock(&lockref->lock);
9747 -diff --git a/lib/mpi/mpi-pow.c b/lib/mpi/mpi-pow.c
9748 -index 5464c87..e24388a 100644
9749 ---- a/lib/mpi/mpi-pow.c
9750 -+++ b/lib/mpi/mpi-pow.c
9751 -@@ -64,8 +64,13 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod)
9752 - if (!esize) {
9753 - /* Exponent is zero, result is 1 mod MOD, i.e., 1 or 0
9754 - * depending on if MOD equals 1. */
9755 -- rp[0] = 1;
9756 - res->nlimbs = (msize == 1 && mod->d[0] == 1) ? 0 : 1;
9757 -+ if (res->nlimbs) {
9758 -+ if (mpi_resize(res, 1) < 0)
9759 -+ goto enomem;
9760 -+ rp = res->d;
9761 -+ rp[0] = 1;
9762 -+ }
9763 - res->sign = 0;
9764 - goto leave;
9765 - }
9766 diff --git a/lib/nlattr.c b/lib/nlattr.c
9767 index fce1e9a..d44559b 100644
9768 --- a/lib/nlattr.c
9769 @@ -155157,7 +155126,7 @@ index f4cd7d8..982c35d 100644
9770 struct bdi_writeback *wb = dtc->wb;
9771 unsigned long write_bw = wb->avg_write_bandwidth;
9772 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
9773 -index a2214c6..72191b7 100644
9774 +index 7401e99..a9d6624 100644
9775 --- a/mm/page_alloc.c
9776 +++ b/mm/page_alloc.c
9777 @@ -64,6 +64,7 @@
9778 @@ -158896,10 +158865,10 @@ index 1108079..1871d16 100644
9779 };
9780
9781 diff --git a/net/can/bcm.c b/net/can/bcm.c
9782 -index 8af9d25..44e9458 100644
9783 +index 436a753..4d61e73 100644
9784 --- a/net/can/bcm.c
9785 +++ b/net/can/bcm.c
9786 -@@ -1688,7 +1688,7 @@ static int __init bcm_module_init(void)
9787 +@@ -1690,7 +1690,7 @@ static int __init bcm_module_init(void)
9788 }
9789
9790 /* create /proc/net/can-bcm directory */
9791 @@ -167525,10 +167494,10 @@ index 21e591d..f3a0afc 100644
9792 + .process_negotiate = vmci_transport_notify_pkt_process_negotiate,
9793 };
9794 diff --git a/net/wireless/scan.c b/net/wireless/scan.c
9795 -index 0358e12..db46495 100644
9796 +index 438143a..b88cdf6 100644
9797 --- a/net/wireless/scan.c
9798 +++ b/net/wireless/scan.c
9799 -@@ -1663,8 +1663,9 @@ static int ieee80211_scan_results(struct cfg80211_registered_device *rdev,
9800 +@@ -1732,8 +1732,9 @@ static int ieee80211_scan_results(struct cfg80211_registered_device *rdev,
9801
9802 int cfg80211_wext_giwscan(struct net_device *dev,
9803 struct iw_request_info *info,
9804
9805 diff --git a/4.8.11/4425_grsec_remove_EI_PAX.patch b/4.8.12/4425_grsec_remove_EI_PAX.patch
9806 similarity index 100%
9807 rename from 4.8.11/4425_grsec_remove_EI_PAX.patch
9808 rename to 4.8.12/4425_grsec_remove_EI_PAX.patch
9809
9810 diff --git a/4.8.11/4427_force_XATTR_PAX_tmpfs.patch b/4.8.12/4427_force_XATTR_PAX_tmpfs.patch
9811 similarity index 100%
9812 rename from 4.8.11/4427_force_XATTR_PAX_tmpfs.patch
9813 rename to 4.8.12/4427_force_XATTR_PAX_tmpfs.patch
9814
9815 diff --git a/4.8.11/4430_grsec-remove-localversion-grsec.patch b/4.8.12/4430_grsec-remove-localversion-grsec.patch
9816 similarity index 100%
9817 rename from 4.8.11/4430_grsec-remove-localversion-grsec.patch
9818 rename to 4.8.12/4430_grsec-remove-localversion-grsec.patch
9819
9820 diff --git a/4.8.11/4435_grsec-mute-warnings.patch b/4.8.12/4435_grsec-mute-warnings.patch
9821 similarity index 100%
9822 rename from 4.8.11/4435_grsec-mute-warnings.patch
9823 rename to 4.8.12/4435_grsec-mute-warnings.patch
9824
9825 diff --git a/4.8.11/4440_grsec-remove-protected-paths.patch b/4.8.12/4440_grsec-remove-protected-paths.patch
9826 similarity index 100%
9827 rename from 4.8.11/4440_grsec-remove-protected-paths.patch
9828 rename to 4.8.12/4440_grsec-remove-protected-paths.patch
9829
9830 diff --git a/4.8.11/4450_grsec-kconfig-default-gids.patch b/4.8.12/4450_grsec-kconfig-default-gids.patch
9831 similarity index 100%
9832 rename from 4.8.11/4450_grsec-kconfig-default-gids.patch
9833 rename to 4.8.12/4450_grsec-kconfig-default-gids.patch
9834
9835 diff --git a/4.8.11/4465_selinux-avc_audit-log-curr_ip.patch b/4.8.12/4465_selinux-avc_audit-log-curr_ip.patch
9836 similarity index 100%
9837 rename from 4.8.11/4465_selinux-avc_audit-log-curr_ip.patch
9838 rename to 4.8.12/4465_selinux-avc_audit-log-curr_ip.patch
9839
9840 diff --git a/4.8.11/4470_disable-compat_vdso.patch b/4.8.12/4470_disable-compat_vdso.patch
9841 similarity index 100%
9842 rename from 4.8.11/4470_disable-compat_vdso.patch
9843 rename to 4.8.12/4470_disable-compat_vdso.patch
9844
9845 diff --git a/4.8.11/4475_emutramp_default_on.patch b/4.8.12/4475_emutramp_default_on.patch
9846 similarity index 100%
9847 rename from 4.8.11/4475_emutramp_default_on.patch
9848 rename to 4.8.12/4475_emutramp_default_on.patch