aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-02-02 12:10:17 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-02-02 12:10:17 -0500
commitb3a54bf9ed76dff9dd26e1fc719431fb14604a8a (patch)
tree38d2b3f00c71a881f303a06dfe361c9d6d591014 /arch
parentc99197902da284b4b723451c1471c45b18537cde (diff)
parente36f014edff70fc02b3d3d79cead1d58f289332e (diff)
Merge 3.19-rc7 into usb-next
We want the USB fixes in here to make merges easier. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/alpha/kernel/pci.c8
-rw-r--r--arch/alpha/mm/fault.c2
-rw-r--r--arch/arc/mm/fault.c2
-rw-r--r--arch/arm/boot/dts/dra7.dtsi6
-rw-r--r--arch/arm/boot/dts/imx25.dtsi8
-rw-r--r--arch/arm/boot/dts/imx6sx-sdb.dts8
-rw-r--r--arch/arm/boot/dts/sun4i-a10.dtsi20
-rw-r--r--arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts6
-rw-r--r--arch/arm/boot/dts/sun5i-a10s.dtsi8
-rw-r--r--arch/arm/boot/dts/sun5i-a13-hsg-h702.dts4
-rw-r--r--arch/arm/boot/dts/sun5i-a13-olinuxino-micro.dts4
-rw-r--r--arch/arm/boot/dts/sun5i-a13-olinuxino.dts4
-rw-r--r--arch/arm/boot/dts/sun5i-a13.dtsi9
-rw-r--r--arch/arm/boot/dts/sun6i-a31.dtsi6
-rw-r--r--arch/arm/boot/dts/sun7i-a20-bananapi.dts6
-rw-r--r--arch/arm/boot/dts/sun7i-a20-hummingbird.dts8
-rw-r--r--arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts3
-rw-r--r--arch/arm/boot/dts/sun7i-a20.dtsi8
-rw-r--r--arch/arm/boot/dts/sun8i-a23-ippo-q8h-v5.dts4
-rw-r--r--arch/arm/boot/dts/sun8i-a23.dtsi9
-rw-r--r--arch/arm/boot/dts/sun9i-a80-optimus.dts5
-rw-r--r--arch/arm/boot/dts/sun9i-a80.dtsi10
-rw-r--r--arch/arm/boot/dts/tegra20-seaboard.dts2
-rw-r--r--arch/arm/include/asm/kvm_emulate.h10
-rw-r--r--arch/arm/include/asm/kvm_host.h3
-rw-r--r--arch/arm/include/asm/kvm_mmu.h77
-rw-r--r--arch/arm/kernel/entry-header.S13
-rw-r--r--arch/arm/kernel/perf_event.c10
-rw-r--r--arch/arm/kernel/setup.c7
-rw-r--r--arch/arm/kvm/arm.c10
-rw-r--r--arch/arm/kvm/coproc.c70
-rw-r--r--arch/arm/kvm/coproc.h6
-rw-r--r--arch/arm/kvm/coproc_a15.c2
-rw-r--r--arch/arm/kvm/coproc_a7.c2
-rw-r--r--arch/arm/kvm/mmu.c164
-rw-r--r--arch/arm/kvm/trace.h39
-rw-r--r--arch/arm/mach-mvebu/coherency.c14
-rw-r--r--arch/arm/mach-omap2/common.h1
-rw-r--r--arch/arm/mach-omap2/omap4-common.c32
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c10
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.h1
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_44xx_data.c5
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_54xx_data.c1
-rw-r--r--arch/arm/mach-omap2/prcm-common.h1
-rw-r--r--arch/arm/mach-omap2/prm44xx.c5
-rw-r--r--arch/arm/mach-omap2/prm_common.c14
-rw-r--r--arch/arm/mach-omap2/twl-common.c7
-rw-r--r--arch/arm/mach-shmobile/board-ape6evm.c20
-rw-r--r--arch/arm/mach-shmobile/board-lager.c13
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7778.c9
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7779.c9
-rw-r--r--arch/arm/mach-shmobile/setup-rcar-gen2.c2
-rw-r--r--arch/arm/mach-shmobile/timer.c12
-rw-r--r--arch/arm/mm/dma-mapping.c53
-rw-r--r--arch/arm64/Makefile1
-rw-r--r--arch/arm64/boot/dts/Makefile2
-rw-r--r--arch/arm64/boot/dts/arm/juno.dts2
-rw-r--r--arch/arm64/include/asm/kvm_emulate.h10
-rw-r--r--arch/arm64/include/asm/kvm_host.h3
-rw-r--r--arch/arm64/include/asm/kvm_mmu.h34
-rw-r--r--arch/arm64/kvm/sys_regs.c75
-rw-r--r--arch/arm64/mm/dump.c1
-rw-r--r--arch/avr32/kernel/module.c13
-rw-r--r--arch/avr32/mm/fault.c2
-rw-r--r--arch/cris/arch-v32/drivers/sync_serial.c2
-rw-r--r--arch/cris/kernel/module.c2
-rw-r--r--arch/cris/mm/fault.c2
-rw-r--r--arch/frv/mb93090-mb00/pci-frv.c2
-rw-r--r--arch/frv/mm/fault.c2
-rw-r--r--arch/ia64/kernel/module.c6
-rw-r--r--arch/ia64/mm/fault.c2
-rw-r--r--arch/ia64/pci/pci.c48
-rw-r--r--arch/m32r/mm/fault.c2
-rw-r--r--arch/m68k/mm/fault.c2
-rw-r--r--arch/metag/mm/fault.c2
-rw-r--r--arch/microblaze/mm/fault.c2
-rw-r--r--arch/microblaze/pci/pci-common.c13
-rw-r--r--arch/mips/mm/fault.c2
-rw-r--r--arch/mips/net/bpf_jit.c2
-rw-r--r--arch/mn10300/mm/fault.c2
-rw-r--r--arch/mn10300/unit-asb2305/pci-asb2305.c2
-rw-r--r--arch/mn10300/unit-asb2305/pci.c47
-rw-r--r--arch/nios2/kernel/module.c2
-rw-r--r--arch/nios2/kernel/signal.c2
-rw-r--r--arch/nios2/mm/fault.c2
-rw-r--r--arch/openrisc/mm/fault.c2
-rw-r--r--arch/parisc/kernel/module.c6
-rw-r--r--arch/parisc/mm/fault.c2
-rw-r--r--arch/powerpc/crypto/sha1.c1
-rw-r--r--arch/powerpc/kernel/pci-common.c12
-rw-r--r--arch/powerpc/mm/copro_fault.c2
-rw-r--r--arch/powerpc/mm/fault.c2
-rw-r--r--arch/powerpc/net/bpf_jit_comp.c2
-rw-r--r--arch/powerpc/platforms/powernv/setup.c2
-rw-r--r--arch/powerpc/xmon/xmon.c1
-rw-r--r--arch/s390/kernel/module.c10
-rw-r--r--arch/s390/mm/fault.c6
-rw-r--r--arch/s390/net/bpf_jit.S28
-rw-r--r--arch/s390/net/bpf_jit_comp.c9
-rw-r--r--arch/score/mm/fault.c2
-rw-r--r--arch/sh/mm/fault.c2
-rw-r--r--arch/sparc/kernel/pci.c5
-rw-r--r--arch/sparc/mm/fault_32.c2
-rw-r--r--arch/sparc/mm/fault_64.c2
-rw-r--r--arch/sparc/net/bpf_jit_comp.c4
-rw-r--r--arch/tile/kernel/module.c4
-rw-r--r--arch/tile/mm/fault.c2
-rw-r--r--arch/um/kernel/trap.c2
-rw-r--r--arch/x86/Kconfig6
-rw-r--r--arch/x86/boot/compressed/Makefile2
-rw-r--r--arch/x86/boot/compressed/misc.c9
-rw-r--r--arch/x86/crypto/sha-mb/sha1_mb.c2
-rw-r--r--arch/x86/include/asm/acpi.h1
-rw-r--r--arch/x86/include/asm/desc.h20
-rw-r--r--arch/x86/include/asm/mmu_context.h20
-rw-r--r--arch/x86/kernel/acpi/boot.c26
-rw-r--r--arch/x86/kernel/cpu/mshyperv.c1
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel.c1
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_rapl.c2
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_uncore.c9
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_uncore.h18
-rw-r--r--arch/x86/kernel/ftrace.c2
-rw-r--r--arch/x86/kernel/irq.c2
-rw-r--r--arch/x86/kernel/tls.c25
-rw-r--r--arch/x86/kernel/tsc.c2
-rw-r--r--arch/x86/kvm/emulate.c31
-rw-r--r--arch/x86/kvm/lapic.c3
-rw-r--r--arch/x86/mm/fault.c2
-rw-r--r--arch/x86/mm/init.c4
-rw-r--r--arch/x86/mm/mpx.c6
-rw-r--r--arch/x86/mm/pat.c7
-rw-r--r--arch/x86/pci/i386.c2
-rw-r--r--arch/x86/pci/xen.c49
-rw-r--r--arch/x86/tools/calc_run_size.pl39
-rw-r--r--arch/x86/tools/calc_run_size.sh42
-rw-r--r--arch/xtensa/mm/fault.c2
136 files changed, 954 insertions, 554 deletions
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 076c35cd6cde..98a1525fa164 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -285,8 +285,12 @@ pcibios_claim_one_bus(struct pci_bus *b)
285 if (r->parent || !r->start || !r->flags) 285 if (r->parent || !r->start || !r->flags)
286 continue; 286 continue;
287 if (pci_has_flag(PCI_PROBE_ONLY) || 287 if (pci_has_flag(PCI_PROBE_ONLY) ||
288 (r->flags & IORESOURCE_PCI_FIXED)) 288 (r->flags & IORESOURCE_PCI_FIXED)) {
289 pci_claim_resource(dev, i); 289 if (pci_claim_resource(dev, i) == 0)
290 continue;
291
292 pci_claim_bridge_resource(dev, i);
293 }
290 } 294 }
291 } 295 }
292 296
diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
index 98838a05ba6d..9d0ac091a52a 100644
--- a/arch/alpha/mm/fault.c
+++ b/arch/alpha/mm/fault.c
@@ -156,6 +156,8 @@ retry:
156 if (unlikely(fault & VM_FAULT_ERROR)) { 156 if (unlikely(fault & VM_FAULT_ERROR)) {
157 if (fault & VM_FAULT_OOM) 157 if (fault & VM_FAULT_OOM)
158 goto out_of_memory; 158 goto out_of_memory;
159 else if (fault & VM_FAULT_SIGSEGV)
160 goto bad_area;
159 else if (fault & VM_FAULT_SIGBUS) 161 else if (fault & VM_FAULT_SIGBUS)
160 goto do_sigbus; 162 goto do_sigbus;
161 BUG(); 163 BUG();
diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
index 6f7e3a68803a..563cb27e37f5 100644
--- a/arch/arc/mm/fault.c
+++ b/arch/arc/mm/fault.c
@@ -161,6 +161,8 @@ good_area:
161 161
162 if (fault & VM_FAULT_OOM) 162 if (fault & VM_FAULT_OOM)
163 goto out_of_memory; 163 goto out_of_memory;
164 else if (fault & VM_FAULT_SIGSEGV)
165 goto bad_area;
164 else if (fault & VM_FAULT_SIGBUS) 166 else if (fault & VM_FAULT_SIGBUS)
165 goto do_sigbus; 167 goto do_sigbus;
166 168
diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index 22771bc1643a..63f8b007bdc5 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -1257,6 +1257,8 @@
1257 tx-fifo-resize; 1257 tx-fifo-resize;
1258 maximum-speed = "super-speed"; 1258 maximum-speed = "super-speed";
1259 dr_mode = "otg"; 1259 dr_mode = "otg";
1260 snps,dis_u3_susphy_quirk;
1261 snps,dis_u2_susphy_quirk;
1260 }; 1262 };
1261 }; 1263 };
1262 1264
@@ -1278,6 +1280,8 @@
1278 tx-fifo-resize; 1280 tx-fifo-resize;
1279 maximum-speed = "high-speed"; 1281 maximum-speed = "high-speed";
1280 dr_mode = "otg"; 1282 dr_mode = "otg";
1283 snps,dis_u3_susphy_quirk;
1284 snps,dis_u2_susphy_quirk;
1281 }; 1285 };
1282 }; 1286 };
1283 1287
@@ -1299,6 +1303,8 @@
1299 tx-fifo-resize; 1303 tx-fifo-resize;
1300 maximum-speed = "high-speed"; 1304 maximum-speed = "high-speed";
1301 dr_mode = "otg"; 1305 dr_mode = "otg";
1306 snps,dis_u3_susphy_quirk;
1307 snps,dis_u2_susphy_quirk;
1302 }; 1308 };
1303 }; 1309 };
1304 1310
diff --git a/arch/arm/boot/dts/imx25.dtsi b/arch/arm/boot/dts/imx25.dtsi
index d238676a9107..e4d3aecc4ed2 100644
--- a/arch/arm/boot/dts/imx25.dtsi
+++ b/arch/arm/boot/dts/imx25.dtsi
@@ -369,7 +369,7 @@
369 compatible = "fsl,imx25-pwm", "fsl,imx27-pwm"; 369 compatible = "fsl,imx25-pwm", "fsl,imx27-pwm";
370 #pwm-cells = <2>; 370 #pwm-cells = <2>;
371 reg = <0x53fa0000 0x4000>; 371 reg = <0x53fa0000 0x4000>;
372 clocks = <&clks 106>, <&clks 36>; 372 clocks = <&clks 106>, <&clks 52>;
373 clock-names = "ipg", "per"; 373 clock-names = "ipg", "per";
374 interrupts = <36>; 374 interrupts = <36>;
375 }; 375 };
@@ -388,7 +388,7 @@
388 compatible = "fsl,imx25-pwm", "fsl,imx27-pwm"; 388 compatible = "fsl,imx25-pwm", "fsl,imx27-pwm";
389 #pwm-cells = <2>; 389 #pwm-cells = <2>;
390 reg = <0x53fa8000 0x4000>; 390 reg = <0x53fa8000 0x4000>;
391 clocks = <&clks 107>, <&clks 36>; 391 clocks = <&clks 107>, <&clks 52>;
392 clock-names = "ipg", "per"; 392 clock-names = "ipg", "per";
393 interrupts = <41>; 393 interrupts = <41>;
394 }; 394 };
@@ -429,7 +429,7 @@
429 pwm4: pwm@53fc8000 { 429 pwm4: pwm@53fc8000 {
430 compatible = "fsl,imx25-pwm", "fsl,imx27-pwm"; 430 compatible = "fsl,imx25-pwm", "fsl,imx27-pwm";
431 reg = <0x53fc8000 0x4000>; 431 reg = <0x53fc8000 0x4000>;
432 clocks = <&clks 108>, <&clks 36>; 432 clocks = <&clks 108>, <&clks 52>;
433 clock-names = "ipg", "per"; 433 clock-names = "ipg", "per";
434 interrupts = <42>; 434 interrupts = <42>;
435 }; 435 };
@@ -476,7 +476,7 @@
476 compatible = "fsl,imx25-pwm", "fsl,imx27-pwm"; 476 compatible = "fsl,imx25-pwm", "fsl,imx27-pwm";
477 #pwm-cells = <2>; 477 #pwm-cells = <2>;
478 reg = <0x53fe0000 0x4000>; 478 reg = <0x53fe0000 0x4000>;
479 clocks = <&clks 105>, <&clks 36>; 479 clocks = <&clks 105>, <&clks 52>;
480 clock-names = "ipg", "per"; 480 clock-names = "ipg", "per";
481 interrupts = <26>; 481 interrupts = <26>;
482 }; 482 };
diff --git a/arch/arm/boot/dts/imx6sx-sdb.dts b/arch/arm/boot/dts/imx6sx-sdb.dts
index 8c1febd7e3f2..c108bb451337 100644
--- a/arch/arm/boot/dts/imx6sx-sdb.dts
+++ b/arch/arm/boot/dts/imx6sx-sdb.dts
@@ -166,12 +166,12 @@
166 #address-cells = <1>; 166 #address-cells = <1>;
167 #size-cells = <0>; 167 #size-cells = <0>;
168 168
169 ethphy1: ethernet-phy@0 { 169 ethphy1: ethernet-phy@1 {
170 reg = <0>; 170 reg = <1>;
171 }; 171 };
172 172
173 ethphy2: ethernet-phy@1 { 173 ethphy2: ethernet-phy@2 {
174 reg = <1>; 174 reg = <2>;
175 }; 175 };
176 }; 176 };
177}; 177};
diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi
index 7b4099fcf817..d5c4669224b1 100644
--- a/arch/arm/boot/dts/sun4i-a10.dtsi
+++ b/arch/arm/boot/dts/sun4i-a10.dtsi
@@ -17,14 +17,6 @@
17 17
18 aliases { 18 aliases {
19 ethernet0 = &emac; 19 ethernet0 = &emac;
20 serial0 = &uart0;
21 serial1 = &uart1;
22 serial2 = &uart2;
23 serial3 = &uart3;
24 serial4 = &uart4;
25 serial5 = &uart5;
26 serial6 = &uart6;
27 serial7 = &uart7;
28 }; 20 };
29 21
30 chosen { 22 chosen {
@@ -39,6 +31,14 @@
39 <&ahb_gates 44>; 31 <&ahb_gates 44>;
40 status = "disabled"; 32 status = "disabled";
41 }; 33 };
34
35 framebuffer@1 {
36 compatible = "allwinner,simple-framebuffer", "simple-framebuffer";
37 allwinner,pipeline = "de_fe0-de_be0-lcd0-hdmi";
38 clocks = <&pll5 1>, <&ahb_gates 36>, <&ahb_gates 43>,
39 <&ahb_gates 44>, <&ahb_gates 46>;
40 status = "disabled";
41 };
42 }; 42 };
43 43
44 cpus { 44 cpus {
@@ -438,8 +438,8 @@
438 reg-names = "phy_ctrl", "pmu1", "pmu2"; 438 reg-names = "phy_ctrl", "pmu1", "pmu2";
439 clocks = <&usb_clk 8>; 439 clocks = <&usb_clk 8>;
440 clock-names = "usb_phy"; 440 clock-names = "usb_phy";
441 resets = <&usb_clk 1>, <&usb_clk 2>; 441 resets = <&usb_clk 0>, <&usb_clk 1>, <&usb_clk 2>;
442 reset-names = "usb1_reset", "usb2_reset"; 442 reset-names = "usb0_reset", "usb1_reset", "usb2_reset";
443 status = "disabled"; 443 status = "disabled";
444 }; 444 };
445 445
diff --git a/arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts b/arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts
index fe3c559ca6a8..bfa742817690 100644
--- a/arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts
+++ b/arch/arm/boot/dts/sun5i-a10s-olinuxino-micro.dts
@@ -55,6 +55,12 @@
55 model = "Olimex A10s-Olinuxino Micro"; 55 model = "Olimex A10s-Olinuxino Micro";
56 compatible = "olimex,a10s-olinuxino-micro", "allwinner,sun5i-a10s"; 56 compatible = "olimex,a10s-olinuxino-micro", "allwinner,sun5i-a10s";
57 57
58 aliases {
59 serial0 = &uart0;
60 serial1 = &uart2;
61 serial2 = &uart3;
62 };
63
58 soc@01c00000 { 64 soc@01c00000 {
59 emac: ethernet@01c0b000 { 65 emac: ethernet@01c0b000 {
60 pinctrl-names = "default"; 66 pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/sun5i-a10s.dtsi b/arch/arm/boot/dts/sun5i-a10s.dtsi
index 1b76667f3182..2e7d8263799d 100644
--- a/arch/arm/boot/dts/sun5i-a10s.dtsi
+++ b/arch/arm/boot/dts/sun5i-a10s.dtsi
@@ -18,10 +18,6 @@
18 18
19 aliases { 19 aliases {
20 ethernet0 = &emac; 20 ethernet0 = &emac;
21 serial0 = &uart0;
22 serial1 = &uart1;
23 serial2 = &uart2;
24 serial3 = &uart3;
25 }; 21 };
26 22
27 chosen { 23 chosen {
@@ -390,8 +386,8 @@
390 reg-names = "phy_ctrl", "pmu1"; 386 reg-names = "phy_ctrl", "pmu1";
391 clocks = <&usb_clk 8>; 387 clocks = <&usb_clk 8>;
392 clock-names = "usb_phy"; 388 clock-names = "usb_phy";
393 resets = <&usb_clk 1>; 389 resets = <&usb_clk 0>, <&usb_clk 1>;
394 reset-names = "usb1_reset"; 390 reset-names = "usb0_reset", "usb1_reset";
395 status = "disabled"; 391 status = "disabled";
396 }; 392 };
397 393
diff --git a/arch/arm/boot/dts/sun5i-a13-hsg-h702.dts b/arch/arm/boot/dts/sun5i-a13-hsg-h702.dts
index eeed1f236ee8..c7be3abd9fcc 100644
--- a/arch/arm/boot/dts/sun5i-a13-hsg-h702.dts
+++ b/arch/arm/boot/dts/sun5i-a13-hsg-h702.dts
@@ -53,6 +53,10 @@
53 model = "HSG H702"; 53 model = "HSG H702";
54 compatible = "hsg,h702", "allwinner,sun5i-a13"; 54 compatible = "hsg,h702", "allwinner,sun5i-a13";
55 55
56 aliases {
57 serial0 = &uart1;
58 };
59
56 soc@01c00000 { 60 soc@01c00000 {
57 mmc0: mmc@01c0f000 { 61 mmc0: mmc@01c0f000 {
58 pinctrl-names = "default"; 62 pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/sun5i-a13-olinuxino-micro.dts b/arch/arm/boot/dts/sun5i-a13-olinuxino-micro.dts
index 916ee8bb826f..3decefb3c37a 100644
--- a/arch/arm/boot/dts/sun5i-a13-olinuxino-micro.dts
+++ b/arch/arm/boot/dts/sun5i-a13-olinuxino-micro.dts
@@ -54,6 +54,10 @@
54 model = "Olimex A13-Olinuxino Micro"; 54 model = "Olimex A13-Olinuxino Micro";
55 compatible = "olimex,a13-olinuxino-micro", "allwinner,sun5i-a13"; 55 compatible = "olimex,a13-olinuxino-micro", "allwinner,sun5i-a13";
56 56
57 aliases {
58 serial0 = &uart1;
59 };
60
57 soc@01c00000 { 61 soc@01c00000 {
58 mmc0: mmc@01c0f000 { 62 mmc0: mmc@01c0f000 {
59 pinctrl-names = "default"; 63 pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/sun5i-a13-olinuxino.dts b/arch/arm/boot/dts/sun5i-a13-olinuxino.dts
index e31d291d14cb..b421f7fa197b 100644
--- a/arch/arm/boot/dts/sun5i-a13-olinuxino.dts
+++ b/arch/arm/boot/dts/sun5i-a13-olinuxino.dts
@@ -55,6 +55,10 @@
55 model = "Olimex A13-Olinuxino"; 55 model = "Olimex A13-Olinuxino";
56 compatible = "olimex,a13-olinuxino", "allwinner,sun5i-a13"; 56 compatible = "olimex,a13-olinuxino", "allwinner,sun5i-a13";
57 57
58 aliases {
59 serial0 = &uart1;
60 };
61
58 soc@01c00000 { 62 soc@01c00000 {
59 mmc0: mmc@01c0f000 { 63 mmc0: mmc@01c0f000 {
60 pinctrl-names = "default"; 64 pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/sun5i-a13.dtsi b/arch/arm/boot/dts/sun5i-a13.dtsi
index c35217ea1f64..c556688f8b8b 100644
--- a/arch/arm/boot/dts/sun5i-a13.dtsi
+++ b/arch/arm/boot/dts/sun5i-a13.dtsi
@@ -16,11 +16,6 @@
16/ { 16/ {
17 interrupt-parent = <&intc>; 17 interrupt-parent = <&intc>;
18 18
19 aliases {
20 serial0 = &uart1;
21 serial1 = &uart3;
22 };
23
24 cpus { 19 cpus {
25 #address-cells = <1>; 20 #address-cells = <1>;
26 #size-cells = <0>; 21 #size-cells = <0>;
@@ -349,8 +344,8 @@
349 reg-names = "phy_ctrl", "pmu1"; 344 reg-names = "phy_ctrl", "pmu1";
350 clocks = <&usb_clk 8>; 345 clocks = <&usb_clk 8>;
351 clock-names = "usb_phy"; 346 clock-names = "usb_phy";
352 resets = <&usb_clk 1>; 347 resets = <&usb_clk 0>, <&usb_clk 1>;
353 reset-names = "usb1_reset"; 348 reset-names = "usb0_reset", "usb1_reset";
354 status = "disabled"; 349 status = "disabled";
355 }; 350 };
356 351
diff --git a/arch/arm/boot/dts/sun6i-a31.dtsi b/arch/arm/boot/dts/sun6i-a31.dtsi
index f47156b6572b..1e7e7bcf8307 100644
--- a/arch/arm/boot/dts/sun6i-a31.dtsi
+++ b/arch/arm/boot/dts/sun6i-a31.dtsi
@@ -53,12 +53,6 @@
53 interrupt-parent = <&gic>; 53 interrupt-parent = <&gic>;
54 54
55 aliases { 55 aliases {
56 serial0 = &uart0;
57 serial1 = &uart1;
58 serial2 = &uart2;
59 serial3 = &uart3;
60 serial4 = &uart4;
61 serial5 = &uart5;
62 ethernet0 = &gmac; 56 ethernet0 = &gmac;
63 }; 57 };
64 58
diff --git a/arch/arm/boot/dts/sun7i-a20-bananapi.dts b/arch/arm/boot/dts/sun7i-a20-bananapi.dts
index 1cf1214cc068..bd7b15add697 100644
--- a/arch/arm/boot/dts/sun7i-a20-bananapi.dts
+++ b/arch/arm/boot/dts/sun7i-a20-bananapi.dts
@@ -55,6 +55,12 @@
55 model = "LeMaker Banana Pi"; 55 model = "LeMaker Banana Pi";
56 compatible = "lemaker,bananapi", "allwinner,sun7i-a20"; 56 compatible = "lemaker,bananapi", "allwinner,sun7i-a20";
57 57
58 aliases {
59 serial0 = &uart0;
60 serial1 = &uart3;
61 serial2 = &uart7;
62 };
63
58 soc@01c00000 { 64 soc@01c00000 {
59 spi0: spi@01c05000 { 65 spi0: spi@01c05000 {
60 pinctrl-names = "default"; 66 pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/sun7i-a20-hummingbird.dts b/arch/arm/boot/dts/sun7i-a20-hummingbird.dts
index 0e4bfa3b2b85..0bcefcbbb756 100644
--- a/arch/arm/boot/dts/sun7i-a20-hummingbird.dts
+++ b/arch/arm/boot/dts/sun7i-a20-hummingbird.dts
@@ -19,6 +19,14 @@
19 model = "Merrii A20 Hummingbird"; 19 model = "Merrii A20 Hummingbird";
20 compatible = "merrii,a20-hummingbird", "allwinner,sun7i-a20"; 20 compatible = "merrii,a20-hummingbird", "allwinner,sun7i-a20";
21 21
22 aliases {
23 serial0 = &uart0;
24 serial1 = &uart2;
25 serial2 = &uart3;
26 serial3 = &uart4;
27 serial4 = &uart5;
28 };
29
22 soc@01c00000 { 30 soc@01c00000 {
23 mmc0: mmc@01c0f000 { 31 mmc0: mmc@01c0f000 {
24 pinctrl-names = "default"; 32 pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts b/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts
index 9d669cdf031d..66cc77707198 100644
--- a/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts
+++ b/arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts
@@ -20,6 +20,9 @@
20 compatible = "olimex,a20-olinuxino-micro", "allwinner,sun7i-a20"; 20 compatible = "olimex,a20-olinuxino-micro", "allwinner,sun7i-a20";
21 21
22 aliases { 22 aliases {
23 serial0 = &uart0;
24 serial1 = &uart6;
25 serial2 = &uart7;
23 spi0 = &spi1; 26 spi0 = &spi1;
24 spi1 = &spi2; 27 spi1 = &spi2;
25 }; 28 };
diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi
index e21ce5992d56..89749ce34a84 100644
--- a/arch/arm/boot/dts/sun7i-a20.dtsi
+++ b/arch/arm/boot/dts/sun7i-a20.dtsi
@@ -54,14 +54,6 @@
54 54
55 aliases { 55 aliases {
56 ethernet0 = &gmac; 56 ethernet0 = &gmac;
57 serial0 = &uart0;
58 serial1 = &uart1;
59 serial2 = &uart2;
60 serial3 = &uart3;
61 serial4 = &uart4;
62 serial5 = &uart5;
63 serial6 = &uart6;
64 serial7 = &uart7;
65 }; 57 };
66 58
67 chosen { 59 chosen {
diff --git a/arch/arm/boot/dts/sun8i-a23-ippo-q8h-v5.dts b/arch/arm/boot/dts/sun8i-a23-ippo-q8h-v5.dts
index 7f2117ce6985..32ad80804dbb 100644
--- a/arch/arm/boot/dts/sun8i-a23-ippo-q8h-v5.dts
+++ b/arch/arm/boot/dts/sun8i-a23-ippo-q8h-v5.dts
@@ -55,6 +55,10 @@
55 model = "Ippo Q8H Dual Core Tablet (v5)"; 55 model = "Ippo Q8H Dual Core Tablet (v5)";
56 compatible = "ippo,q8h-v5", "allwinner,sun8i-a23"; 56 compatible = "ippo,q8h-v5", "allwinner,sun8i-a23";
57 57
58 aliases {
59 serial0 = &r_uart;
60 };
61
58 chosen { 62 chosen {
59 bootargs = "earlyprintk console=ttyS0,115200"; 63 bootargs = "earlyprintk console=ttyS0,115200";
60 }; 64 };
diff --git a/arch/arm/boot/dts/sun8i-a23.dtsi b/arch/arm/boot/dts/sun8i-a23.dtsi
index 0746cd1024d7..86584fcf5e32 100644
--- a/arch/arm/boot/dts/sun8i-a23.dtsi
+++ b/arch/arm/boot/dts/sun8i-a23.dtsi
@@ -52,15 +52,6 @@
52/ { 52/ {
53 interrupt-parent = <&gic>; 53 interrupt-parent = <&gic>;
54 54
55 aliases {
56 serial0 = &uart0;
57 serial1 = &uart1;
58 serial2 = &uart2;
59 serial3 = &uart3;
60 serial4 = &uart4;
61 serial5 = &r_uart;
62 };
63
64 cpus { 55 cpus {
65 #address-cells = <1>; 56 #address-cells = <1>;
66 #size-cells = <0>; 57 #size-cells = <0>;
diff --git a/arch/arm/boot/dts/sun9i-a80-optimus.dts b/arch/arm/boot/dts/sun9i-a80-optimus.dts
index 506948f582ee..11ec71072e81 100644
--- a/arch/arm/boot/dts/sun9i-a80-optimus.dts
+++ b/arch/arm/boot/dts/sun9i-a80-optimus.dts
@@ -54,6 +54,11 @@
54 model = "Merrii A80 Optimus Board"; 54 model = "Merrii A80 Optimus Board";
55 compatible = "merrii,a80-optimus", "allwinner,sun9i-a80"; 55 compatible = "merrii,a80-optimus", "allwinner,sun9i-a80";
56 56
57 aliases {
58 serial0 = &uart0;
59 serial1 = &uart4;
60 };
61
57 chosen { 62 chosen {
58 bootargs = "earlyprintk console=ttyS0,115200"; 63 bootargs = "earlyprintk console=ttyS0,115200";
59 }; 64 };
diff --git a/arch/arm/boot/dts/sun9i-a80.dtsi b/arch/arm/boot/dts/sun9i-a80.dtsi
index 494714f67b57..9ef4438206a9 100644
--- a/arch/arm/boot/dts/sun9i-a80.dtsi
+++ b/arch/arm/boot/dts/sun9i-a80.dtsi
@@ -52,16 +52,6 @@
52/ { 52/ {
53 interrupt-parent = <&gic>; 53 interrupt-parent = <&gic>;
54 54
55 aliases {
56 serial0 = &uart0;
57 serial1 = &uart1;
58 serial2 = &uart2;
59 serial3 = &uart3;
60 serial4 = &uart4;
61 serial5 = &uart5;
62 serial6 = &r_uart;
63 };
64
65 cpus { 55 cpus {
66 #address-cells = <1>; 56 #address-cells = <1>;
67 #size-cells = <0>; 57 #size-cells = <0>;
diff --git a/arch/arm/boot/dts/tegra20-seaboard.dts b/arch/arm/boot/dts/tegra20-seaboard.dts
index ea282c7c0ca5..e2fed2712249 100644
--- a/arch/arm/boot/dts/tegra20-seaboard.dts
+++ b/arch/arm/boot/dts/tegra20-seaboard.dts
@@ -406,7 +406,7 @@
406 clock-frequency = <400000>; 406 clock-frequency = <400000>;
407 407
408 magnetometer@c { 408 magnetometer@c {
409 compatible = "ak,ak8975"; 409 compatible = "asahi-kasei,ak8975";
410 reg = <0xc>; 410 reg = <0xc>;
411 interrupt-parent = <&gpio>; 411 interrupt-parent = <&gpio>;
412 interrupts = <TEGRA_GPIO(N, 5) IRQ_TYPE_LEVEL_HIGH>; 412 interrupts = <TEGRA_GPIO(N, 5) IRQ_TYPE_LEVEL_HIGH>;
diff --git a/arch/arm/include/asm/kvm_emulate.h b/arch/arm/include/asm/kvm_emulate.h
index 66ce17655bb9..7b0152321b20 100644
--- a/arch/arm/include/asm/kvm_emulate.h
+++ b/arch/arm/include/asm/kvm_emulate.h
@@ -38,6 +38,16 @@ static inline void vcpu_reset_hcr(struct kvm_vcpu *vcpu)
38 vcpu->arch.hcr = HCR_GUEST_MASK; 38 vcpu->arch.hcr = HCR_GUEST_MASK;
39} 39}
40 40
41static inline unsigned long vcpu_get_hcr(struct kvm_vcpu *vcpu)
42{
43 return vcpu->arch.hcr;
44}
45
46static inline void vcpu_set_hcr(struct kvm_vcpu *vcpu, unsigned long hcr)
47{
48 vcpu->arch.hcr = hcr;
49}
50
41static inline bool vcpu_mode_is_32bit(struct kvm_vcpu *vcpu) 51static inline bool vcpu_mode_is_32bit(struct kvm_vcpu *vcpu)
42{ 52{
43 return 1; 53 return 1;
diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h
index 254e0650e48b..04b4ea0b550a 100644
--- a/arch/arm/include/asm/kvm_host.h
+++ b/arch/arm/include/asm/kvm_host.h
@@ -125,9 +125,6 @@ struct kvm_vcpu_arch {
125 * Anything that is not used directly from assembly code goes 125 * Anything that is not used directly from assembly code goes
126 * here. 126 * here.
127 */ 127 */
128 /* dcache set/way operation pending */
129 int last_pcpu;
130 cpumask_t require_dcache_flush;
131 128
132 /* Don't run the guest on this vcpu */ 129 /* Don't run the guest on this vcpu */
133 bool pause; 130 bool pause;
diff --git a/arch/arm/include/asm/kvm_mmu.h b/arch/arm/include/asm/kvm_mmu.h
index 63e0ecc04901..1bca8f8af442 100644
--- a/arch/arm/include/asm/kvm_mmu.h
+++ b/arch/arm/include/asm/kvm_mmu.h
@@ -44,6 +44,7 @@
44 44
45#ifndef __ASSEMBLY__ 45#ifndef __ASSEMBLY__
46 46
47#include <linux/highmem.h>
47#include <asm/cacheflush.h> 48#include <asm/cacheflush.h>
48#include <asm/pgalloc.h> 49#include <asm/pgalloc.h>
49 50
@@ -161,13 +162,10 @@ static inline bool vcpu_has_cache_enabled(struct kvm_vcpu *vcpu)
161 return (vcpu->arch.cp15[c1_SCTLR] & 0b101) == 0b101; 162 return (vcpu->arch.cp15[c1_SCTLR] & 0b101) == 0b101;
162} 163}
163 164
164static inline void coherent_cache_guest_page(struct kvm_vcpu *vcpu, hva_t hva, 165static inline void __coherent_cache_guest_page(struct kvm_vcpu *vcpu, pfn_t pfn,
165 unsigned long size, 166 unsigned long size,
166 bool ipa_uncached) 167 bool ipa_uncached)
167{ 168{
168 if (!vcpu_has_cache_enabled(vcpu) || ipa_uncached)
169 kvm_flush_dcache_to_poc((void *)hva, size);
170
171 /* 169 /*
172 * If we are going to insert an instruction page and the icache is 170 * If we are going to insert an instruction page and the icache is
173 * either VIPT or PIPT, there is a potential problem where the host 171 * either VIPT or PIPT, there is a potential problem where the host
@@ -179,18 +177,77 @@ static inline void coherent_cache_guest_page(struct kvm_vcpu *vcpu, hva_t hva,
179 * 177 *
180 * VIVT caches are tagged using both the ASID and the VMID and doesn't 178 * VIVT caches are tagged using both the ASID and the VMID and doesn't
181 * need any kind of flushing (DDI 0406C.b - Page B3-1392). 179 * need any kind of flushing (DDI 0406C.b - Page B3-1392).
180 *
181 * We need to do this through a kernel mapping (using the
182 * user-space mapping has proved to be the wrong
183 * solution). For that, we need to kmap one page at a time,
184 * and iterate over the range.
182 */ 185 */
183 if (icache_is_pipt()) { 186
184 __cpuc_coherent_user_range(hva, hva + size); 187 bool need_flush = !vcpu_has_cache_enabled(vcpu) || ipa_uncached;
185 } else if (!icache_is_vivt_asid_tagged()) { 188
189 VM_BUG_ON(size & PAGE_MASK);
190
191 if (!need_flush && !icache_is_pipt())
192 goto vipt_cache;
193
194 while (size) {
195 void *va = kmap_atomic_pfn(pfn);
196
197 if (need_flush)
198 kvm_flush_dcache_to_poc(va, PAGE_SIZE);
199
200 if (icache_is_pipt())
201 __cpuc_coherent_user_range((unsigned long)va,
202 (unsigned long)va + PAGE_SIZE);
203
204 size -= PAGE_SIZE;
205 pfn++;
206
207 kunmap_atomic(va);
208 }
209
210vipt_cache:
211 if (!icache_is_pipt() && !icache_is_vivt_asid_tagged()) {
186 /* any kind of VIPT cache */ 212 /* any kind of VIPT cache */
187 __flush_icache_all(); 213 __flush_icache_all();
188 } 214 }
189} 215}
190 216
217static inline void __kvm_flush_dcache_pte(pte_t pte)
218{
219 void *va = kmap_atomic(pte_page(pte));
220
221 kvm_flush_dcache_to_poc(va, PAGE_SIZE);
222
223 kunmap_atomic(va);
224}
225
226static inline void __kvm_flush_dcache_pmd(pmd_t pmd)
227{
228 unsigned long size = PMD_SIZE;
229 pfn_t pfn = pmd_pfn(pmd);
230
231 while (size) {
232 void *va = kmap_atomic_pfn(pfn);
233
234 kvm_flush_dcache_to_poc(va, PAGE_SIZE);
235
236 pfn++;
237 size -= PAGE_SIZE;
238
239 kunmap_atomic(va);
240 }
241}
242
243static inline void __kvm_flush_dcache_pud(pud_t pud)
244{
245}
246
191#define kvm_virt_to_phys(x) virt_to_idmap((unsigned long)(x)) 247#define kvm_virt_to_phys(x) virt_to_idmap((unsigned long)(x))
192 248
193void stage2_flush_vm(struct kvm *kvm); 249void kvm_set_way_flush(struct kvm_vcpu *vcpu);
250void kvm_toggle_cache(struct kvm_vcpu *vcpu, bool was_enabled);
194 251
195#endif /* !__ASSEMBLY__ */ 252#endif /* !__ASSEMBLY__ */
196 253
diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
index 4176df721bf0..1a0045abead7 100644
--- a/arch/arm/kernel/entry-header.S
+++ b/arch/arm/kernel/entry-header.S
@@ -253,21 +253,22 @@
253 .endm 253 .endm
254 254
255 .macro restore_user_regs, fast = 0, offset = 0 255 .macro restore_user_regs, fast = 0, offset = 0
256 ldr r1, [sp, #\offset + S_PSR] @ get calling cpsr 256 mov r2, sp
257 ldr lr, [sp, #\offset + S_PC]! @ get pc 257 ldr r1, [r2, #\offset + S_PSR] @ get calling cpsr
258 ldr lr, [r2, #\offset + S_PC]! @ get pc
258 msr spsr_cxsf, r1 @ save in spsr_svc 259 msr spsr_cxsf, r1 @ save in spsr_svc
259#if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_32v6K) 260#if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_32v6K)
260 @ We must avoid clrex due to Cortex-A15 erratum #830321 261 @ We must avoid clrex due to Cortex-A15 erratum #830321
261 strex r1, r2, [sp] @ clear the exclusive monitor 262 strex r1, r2, [r2] @ clear the exclusive monitor
262#endif 263#endif
263 .if \fast 264 .if \fast
264 ldmdb sp, {r1 - lr}^ @ get calling r1 - lr 265 ldmdb r2, {r1 - lr}^ @ get calling r1 - lr
265 .else 266 .else
266 ldmdb sp, {r0 - lr}^ @ get calling r0 - lr 267 ldmdb r2, {r0 - lr}^ @ get calling r0 - lr
267 .endif 268 .endif
268 mov r0, r0 @ ARMv5T and earlier require a nop 269 mov r0, r0 @ ARMv5T and earlier require a nop
269 @ after ldm {}^ 270 @ after ldm {}^
270 add sp, sp, #S_FRAME_SIZE - S_PC 271 add sp, sp, #\offset + S_FRAME_SIZE
271 movs pc, lr @ return & move spsr_svc into cpsr 272 movs pc, lr @ return & move spsr_svc into cpsr
272 .endm 273 .endm
273 274
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
index f7c65adaa428..557e128e4df0 100644
--- a/arch/arm/kernel/perf_event.c
+++ b/arch/arm/kernel/perf_event.c
@@ -116,8 +116,14 @@ int armpmu_event_set_period(struct perf_event *event)
116 ret = 1; 116 ret = 1;
117 } 117 }
118 118
119 if (left > (s64)armpmu->max_period) 119 /*
120 left = armpmu->max_period; 120 * Limit the maximum period to prevent the counter value
121 * from overtaking the one we are about to program. In
122 * effect we are reducing max_period to account for
123 * interrupt latency (and we are being very conservative).
124 */
125 if (left > (armpmu->max_period >> 1))
126 left = armpmu->max_period >> 1;
121 127
122 local64_set(&hwc->prev_count, (u64)-left); 128 local64_set(&hwc->prev_count, (u64)-left);
123 129
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 715ae19bc7c8..e55408e96559 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -657,10 +657,13 @@ int __init arm_add_memory(u64 start, u64 size)
657 657
658 /* 658 /*
659 * Ensure that start/size are aligned to a page boundary. 659 * Ensure that start/size are aligned to a page boundary.
660 * Size is appropriately rounded down, start is rounded up. 660 * Size is rounded down, start is rounded up.
661 */ 661 */
662 size -= start & ~PAGE_MASK;
663 aligned_start = PAGE_ALIGN(start); 662 aligned_start = PAGE_ALIGN(start);
663 if (aligned_start > start + size)
664 size = 0;
665 else
666 size -= aligned_start - start;
664 667
665#ifndef CONFIG_ARCH_PHYS_ADDR_T_64BIT 668#ifndef CONFIG_ARCH_PHYS_ADDR_T_64BIT
666 if (aligned_start > ULONG_MAX) { 669 if (aligned_start > ULONG_MAX) {
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index 2d6d91001062..0b0d58a905c4 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -281,15 +281,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
281 vcpu->cpu = cpu; 281 vcpu->cpu = cpu;
282 vcpu->arch.host_cpu_context = this_cpu_ptr(kvm_host_cpu_state); 282 vcpu->arch.host_cpu_context = this_cpu_ptr(kvm_host_cpu_state);
283 283
284 /*
285 * Check whether this vcpu requires the cache to be flushed on
286 * this physical CPU. This is a consequence of doing dcache
287 * operations by set/way on this vcpu. We do it here to be in
288 * a non-preemptible section.
289 */
290 if (cpumask_test_and_clear_cpu(cpu, &vcpu->arch.require_dcache_flush))
291 flush_cache_all(); /* We'd really want v7_flush_dcache_all() */
292
293 kvm_arm_set_running_vcpu(vcpu); 284 kvm_arm_set_running_vcpu(vcpu);
294} 285}
295 286
@@ -541,7 +532,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
541 ret = kvm_call_hyp(__kvm_vcpu_run, vcpu); 532 ret = kvm_call_hyp(__kvm_vcpu_run, vcpu);
542 533
543 vcpu->mode = OUTSIDE_GUEST_MODE; 534 vcpu->mode = OUTSIDE_GUEST_MODE;
544 vcpu->arch.last_pcpu = smp_processor_id();
545 kvm_guest_exit(); 535 kvm_guest_exit();
546 trace_kvm_exit(*vcpu_pc(vcpu)); 536 trace_kvm_exit(*vcpu_pc(vcpu));
547 /* 537 /*
diff --git a/arch/arm/kvm/coproc.c b/arch/arm/kvm/coproc.c
index 7928dbdf2102..f3d88dc388bc 100644
--- a/arch/arm/kvm/coproc.c
+++ b/arch/arm/kvm/coproc.c
@@ -189,82 +189,40 @@ static bool access_l2ectlr(struct kvm_vcpu *vcpu,
189 return true; 189 return true;
190} 190}
191 191
192/* See note at ARM ARM B1.14.4 */ 192/*
193 * See note at ARMv7 ARM B1.14.4 (TL;DR: S/W ops are not easily virtualized).
194 */
193static bool access_dcsw(struct kvm_vcpu *vcpu, 195static bool access_dcsw(struct kvm_vcpu *vcpu,
194 const struct coproc_params *p, 196 const struct coproc_params *p,
195 const struct coproc_reg *r) 197 const struct coproc_reg *r)
196{ 198{
197 unsigned long val;
198 int cpu;
199
200 if (!p->is_write) 199 if (!p->is_write)
201 return read_from_write_only(vcpu, p); 200 return read_from_write_only(vcpu, p);
202 201
203 cpu = get_cpu(); 202 kvm_set_way_flush(vcpu);
204
205 cpumask_setall(&vcpu->arch.require_dcache_flush);
206 cpumask_clear_cpu(cpu, &vcpu->arch.require_dcache_flush);
207
208 /* If we were already preempted, take the long way around */
209 if (cpu != vcpu->arch.last_pcpu) {
210 flush_cache_all();
211 goto done;
212 }
213
214 val = *vcpu_reg(vcpu, p->Rt1);
215
216 switch (p->CRm) {
217 case 6: /* Upgrade DCISW to DCCISW, as per HCR.SWIO */
218 case 14: /* DCCISW */
219 asm volatile("mcr p15, 0, %0, c7, c14, 2" : : "r" (val));
220 break;
221
222 case 10: /* DCCSW */
223 asm volatile("mcr p15, 0, %0, c7, c10, 2" : : "r" (val));
224 break;
225 }
226
227done:
228 put_cpu();
229
230 return true; 203 return true;
231} 204}
232 205
233/* 206/*
234 * Generic accessor for VM registers. Only called as long as HCR_TVM 207 * Generic accessor for VM registers. Only called as long as HCR_TVM
235 * is set. 208 * is set. If the guest enables the MMU, we stop trapping the VM
209 * sys_regs and leave it in complete control of the caches.
210 *
211 * Used by the cpu-specific code.
236 */ 212 */
237static bool access_vm_reg(struct kvm_vcpu *vcpu, 213bool access_vm_reg(struct kvm_vcpu *vcpu,
238 const struct coproc_params *p, 214 const struct coproc_params *p,
239 const struct coproc_reg *r) 215 const struct coproc_reg *r)
240{ 216{
217 bool was_enabled = vcpu_has_cache_enabled(vcpu);
218
241 BUG_ON(!p->is_write); 219 BUG_ON(!p->is_write);
242 220
243 vcpu->arch.cp15[r->reg] = *vcpu_reg(vcpu, p->Rt1); 221 vcpu->arch.cp15[r->reg] = *vcpu_reg(vcpu, p->Rt1);
244 if (p->is_64bit) 222 if (p->is_64bit)
245 vcpu->arch.cp15[r->reg + 1] = *vcpu_reg(vcpu, p->Rt2); 223 vcpu->arch.cp15[r->reg + 1] = *vcpu_reg(vcpu, p->Rt2);
246 224
247 return true; 225 kvm_toggle_cache(vcpu, was_enabled);
248}
249
250/*
251 * SCTLR accessor. Only called as long as HCR_TVM is set. If the
252 * guest enables the MMU, we stop trapping the VM sys_regs and leave
253 * it in complete control of the caches.
254 *
255 * Used by the cpu-specific code.
256 */
257bool access_sctlr(struct kvm_vcpu *vcpu,
258 const struct coproc_params *p,
259 const struct coproc_reg *r)
260{
261 access_vm_reg(vcpu, p, r);
262
263 if (vcpu_has_cache_enabled(vcpu)) { /* MMU+Caches enabled? */
264 vcpu->arch.hcr &= ~HCR_TVM;
265 stage2_flush_vm(vcpu->kvm);
266 }
267
268 return true; 226 return true;
269} 227}
270 228
diff --git a/arch/arm/kvm/coproc.h b/arch/arm/kvm/coproc.h
index 1a44bbe39643..88d24a3a9778 100644
--- a/arch/arm/kvm/coproc.h
+++ b/arch/arm/kvm/coproc.h
@@ -153,8 +153,8 @@ static inline int cmp_reg(const struct coproc_reg *i1,
153#define is64 .is_64 = true 153#define is64 .is_64 = true
154#define is32 .is_64 = false 154#define is32 .is_64 = false
155 155
156bool access_sctlr(struct kvm_vcpu *vcpu, 156bool access_vm_reg(struct kvm_vcpu *vcpu,
157 const struct coproc_params *p, 157 const struct coproc_params *p,
158 const struct coproc_reg *r); 158 const struct coproc_reg *r);
159 159
160#endif /* __ARM_KVM_COPROC_LOCAL_H__ */ 160#endif /* __ARM_KVM_COPROC_LOCAL_H__ */
diff --git a/arch/arm/kvm/coproc_a15.c b/arch/arm/kvm/coproc_a15.c
index e6f4ae48bda9..a7136757d373 100644
--- a/arch/arm/kvm/coproc_a15.c
+++ b/arch/arm/kvm/coproc_a15.c
@@ -34,7 +34,7 @@
34static const struct coproc_reg a15_regs[] = { 34static const struct coproc_reg a15_regs[] = {
35 /* SCTLR: swapped by interrupt.S. */ 35 /* SCTLR: swapped by interrupt.S. */
36 { CRn( 1), CRm( 0), Op1( 0), Op2( 0), is32, 36 { CRn( 1), CRm( 0), Op1( 0), Op2( 0), is32,
37 access_sctlr, reset_val, c1_SCTLR, 0x00C50078 }, 37 access_vm_reg, reset_val, c1_SCTLR, 0x00C50078 },
38}; 38};
39 39
40static struct kvm_coproc_target_table a15_target_table = { 40static struct kvm_coproc_target_table a15_target_table = {
diff --git a/arch/arm/kvm/coproc_a7.c b/arch/arm/kvm/coproc_a7.c
index 17fc7cd479d3..b19e46d1b2c0 100644
--- a/arch/arm/kvm/coproc_a7.c
+++ b/arch/arm/kvm/coproc_a7.c
@@ -37,7 +37,7 @@
37static const struct coproc_reg a7_regs[] = { 37static const struct coproc_reg a7_regs[] = {
38 /* SCTLR: swapped by interrupt.S. */ 38 /* SCTLR: swapped by interrupt.S. */
39 { CRn( 1), CRm( 0), Op1( 0), Op2( 0), is32, 39 { CRn( 1), CRm( 0), Op1( 0), Op2( 0), is32,
40 access_sctlr, reset_val, c1_SCTLR, 0x00C50878 }, 40 access_vm_reg, reset_val, c1_SCTLR, 0x00C50878 },
41}; 41};
42 42
43static struct kvm_coproc_target_table a7_target_table = { 43static struct kvm_coproc_target_table a7_target_table = {
diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index 1dc9778a00af..136662547ca6 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -58,6 +58,26 @@ static void kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa)
58 kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, kvm, ipa); 58 kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, kvm, ipa);
59} 59}
60 60
61/*
62 * D-Cache management functions. They take the page table entries by
63 * value, as they are flushing the cache using the kernel mapping (or
64 * kmap on 32bit).
65 */
66static void kvm_flush_dcache_pte(pte_t pte)
67{
68 __kvm_flush_dcache_pte(pte);
69}
70
71static void kvm_flush_dcache_pmd(pmd_t pmd)
72{
73 __kvm_flush_dcache_pmd(pmd);
74}
75
76static void kvm_flush_dcache_pud(pud_t pud)
77{
78 __kvm_flush_dcache_pud(pud);
79}
80
61static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *cache, 81static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *cache,
62 int min, int max) 82 int min, int max)
63{ 83{
@@ -119,6 +139,26 @@ static void clear_pmd_entry(struct kvm *kvm, pmd_t *pmd, phys_addr_t addr)
119 put_page(virt_to_page(pmd)); 139 put_page(virt_to_page(pmd));
120} 140}
121 141
142/*
143 * Unmapping vs dcache management:
144 *
145 * If a guest maps certain memory pages as uncached, all writes will
146 * bypass the data cache and go directly to RAM. However, the CPUs
147 * can still speculate reads (not writes) and fill cache lines with
148 * data.
149 *
150 * Those cache lines will be *clean* cache lines though, so a
151 * clean+invalidate operation is equivalent to an invalidate
152 * operation, because no cache lines are marked dirty.
153 *
154 * Those clean cache lines could be filled prior to an uncached write
155 * by the guest, and the cache coherent IO subsystem would therefore
156 * end up writing old data to disk.
157 *
158 * This is why right after unmapping a page/section and invalidating
159 * the corresponding TLBs, we call kvm_flush_dcache_p*() to make sure
160 * the IO subsystem will never hit in the cache.
161 */
122static void unmap_ptes(struct kvm *kvm, pmd_t *pmd, 162static void unmap_ptes(struct kvm *kvm, pmd_t *pmd,
123 phys_addr_t addr, phys_addr_t end) 163 phys_addr_t addr, phys_addr_t end)
124{ 164{
@@ -128,9 +168,16 @@ static void unmap_ptes(struct kvm *kvm, pmd_t *pmd,
128 start_pte = pte = pte_offset_kernel(pmd, addr); 168 start_pte = pte = pte_offset_kernel(pmd, addr);
129 do { 169 do {
130 if (!pte_none(*pte)) { 170 if (!pte_none(*pte)) {
171 pte_t old_pte = *pte;
172
131 kvm_set_pte(pte, __pte(0)); 173 kvm_set_pte(pte, __pte(0));
132 put_page(virt_to_page(pte));
133 kvm_tlb_flush_vmid_ipa(kvm, addr); 174 kvm_tlb_flush_vmid_ipa(kvm, addr);
175
176 /* No need to invalidate the cache for device mappings */
177 if ((pte_val(old_pte) & PAGE_S2_DEVICE) != PAGE_S2_DEVICE)
178 kvm_flush_dcache_pte(old_pte);
179
180 put_page(virt_to_page(pte));
134 } 181 }
135 } while (pte++, addr += PAGE_SIZE, addr != end); 182 } while (pte++, addr += PAGE_SIZE, addr != end);
136 183
@@ -149,8 +196,13 @@ static void unmap_pmds(struct kvm *kvm, pud_t *pud,
149 next = kvm_pmd_addr_end(addr, end); 196 next = kvm_pmd_addr_end(addr, end);
150 if (!pmd_none(*pmd)) { 197 if (!pmd_none(*pmd)) {
151 if (kvm_pmd_huge(*pmd)) { 198 if (kvm_pmd_huge(*pmd)) {
199 pmd_t old_pmd = *pmd;
200
152 pmd_clear(pmd); 201 pmd_clear(pmd);
153 kvm_tlb_flush_vmid_ipa(kvm, addr); 202 kvm_tlb_flush_vmid_ipa(kvm, addr);
203
204 kvm_flush_dcache_pmd(old_pmd);
205
154 put_page(virt_to_page(pmd)); 206 put_page(virt_to_page(pmd));
155 } else { 207 } else {
156 unmap_ptes(kvm, pmd, addr, next); 208 unmap_ptes(kvm, pmd, addr, next);
@@ -173,8 +225,13 @@ static void unmap_puds(struct kvm *kvm, pgd_t *pgd,
173 next = kvm_pud_addr_end(addr, end); 225 next = kvm_pud_addr_end(addr, end);
174 if (!pud_none(*pud)) { 226 if (!pud_none(*pud)) {
175 if (pud_huge(*pud)) { 227 if (pud_huge(*pud)) {
228 pud_t old_pud = *pud;
229
176 pud_clear(pud); 230 pud_clear(pud);
177 kvm_tlb_flush_vmid_ipa(kvm, addr); 231 kvm_tlb_flush_vmid_ipa(kvm, addr);
232
233 kvm_flush_dcache_pud(old_pud);
234
178 put_page(virt_to_page(pud)); 235 put_page(virt_to_page(pud));
179 } else { 236 } else {
180 unmap_pmds(kvm, pud, addr, next); 237 unmap_pmds(kvm, pud, addr, next);
@@ -209,10 +266,9 @@ static void stage2_flush_ptes(struct kvm *kvm, pmd_t *pmd,
209 266
210 pte = pte_offset_kernel(pmd, addr); 267 pte = pte_offset_kernel(pmd, addr);
211 do { 268 do {
212 if (!pte_none(*pte)) { 269 if (!pte_none(*pte) &&
213 hva_t hva = gfn_to_hva(kvm, addr >> PAGE_SHIFT); 270 (pte_val(*pte) & PAGE_S2_DEVICE) != PAGE_S2_DEVICE)
214 kvm_flush_dcache_to_poc((void*)hva, PAGE_SIZE); 271 kvm_flush_dcache_pte(*pte);
215 }
216 } while (pte++, addr += PAGE_SIZE, addr != end); 272 } while (pte++, addr += PAGE_SIZE, addr != end);
217} 273}
218 274
@@ -226,12 +282,10 @@ static void stage2_flush_pmds(struct kvm *kvm, pud_t *pud,
226 do { 282 do {
227 next = kvm_pmd_addr_end(addr, end); 283 next = kvm_pmd_addr_end(addr, end);
228 if (!pmd_none(*pmd)) { 284 if (!pmd_none(*pmd)) {
229 if (kvm_pmd_huge(*pmd)) { 285 if (kvm_pmd_huge(*pmd))
230 hva_t hva = gfn_to_hva(kvm, addr >> PAGE_SHIFT); 286 kvm_flush_dcache_pmd(*pmd);
231 kvm_flush_dcache_to_poc((void*)hva, PMD_SIZE); 287 else
232 } else {
233 stage2_flush_ptes(kvm, pmd, addr, next); 288 stage2_flush_ptes(kvm, pmd, addr, next);
234 }
235 } 289 }
236 } while (pmd++, addr = next, addr != end); 290 } while (pmd++, addr = next, addr != end);
237} 291}
@@ -246,12 +300,10 @@ static void stage2_flush_puds(struct kvm *kvm, pgd_t *pgd,
246 do { 300 do {
247 next = kvm_pud_addr_end(addr, end); 301 next = kvm_pud_addr_end(addr, end);
248 if (!pud_none(*pud)) { 302 if (!pud_none(*pud)) {
249 if (pud_huge(*pud)) { 303 if (pud_huge(*pud))
250 hva_t hva = gfn_to_hva(kvm, addr >> PAGE_SHIFT); 304 kvm_flush_dcache_pud(*pud);
251 kvm_flush_dcache_to_poc((void*)hva, PUD_SIZE); 305 else
252 } else {
253 stage2_flush_pmds(kvm, pud, addr, next); 306 stage2_flush_pmds(kvm, pud, addr, next);
254 }
255 } 307 }
256 } while (pud++, addr = next, addr != end); 308 } while (pud++, addr = next, addr != end);
257} 309}
@@ -278,7 +330,7 @@ static void stage2_flush_memslot(struct kvm *kvm,
278 * Go through the stage 2 page tables and invalidate any cache lines 330 * Go through the stage 2 page tables and invalidate any cache lines
279 * backing memory already mapped to the VM. 331 * backing memory already mapped to the VM.
280 */ 332 */
281void stage2_flush_vm(struct kvm *kvm) 333static void stage2_flush_vm(struct kvm *kvm)
282{ 334{
283 struct kvm_memslots *slots; 335 struct kvm_memslots *slots;
284 struct kvm_memory_slot *memslot; 336 struct kvm_memory_slot *memslot;
@@ -905,6 +957,12 @@ static bool kvm_is_device_pfn(unsigned long pfn)
905 return !pfn_valid(pfn); 957 return !pfn_valid(pfn);
906} 958}
907 959
960static void coherent_cache_guest_page(struct kvm_vcpu *vcpu, pfn_t pfn,
961 unsigned long size, bool uncached)
962{
963 __coherent_cache_guest_page(vcpu, pfn, size, uncached);
964}
965
908static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, 966static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
909 struct kvm_memory_slot *memslot, unsigned long hva, 967 struct kvm_memory_slot *memslot, unsigned long hva,
910 unsigned long fault_status) 968 unsigned long fault_status)
@@ -994,8 +1052,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
994 kvm_set_s2pmd_writable(&new_pmd); 1052 kvm_set_s2pmd_writable(&new_pmd);
995 kvm_set_pfn_dirty(pfn); 1053 kvm_set_pfn_dirty(pfn);
996 } 1054 }
997 coherent_cache_guest_page(vcpu, hva & PMD_MASK, PMD_SIZE, 1055 coherent_cache_guest_page(vcpu, pfn, PMD_SIZE, fault_ipa_uncached);
998 fault_ipa_uncached);
999 ret = stage2_set_pmd_huge(kvm, memcache, fault_ipa, &new_pmd); 1056 ret = stage2_set_pmd_huge(kvm, memcache, fault_ipa, &new_pmd);
1000 } else { 1057 } else {
1001 pte_t new_pte = pfn_pte(pfn, mem_type); 1058 pte_t new_pte = pfn_pte(pfn, mem_type);
@@ -1003,8 +1060,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
1003 kvm_set_s2pte_writable(&new_pte); 1060 kvm_set_s2pte_writable(&new_pte);
1004 kvm_set_pfn_dirty(pfn); 1061 kvm_set_pfn_dirty(pfn);
1005 } 1062 }
1006 coherent_cache_guest_page(vcpu, hva, PAGE_SIZE, 1063 coherent_cache_guest_page(vcpu, pfn, PAGE_SIZE, fault_ipa_uncached);
1007 fault_ipa_uncached);
1008 ret = stage2_set_pte(kvm, memcache, fault_ipa, &new_pte, 1064 ret = stage2_set_pte(kvm, memcache, fault_ipa, &new_pte,
1009 pgprot_val(mem_type) == pgprot_val(PAGE_S2_DEVICE)); 1065 pgprot_val(mem_type) == pgprot_val(PAGE_S2_DEVICE));
1010 } 1066 }
@@ -1411,3 +1467,71 @@ void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
1411 unmap_stage2_range(kvm, gpa, size); 1467 unmap_stage2_range(kvm, gpa, size);
1412 spin_unlock(&kvm->mmu_lock); 1468 spin_unlock(&kvm->mmu_lock);
1413} 1469}
1470
1471/*
1472 * See note at ARMv7 ARM B1.14.4 (TL;DR: S/W ops are not easily virtualized).
1473 *
1474 * Main problems:
1475 * - S/W ops are local to a CPU (not broadcast)
1476 * - We have line migration behind our back (speculation)
1477 * - System caches don't support S/W at all (damn!)
1478 *
1479 * In the face of the above, the best we can do is to try and convert
1480 * S/W ops to VA ops. Because the guest is not allowed to infer the
1481 * S/W to PA mapping, it can only use S/W to nuke the whole cache,
1482 * which is a rather good thing for us.
1483 *
1484 * Also, it is only used when turning caches on/off ("The expected
1485 * usage of the cache maintenance instructions that operate by set/way
1486 * is associated with the cache maintenance instructions associated
1487 * with the powerdown and powerup of caches, if this is required by
1488 * the implementation.").
1489 *
1490 * We use the following policy:
1491 *
1492 * - If we trap a S/W operation, we enable VM trapping to detect
1493 * caches being turned on/off, and do a full clean.
1494 *
1495 * - We flush the caches on both caches being turned on and off.
1496 *
1497 * - Once the caches are enabled, we stop trapping VM ops.
1498 */
1499void kvm_set_way_flush(struct kvm_vcpu *vcpu)
1500{
1501 unsigned long hcr = vcpu_get_hcr(vcpu);
1502
1503 /*
1504 * If this is the first time we do a S/W operation
1505 * (i.e. HCR_TVM not set) flush the whole memory, and set the
1506 * VM trapping.
1507 *
1508 * Otherwise, rely on the VM trapping to wait for the MMU +
1509 * Caches to be turned off. At that point, we'll be able to
1510 * clean the caches again.
1511 */
1512 if (!(hcr & HCR_TVM)) {
1513 trace_kvm_set_way_flush(*vcpu_pc(vcpu),
1514 vcpu_has_cache_enabled(vcpu));
1515 stage2_flush_vm(vcpu->kvm);
1516 vcpu_set_hcr(vcpu, hcr | HCR_TVM);
1517 }
1518}
1519
1520void kvm_toggle_cache(struct kvm_vcpu *vcpu, bool was_enabled)
1521{
1522 bool now_enabled = vcpu_has_cache_enabled(vcpu);
1523
1524 /*
1525 * If switching the MMU+caches on, need to invalidate the caches.
1526 * If switching it off, need to clean the caches.
1527 * Clean + invalidate does the trick always.
1528 */
1529 if (now_enabled != was_enabled)
1530 stage2_flush_vm(vcpu->kvm);
1531
1532 /* Caches are now on, stop trapping VM ops (until a S/W op) */
1533 if (now_enabled)
1534 vcpu_set_hcr(vcpu, vcpu_get_hcr(vcpu) & ~HCR_TVM);
1535
1536 trace_kvm_toggle_cache(*vcpu_pc(vcpu), was_enabled, now_enabled);
1537}
diff --git a/arch/arm/kvm/trace.h b/arch/arm/kvm/trace.h
index b1d640f78623..b6a6e7102201 100644
--- a/arch/arm/kvm/trace.h
+++ b/arch/arm/kvm/trace.h
@@ -223,6 +223,45 @@ TRACE_EVENT(kvm_hvc,
223 __entry->vcpu_pc, __entry->r0, __entry->imm) 223 __entry->vcpu_pc, __entry->r0, __entry->imm)
224); 224);
225 225
226TRACE_EVENT(kvm_set_way_flush,
227 TP_PROTO(unsigned long vcpu_pc, bool cache),
228 TP_ARGS(vcpu_pc, cache),
229
230 TP_STRUCT__entry(
231 __field( unsigned long, vcpu_pc )
232 __field( bool, cache )
233 ),
234
235 TP_fast_assign(
236 __entry->vcpu_pc = vcpu_pc;
237 __entry->cache = cache;
238 ),
239
240 TP_printk("S/W flush at 0x%016lx (cache %s)",
241 __entry->vcpu_pc, __entry->cache ? "on" : "off")
242);
243
244TRACE_EVENT(kvm_toggle_cache,
245 TP_PROTO(unsigned long vcpu_pc, bool was, bool now),
246 TP_ARGS(vcpu_pc, was, now),
247
248 TP_STRUCT__entry(
249 __field( unsigned long, vcpu_pc )
250 __field( bool, was )
251 __field( bool, now )
252 ),
253
254 TP_fast_assign(
255 __entry->vcpu_pc = vcpu_pc;
256 __entry->was = was;
257 __entry->now = now;
258 ),
259
260 TP_printk("VM op at 0x%016lx (cache was %s, now %s)",
261 __entry->vcpu_pc, __entry->was ? "on" : "off",
262 __entry->now ? "on" : "off")
263);
264
226#endif /* _TRACE_KVM_H */ 265#endif /* _TRACE_KVM_H */
227 266
228#undef TRACE_INCLUDE_PATH 267#undef TRACE_INCLUDE_PATH
diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c
index 3585cb394e9b..ccef8806bb58 100644
--- a/arch/arm/mach-mvebu/coherency.c
+++ b/arch/arm/mach-mvebu/coherency.c
@@ -190,6 +190,13 @@ static void __init armada_375_380_coherency_init(struct device_node *np)
190 arch_ioremap_caller = armada_pcie_wa_ioremap_caller; 190 arch_ioremap_caller = armada_pcie_wa_ioremap_caller;
191 191
192 /* 192 /*
193 * We should switch the PL310 to I/O coherency mode only if
194 * I/O coherency is actually enabled.
195 */
196 if (!coherency_available())
197 return;
198
199 /*
193 * Add the PL310 property "arm,io-coherent". This makes sure the 200 * Add the PL310 property "arm,io-coherent". This makes sure the
194 * outer sync operation is not used, which allows to 201 * outer sync operation is not used, which allows to
195 * workaround the system erratum that causes deadlocks when 202 * workaround the system erratum that causes deadlocks when
@@ -246,9 +253,14 @@ static int coherency_type(void)
246 return type; 253 return type;
247} 254}
248 255
256/*
257 * As a precaution, we currently completely disable hardware I/O
258 * coherency, until enough testing is done with automatic I/O
259 * synchronization barriers to validate that it is a proper solution.
260 */
249int coherency_available(void) 261int coherency_available(void)
250{ 262{
251 return coherency_type() != COHERENCY_FABRIC_TYPE_NONE; 263 return false;
252} 264}
253 265
254int __init coherency_init(void) 266int __init coherency_init(void)
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
index db57741c9c8a..64e44d6d07c0 100644
--- a/arch/arm/mach-omap2/common.h
+++ b/arch/arm/mach-omap2/common.h
@@ -211,6 +211,7 @@ extern struct device *omap2_get_iva_device(void);
211extern struct device *omap2_get_l3_device(void); 211extern struct device *omap2_get_l3_device(void);
212extern struct device *omap4_get_dsp_device(void); 212extern struct device *omap4_get_dsp_device(void);
213 213
214unsigned int omap4_xlate_irq(unsigned int hwirq);
214void omap_gic_of_init(void); 215void omap_gic_of_init(void);
215 216
216#ifdef CONFIG_CACHE_L2X0 217#ifdef CONFIG_CACHE_L2X0
diff --git a/arch/arm/mach-omap2/omap4-common.c b/arch/arm/mach-omap2/omap4-common.c
index b7cb44abe49b..cc30e49a4cc2 100644
--- a/arch/arm/mach-omap2/omap4-common.c
+++ b/arch/arm/mach-omap2/omap4-common.c
@@ -256,6 +256,38 @@ static int __init omap4_sar_ram_init(void)
256} 256}
257omap_early_initcall(omap4_sar_ram_init); 257omap_early_initcall(omap4_sar_ram_init);
258 258
259static struct of_device_id gic_match[] = {
260 { .compatible = "arm,cortex-a9-gic", },
261 { .compatible = "arm,cortex-a15-gic", },
262 { },
263};
264
265static struct device_node *gic_node;
266
267unsigned int omap4_xlate_irq(unsigned int hwirq)
268{
269 struct of_phandle_args irq_data;
270 unsigned int irq;
271
272 if (!gic_node)
273 gic_node = of_find_matching_node(NULL, gic_match);
274
275 if (WARN_ON(!gic_node))
276 return hwirq;
277
278 irq_data.np = gic_node;
279 irq_data.args_count = 3;
280 irq_data.args[0] = 0;
281 irq_data.args[1] = hwirq - OMAP44XX_IRQ_GIC_START;
282 irq_data.args[2] = IRQ_TYPE_LEVEL_HIGH;
283
284 irq = irq_create_of_mapping(&irq_data);
285 if (WARN_ON(!irq))
286 irq = hwirq;
287
288 return irq;
289}
290
259void __init omap_gic_of_init(void) 291void __init omap_gic_of_init(void)
260{ 292{
261 struct device_node *np; 293 struct device_node *np;
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index cbb908dc5cf0..9025ffffd2dc 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -3534,9 +3534,15 @@ int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res)
3534 3534
3535 mpu_irqs_cnt = _count_mpu_irqs(oh); 3535 mpu_irqs_cnt = _count_mpu_irqs(oh);
3536 for (i = 0; i < mpu_irqs_cnt; i++) { 3536 for (i = 0; i < mpu_irqs_cnt; i++) {
3537 unsigned int irq;
3538
3539 if (oh->xlate_irq)
3540 irq = oh->xlate_irq((oh->mpu_irqs + i)->irq);
3541 else
3542 irq = (oh->mpu_irqs + i)->irq;
3537 (res + r)->name = (oh->mpu_irqs + i)->name; 3543 (res + r)->name = (oh->mpu_irqs + i)->name;
3538 (res + r)->start = (oh->mpu_irqs + i)->irq; 3544 (res + r)->start = irq;
3539 (res + r)->end = (oh->mpu_irqs + i)->irq; 3545 (res + r)->end = irq;
3540 (res + r)->flags = IORESOURCE_IRQ; 3546 (res + r)->flags = IORESOURCE_IRQ;
3541 r++; 3547 r++;
3542 } 3548 }
diff --git a/arch/arm/mach-omap2/omap_hwmod.h b/arch/arm/mach-omap2/omap_hwmod.h
index 35ca6efbec31..5b42fafcaf55 100644
--- a/arch/arm/mach-omap2/omap_hwmod.h
+++ b/arch/arm/mach-omap2/omap_hwmod.h
@@ -676,6 +676,7 @@ struct omap_hwmod {
676 spinlock_t _lock; 676 spinlock_t _lock;
677 struct list_head node; 677 struct list_head node;
678 struct omap_hwmod_ocp_if *_mpu_port; 678 struct omap_hwmod_ocp_if *_mpu_port;
679 unsigned int (*xlate_irq)(unsigned int);
679 u16 flags; 680 u16 flags;
680 u8 mpu_rt_idx; 681 u8 mpu_rt_idx;
681 u8 response_lat; 682 u8 response_lat;
diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index c314b3c31117..f5e68a782025 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -479,6 +479,7 @@ static struct omap_hwmod omap44xx_dma_system_hwmod = {
479 .class = &omap44xx_dma_hwmod_class, 479 .class = &omap44xx_dma_hwmod_class,
480 .clkdm_name = "l3_dma_clkdm", 480 .clkdm_name = "l3_dma_clkdm",
481 .mpu_irqs = omap44xx_dma_system_irqs, 481 .mpu_irqs = omap44xx_dma_system_irqs,
482 .xlate_irq = omap4_xlate_irq,
482 .main_clk = "l3_div_ck", 483 .main_clk = "l3_div_ck",
483 .prcm = { 484 .prcm = {
484 .omap4 = { 485 .omap4 = {
@@ -640,6 +641,7 @@ static struct omap_hwmod omap44xx_dss_dispc_hwmod = {
640 .class = &omap44xx_dispc_hwmod_class, 641 .class = &omap44xx_dispc_hwmod_class,
641 .clkdm_name = "l3_dss_clkdm", 642 .clkdm_name = "l3_dss_clkdm",
642 .mpu_irqs = omap44xx_dss_dispc_irqs, 643 .mpu_irqs = omap44xx_dss_dispc_irqs,
644 .xlate_irq = omap4_xlate_irq,
643 .sdma_reqs = omap44xx_dss_dispc_sdma_reqs, 645 .sdma_reqs = omap44xx_dss_dispc_sdma_reqs,
644 .main_clk = "dss_dss_clk", 646 .main_clk = "dss_dss_clk",
645 .prcm = { 647 .prcm = {
@@ -693,6 +695,7 @@ static struct omap_hwmod omap44xx_dss_dsi1_hwmod = {
693 .class = &omap44xx_dsi_hwmod_class, 695 .class = &omap44xx_dsi_hwmod_class,
694 .clkdm_name = "l3_dss_clkdm", 696 .clkdm_name = "l3_dss_clkdm",
695 .mpu_irqs = omap44xx_dss_dsi1_irqs, 697 .mpu_irqs = omap44xx_dss_dsi1_irqs,
698 .xlate_irq = omap4_xlate_irq,
696 .sdma_reqs = omap44xx_dss_dsi1_sdma_reqs, 699 .sdma_reqs = omap44xx_dss_dsi1_sdma_reqs,
697 .main_clk = "dss_dss_clk", 700 .main_clk = "dss_dss_clk",
698 .prcm = { 701 .prcm = {
@@ -726,6 +729,7 @@ static struct omap_hwmod omap44xx_dss_dsi2_hwmod = {
726 .class = &omap44xx_dsi_hwmod_class, 729 .class = &omap44xx_dsi_hwmod_class,
727 .clkdm_name = "l3_dss_clkdm", 730 .clkdm_name = "l3_dss_clkdm",
728 .mpu_irqs = omap44xx_dss_dsi2_irqs, 731 .mpu_irqs = omap44xx_dss_dsi2_irqs,
732 .xlate_irq = omap4_xlate_irq,
729 .sdma_reqs = omap44xx_dss_dsi2_sdma_reqs, 733 .sdma_reqs = omap44xx_dss_dsi2_sdma_reqs,
730 .main_clk = "dss_dss_clk", 734 .main_clk = "dss_dss_clk",
731 .prcm = { 735 .prcm = {
@@ -784,6 +788,7 @@ static struct omap_hwmod omap44xx_dss_hdmi_hwmod = {
784 */ 788 */
785 .flags = HWMOD_SWSUP_SIDLE, 789 .flags = HWMOD_SWSUP_SIDLE,
786 .mpu_irqs = omap44xx_dss_hdmi_irqs, 790 .mpu_irqs = omap44xx_dss_hdmi_irqs,
791 .xlate_irq = omap4_xlate_irq,
787 .sdma_reqs = omap44xx_dss_hdmi_sdma_reqs, 792 .sdma_reqs = omap44xx_dss_hdmi_sdma_reqs,
788 .main_clk = "dss_48mhz_clk", 793 .main_clk = "dss_48mhz_clk",
789 .prcm = { 794 .prcm = {
diff --git a/arch/arm/mach-omap2/omap_hwmod_54xx_data.c b/arch/arm/mach-omap2/omap_hwmod_54xx_data.c
index 3e9523084b2a..7c3fac035e93 100644
--- a/arch/arm/mach-omap2/omap_hwmod_54xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_54xx_data.c
@@ -288,6 +288,7 @@ static struct omap_hwmod omap54xx_dma_system_hwmod = {
288 .class = &omap54xx_dma_hwmod_class, 288 .class = &omap54xx_dma_hwmod_class,
289 .clkdm_name = "dma_clkdm", 289 .clkdm_name = "dma_clkdm",
290 .mpu_irqs = omap54xx_dma_system_irqs, 290 .mpu_irqs = omap54xx_dma_system_irqs,
291 .xlate_irq = omap4_xlate_irq,
291 .main_clk = "l3_iclk_div", 292 .main_clk = "l3_iclk_div",
292 .prcm = { 293 .prcm = {
293 .omap4 = { 294 .omap4 = {
diff --git a/arch/arm/mach-omap2/prcm-common.h b/arch/arm/mach-omap2/prcm-common.h
index a8e4b582c527..6163d66102a3 100644
--- a/arch/arm/mach-omap2/prcm-common.h
+++ b/arch/arm/mach-omap2/prcm-common.h
@@ -498,6 +498,7 @@ struct omap_prcm_irq_setup {
498 u8 nr_irqs; 498 u8 nr_irqs;
499 const struct omap_prcm_irq *irqs; 499 const struct omap_prcm_irq *irqs;
500 int irq; 500 int irq;
501 unsigned int (*xlate_irq)(unsigned int);
501 void (*read_pending_irqs)(unsigned long *events); 502 void (*read_pending_irqs)(unsigned long *events);
502 void (*ocp_barrier)(void); 503 void (*ocp_barrier)(void);
503 void (*save_and_clear_irqen)(u32 *saved_mask); 504 void (*save_and_clear_irqen)(u32 *saved_mask);
diff --git a/arch/arm/mach-omap2/prm44xx.c b/arch/arm/mach-omap2/prm44xx.c
index cc170fb81ff7..408c64efb807 100644
--- a/arch/arm/mach-omap2/prm44xx.c
+++ b/arch/arm/mach-omap2/prm44xx.c
@@ -49,6 +49,7 @@ static struct omap_prcm_irq_setup omap4_prcm_irq_setup = {
49 .irqs = omap4_prcm_irqs, 49 .irqs = omap4_prcm_irqs,
50 .nr_irqs = ARRAY_SIZE(omap4_prcm_irqs), 50 .nr_irqs = ARRAY_SIZE(omap4_prcm_irqs),
51 .irq = 11 + OMAP44XX_IRQ_GIC_START, 51 .irq = 11 + OMAP44XX_IRQ_GIC_START,
52 .xlate_irq = omap4_xlate_irq,
52 .read_pending_irqs = &omap44xx_prm_read_pending_irqs, 53 .read_pending_irqs = &omap44xx_prm_read_pending_irqs,
53 .ocp_barrier = &omap44xx_prm_ocp_barrier, 54 .ocp_barrier = &omap44xx_prm_ocp_barrier,
54 .save_and_clear_irqen = &omap44xx_prm_save_and_clear_irqen, 55 .save_and_clear_irqen = &omap44xx_prm_save_and_clear_irqen,
@@ -751,8 +752,10 @@ static int omap44xx_prm_late_init(void)
751 } 752 }
752 753
753 /* Once OMAP4 DT is filled as well */ 754 /* Once OMAP4 DT is filled as well */
754 if (irq_num >= 0) 755 if (irq_num >= 0) {
755 omap4_prcm_irq_setup.irq = irq_num; 756 omap4_prcm_irq_setup.irq = irq_num;
757 omap4_prcm_irq_setup.xlate_irq = NULL;
758 }
756 } 759 }
757 760
758 omap44xx_prm_enable_io_wakeup(); 761 omap44xx_prm_enable_io_wakeup();
diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c
index 779940cb6e56..dea2833ca627 100644
--- a/arch/arm/mach-omap2/prm_common.c
+++ b/arch/arm/mach-omap2/prm_common.c
@@ -187,6 +187,7 @@ int omap_prcm_event_to_irq(const char *name)
187 */ 187 */
188void omap_prcm_irq_cleanup(void) 188void omap_prcm_irq_cleanup(void)
189{ 189{
190 unsigned int irq;
190 int i; 191 int i;
191 192
192 if (!prcm_irq_setup) { 193 if (!prcm_irq_setup) {
@@ -211,7 +212,11 @@ void omap_prcm_irq_cleanup(void)
211 kfree(prcm_irq_setup->priority_mask); 212 kfree(prcm_irq_setup->priority_mask);
212 prcm_irq_setup->priority_mask = NULL; 213 prcm_irq_setup->priority_mask = NULL;
213 214
214 irq_set_chained_handler(prcm_irq_setup->irq, NULL); 215 if (prcm_irq_setup->xlate_irq)
216 irq = prcm_irq_setup->xlate_irq(prcm_irq_setup->irq);
217 else
218 irq = prcm_irq_setup->irq;
219 irq_set_chained_handler(irq, NULL);
215 220
216 if (prcm_irq_setup->base_irq > 0) 221 if (prcm_irq_setup->base_irq > 0)
217 irq_free_descs(prcm_irq_setup->base_irq, 222 irq_free_descs(prcm_irq_setup->base_irq,
@@ -259,6 +264,7 @@ int omap_prcm_register_chain_handler(struct omap_prcm_irq_setup *irq_setup)
259 int offset, i; 264 int offset, i;
260 struct irq_chip_generic *gc; 265 struct irq_chip_generic *gc;
261 struct irq_chip_type *ct; 266 struct irq_chip_type *ct;
267 unsigned int irq;
262 268
263 if (!irq_setup) 269 if (!irq_setup)
264 return -EINVAL; 270 return -EINVAL;
@@ -298,7 +304,11 @@ int omap_prcm_register_chain_handler(struct omap_prcm_irq_setup *irq_setup)
298 1 << (offset & 0x1f); 304 1 << (offset & 0x1f);
299 } 305 }
300 306
301 irq_set_chained_handler(irq_setup->irq, omap_prcm_irq_handler); 307 if (irq_setup->xlate_irq)
308 irq = irq_setup->xlate_irq(irq_setup->irq);
309 else
310 irq = irq_setup->irq;
311 irq_set_chained_handler(irq, omap_prcm_irq_handler);
302 312
303 irq_setup->base_irq = irq_alloc_descs(-1, 0, irq_setup->nr_regs * 32, 313 irq_setup->base_irq = irq_alloc_descs(-1, 0, irq_setup->nr_regs * 32,
304 0); 314 0);
diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c
index 4457e731f7a4..292eca0e78ed 100644
--- a/arch/arm/mach-omap2/twl-common.c
+++ b/arch/arm/mach-omap2/twl-common.c
@@ -66,19 +66,24 @@ void __init omap_pmic_init(int bus, u32 clkrate,
66 omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1); 66 omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1);
67} 67}
68 68
69#ifdef CONFIG_ARCH_OMAP4
69void __init omap4_pmic_init(const char *pmic_type, 70void __init omap4_pmic_init(const char *pmic_type,
70 struct twl4030_platform_data *pmic_data, 71 struct twl4030_platform_data *pmic_data,
71 struct i2c_board_info *devices, int nr_devices) 72 struct i2c_board_info *devices, int nr_devices)
72{ 73{
73 /* PMIC part*/ 74 /* PMIC part*/
75 unsigned int irq;
76
74 omap_mux_init_signal("sys_nirq1", OMAP_PIN_INPUT_PULLUP | OMAP_PIN_OFF_WAKEUPENABLE); 77 omap_mux_init_signal("sys_nirq1", OMAP_PIN_INPUT_PULLUP | OMAP_PIN_OFF_WAKEUPENABLE);
75 omap_mux_init_signal("fref_clk0_out.sys_drm_msecure", OMAP_PIN_OUTPUT); 78 omap_mux_init_signal("fref_clk0_out.sys_drm_msecure", OMAP_PIN_OUTPUT);
76 omap_pmic_init(1, 400, pmic_type, 7 + OMAP44XX_IRQ_GIC_START, pmic_data); 79 irq = omap4_xlate_irq(7 + OMAP44XX_IRQ_GIC_START);
80 omap_pmic_init(1, 400, pmic_type, irq, pmic_data);
77 81
78 /* Register additional devices on i2c1 bus if needed */ 82 /* Register additional devices on i2c1 bus if needed */
79 if (devices) 83 if (devices)
80 i2c_register_board_info(1, devices, nr_devices); 84 i2c_register_board_info(1, devices, nr_devices);
81} 85}
86#endif
82 87
83void __init omap_pmic_late_init(void) 88void __init omap_pmic_late_init(void)
84{ 89{
diff --git a/arch/arm/mach-shmobile/board-ape6evm.c b/arch/arm/mach-shmobile/board-ape6evm.c
index 66f67816a844..444f22d370f0 100644
--- a/arch/arm/mach-shmobile/board-ape6evm.c
+++ b/arch/arm/mach-shmobile/board-ape6evm.c
@@ -18,6 +18,8 @@
18#include <linux/gpio_keys.h> 18#include <linux/gpio_keys.h>
19#include <linux/input.h> 19#include <linux/input.h>
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/irqchip.h>
22#include <linux/irqchip/arm-gic.h>
21#include <linux/kernel.h> 23#include <linux/kernel.h>
22#include <linux/mfd/tmio.h> 24#include <linux/mfd/tmio.h>
23#include <linux/mmc/host.h> 25#include <linux/mmc/host.h>
@@ -273,6 +275,22 @@ static void __init ape6evm_add_standard_devices(void)
273 sizeof(ape6evm_leds_pdata)); 275 sizeof(ape6evm_leds_pdata));
274} 276}
275 277
278static void __init ape6evm_legacy_init_time(void)
279{
280 /* Do not invoke DT-based timers via clocksource_of_init() */
281}
282
283static void __init ape6evm_legacy_init_irq(void)
284{
285 void __iomem *gic_dist_base = ioremap_nocache(0xf1001000, 0x1000);
286 void __iomem *gic_cpu_base = ioremap_nocache(0xf1002000, 0x1000);
287
288 gic_init(0, 29, gic_dist_base, gic_cpu_base);
289
290 /* Do not invoke DT-based interrupt code via irqchip_init() */
291}
292
293
276static const char *ape6evm_boards_compat_dt[] __initdata = { 294static const char *ape6evm_boards_compat_dt[] __initdata = {
277 "renesas,ape6evm", 295 "renesas,ape6evm",
278 NULL, 296 NULL,
@@ -280,7 +298,9 @@ static const char *ape6evm_boards_compat_dt[] __initdata = {
280 298
281DT_MACHINE_START(APE6EVM_DT, "ape6evm") 299DT_MACHINE_START(APE6EVM_DT, "ape6evm")
282 .init_early = shmobile_init_delay, 300 .init_early = shmobile_init_delay,
301 .init_irq = ape6evm_legacy_init_irq,
283 .init_machine = ape6evm_add_standard_devices, 302 .init_machine = ape6evm_add_standard_devices,
284 .init_late = shmobile_init_late, 303 .init_late = shmobile_init_late,
285 .dt_compat = ape6evm_boards_compat_dt, 304 .dt_compat = ape6evm_boards_compat_dt,
305 .init_time = ape6evm_legacy_init_time,
286MACHINE_END 306MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-lager.c b/arch/arm/mach-shmobile/board-lager.c
index f8197eb6e566..65b128dd4072 100644
--- a/arch/arm/mach-shmobile/board-lager.c
+++ b/arch/arm/mach-shmobile/board-lager.c
@@ -21,6 +21,8 @@
21#include <linux/input.h> 21#include <linux/input.h>
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/irq.h> 23#include <linux/irq.h>
24#include <linux/irqchip.h>
25#include <linux/irqchip/arm-gic.h>
24#include <linux/kernel.h> 26#include <linux/kernel.h>
25#include <linux/leds.h> 27#include <linux/leds.h>
26#include <linux/mfd/tmio.h> 28#include <linux/mfd/tmio.h>
@@ -811,6 +813,16 @@ static void __init lager_init(void)
811 lager_ksz8041_fixup); 813 lager_ksz8041_fixup);
812} 814}
813 815
816static void __init lager_legacy_init_irq(void)
817{
818 void __iomem *gic_dist_base = ioremap_nocache(0xf1001000, 0x1000);
819 void __iomem *gic_cpu_base = ioremap_nocache(0xf1002000, 0x1000);
820
821 gic_init(0, 29, gic_dist_base, gic_cpu_base);
822
823 /* Do not invoke DT-based interrupt code via irqchip_init() */
824}
825
814static const char * const lager_boards_compat_dt[] __initconst = { 826static const char * const lager_boards_compat_dt[] __initconst = {
815 "renesas,lager", 827 "renesas,lager",
816 NULL, 828 NULL,
@@ -819,6 +831,7 @@ static const char * const lager_boards_compat_dt[] __initconst = {
819DT_MACHINE_START(LAGER_DT, "lager") 831DT_MACHINE_START(LAGER_DT, "lager")
820 .smp = smp_ops(r8a7790_smp_ops), 832 .smp = smp_ops(r8a7790_smp_ops),
821 .init_early = shmobile_init_delay, 833 .init_early = shmobile_init_delay,
834 .init_irq = lager_legacy_init_irq,
822 .init_time = rcar_gen2_timer_init, 835 .init_time = rcar_gen2_timer_init,
823 .init_machine = lager_init, 836 .init_machine = lager_init,
824 .init_late = shmobile_init_late, 837 .init_late = shmobile_init_late,
diff --git a/arch/arm/mach-shmobile/setup-r8a7778.c b/arch/arm/mach-shmobile/setup-r8a7778.c
index 170bd146ba17..cef8895a9b82 100644
--- a/arch/arm/mach-shmobile/setup-r8a7778.c
+++ b/arch/arm/mach-shmobile/setup-r8a7778.c
@@ -576,11 +576,18 @@ void __init r8a7778_init_irq_extpin(int irlm)
576void __init r8a7778_init_irq_dt(void) 576void __init r8a7778_init_irq_dt(void)
577{ 577{
578 void __iomem *base = ioremap_nocache(0xfe700000, 0x00100000); 578 void __iomem *base = ioremap_nocache(0xfe700000, 0x00100000);
579#ifdef CONFIG_ARCH_SHMOBILE_LEGACY
580 void __iomem *gic_dist_base = ioremap_nocache(0xfe438000, 0x1000);
581 void __iomem *gic_cpu_base = ioremap_nocache(0xfe430000, 0x1000);
582#endif
579 583
580 BUG_ON(!base); 584 BUG_ON(!base);
581 585
586#ifdef CONFIG_ARCH_SHMOBILE_LEGACY
587 gic_init(0, 29, gic_dist_base, gic_cpu_base);
588#else
582 irqchip_init(); 589 irqchip_init();
583 590#endif
584 /* route all interrupts to ARM */ 591 /* route all interrupts to ARM */
585 __raw_writel(0x73ffffff, base + INT2NTSR0); 592 __raw_writel(0x73ffffff, base + INT2NTSR0);
586 __raw_writel(0xffffffff, base + INT2NTSR1); 593 __raw_writel(0xffffffff, base + INT2NTSR1);
diff --git a/arch/arm/mach-shmobile/setup-r8a7779.c b/arch/arm/mach-shmobile/setup-r8a7779.c
index 6156d172cf31..27dceaf9e688 100644
--- a/arch/arm/mach-shmobile/setup-r8a7779.c
+++ b/arch/arm/mach-shmobile/setup-r8a7779.c
@@ -720,10 +720,17 @@ static int r8a7779_set_wake(struct irq_data *data, unsigned int on)
720 720
721void __init r8a7779_init_irq_dt(void) 721void __init r8a7779_init_irq_dt(void)
722{ 722{
723#ifdef CONFIG_ARCH_SHMOBILE_LEGACY
724 void __iomem *gic_dist_base = ioremap_nocache(0xf0001000, 0x1000);
725 void __iomem *gic_cpu_base = ioremap_nocache(0xf0000100, 0x1000);
726#endif
723 gic_arch_extn.irq_set_wake = r8a7779_set_wake; 727 gic_arch_extn.irq_set_wake = r8a7779_set_wake;
724 728
729#ifdef CONFIG_ARCH_SHMOBILE_LEGACY
730 gic_init(0, 29, gic_dist_base, gic_cpu_base);
731#else
725 irqchip_init(); 732 irqchip_init();
726 733#endif
727 /* route all interrupts to ARM */ 734 /* route all interrupts to ARM */
728 __raw_writel(0xffffffff, INT2NTSR0); 735 __raw_writel(0xffffffff, INT2NTSR0);
729 __raw_writel(0x3fffffff, INT2NTSR1); 736 __raw_writel(0x3fffffff, INT2NTSR1);
diff --git a/arch/arm/mach-shmobile/setup-rcar-gen2.c b/arch/arm/mach-shmobile/setup-rcar-gen2.c
index 3dd6edd9bd1d..cc9470dfb1ce 100644
--- a/arch/arm/mach-shmobile/setup-rcar-gen2.c
+++ b/arch/arm/mach-shmobile/setup-rcar-gen2.c
@@ -133,7 +133,9 @@ void __init rcar_gen2_timer_init(void)
133#ifdef CONFIG_COMMON_CLK 133#ifdef CONFIG_COMMON_CLK
134 rcar_gen2_clocks_init(mode); 134 rcar_gen2_clocks_init(mode);
135#endif 135#endif
136#ifdef CONFIG_ARCH_SHMOBILE_MULTI
136 clocksource_of_init(); 137 clocksource_of_init();
138#endif
137} 139}
138 140
139struct memory_reserve_config { 141struct memory_reserve_config {
diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
index f1d027aa7a81..0edf2a6d2bbe 100644
--- a/arch/arm/mach-shmobile/timer.c
+++ b/arch/arm/mach-shmobile/timer.c
@@ -70,6 +70,18 @@ void __init shmobile_init_delay(void)
70 if (!max_freq) 70 if (!max_freq)
71 return; 71 return;
72 72
73#ifdef CONFIG_ARCH_SHMOBILE_LEGACY
74 /* Non-multiplatform r8a73a4 SoC cannot use arch timer due
75 * to GIC being initialized from C and arch timer via DT */
76 if (of_machine_is_compatible("renesas,r8a73a4"))
77 has_arch_timer = false;
78
79 /* Non-multiplatform r8a7790 SoC cannot use arch timer due
80 * to GIC being initialized from C and arch timer via DT */
81 if (of_machine_is_compatible("renesas,r8a7790"))
82 has_arch_timer = false;
83#endif
84
73 if (!has_arch_timer || !IS_ENABLED(CONFIG_ARM_ARCH_TIMER)) { 85 if (!has_arch_timer || !IS_ENABLED(CONFIG_ARM_ARCH_TIMER)) {
74 if (is_a7_a8_a9) 86 if (is_a7_a8_a9)
75 shmobile_setup_delay_hz(max_freq, 1, 3); 87 shmobile_setup_delay_hz(max_freq, 1, 3);
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 7864797609b3..a673c7f7e208 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -1940,13 +1940,32 @@ void arm_iommu_release_mapping(struct dma_iommu_mapping *mapping)
1940} 1940}
1941EXPORT_SYMBOL_GPL(arm_iommu_release_mapping); 1941EXPORT_SYMBOL_GPL(arm_iommu_release_mapping);
1942 1942
1943static int __arm_iommu_attach_device(struct device *dev,
1944 struct dma_iommu_mapping *mapping)
1945{
1946 int err;
1947
1948 err = iommu_attach_device(mapping->domain, dev);
1949 if (err)
1950 return err;
1951
1952 kref_get(&mapping->kref);
1953 dev->archdata.mapping = mapping;
1954
1955 pr_debug("Attached IOMMU controller to %s device.\n", dev_name(dev));
1956 return 0;
1957}
1958
1943/** 1959/**
1944 * arm_iommu_attach_device 1960 * arm_iommu_attach_device
1945 * @dev: valid struct device pointer 1961 * @dev: valid struct device pointer
1946 * @mapping: io address space mapping structure (returned from 1962 * @mapping: io address space mapping structure (returned from
1947 * arm_iommu_create_mapping) 1963 * arm_iommu_create_mapping)
1948 * 1964 *
1949 * Attaches specified io address space mapping to the provided device, 1965 * Attaches specified io address space mapping to the provided device.
1966 * This replaces the dma operations (dma_map_ops pointer) with the
1967 * IOMMU aware version.
1968 *
1950 * More than one client might be attached to the same io address space 1969 * More than one client might be attached to the same io address space
1951 * mapping. 1970 * mapping.
1952 */ 1971 */
@@ -1955,25 +1974,16 @@ int arm_iommu_attach_device(struct device *dev,
1955{ 1974{
1956 int err; 1975 int err;
1957 1976
1958 err = iommu_attach_device(mapping->domain, dev); 1977 err = __arm_iommu_attach_device(dev, mapping);
1959 if (err) 1978 if (err)
1960 return err; 1979 return err;
1961 1980
1962 kref_get(&mapping->kref); 1981 set_dma_ops(dev, &iommu_ops);
1963 dev->archdata.mapping = mapping;
1964
1965 pr_debug("Attached IOMMU controller to %s device.\n", dev_name(dev));
1966 return 0; 1982 return 0;
1967} 1983}
1968EXPORT_SYMBOL_GPL(arm_iommu_attach_device); 1984EXPORT_SYMBOL_GPL(arm_iommu_attach_device);
1969 1985
1970/** 1986static void __arm_iommu_detach_device(struct device *dev)
1971 * arm_iommu_detach_device
1972 * @dev: valid struct device pointer
1973 *
1974 * Detaches the provided device from a previously attached map.
1975 */
1976void arm_iommu_detach_device(struct device *dev)
1977{ 1987{
1978 struct dma_iommu_mapping *mapping; 1988 struct dma_iommu_mapping *mapping;
1979 1989
@@ -1989,6 +1999,19 @@ void arm_iommu_detach_device(struct device *dev)
1989 1999
1990 pr_debug("Detached IOMMU controller from %s device.\n", dev_name(dev)); 2000 pr_debug("Detached IOMMU controller from %s device.\n", dev_name(dev));
1991} 2001}
2002
2003/**
2004 * arm_iommu_detach_device
2005 * @dev: valid struct device pointer
2006 *
2007 * Detaches the provided device from a previously attached map.
2008 * This voids the dma operations (dma_map_ops pointer)
2009 */
2010void arm_iommu_detach_device(struct device *dev)
2011{
2012 __arm_iommu_detach_device(dev);
2013 set_dma_ops(dev, NULL);
2014}
1992EXPORT_SYMBOL_GPL(arm_iommu_detach_device); 2015EXPORT_SYMBOL_GPL(arm_iommu_detach_device);
1993 2016
1994static struct dma_map_ops *arm_get_iommu_dma_map_ops(bool coherent) 2017static struct dma_map_ops *arm_get_iommu_dma_map_ops(bool coherent)
@@ -2011,7 +2034,7 @@ static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
2011 return false; 2034 return false;
2012 } 2035 }
2013 2036
2014 if (arm_iommu_attach_device(dev, mapping)) { 2037 if (__arm_iommu_attach_device(dev, mapping)) {
2015 pr_warn("Failed to attached device %s to IOMMU_mapping\n", 2038 pr_warn("Failed to attached device %s to IOMMU_mapping\n",
2016 dev_name(dev)); 2039 dev_name(dev));
2017 arm_iommu_release_mapping(mapping); 2040 arm_iommu_release_mapping(mapping);
@@ -2025,7 +2048,7 @@ static void arm_teardown_iommu_dma_ops(struct device *dev)
2025{ 2048{
2026 struct dma_iommu_mapping *mapping = dev->archdata.mapping; 2049 struct dma_iommu_mapping *mapping = dev->archdata.mapping;
2027 2050
2028 arm_iommu_detach_device(dev); 2051 __arm_iommu_detach_device(dev);
2029 arm_iommu_release_mapping(mapping); 2052 arm_iommu_release_mapping(mapping);
2030} 2053}
2031 2054
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 1c43cec971b5..066688863920 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -85,6 +85,7 @@ vdso_install:
85# We use MRPROPER_FILES and CLEAN_FILES now 85# We use MRPROPER_FILES and CLEAN_FILES now
86archclean: 86archclean:
87 $(Q)$(MAKE) $(clean)=$(boot) 87 $(Q)$(MAKE) $(clean)=$(boot)
88 $(Q)$(MAKE) $(clean)=$(boot)/dts
88 89
89define archhelp 90define archhelp
90 echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)' 91 echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)'
diff --git a/arch/arm64/boot/dts/Makefile b/arch/arm64/boot/dts/Makefile
index 3b8d427c3985..c62b0f4d9ef6 100644
--- a/arch/arm64/boot/dts/Makefile
+++ b/arch/arm64/boot/dts/Makefile
@@ -3,6 +3,4 @@ dts-dirs += apm
3dts-dirs += arm 3dts-dirs += arm
4dts-dirs += cavium 4dts-dirs += cavium
5 5
6always := $(dtb-y)
7subdir-y := $(dts-dirs) 6subdir-y := $(dts-dirs)
8clean-files := *.dtb
diff --git a/arch/arm64/boot/dts/arm/juno.dts b/arch/arm64/boot/dts/arm/juno.dts
index cb3073e4e7a8..d429129ecb3d 100644
--- a/arch/arm64/boot/dts/arm/juno.dts
+++ b/arch/arm64/boot/dts/arm/juno.dts
@@ -22,7 +22,7 @@
22 }; 22 };
23 23
24 chosen { 24 chosen {
25 stdout-path = &soc_uart0; 25 stdout-path = "serial0:115200n8";
26 }; 26 };
27 27
28 psci { 28 psci {
diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h
index 865a7e28ea2d..3cb4c856b10d 100644
--- a/arch/arm64/include/asm/kvm_emulate.h
+++ b/arch/arm64/include/asm/kvm_emulate.h
@@ -45,6 +45,16 @@ static inline void vcpu_reset_hcr(struct kvm_vcpu *vcpu)
45 vcpu->arch.hcr_el2 &= ~HCR_RW; 45 vcpu->arch.hcr_el2 &= ~HCR_RW;
46} 46}
47 47
48static inline unsigned long vcpu_get_hcr(struct kvm_vcpu *vcpu)
49{
50 return vcpu->arch.hcr_el2;
51}
52
53static inline void vcpu_set_hcr(struct kvm_vcpu *vcpu, unsigned long hcr)
54{
55 vcpu->arch.hcr_el2 = hcr;
56}
57
48static inline unsigned long *vcpu_pc(const struct kvm_vcpu *vcpu) 58static inline unsigned long *vcpu_pc(const struct kvm_vcpu *vcpu)
49{ 59{
50 return (unsigned long *)&vcpu_gp_regs(vcpu)->regs.pc; 60 return (unsigned long *)&vcpu_gp_regs(vcpu)->regs.pc;
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 0b7dfdb931df..acd101a9014d 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -116,9 +116,6 @@ struct kvm_vcpu_arch {
116 * Anything that is not used directly from assembly code goes 116 * Anything that is not used directly from assembly code goes
117 * here. 117 * here.
118 */ 118 */
119 /* dcache set/way operation pending */
120 int last_pcpu;
121 cpumask_t require_dcache_flush;
122 119
123 /* Don't run the guest */ 120 /* Don't run the guest */
124 bool pause; 121 bool pause;
diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h
index 14a74f136272..adcf49547301 100644
--- a/arch/arm64/include/asm/kvm_mmu.h
+++ b/arch/arm64/include/asm/kvm_mmu.h
@@ -243,24 +243,46 @@ static inline bool vcpu_has_cache_enabled(struct kvm_vcpu *vcpu)
243 return (vcpu_sys_reg(vcpu, SCTLR_EL1) & 0b101) == 0b101; 243 return (vcpu_sys_reg(vcpu, SCTLR_EL1) & 0b101) == 0b101;
244} 244}
245 245
246static inline void coherent_cache_guest_page(struct kvm_vcpu *vcpu, hva_t hva, 246static inline void __coherent_cache_guest_page(struct kvm_vcpu *vcpu, pfn_t pfn,
247 unsigned long size, 247 unsigned long size,
248 bool ipa_uncached) 248 bool ipa_uncached)
249{ 249{
250 void *va = page_address(pfn_to_page(pfn));
251
250 if (!vcpu_has_cache_enabled(vcpu) || ipa_uncached) 252 if (!vcpu_has_cache_enabled(vcpu) || ipa_uncached)
251 kvm_flush_dcache_to_poc((void *)hva, size); 253 kvm_flush_dcache_to_poc(va, size);
252 254
253 if (!icache_is_aliasing()) { /* PIPT */ 255 if (!icache_is_aliasing()) { /* PIPT */
254 flush_icache_range(hva, hva + size); 256 flush_icache_range((unsigned long)va,
257 (unsigned long)va + size);
255 } else if (!icache_is_aivivt()) { /* non ASID-tagged VIVT */ 258 } else if (!icache_is_aivivt()) { /* non ASID-tagged VIVT */
256 /* any kind of VIPT cache */ 259 /* any kind of VIPT cache */
257 __flush_icache_all(); 260 __flush_icache_all();
258 } 261 }
259} 262}
260 263
264static inline void __kvm_flush_dcache_pte(pte_t pte)
265{
266 struct page *page = pte_page(pte);
267 kvm_flush_dcache_to_poc(page_address(page), PAGE_SIZE);
268}
269
270static inline void __kvm_flush_dcache_pmd(pmd_t pmd)
271{
272 struct page *page = pmd_page(pmd);
273 kvm_flush_dcache_to_poc(page_address(page), PMD_SIZE);
274}
275
276static inline void __kvm_flush_dcache_pud(pud_t pud)
277{
278 struct page *page = pud_page(pud);
279 kvm_flush_dcache_to_poc(page_address(page), PUD_SIZE);
280}
281
261#define kvm_virt_to_phys(x) __virt_to_phys((unsigned long)(x)) 282#define kvm_virt_to_phys(x) __virt_to_phys((unsigned long)(x))
262 283
263void stage2_flush_vm(struct kvm *kvm); 284void kvm_set_way_flush(struct kvm_vcpu *vcpu);
285void kvm_toggle_cache(struct kvm_vcpu *vcpu, bool was_enabled);
264 286
265#endif /* __ASSEMBLY__ */ 287#endif /* __ASSEMBLY__ */
266#endif /* __ARM64_KVM_MMU_H__ */ 288#endif /* __ARM64_KVM_MMU_H__ */
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 3d7c2df89946..f31e8bb2bc5b 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -69,68 +69,31 @@ static u32 get_ccsidr(u32 csselr)
69 return ccsidr; 69 return ccsidr;
70} 70}
71 71
72static void do_dc_cisw(u32 val) 72/*
73{ 73 * See note at ARMv7 ARM B1.14.4 (TL;DR: S/W ops are not easily virtualized).
74 asm volatile("dc cisw, %x0" : : "r" (val)); 74 */
75 dsb(ish);
76}
77
78static void do_dc_csw(u32 val)
79{
80 asm volatile("dc csw, %x0" : : "r" (val));
81 dsb(ish);
82}
83
84/* See note at ARM ARM B1.14.4 */
85static bool access_dcsw(struct kvm_vcpu *vcpu, 75static bool access_dcsw(struct kvm_vcpu *vcpu,
86 const struct sys_reg_params *p, 76 const struct sys_reg_params *p,
87 const struct sys_reg_desc *r) 77 const struct sys_reg_desc *r)
88{ 78{
89 unsigned long val;
90 int cpu;
91
92 if (!p->is_write) 79 if (!p->is_write)
93 return read_from_write_only(vcpu, p); 80 return read_from_write_only(vcpu, p);
94 81
95 cpu = get_cpu(); 82 kvm_set_way_flush(vcpu);
96
97 cpumask_setall(&vcpu->arch.require_dcache_flush);
98 cpumask_clear_cpu(cpu, &vcpu->arch.require_dcache_flush);
99
100 /* If we were already preempted, take the long way around */
101 if (cpu != vcpu->arch.last_pcpu) {
102 flush_cache_all();
103 goto done;
104 }
105
106 val = *vcpu_reg(vcpu, p->Rt);
107
108 switch (p->CRm) {
109 case 6: /* Upgrade DCISW to DCCISW, as per HCR.SWIO */
110 case 14: /* DCCISW */
111 do_dc_cisw(val);
112 break;
113
114 case 10: /* DCCSW */
115 do_dc_csw(val);
116 break;
117 }
118
119done:
120 put_cpu();
121
122 return true; 83 return true;
123} 84}
124 85
125/* 86/*
126 * Generic accessor for VM registers. Only called as long as HCR_TVM 87 * Generic accessor for VM registers. Only called as long as HCR_TVM
127 * is set. 88 * is set. If the guest enables the MMU, we stop trapping the VM
89 * sys_regs and leave it in complete control of the caches.
128 */ 90 */
129static bool access_vm_reg(struct kvm_vcpu *vcpu, 91static bool access_vm_reg(struct kvm_vcpu *vcpu,
130 const struct sys_reg_params *p, 92 const struct sys_reg_params *p,
131 const struct sys_reg_desc *r) 93 const struct sys_reg_desc *r)
132{ 94{
133 unsigned long val; 95 unsigned long val;
96 bool was_enabled = vcpu_has_cache_enabled(vcpu);
134 97
135 BUG_ON(!p->is_write); 98 BUG_ON(!p->is_write);
136 99
@@ -143,25 +106,7 @@ static bool access_vm_reg(struct kvm_vcpu *vcpu,
143 vcpu_cp15_64_low(vcpu, r->reg) = val & 0xffffffffUL; 106 vcpu_cp15_64_low(vcpu, r->reg) = val & 0xffffffffUL;
144 } 107 }
145 108
146 return true; 109 kvm_toggle_cache(vcpu, was_enabled);
147}
148
149/*
150 * SCTLR_EL1 accessor. Only called as long as HCR_TVM is set. If the
151 * guest enables the MMU, we stop trapping the VM sys_regs and leave
152 * it in complete control of the caches.
153 */
154static bool access_sctlr(struct kvm_vcpu *vcpu,
155 const struct sys_reg_params *p,
156 const struct sys_reg_desc *r)
157{
158 access_vm_reg(vcpu, p, r);
159
160 if (vcpu_has_cache_enabled(vcpu)) { /* MMU+Caches enabled? */
161 vcpu->arch.hcr_el2 &= ~HCR_TVM;
162 stage2_flush_vm(vcpu->kvm);
163 }
164
165 return true; 110 return true;
166} 111}
167 112
@@ -377,7 +322,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
377 NULL, reset_mpidr, MPIDR_EL1 }, 322 NULL, reset_mpidr, MPIDR_EL1 },
378 /* SCTLR_EL1 */ 323 /* SCTLR_EL1 */
379 { Op0(0b11), Op1(0b000), CRn(0b0001), CRm(0b0000), Op2(0b000), 324 { Op0(0b11), Op1(0b000), CRn(0b0001), CRm(0b0000), Op2(0b000),
380 access_sctlr, reset_val, SCTLR_EL1, 0x00C50078 }, 325 access_vm_reg, reset_val, SCTLR_EL1, 0x00C50078 },
381 /* CPACR_EL1 */ 326 /* CPACR_EL1 */
382 { Op0(0b11), Op1(0b000), CRn(0b0001), CRm(0b0000), Op2(0b010), 327 { Op0(0b11), Op1(0b000), CRn(0b0001), CRm(0b0000), Op2(0b010),
383 NULL, reset_val, CPACR_EL1, 0 }, 328 NULL, reset_val, CPACR_EL1, 0 },
@@ -657,7 +602,7 @@ static const struct sys_reg_desc cp14_64_regs[] = {
657 * register). 602 * register).
658 */ 603 */
659static const struct sys_reg_desc cp15_regs[] = { 604static const struct sys_reg_desc cp15_regs[] = {
660 { Op1( 0), CRn( 1), CRm( 0), Op2( 0), access_sctlr, NULL, c1_SCTLR }, 605 { Op1( 0), CRn( 1), CRm( 0), Op2( 0), access_vm_reg, NULL, c1_SCTLR },
661 { Op1( 0), CRn( 2), CRm( 0), Op2( 0), access_vm_reg, NULL, c2_TTBR0 }, 606 { Op1( 0), CRn( 2), CRm( 0), Op2( 0), access_vm_reg, NULL, c2_TTBR0 },
662 { Op1( 0), CRn( 2), CRm( 0), Op2( 1), access_vm_reg, NULL, c2_TTBR1 }, 607 { Op1( 0), CRn( 2), CRm( 0), Op2( 1), access_vm_reg, NULL, c2_TTBR1 },
663 { Op1( 0), CRn( 2), CRm( 0), Op2( 2), access_vm_reg, NULL, c2_TTBCR }, 608 { Op1( 0), CRn( 2), CRm( 0), Op2( 2), access_vm_reg, NULL, c2_TTBCR },
diff --git a/arch/arm64/mm/dump.c b/arch/arm64/mm/dump.c
index cf33f33333cc..d54dc9ac4b70 100644
--- a/arch/arm64/mm/dump.c
+++ b/arch/arm64/mm/dump.c
@@ -15,6 +15,7 @@
15 */ 15 */
16#include <linux/debugfs.h> 16#include <linux/debugfs.h>
17#include <linux/fs.h> 17#include <linux/fs.h>
18#include <linux/io.h>
18#include <linux/mm.h> 19#include <linux/mm.h>
19#include <linux/sched.h> 20#include <linux/sched.h>
20#include <linux/seq_file.h> 21#include <linux/seq_file.h>
diff --git a/arch/avr32/kernel/module.c b/arch/avr32/kernel/module.c
index 2c9412908024..164efa009e5b 100644
--- a/arch/avr32/kernel/module.c
+++ b/arch/avr32/kernel/module.c
@@ -19,12 +19,10 @@
19#include <linux/moduleloader.h> 19#include <linux/moduleloader.h>
20#include <linux/vmalloc.h> 20#include <linux/vmalloc.h>
21 21
22void module_free(struct module *mod, void *module_region) 22void module_arch_freeing_init(struct module *mod)
23{ 23{
24 vfree(mod->arch.syminfo); 24 vfree(mod->arch.syminfo);
25 mod->arch.syminfo = NULL; 25 mod->arch.syminfo = NULL;
26
27 vfree(module_region);
28} 26}
29 27
30static inline int check_rela(Elf32_Rela *rela, struct module *module, 28static inline int check_rela(Elf32_Rela *rela, struct module *module,
@@ -291,12 +289,3 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
291 289
292 return ret; 290 return ret;
293} 291}
294
295int module_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
296 struct module *module)
297{
298 vfree(module->arch.syminfo);
299 module->arch.syminfo = NULL;
300
301 return 0;
302}
diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
index 0eca93327195..d223a8b57c1e 100644
--- a/arch/avr32/mm/fault.c
+++ b/arch/avr32/mm/fault.c
@@ -142,6 +142,8 @@ good_area:
142 if (unlikely(fault & VM_FAULT_ERROR)) { 142 if (unlikely(fault & VM_FAULT_ERROR)) {
143 if (fault & VM_FAULT_OOM) 143 if (fault & VM_FAULT_OOM)
144 goto out_of_memory; 144 goto out_of_memory;
145 else if (fault & VM_FAULT_SIGSEGV)
146 goto bad_area;
145 else if (fault & VM_FAULT_SIGBUS) 147 else if (fault & VM_FAULT_SIGBUS)
146 goto do_sigbus; 148 goto do_sigbus;
147 BUG(); 149 BUG();
diff --git a/arch/cris/arch-v32/drivers/sync_serial.c b/arch/cris/arch-v32/drivers/sync_serial.c
index 08a313fc2241..f772068d9e79 100644
--- a/arch/cris/arch-v32/drivers/sync_serial.c
+++ b/arch/cris/arch-v32/drivers/sync_serial.c
@@ -604,7 +604,7 @@ static ssize_t __sync_serial_read(struct file *file,
604 struct timespec *ts) 604 struct timespec *ts)
605{ 605{
606 unsigned long flags; 606 unsigned long flags;
607 int dev = MINOR(file->f_dentry->d_inode->i_rdev); 607 int dev = MINOR(file_inode(file)->i_rdev);
608 int avail; 608 int avail;
609 struct sync_port *port; 609 struct sync_port *port;
610 unsigned char *start; 610 unsigned char *start;
diff --git a/arch/cris/kernel/module.c b/arch/cris/kernel/module.c
index 51123f985eb5..af04cb6b6dc9 100644
--- a/arch/cris/kernel/module.c
+++ b/arch/cris/kernel/module.c
@@ -36,7 +36,7 @@ void *module_alloc(unsigned long size)
36} 36}
37 37
38/* Free memory returned from module_alloc */ 38/* Free memory returned from module_alloc */
39void module_free(struct module *mod, void *module_region) 39void module_memfree(void *module_region)
40{ 40{
41 kfree(module_region); 41 kfree(module_region);
42} 42}
diff --git a/arch/cris/mm/fault.c b/arch/cris/mm/fault.c
index 1790f22e71a2..2686a7aa8ec8 100644
--- a/arch/cris/mm/fault.c
+++ b/arch/cris/mm/fault.c
@@ -176,6 +176,8 @@ retry:
176 if (unlikely(fault & VM_FAULT_ERROR)) { 176 if (unlikely(fault & VM_FAULT_ERROR)) {
177 if (fault & VM_FAULT_OOM) 177 if (fault & VM_FAULT_OOM)
178 goto out_of_memory; 178 goto out_of_memory;
179 else if (fault & VM_FAULT_SIGSEGV)
180 goto bad_area;
179 else if (fault & VM_FAULT_SIGBUS) 181 else if (fault & VM_FAULT_SIGBUS)
180 goto do_sigbus; 182 goto do_sigbus;
181 BUG(); 183 BUG();
diff --git a/arch/frv/mb93090-mb00/pci-frv.c b/arch/frv/mb93090-mb00/pci-frv.c
index 67b1d1685759..0635bd6c2af3 100644
--- a/arch/frv/mb93090-mb00/pci-frv.c
+++ b/arch/frv/mb93090-mb00/pci-frv.c
@@ -94,7 +94,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
94 r = &dev->resource[idx]; 94 r = &dev->resource[idx];
95 if (!r->start) 95 if (!r->start)
96 continue; 96 continue;
97 pci_claim_resource(dev, idx); 97 pci_claim_bridge_resource(dev, idx);
98 } 98 }
99 } 99 }
100 pcibios_allocate_bus_resources(&bus->children); 100 pcibios_allocate_bus_resources(&bus->children);
diff --git a/arch/frv/mm/fault.c b/arch/frv/mm/fault.c
index 9a66372fc7c7..ec4917ddf678 100644
--- a/arch/frv/mm/fault.c
+++ b/arch/frv/mm/fault.c
@@ -168,6 +168,8 @@ asmlinkage void do_page_fault(int datammu, unsigned long esr0, unsigned long ear
168 if (unlikely(fault & VM_FAULT_ERROR)) { 168 if (unlikely(fault & VM_FAULT_ERROR)) {
169 if (fault & VM_FAULT_OOM) 169 if (fault & VM_FAULT_OOM)
170 goto out_of_memory; 170 goto out_of_memory;
171 else if (fault & VM_FAULT_SIGSEGV)
172 goto bad_area;
171 else if (fault & VM_FAULT_SIGBUS) 173 else if (fault & VM_FAULT_SIGBUS)
172 goto do_sigbus; 174 goto do_sigbus;
173 BUG(); 175 BUG();
diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
index 24603be24c14..29754aae5177 100644
--- a/arch/ia64/kernel/module.c
+++ b/arch/ia64/kernel/module.c
@@ -305,14 +305,12 @@ plt_target (struct plt_entry *plt)
305#endif /* !USE_BRL */ 305#endif /* !USE_BRL */
306 306
307void 307void
308module_free (struct module *mod, void *module_region) 308module_arch_freeing_init (struct module *mod)
309{ 309{
310 if (mod && mod->arch.init_unw_table && 310 if (mod->arch.init_unw_table) {
311 module_region == mod->module_init) {
312 unw_remove_unwind_table(mod->arch.init_unw_table); 311 unw_remove_unwind_table(mod->arch.init_unw_table);
313 mod->arch.init_unw_table = NULL; 312 mod->arch.init_unw_table = NULL;
314 } 313 }
315 vfree(module_region);
316} 314}
317 315
318/* Have we already seen one of these relocations? */ 316/* Have we already seen one of these relocations? */
diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
index 7225dad87094..ba5ba7accd0d 100644
--- a/arch/ia64/mm/fault.c
+++ b/arch/ia64/mm/fault.c
@@ -172,6 +172,8 @@ retry:
172 */ 172 */
173 if (fault & VM_FAULT_OOM) { 173 if (fault & VM_FAULT_OOM) {
174 goto out_of_memory; 174 goto out_of_memory;
175 } else if (fault & VM_FAULT_SIGSEGV) {
176 goto bad_area;
175 } else if (fault & VM_FAULT_SIGBUS) { 177 } else if (fault & VM_FAULT_SIGBUS) {
176 signal = SIGBUS; 178 signal = SIGBUS;
177 goto bad_area; 179 goto bad_area;
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 291a582777cf..900cc93e5409 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -487,45 +487,39 @@ int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
487 return 0; 487 return 0;
488} 488}
489 489
490static int is_valid_resource(struct pci_dev *dev, int idx) 490void pcibios_fixup_device_resources(struct pci_dev *dev)
491{ 491{
492 unsigned int i, type_mask = IORESOURCE_IO | IORESOURCE_MEM; 492 int idx;
493 struct resource *devr = &dev->resource[idx], *busr;
494 493
495 if (!dev->bus) 494 if (!dev->bus)
496 return 0; 495 return;
497
498 pci_bus_for_each_resource(dev->bus, busr, i) {
499 if (!busr || ((busr->flags ^ devr->flags) & type_mask))
500 continue;
501 if ((devr->start) && (devr->start >= busr->start) &&
502 (devr->end <= busr->end))
503 return 1;
504 }
505 return 0;
506}
507 496
508static void pcibios_fixup_resources(struct pci_dev *dev, int start, int limit) 497 for (idx = 0; idx < PCI_BRIDGE_RESOURCES; idx++) {
509{ 498 struct resource *r = &dev->resource[idx];
510 int i;
511 499
512 for (i = start; i < limit; i++) { 500 if (!r->flags || r->parent || !r->start)
513 if (!dev->resource[i].flags)
514 continue; 501 continue;
515 if ((is_valid_resource(dev, i)))
516 pci_claim_resource(dev, i);
517 }
518}
519 502
520void pcibios_fixup_device_resources(struct pci_dev *dev) 503 pci_claim_resource(dev, idx);
521{ 504 }
522 pcibios_fixup_resources(dev, 0, PCI_BRIDGE_RESOURCES);
523} 505}
524EXPORT_SYMBOL_GPL(pcibios_fixup_device_resources); 506EXPORT_SYMBOL_GPL(pcibios_fixup_device_resources);
525 507
526static void pcibios_fixup_bridge_resources(struct pci_dev *dev) 508static void pcibios_fixup_bridge_resources(struct pci_dev *dev)
527{ 509{
528 pcibios_fixup_resources(dev, PCI_BRIDGE_RESOURCES, PCI_NUM_RESOURCES); 510 int idx;
511
512 if (!dev->bus)
513 return;
514
515 for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) {
516 struct resource *r = &dev->resource[idx];
517
518 if (!r->flags || r->parent || !r->start)
519 continue;
520
521 pci_claim_bridge_resource(dev, idx);
522 }
529} 523}
530 524
531/* 525/*
diff --git a/arch/m32r/mm/fault.c b/arch/m32r/mm/fault.c
index e9c6a8014bd6..e3d4d4890104 100644
--- a/arch/m32r/mm/fault.c
+++ b/arch/m32r/mm/fault.c
@@ -200,6 +200,8 @@ good_area:
200 if (unlikely(fault & VM_FAULT_ERROR)) { 200 if (unlikely(fault & VM_FAULT_ERROR)) {
201 if (fault & VM_FAULT_OOM) 201 if (fault & VM_FAULT_OOM)
202 goto out_of_memory; 202 goto out_of_memory;
203 else if (fault & VM_FAULT_SIGSEGV)
204 goto bad_area;
203 else if (fault & VM_FAULT_SIGBUS) 205 else if (fault & VM_FAULT_SIGBUS)
204 goto do_sigbus; 206 goto do_sigbus;
205 BUG(); 207 BUG();
diff --git a/arch/m68k/mm/fault.c b/arch/m68k/mm/fault.c
index 2bd7487440c4..b2f04aee46ec 100644
--- a/arch/m68k/mm/fault.c
+++ b/arch/m68k/mm/fault.c
@@ -145,6 +145,8 @@ good_area:
145 if (unlikely(fault & VM_FAULT_ERROR)) { 145 if (unlikely(fault & VM_FAULT_ERROR)) {
146 if (fault & VM_FAULT_OOM) 146 if (fault & VM_FAULT_OOM)
147 goto out_of_memory; 147 goto out_of_memory;
148 else if (fault & VM_FAULT_SIGSEGV)
149 goto map_err;
148 else if (fault & VM_FAULT_SIGBUS) 150 else if (fault & VM_FAULT_SIGBUS)
149 goto bus_err; 151 goto bus_err;
150 BUG(); 152 BUG();
diff --git a/arch/metag/mm/fault.c b/arch/metag/mm/fault.c
index 332680e5ebf2..2de5dc695a87 100644
--- a/arch/metag/mm/fault.c
+++ b/arch/metag/mm/fault.c
@@ -141,6 +141,8 @@ good_area:
141 if (unlikely(fault & VM_FAULT_ERROR)) { 141 if (unlikely(fault & VM_FAULT_ERROR)) {
142 if (fault & VM_FAULT_OOM) 142 if (fault & VM_FAULT_OOM)
143 goto out_of_memory; 143 goto out_of_memory;
144 else if (fault & VM_FAULT_SIGSEGV)
145 goto bad_area;
144 else if (fault & VM_FAULT_SIGBUS) 146 else if (fault & VM_FAULT_SIGBUS)
145 goto do_sigbus; 147 goto do_sigbus;
146 BUG(); 148 BUG();
diff --git a/arch/microblaze/mm/fault.c b/arch/microblaze/mm/fault.c
index fa4cf52aa7a6..d46a5ebb7570 100644
--- a/arch/microblaze/mm/fault.c
+++ b/arch/microblaze/mm/fault.c
@@ -224,6 +224,8 @@ good_area:
224 if (unlikely(fault & VM_FAULT_ERROR)) { 224 if (unlikely(fault & VM_FAULT_ERROR)) {
225 if (fault & VM_FAULT_OOM) 225 if (fault & VM_FAULT_OOM)
226 goto out_of_memory; 226 goto out_of_memory;
227 else if (fault & VM_FAULT_SIGSEGV)
228 goto bad_area;
227 else if (fault & VM_FAULT_SIGBUS) 229 else if (fault & VM_FAULT_SIGBUS)
228 goto do_sigbus; 230 goto do_sigbus;
229 BUG(); 231 BUG();
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index b30e41c0c033..48528fb81eff 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1026,6 +1026,8 @@ static void pcibios_allocate_bus_resources(struct pci_bus *bus)
1026 pr, (pr && pr->name) ? pr->name : "nil"); 1026 pr, (pr && pr->name) ? pr->name : "nil");
1027 1027
1028 if (pr && !(pr->flags & IORESOURCE_UNSET)) { 1028 if (pr && !(pr->flags & IORESOURCE_UNSET)) {
1029 struct pci_dev *dev = bus->self;
1030
1029 if (request_resource(pr, res) == 0) 1031 if (request_resource(pr, res) == 0)
1030 continue; 1032 continue;
1031 /* 1033 /*
@@ -1035,6 +1037,12 @@ static void pcibios_allocate_bus_resources(struct pci_bus *bus)
1035 */ 1037 */
1036 if (reparent_resources(pr, res) == 0) 1038 if (reparent_resources(pr, res) == 0)
1037 continue; 1039 continue;
1040
1041 if (dev && i < PCI_BRIDGE_RESOURCE_NUM &&
1042 pci_claim_bridge_resource(dev,
1043 i + PCI_BRIDGE_RESOURCES) == 0)
1044 continue;
1045
1038 } 1046 }
1039 pr_warn("PCI: Cannot allocate resource region "); 1047 pr_warn("PCI: Cannot allocate resource region ");
1040 pr_cont("%d of PCI bridge %d, will remap\n", i, bus->number); 1048 pr_cont("%d of PCI bridge %d, will remap\n", i, bus->number);
@@ -1227,7 +1235,10 @@ void pcibios_claim_one_bus(struct pci_bus *bus)
1227 (unsigned long long)r->end, 1235 (unsigned long long)r->end,
1228 (unsigned int)r->flags); 1236 (unsigned int)r->flags);
1229 1237
1230 pci_claim_resource(dev, i); 1238 if (pci_claim_resource(dev, i) == 0)
1239 continue;
1240
1241 pci_claim_bridge_resource(dev, i);
1231 } 1242 }
1232 } 1243 }
1233 1244
diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
index becc42bb1849..70ab5d664332 100644
--- a/arch/mips/mm/fault.c
+++ b/arch/mips/mm/fault.c
@@ -158,6 +158,8 @@ good_area:
158 if (unlikely(fault & VM_FAULT_ERROR)) { 158 if (unlikely(fault & VM_FAULT_ERROR)) {
159 if (fault & VM_FAULT_OOM) 159 if (fault & VM_FAULT_OOM)
160 goto out_of_memory; 160 goto out_of_memory;
161 else if (fault & VM_FAULT_SIGSEGV)
162 goto bad_area;
161 else if (fault & VM_FAULT_SIGBUS) 163 else if (fault & VM_FAULT_SIGBUS)
162 goto do_sigbus; 164 goto do_sigbus;
163 BUG(); 165 BUG();
diff --git a/arch/mips/net/bpf_jit.c b/arch/mips/net/bpf_jit.c
index 9fd6834a2172..5d6139390bf8 100644
--- a/arch/mips/net/bpf_jit.c
+++ b/arch/mips/net/bpf_jit.c
@@ -1388,7 +1388,7 @@ out:
1388void bpf_jit_free(struct bpf_prog *fp) 1388void bpf_jit_free(struct bpf_prog *fp)
1389{ 1389{
1390 if (fp->jited) 1390 if (fp->jited)
1391 module_free(NULL, fp->bpf_func); 1391 module_memfree(fp->bpf_func);
1392 1392
1393 bpf_prog_unlock_free(fp); 1393 bpf_prog_unlock_free(fp);
1394} 1394}
diff --git a/arch/mn10300/mm/fault.c b/arch/mn10300/mm/fault.c
index 3516cbdf1ee9..0c2cc5d39c8e 100644
--- a/arch/mn10300/mm/fault.c
+++ b/arch/mn10300/mm/fault.c
@@ -262,6 +262,8 @@ good_area:
262 if (unlikely(fault & VM_FAULT_ERROR)) { 262 if (unlikely(fault & VM_FAULT_ERROR)) {
263 if (fault & VM_FAULT_OOM) 263 if (fault & VM_FAULT_OOM)
264 goto out_of_memory; 264 goto out_of_memory;
265 else if (fault & VM_FAULT_SIGSEGV)
266 goto bad_area;
265 else if (fault & VM_FAULT_SIGBUS) 267 else if (fault & VM_FAULT_SIGBUS)
266 goto do_sigbus; 268 goto do_sigbus;
267 BUG(); 269 BUG();
diff --git a/arch/mn10300/unit-asb2305/pci-asb2305.c b/arch/mn10300/unit-asb2305/pci-asb2305.c
index febb9cd83177..b5b036f64275 100644
--- a/arch/mn10300/unit-asb2305/pci-asb2305.c
+++ b/arch/mn10300/unit-asb2305/pci-asb2305.c
@@ -106,7 +106,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
106 if (!r->flags) 106 if (!r->flags)
107 continue; 107 continue;
108 if (!r->start || 108 if (!r->start ||
109 pci_claim_resource(dev, idx) < 0) { 109 pci_claim_bridge_resource(dev, idx) < 0) {
110 printk(KERN_ERR "PCI:" 110 printk(KERN_ERR "PCI:"
111 " Cannot allocate resource" 111 " Cannot allocate resource"
112 " region %d of bridge %s\n", 112 " region %d of bridge %s\n",
diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c
index 6b4339f8c9c2..471ff398090c 100644
--- a/arch/mn10300/unit-asb2305/pci.c
+++ b/arch/mn10300/unit-asb2305/pci.c
@@ -281,42 +281,37 @@ static int __init pci_check_direct(void)
281 return -ENODEV; 281 return -ENODEV;
282} 282}
283 283
284static int is_valid_resource(struct pci_dev *dev, int idx) 284static void pcibios_fixup_device_resources(struct pci_dev *dev)
285{ 285{
286 unsigned int i, type_mask = IORESOURCE_IO | IORESOURCE_MEM; 286 int idx;
287 struct resource *devr = &dev->resource[idx], *busr;
288
289 if (dev->bus) {
290 pci_bus_for_each_resource(dev->bus, busr, i) {
291 if (!busr || (busr->flags ^ devr->flags) & type_mask)
292 continue;
293
294 if (devr->start &&
295 devr->start >= busr->start &&
296 devr->end <= busr->end)
297 return 1;
298 }
299 }
300 287
301 return 0; 288 if (!dev->bus)
289 return;
290
291 for (idx = 0; idx < PCI_BRIDGE_RESOURCES; idx++) {
292 struct resource *r = &dev->resource[idx];
293
294 if (!r->flags || r->parent || !r->start)
295 continue;
296
297 pci_claim_resource(dev, idx);
298 }
302} 299}
303 300
304static void pcibios_fixup_device_resources(struct pci_dev *dev) 301static void pcibios_fixup_bridge_resources(struct pci_dev *dev)
305{ 302{
306 int limit, i; 303 int idx;
307 304
308 if (dev->bus->number != 0) 305 if (!dev->bus)
309 return; 306 return;
310 307
311 limit = (dev->hdr_type == PCI_HEADER_TYPE_NORMAL) ? 308 for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) {
312 PCI_BRIDGE_RESOURCES : PCI_NUM_RESOURCES; 309 struct resource *r = &dev->resource[idx];
313 310
314 for (i = 0; i < limit; i++) { 311 if (!r->flags || r->parent || !r->start)
315 if (!dev->resource[i].flags)
316 continue; 312 continue;
317 313
318 if (is_valid_resource(dev, i)) 314 pci_claim_bridge_resource(dev, idx);
319 pci_claim_resource(dev, i);
320 } 315 }
321} 316}
322 317
@@ -330,7 +325,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)
330 325
331 if (bus->self) { 326 if (bus->self) {
332 pci_read_bridge_bases(bus); 327 pci_read_bridge_bases(bus);
333 pcibios_fixup_device_resources(bus->self); 328 pcibios_fixup_bridge_resources(bus->self);
334 } 329 }
335 330
336 list_for_each_entry(dev, &bus->devices, bus_list) 331 list_for_each_entry(dev, &bus->devices, bus_list)
diff --git a/arch/nios2/kernel/module.c b/arch/nios2/kernel/module.c
index cc924a38f22a..e2e3f13f98d5 100644
--- a/arch/nios2/kernel/module.c
+++ b/arch/nios2/kernel/module.c
@@ -36,7 +36,7 @@ void *module_alloc(unsigned long size)
36} 36}
37 37
38/* Free memory returned from module_alloc */ 38/* Free memory returned from module_alloc */
39void module_free(struct module *mod, void *module_region) 39void module_memfree(void *module_region)
40{ 40{
41 kfree(module_region); 41 kfree(module_region);
42} 42}
diff --git a/arch/nios2/kernel/signal.c b/arch/nios2/kernel/signal.c
index f9d27883a714..2d0ea25be171 100644
--- a/arch/nios2/kernel/signal.c
+++ b/arch/nios2/kernel/signal.c
@@ -200,7 +200,7 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set,
200 200
201 /* Set up to return from userspace; jump to fixed address sigreturn 201 /* Set up to return from userspace; jump to fixed address sigreturn
202 trampoline on kuser page. */ 202 trampoline on kuser page. */
203 regs->ra = (unsigned long) (0x1040); 203 regs->ra = (unsigned long) (0x1044);
204 204
205 /* Set up registers for signal handler */ 205 /* Set up registers for signal handler */
206 regs->sp = (unsigned long) frame; 206 regs->sp = (unsigned long) frame;
diff --git a/arch/nios2/mm/fault.c b/arch/nios2/mm/fault.c
index 15a0bb5fc06d..34429d5a0ccd 100644
--- a/arch/nios2/mm/fault.c
+++ b/arch/nios2/mm/fault.c
@@ -135,6 +135,8 @@ survive:
135 if (unlikely(fault & VM_FAULT_ERROR)) { 135 if (unlikely(fault & VM_FAULT_ERROR)) {
136 if (fault & VM_FAULT_OOM) 136 if (fault & VM_FAULT_OOM)
137 goto out_of_memory; 137 goto out_of_memory;
138 else if (fault & VM_FAULT_SIGSEGV)
139 goto bad_area;
138 else if (fault & VM_FAULT_SIGBUS) 140 else if (fault & VM_FAULT_SIGBUS)
139 goto do_sigbus; 141 goto do_sigbus;
140 BUG(); 142 BUG();
diff --git a/arch/openrisc/mm/fault.c b/arch/openrisc/mm/fault.c
index 0703acf7d327..230ac20ae794 100644
--- a/arch/openrisc/mm/fault.c
+++ b/arch/openrisc/mm/fault.c
@@ -171,6 +171,8 @@ good_area:
171 if (unlikely(fault & VM_FAULT_ERROR)) { 171 if (unlikely(fault & VM_FAULT_ERROR)) {
172 if (fault & VM_FAULT_OOM) 172 if (fault & VM_FAULT_OOM)
173 goto out_of_memory; 173 goto out_of_memory;
174 else if (fault & VM_FAULT_SIGSEGV)
175 goto bad_area;
174 else if (fault & VM_FAULT_SIGBUS) 176 else if (fault & VM_FAULT_SIGBUS)
175 goto do_sigbus; 177 goto do_sigbus;
176 BUG(); 178 BUG();
diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
index 50dfafc3f2c1..5822e8e200e6 100644
--- a/arch/parisc/kernel/module.c
+++ b/arch/parisc/kernel/module.c
@@ -298,14 +298,10 @@ static inline unsigned long count_stubs(const Elf_Rela *rela, unsigned long n)
298} 298}
299#endif 299#endif
300 300
301 301void module_arch_freeing_init(struct module *mod)
302/* Free memory returned from module_alloc */
303void module_free(struct module *mod, void *module_region)
304{ 302{
305 kfree(mod->arch.section); 303 kfree(mod->arch.section);
306 mod->arch.section = NULL; 304 mod->arch.section = NULL;
307
308 vfree(module_region);
309} 305}
310 306
311/* Additional bytes needed in front of individual sections */ 307/* Additional bytes needed in front of individual sections */
diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
index 3ca9c1131cfe..e5120e653240 100644
--- a/arch/parisc/mm/fault.c
+++ b/arch/parisc/mm/fault.c
@@ -256,6 +256,8 @@ good_area:
256 */ 256 */
257 if (fault & VM_FAULT_OOM) 257 if (fault & VM_FAULT_OOM)
258 goto out_of_memory; 258 goto out_of_memory;
259 else if (fault & VM_FAULT_SIGSEGV)
260 goto bad_area;
259 else if (fault & VM_FAULT_SIGBUS) 261 else if (fault & VM_FAULT_SIGBUS)
260 goto bad_area; 262 goto bad_area;
261 BUG(); 263 BUG();
diff --git a/arch/powerpc/crypto/sha1.c b/arch/powerpc/crypto/sha1.c
index d3feba5a275f..c154cebc1041 100644
--- a/arch/powerpc/crypto/sha1.c
+++ b/arch/powerpc/crypto/sha1.c
@@ -154,4 +154,5 @@ module_exit(sha1_powerpc_mod_fini);
154MODULE_LICENSE("GPL"); 154MODULE_LICENSE("GPL");
155MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm"); 155MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm");
156 156
157MODULE_ALIAS_CRYPTO("sha1");
157MODULE_ALIAS_CRYPTO("sha1-powerpc"); 158MODULE_ALIAS_CRYPTO("sha1-powerpc");
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 37d512d35943..2a525c938158 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1184,6 +1184,8 @@ static void pcibios_allocate_bus_resources(struct pci_bus *bus)
1184 pr, (pr && pr->name) ? pr->name : "nil"); 1184 pr, (pr && pr->name) ? pr->name : "nil");
1185 1185
1186 if (pr && !(pr->flags & IORESOURCE_UNSET)) { 1186 if (pr && !(pr->flags & IORESOURCE_UNSET)) {
1187 struct pci_dev *dev = bus->self;
1188
1187 if (request_resource(pr, res) == 0) 1189 if (request_resource(pr, res) == 0)
1188 continue; 1190 continue;
1189 /* 1191 /*
@@ -1193,6 +1195,11 @@ static void pcibios_allocate_bus_resources(struct pci_bus *bus)
1193 */ 1195 */
1194 if (reparent_resources(pr, res) == 0) 1196 if (reparent_resources(pr, res) == 0)
1195 continue; 1197 continue;
1198
1199 if (dev && i < PCI_BRIDGE_RESOURCE_NUM &&
1200 pci_claim_bridge_resource(dev,
1201 i + PCI_BRIDGE_RESOURCES) == 0)
1202 continue;
1196 } 1203 }
1197 pr_warning("PCI: Cannot allocate resource region " 1204 pr_warning("PCI: Cannot allocate resource region "
1198 "%d of PCI bridge %d, will remap\n", i, bus->number); 1205 "%d of PCI bridge %d, will remap\n", i, bus->number);
@@ -1401,7 +1408,10 @@ void pcibios_claim_one_bus(struct pci_bus *bus)
1401 (unsigned long long)r->end, 1408 (unsigned long long)r->end,
1402 (unsigned int)r->flags); 1409 (unsigned int)r->flags);
1403 1410
1404 pci_claim_resource(dev, i); 1411 if (pci_claim_resource(dev, i) == 0)
1412 continue;
1413
1414 pci_claim_bridge_resource(dev, i);
1405 } 1415 }
1406 } 1416 }
1407 1417
diff --git a/arch/powerpc/mm/copro_fault.c b/arch/powerpc/mm/copro_fault.c
index 5a236f082c78..1b5305d4bdab 100644
--- a/arch/powerpc/mm/copro_fault.c
+++ b/arch/powerpc/mm/copro_fault.c
@@ -76,7 +76,7 @@ int copro_handle_mm_fault(struct mm_struct *mm, unsigned long ea,
76 if (*flt & VM_FAULT_OOM) { 76 if (*flt & VM_FAULT_OOM) {
77 ret = -ENOMEM; 77 ret = -ENOMEM;
78 goto out_unlock; 78 goto out_unlock;
79 } else if (*flt & VM_FAULT_SIGBUS) { 79 } else if (*flt & (VM_FAULT_SIGBUS | VM_FAULT_SIGSEGV)) {
80 ret = -EFAULT; 80 ret = -EFAULT;
81 goto out_unlock; 81 goto out_unlock;
82 } 82 }
diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index eb79907f34fa..6154b0a2b063 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -437,6 +437,8 @@ good_area:
437 */ 437 */
438 fault = handle_mm_fault(mm, vma, address, flags); 438 fault = handle_mm_fault(mm, vma, address, flags);
439 if (unlikely(fault & (VM_FAULT_RETRY|VM_FAULT_ERROR))) { 439 if (unlikely(fault & (VM_FAULT_RETRY|VM_FAULT_ERROR))) {
440 if (fault & VM_FAULT_SIGSEGV)
441 goto bad_area;
440 rc = mm_fault_error(regs, address, fault); 442 rc = mm_fault_error(regs, address, fault);
441 if (rc >= MM_FAULT_RETURN) 443 if (rc >= MM_FAULT_RETURN)
442 goto bail; 444 goto bail;
diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
index 1ca125b9c226..d1916b577f2c 100644
--- a/arch/powerpc/net/bpf_jit_comp.c
+++ b/arch/powerpc/net/bpf_jit_comp.c
@@ -699,7 +699,7 @@ out:
699void bpf_jit_free(struct bpf_prog *fp) 699void bpf_jit_free(struct bpf_prog *fp)
700{ 700{
701 if (fp->jited) 701 if (fp->jited)
702 module_free(NULL, fp->bpf_func); 702 module_memfree(fp->bpf_func);
703 703
704 bpf_prog_unlock_free(fp); 704 bpf_prog_unlock_free(fp);
705} 705}
diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
index b700a329c31d..d2de7d5d7574 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -304,7 +304,7 @@ int pnv_save_sprs_for_winkle(void)
304 * all cpus at boot. Get these reg values of current cpu and use the 304 * all cpus at boot. Get these reg values of current cpu and use the
305 * same accross all cpus. 305 * same accross all cpus.
306 */ 306 */
307 uint64_t lpcr_val = mfspr(SPRN_LPCR); 307 uint64_t lpcr_val = mfspr(SPRN_LPCR) & ~(u64)LPCR_PECE1;
308 uint64_t hid0_val = mfspr(SPRN_HID0); 308 uint64_t hid0_val = mfspr(SPRN_HID0);
309 uint64_t hid1_val = mfspr(SPRN_HID1); 309 uint64_t hid1_val = mfspr(SPRN_HID1);
310 uint64_t hid4_val = mfspr(SPRN_HID4); 310 uint64_t hid4_val = mfspr(SPRN_HID4);
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 5b150f0c5df9..13c6e200b24e 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -337,6 +337,7 @@ static inline void disable_surveillance(void)
337 args.token = rtas_token("set-indicator"); 337 args.token = rtas_token("set-indicator");
338 if (args.token == RTAS_UNKNOWN_SERVICE) 338 if (args.token == RTAS_UNKNOWN_SERVICE)
339 return; 339 return;
340 args.token = cpu_to_be32(args.token);
340 args.nargs = cpu_to_be32(3); 341 args.nargs = cpu_to_be32(3);
341 args.nret = cpu_to_be32(1); 342 args.nret = cpu_to_be32(1);
342 args.rets = &args.args[3]; 343 args.rets = &args.args[3];
diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
index b89b59158b95..409d152585be 100644
--- a/arch/s390/kernel/module.c
+++ b/arch/s390/kernel/module.c
@@ -55,14 +55,10 @@ void *module_alloc(unsigned long size)
55} 55}
56#endif 56#endif
57 57
58/* Free memory returned from module_alloc */ 58void module_arch_freeing_init(struct module *mod)
59void module_free(struct module *mod, void *module_region)
60{ 59{
61 if (mod) { 60 vfree(mod->arch.syminfo);
62 vfree(mod->arch.syminfo); 61 mod->arch.syminfo = NULL;
63 mod->arch.syminfo = NULL;
64 }
65 vfree(module_region);
66} 62}
67 63
68static void check_rela(Elf_Rela *rela, struct module *me) 64static void check_rela(Elf_Rela *rela, struct module *me)
diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
index 811937bb90be..9065d5aa3932 100644
--- a/arch/s390/mm/fault.c
+++ b/arch/s390/mm/fault.c
@@ -374,6 +374,12 @@ static noinline void do_fault_error(struct pt_regs *regs, int fault)
374 do_no_context(regs); 374 do_no_context(regs);
375 else 375 else
376 pagefault_out_of_memory(); 376 pagefault_out_of_memory();
377 } else if (fault & VM_FAULT_SIGSEGV) {
378 /* Kernel mode? Handle exceptions or die */
379 if (!user_mode(regs))
380 do_no_context(regs);
381 else
382 do_sigsegv(regs, SEGV_MAPERR);
377 } else if (fault & VM_FAULT_SIGBUS) { 383 } else if (fault & VM_FAULT_SIGBUS) {
378 /* Kernel mode? Handle exceptions or die */ 384 /* Kernel mode? Handle exceptions or die */
379 if (!user_mode(regs)) 385 if (!user_mode(regs))
diff --git a/arch/s390/net/bpf_jit.S b/arch/s390/net/bpf_jit.S
index 7e45d13816c1..ba44c9f55346 100644
--- a/arch/s390/net/bpf_jit.S
+++ b/arch/s390/net/bpf_jit.S
@@ -22,8 +22,8 @@
22 * skb_copy_bits takes 4 parameters: 22 * skb_copy_bits takes 4 parameters:
23 * %r2 = skb pointer 23 * %r2 = skb pointer
24 * %r3 = offset into skb data 24 * %r3 = offset into skb data
25 * %r4 = length to copy 25 * %r4 = pointer to temp buffer
26 * %r5 = pointer to temp buffer 26 * %r5 = length to copy
27 */ 27 */
28#define SKBDATA %r8 28#define SKBDATA %r8
29 29
@@ -44,8 +44,9 @@ ENTRY(sk_load_word)
44 44
45sk_load_word_slow: 45sk_load_word_slow:
46 lgr %r9,%r2 # save %r2 46 lgr %r9,%r2 # save %r2
47 lhi %r4,4 # 4 bytes 47 lgr %r3,%r1 # offset
48 la %r5,160(%r15) # pointer to temp buffer 48 la %r4,160(%r15) # pointer to temp buffer
49 lghi %r5,4 # 4 bytes
49 brasl %r14,skb_copy_bits # get data from skb 50 brasl %r14,skb_copy_bits # get data from skb
50 l %r5,160(%r15) # load result from temp buffer 51 l %r5,160(%r15) # load result from temp buffer
51 ltgr %r2,%r2 # set cc to (%r2 != 0) 52 ltgr %r2,%r2 # set cc to (%r2 != 0)
@@ -69,8 +70,9 @@ ENTRY(sk_load_half)
69 70
70sk_load_half_slow: 71sk_load_half_slow:
71 lgr %r9,%r2 # save %r2 72 lgr %r9,%r2 # save %r2
72 lhi %r4,2 # 2 bytes 73 lgr %r3,%r1 # offset
73 la %r5,162(%r15) # pointer to temp buffer 74 la %r4,162(%r15) # pointer to temp buffer
75 lghi %r5,2 # 2 bytes
74 brasl %r14,skb_copy_bits # get data from skb 76 brasl %r14,skb_copy_bits # get data from skb
75 xc 160(2,%r15),160(%r15) 77 xc 160(2,%r15),160(%r15)
76 l %r5,160(%r15) # load result from temp buffer 78 l %r5,160(%r15) # load result from temp buffer
@@ -95,8 +97,9 @@ ENTRY(sk_load_byte)
95 97
96sk_load_byte_slow: 98sk_load_byte_slow:
97 lgr %r9,%r2 # save %r2 99 lgr %r9,%r2 # save %r2
98 lhi %r4,1 # 1 bytes 100 lgr %r3,%r1 # offset
99 la %r5,163(%r15) # pointer to temp buffer 101 la %r4,163(%r15) # pointer to temp buffer
102 lghi %r5,1 # 1 byte
100 brasl %r14,skb_copy_bits # get data from skb 103 brasl %r14,skb_copy_bits # get data from skb
101 xc 160(3,%r15),160(%r15) 104 xc 160(3,%r15),160(%r15)
102 l %r5,160(%r15) # load result from temp buffer 105 l %r5,160(%r15) # load result from temp buffer
@@ -104,11 +107,11 @@ sk_load_byte_slow:
104 lgr %r2,%r9 # restore %r2 107 lgr %r2,%r9 # restore %r2
105 br %r8 108 br %r8
106 109
107 /* A = (*(u8 *)(skb->data+K) & 0xf) << 2 */ 110 /* X = (*(u8 *)(skb->data+K) & 0xf) << 2 */
108ENTRY(sk_load_byte_msh) 111ENTRY(sk_load_byte_msh)
109 llgfr %r1,%r3 # extend offset 112 llgfr %r1,%r3 # extend offset
110 clr %r11,%r3 # hlen < offset ? 113 clr %r11,%r3 # hlen < offset ?
111 jle sk_load_byte_slow 114 jle sk_load_byte_msh_slow
112 lhi %r12,0 115 lhi %r12,0
113 ic %r12,0(%r1,%r10) # get byte from skb 116 ic %r12,0(%r1,%r10) # get byte from skb
114 nill %r12,0x0f 117 nill %r12,0x0f
@@ -118,8 +121,9 @@ ENTRY(sk_load_byte_msh)
118 121
119sk_load_byte_msh_slow: 122sk_load_byte_msh_slow:
120 lgr %r9,%r2 # save %r2 123 lgr %r9,%r2 # save %r2
121 lhi %r4,2 # 2 bytes 124 lgr %r3,%r1 # offset
122 la %r5,162(%r15) # pointer to temp buffer 125 la %r4,163(%r15) # pointer to temp buffer
126 lghi %r5,1 # 1 byte
123 brasl %r14,skb_copy_bits # get data from skb 127 brasl %r14,skb_copy_bits # get data from skb
124 xc 160(3,%r15),160(%r15) 128 xc 160(3,%r15),160(%r15)
125 l %r12,160(%r15) # load result from temp buffer 129 l %r12,160(%r15) # load result from temp buffer
diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
index 524496d47ef5..bbd1981cc150 100644
--- a/arch/s390/net/bpf_jit_comp.c
+++ b/arch/s390/net/bpf_jit_comp.c
@@ -448,15 +448,12 @@ static int bpf_jit_insn(struct bpf_jit *jit, struct sock_filter *filter,
448 mask = 0x800000; /* je */ 448 mask = 0x800000; /* je */
449kbranch: /* Emit compare if the branch targets are different */ 449kbranch: /* Emit compare if the branch targets are different */
450 if (filter->jt != filter->jf) { 450 if (filter->jt != filter->jf) {
451 if (K <= 16383) 451 if (test_facility(21))
452 /* chi %r5,<K> */
453 EMIT4_IMM(0xa75e0000, K);
454 else if (test_facility(21))
455 /* clfi %r5,<K> */ 452 /* clfi %r5,<K> */
456 EMIT6_IMM(0xc25f0000, K); 453 EMIT6_IMM(0xc25f0000, K);
457 else 454 else
458 /* c %r5,<d(K)>(%r13) */ 455 /* cl %r5,<d(K)>(%r13) */
459 EMIT4_DISP(0x5950d000, EMIT_CONST(K)); 456 EMIT4_DISP(0x5550d000, EMIT_CONST(K));
460 } 457 }
461branch: if (filter->jt == filter->jf) { 458branch: if (filter->jt == filter->jf) {
462 if (filter->jt == 0) 459 if (filter->jt == 0)
diff --git a/arch/score/mm/fault.c b/arch/score/mm/fault.c
index 52238983527d..6860beb2a280 100644
--- a/arch/score/mm/fault.c
+++ b/arch/score/mm/fault.c
@@ -114,6 +114,8 @@ good_area:
114 if (unlikely(fault & VM_FAULT_ERROR)) { 114 if (unlikely(fault & VM_FAULT_ERROR)) {
115 if (fault & VM_FAULT_OOM) 115 if (fault & VM_FAULT_OOM)
116 goto out_of_memory; 116 goto out_of_memory;
117 else if (fault & VM_FAULT_SIGSEGV)
118 goto bad_area;
117 else if (fault & VM_FAULT_SIGBUS) 119 else if (fault & VM_FAULT_SIGBUS)
118 goto do_sigbus; 120 goto do_sigbus;
119 BUG(); 121 BUG();
diff --git a/arch/sh/mm/fault.c b/arch/sh/mm/fault.c
index 541dc6101508..a58fec9b55e0 100644
--- a/arch/sh/mm/fault.c
+++ b/arch/sh/mm/fault.c
@@ -353,6 +353,8 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code,
353 } else { 353 } else {
354 if (fault & VM_FAULT_SIGBUS) 354 if (fault & VM_FAULT_SIGBUS)
355 do_sigbus(regs, error_code, address); 355 do_sigbus(regs, error_code, address);
356 else if (fault & VM_FAULT_SIGSEGV)
357 bad_area(regs, error_code, address);
356 else 358 else
357 BUG(); 359 BUG();
358 } 360 }
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index b36365f49478..9ce5afe167ff 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -639,7 +639,10 @@ static void pci_claim_bus_resources(struct pci_bus *bus)
639 (unsigned long long)r->end, 639 (unsigned long long)r->end,
640 (unsigned int)r->flags); 640 (unsigned int)r->flags);
641 641
642 pci_claim_resource(dev, i); 642 if (pci_claim_resource(dev, i) == 0)
643 continue;
644
645 pci_claim_bridge_resource(dev, i);
643 } 646 }
644 } 647 }
645 648
diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
index 908e8c17c902..70d817154fe8 100644
--- a/arch/sparc/mm/fault_32.c
+++ b/arch/sparc/mm/fault_32.c
@@ -249,6 +249,8 @@ good_area:
249 if (unlikely(fault & VM_FAULT_ERROR)) { 249 if (unlikely(fault & VM_FAULT_ERROR)) {
250 if (fault & VM_FAULT_OOM) 250 if (fault & VM_FAULT_OOM)
251 goto out_of_memory; 251 goto out_of_memory;
252 else if (fault & VM_FAULT_SIGSEGV)
253 goto bad_area;
252 else if (fault & VM_FAULT_SIGBUS) 254 else if (fault & VM_FAULT_SIGBUS)
253 goto do_sigbus; 255 goto do_sigbus;
254 BUG(); 256 BUG();
diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
index 18fcd7167095..479823249429 100644
--- a/arch/sparc/mm/fault_64.c
+++ b/arch/sparc/mm/fault_64.c
@@ -446,6 +446,8 @@ good_area:
446 if (unlikely(fault & VM_FAULT_ERROR)) { 446 if (unlikely(fault & VM_FAULT_ERROR)) {
447 if (fault & VM_FAULT_OOM) 447 if (fault & VM_FAULT_OOM)
448 goto out_of_memory; 448 goto out_of_memory;
449 else if (fault & VM_FAULT_SIGSEGV)
450 goto bad_area;
449 else if (fault & VM_FAULT_SIGBUS) 451 else if (fault & VM_FAULT_SIGBUS)
450 goto do_sigbus; 452 goto do_sigbus;
451 BUG(); 453 BUG();
diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
index f33e7c7a3bf7..7931eeeb649a 100644
--- a/arch/sparc/net/bpf_jit_comp.c
+++ b/arch/sparc/net/bpf_jit_comp.c
@@ -776,7 +776,7 @@ cond_branch: f_offset = addrs[i + filter[i].jf];
776 if (unlikely(proglen + ilen > oldproglen)) { 776 if (unlikely(proglen + ilen > oldproglen)) {
777 pr_err("bpb_jit_compile fatal error\n"); 777 pr_err("bpb_jit_compile fatal error\n");
778 kfree(addrs); 778 kfree(addrs);
779 module_free(NULL, image); 779 module_memfree(image);
780 return; 780 return;
781 } 781 }
782 memcpy(image + proglen, temp, ilen); 782 memcpy(image + proglen, temp, ilen);
@@ -822,7 +822,7 @@ out:
822void bpf_jit_free(struct bpf_prog *fp) 822void bpf_jit_free(struct bpf_prog *fp)
823{ 823{
824 if (fp->jited) 824 if (fp->jited)
825 module_free(NULL, fp->bpf_func); 825 module_memfree(fp->bpf_func);
826 826
827 bpf_prog_unlock_free(fp); 827 bpf_prog_unlock_free(fp);
828} 828}
diff --git a/arch/tile/kernel/module.c b/arch/tile/kernel/module.c
index 96447c9160a0..2305084c9b93 100644
--- a/arch/tile/kernel/module.c
+++ b/arch/tile/kernel/module.c
@@ -74,7 +74,7 @@ error:
74 74
75 75
76/* Free memory returned from module_alloc */ 76/* Free memory returned from module_alloc */
77void module_free(struct module *mod, void *module_region) 77void module_memfree(void *module_region)
78{ 78{
79 vfree(module_region); 79 vfree(module_region);
80 80
@@ -83,7 +83,7 @@ void module_free(struct module *mod, void *module_region)
83 0, 0, 0, NULL, NULL, 0); 83 0, 0, 0, NULL, NULL, 0);
84 84
85 /* 85 /*
86 * FIXME: If module_region == mod->module_init, trim exception 86 * FIXME: Add module_arch_freeing_init to trim exception
87 * table entries. 87 * table entries.
88 */ 88 */
89} 89}
diff --git a/arch/tile/mm/fault.c b/arch/tile/mm/fault.c
index 565e25a98334..0f61a73534e6 100644
--- a/arch/tile/mm/fault.c
+++ b/arch/tile/mm/fault.c
@@ -442,6 +442,8 @@ good_area:
442 if (unlikely(fault & VM_FAULT_ERROR)) { 442 if (unlikely(fault & VM_FAULT_ERROR)) {
443 if (fault & VM_FAULT_OOM) 443 if (fault & VM_FAULT_OOM)
444 goto out_of_memory; 444 goto out_of_memory;
445 else if (fault & VM_FAULT_SIGSEGV)
446 goto bad_area;
445 else if (fault & VM_FAULT_SIGBUS) 447 else if (fault & VM_FAULT_SIGBUS)
446 goto do_sigbus; 448 goto do_sigbus;
447 BUG(); 449 BUG();
diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c
index 5678c3571e7c..209617302df8 100644
--- a/arch/um/kernel/trap.c
+++ b/arch/um/kernel/trap.c
@@ -80,6 +80,8 @@ good_area:
80 if (unlikely(fault & VM_FAULT_ERROR)) { 80 if (unlikely(fault & VM_FAULT_ERROR)) {
81 if (fault & VM_FAULT_OOM) { 81 if (fault & VM_FAULT_OOM) {
82 goto out_of_memory; 82 goto out_of_memory;
83 } else if (fault & VM_FAULT_SIGSEGV) {
84 goto out;
83 } else if (fault & VM_FAULT_SIGBUS) { 85 } else if (fault & VM_FAULT_SIGBUS) {
84 err = -EACCES; 86 err = -EACCES;
85 goto out; 87 goto out;
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index ba397bde7948..0dc9d0144a27 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -857,7 +857,7 @@ source "kernel/Kconfig.preempt"
857 857
858config X86_UP_APIC 858config X86_UP_APIC
859 bool "Local APIC support on uniprocessors" 859 bool "Local APIC support on uniprocessors"
860 depends on X86_32 && !SMP && !X86_32_NON_STANDARD && !PCI_MSI 860 depends on X86_32 && !SMP && !X86_32_NON_STANDARD
861 ---help--- 861 ---help---
862 A local APIC (Advanced Programmable Interrupt Controller) is an 862 A local APIC (Advanced Programmable Interrupt Controller) is an
863 integrated interrupt controller in the CPU. If you have a single-CPU 863 integrated interrupt controller in the CPU. If you have a single-CPU
@@ -868,6 +868,10 @@ config X86_UP_APIC
868 performance counters), and the NMI watchdog which detects hard 868 performance counters), and the NMI watchdog which detects hard
869 lockups. 869 lockups.
870 870
871config X86_UP_APIC_MSI
872 def_bool y
873 select X86_UP_APIC if X86_32 && !SMP && !X86_32_NON_STANDARD && PCI_MSI
874
871config X86_UP_IOAPIC 875config X86_UP_IOAPIC
872 bool "IO-APIC support on uniprocessors" 876 bool "IO-APIC support on uniprocessors"
873 depends on X86_UP_APIC 877 depends on X86_UP_APIC
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index d999398928bc..ad754b4411f7 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -90,7 +90,7 @@ suffix-$(CONFIG_KERNEL_LZO) := lzo
90suffix-$(CONFIG_KERNEL_LZ4) := lz4 90suffix-$(CONFIG_KERNEL_LZ4) := lz4
91 91
92RUN_SIZE = $(shell $(OBJDUMP) -h vmlinux | \ 92RUN_SIZE = $(shell $(OBJDUMP) -h vmlinux | \
93 perl $(srctree)/arch/x86/tools/calc_run_size.pl) 93 $(CONFIG_SHELL) $(srctree)/arch/x86/tools/calc_run_size.sh)
94quiet_cmd_mkpiggy = MKPIGGY $@ 94quiet_cmd_mkpiggy = MKPIGGY $@
95 cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false ) 95 cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false )
96 96
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index dcc1c536cc21..a950864a64da 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -373,6 +373,8 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap,
373 unsigned long output_len, 373 unsigned long output_len,
374 unsigned long run_size) 374 unsigned long run_size)
375{ 375{
376 unsigned char *output_orig = output;
377
376 real_mode = rmode; 378 real_mode = rmode;
377 379
378 sanitize_boot_params(real_mode); 380 sanitize_boot_params(real_mode);
@@ -421,7 +423,12 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap,
421 debug_putstr("\nDecompressing Linux... "); 423 debug_putstr("\nDecompressing Linux... ");
422 decompress(input_data, input_len, NULL, NULL, output, NULL, error); 424 decompress(input_data, input_len, NULL, NULL, output, NULL, error);
423 parse_elf(output); 425 parse_elf(output);
424 handle_relocations(output, output_len); 426 /*
427 * 32-bit always performs relocations. 64-bit relocations are only
428 * needed if kASLR has chosen a different load address.
429 */
430 if (!IS_ENABLED(CONFIG_X86_64) || output != output_orig)
431 handle_relocations(output, output_len);
425 debug_putstr("done.\nBooting the kernel.\n"); 432 debug_putstr("done.\nBooting the kernel.\n");
426 return output; 433 return output;
427} 434}
diff --git a/arch/x86/crypto/sha-mb/sha1_mb.c b/arch/x86/crypto/sha-mb/sha1_mb.c
index a225a5ca1037..fd9f6b035b16 100644
--- a/arch/x86/crypto/sha-mb/sha1_mb.c
+++ b/arch/x86/crypto/sha-mb/sha1_mb.c
@@ -931,4 +931,4 @@ module_exit(sha1_mb_mod_fini);
931MODULE_LICENSE("GPL"); 931MODULE_LICENSE("GPL");
932MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm, multi buffer accelerated"); 932MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm, multi buffer accelerated");
933 933
934MODULE_ALIAS("sha1"); 934MODULE_ALIAS_CRYPTO("sha1");
diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index 0ab4f9fd2687..3a45668f6dc3 100644
--- a/arch/x86/include/asm/acpi.h
+++ b/arch/x86/include/asm/acpi.h
@@ -50,6 +50,7 @@ void acpi_pic_sci_set_trigger(unsigned int, u16);
50 50
51extern int (*__acpi_register_gsi)(struct device *dev, u32 gsi, 51extern int (*__acpi_register_gsi)(struct device *dev, u32 gsi,
52 int trigger, int polarity); 52 int trigger, int polarity);
53extern void (*__acpi_unregister_gsi)(u32 gsi);
53 54
54static inline void disable_acpi(void) 55static inline void disable_acpi(void)
55{ 56{
diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
index 50d033a8947d..a94b82e8f156 100644
--- a/arch/x86/include/asm/desc.h
+++ b/arch/x86/include/asm/desc.h
@@ -251,7 +251,8 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
251 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i]; 251 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
252} 252}
253 253
254#define _LDT_empty(info) \ 254/* This intentionally ignores lm, since 32-bit apps don't have that field. */
255#define LDT_empty(info) \
255 ((info)->base_addr == 0 && \ 256 ((info)->base_addr == 0 && \
256 (info)->limit == 0 && \ 257 (info)->limit == 0 && \
257 (info)->contents == 0 && \ 258 (info)->contents == 0 && \
@@ -261,11 +262,18 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
261 (info)->seg_not_present == 1 && \ 262 (info)->seg_not_present == 1 && \
262 (info)->useable == 0) 263 (info)->useable == 0)
263 264
264#ifdef CONFIG_X86_64 265/* Lots of programs expect an all-zero user_desc to mean "no segment at all". */
265#define LDT_empty(info) (_LDT_empty(info) && ((info)->lm == 0)) 266static inline bool LDT_zero(const struct user_desc *info)
266#else 267{
267#define LDT_empty(info) (_LDT_empty(info)) 268 return (info->base_addr == 0 &&
268#endif 269 info->limit == 0 &&
270 info->contents == 0 &&
271 info->read_exec_only == 0 &&
272 info->seg_32bit == 0 &&
273 info->limit_in_pages == 0 &&
274 info->seg_not_present == 0 &&
275 info->useable == 0);
276}
269 277
270static inline void clear_LDT(void) 278static inline void clear_LDT(void)
271{ 279{
diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
index 40269a2bf6f9..4b75d591eb5e 100644
--- a/arch/x86/include/asm/mmu_context.h
+++ b/arch/x86/include/asm/mmu_context.h
@@ -130,7 +130,25 @@ static inline void arch_bprm_mm_init(struct mm_struct *mm,
130static inline void arch_unmap(struct mm_struct *mm, struct vm_area_struct *vma, 130static inline void arch_unmap(struct mm_struct *mm, struct vm_area_struct *vma,
131 unsigned long start, unsigned long end) 131 unsigned long start, unsigned long end)
132{ 132{
133 mpx_notify_unmap(mm, vma, start, end); 133 /*
134 * mpx_notify_unmap() goes and reads a rarely-hot
135 * cacheline in the mm_struct. That can be expensive
136 * enough to be seen in profiles.
137 *
138 * The mpx_notify_unmap() call and its contents have been
139 * observed to affect munmap() performance on hardware
140 * where MPX is not present.
141 *
142 * The unlikely() optimizes for the fast case: no MPX
143 * in the CPU, or no MPX use in the process. Even if
144 * we get this wrong (in the unlikely event that MPX
145 * is widely enabled on some system) the overhead of
146 * MPX itself (reading bounds tables) is expected to
147 * overwhelm the overhead of getting this unlikely()
148 * consistently wrong.
149 */
150 if (unlikely(cpu_feature_enabled(X86_FEATURE_MPX)))
151 mpx_notify_unmap(mm, vma, start, end);
134} 152}
135 153
136#endif /* _ASM_X86_MMU_CONTEXT_H */ 154#endif /* _ASM_X86_MMU_CONTEXT_H */
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index d1626364a28a..b9e30daa0881 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -611,20 +611,20 @@ void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
611 611
612int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp) 612int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp)
613{ 613{
614 int irq; 614 int rc, irq, trigger, polarity;
615 615
616 if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) { 616 rc = acpi_get_override_irq(gsi, &trigger, &polarity);
617 *irqp = gsi; 617 if (rc == 0) {
618 } else { 618 trigger = trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
619 mutex_lock(&acpi_ioapic_lock); 619 polarity = polarity ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
620 irq = mp_map_gsi_to_irq(gsi, 620 irq = acpi_register_gsi(NULL, gsi, trigger, polarity);
621 IOAPIC_MAP_ALLOC | IOAPIC_MAP_CHECK); 621 if (irq >= 0) {
622 mutex_unlock(&acpi_ioapic_lock); 622 *irqp = irq;
623 if (irq < 0) 623 return 0;
624 return -1; 624 }
625 *irqp = irq;
626 } 625 }
627 return 0; 626
627 return -1;
628} 628}
629EXPORT_SYMBOL_GPL(acpi_gsi_to_irq); 629EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
630 630
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index a450373e8e91..939155ffdece 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -107,6 +107,7 @@ static struct clocksource hyperv_cs = {
107 .rating = 400, /* use this when running on Hyperv*/ 107 .rating = 400, /* use this when running on Hyperv*/
108 .read = read_hv_clock, 108 .read = read_hv_clock,
109 .mask = CLOCKSOURCE_MASK(64), 109 .mask = CLOCKSOURCE_MASK(64),
110 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
110}; 111};
111 112
112static void __init ms_hyperv_init_platform(void) 113static void __init ms_hyperv_init_platform(void)
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index 944bf019b74f..498b6d967138 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -2431,6 +2431,7 @@ __init int intel_pmu_init(void)
2431 break; 2431 break;
2432 2432
2433 case 55: /* 22nm Atom "Silvermont" */ 2433 case 55: /* 22nm Atom "Silvermont" */
2434 case 76: /* 14nm Atom "Airmont" */
2434 case 77: /* 22nm Atom "Silvermont Avoton/Rangely" */ 2435 case 77: /* 22nm Atom "Silvermont Avoton/Rangely" */
2435 memcpy(hw_cache_event_ids, slm_hw_cache_event_ids, 2436 memcpy(hw_cache_event_ids, slm_hw_cache_event_ids,
2436 sizeof(hw_cache_event_ids)); 2437 sizeof(hw_cache_event_ids));
diff --git a/arch/x86/kernel/cpu/perf_event_intel_rapl.c b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
index 6e434f8e5fc8..c4bb8b8e5017 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
@@ -142,7 +142,7 @@ static inline u64 rapl_scale(u64 v)
142 * or use ldexp(count, -32). 142 * or use ldexp(count, -32).
143 * Watts = Joules/Time delta 143 * Watts = Joules/Time delta
144 */ 144 */
145 return v << (32 - __this_cpu_read(rapl_pmu->hw_unit)); 145 return v << (32 - __this_cpu_read(rapl_pmu)->hw_unit);
146} 146}
147 147
148static u64 rapl_event_update(struct perf_event *event) 148static u64 rapl_event_update(struct perf_event *event)
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index 10b8d3eaaf15..c635b8b49e93 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -840,7 +840,6 @@ static int uncore_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id
840 box->phys_id = phys_id; 840 box->phys_id = phys_id;
841 box->pci_dev = pdev; 841 box->pci_dev = pdev;
842 box->pmu = pmu; 842 box->pmu = pmu;
843 uncore_box_init(box);
844 pci_set_drvdata(pdev, box); 843 pci_set_drvdata(pdev, box);
845 844
846 raw_spin_lock(&uncore_box_lock); 845 raw_spin_lock(&uncore_box_lock);
@@ -1004,10 +1003,8 @@ static int uncore_cpu_starting(int cpu)
1004 pmu = &type->pmus[j]; 1003 pmu = &type->pmus[j];
1005 box = *per_cpu_ptr(pmu->box, cpu); 1004 box = *per_cpu_ptr(pmu->box, cpu);
1006 /* called by uncore_cpu_init? */ 1005 /* called by uncore_cpu_init? */
1007 if (box && box->phys_id >= 0) { 1006 if (box && box->phys_id >= 0)
1008 uncore_box_init(box);
1009 continue; 1007 continue;
1010 }
1011 1008
1012 for_each_online_cpu(k) { 1009 for_each_online_cpu(k) {
1013 exist = *per_cpu_ptr(pmu->box, k); 1010 exist = *per_cpu_ptr(pmu->box, k);
@@ -1023,10 +1020,8 @@ static int uncore_cpu_starting(int cpu)
1023 } 1020 }
1024 } 1021 }
1025 1022
1026 if (box) { 1023 if (box)
1027 box->phys_id = phys_id; 1024 box->phys_id = phys_id;
1028 uncore_box_init(box);
1029 }
1030 } 1025 }
1031 } 1026 }
1032 return 0; 1027 return 0;
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
index 863d9b02563e..6c8c1e7e69d8 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
@@ -257,6 +257,14 @@ static inline int uncore_num_counters(struct intel_uncore_box *box)
257 return box->pmu->type->num_counters; 257 return box->pmu->type->num_counters;
258} 258}
259 259
260static inline void uncore_box_init(struct intel_uncore_box *box)
261{
262 if (!test_and_set_bit(UNCORE_BOX_FLAG_INITIATED, &box->flags)) {
263 if (box->pmu->type->ops->init_box)
264 box->pmu->type->ops->init_box(box);
265 }
266}
267
260static inline void uncore_disable_box(struct intel_uncore_box *box) 268static inline void uncore_disable_box(struct intel_uncore_box *box)
261{ 269{
262 if (box->pmu->type->ops->disable_box) 270 if (box->pmu->type->ops->disable_box)
@@ -265,6 +273,8 @@ static inline void uncore_disable_box(struct intel_uncore_box *box)
265 273
266static inline void uncore_enable_box(struct intel_uncore_box *box) 274static inline void uncore_enable_box(struct intel_uncore_box *box)
267{ 275{
276 uncore_box_init(box);
277
268 if (box->pmu->type->ops->enable_box) 278 if (box->pmu->type->ops->enable_box)
269 box->pmu->type->ops->enable_box(box); 279 box->pmu->type->ops->enable_box(box);
270} 280}
@@ -287,14 +297,6 @@ static inline u64 uncore_read_counter(struct intel_uncore_box *box,
287 return box->pmu->type->ops->read_counter(box, event); 297 return box->pmu->type->ops->read_counter(box, event);
288} 298}
289 299
290static inline void uncore_box_init(struct intel_uncore_box *box)
291{
292 if (!test_and_set_bit(UNCORE_BOX_FLAG_INITIATED, &box->flags)) {
293 if (box->pmu->type->ops->init_box)
294 box->pmu->type->ops->init_box(box);
295 }
296}
297
298static inline bool uncore_box_is_fake(struct intel_uncore_box *box) 300static inline bool uncore_box_is_fake(struct intel_uncore_box *box)
299{ 301{
300 return (box->phys_id < 0); 302 return (box->phys_id < 0);
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 2142376dc8c6..8b7b0a51e742 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -674,7 +674,7 @@ static inline void *alloc_tramp(unsigned long size)
674} 674}
675static inline void tramp_free(void *tramp) 675static inline void tramp_free(void *tramp)
676{ 676{
677 module_free(NULL, tramp); 677 module_memfree(tramp);
678} 678}
679#else 679#else
680/* Trampolines can only be created if modules are supported */ 680/* Trampolines can only be created if modules are supported */
diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
index 6307a0f0cf17..705ef8d48e2d 100644
--- a/arch/x86/kernel/irq.c
+++ b/arch/x86/kernel/irq.c
@@ -127,7 +127,7 @@ int arch_show_interrupts(struct seq_file *p, int prec)
127 seq_puts(p, " Machine check polls\n"); 127 seq_puts(p, " Machine check polls\n");
128#endif 128#endif
129#if IS_ENABLED(CONFIG_HYPERV) || defined(CONFIG_XEN) 129#if IS_ENABLED(CONFIG_HYPERV) || defined(CONFIG_XEN)
130 seq_printf(p, "%*s: ", prec, "THR"); 130 seq_printf(p, "%*s: ", prec, "HYP");
131 for_each_online_cpu(j) 131 for_each_online_cpu(j)
132 seq_printf(p, "%10u ", irq_stats(j)->irq_hv_callback_count); 132 seq_printf(p, "%10u ", irq_stats(j)->irq_hv_callback_count);
133 seq_puts(p, " Hypervisor callback interrupts\n"); 133 seq_puts(p, " Hypervisor callback interrupts\n");
diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
index 4e942f31b1a7..7fc5e843f247 100644
--- a/arch/x86/kernel/tls.c
+++ b/arch/x86/kernel/tls.c
@@ -29,7 +29,28 @@ static int get_free_idx(void)
29 29
30static bool tls_desc_okay(const struct user_desc *info) 30static bool tls_desc_okay(const struct user_desc *info)
31{ 31{
32 if (LDT_empty(info)) 32 /*
33 * For historical reasons (i.e. no one ever documented how any
34 * of the segmentation APIs work), user programs can and do
35 * assume that a struct user_desc that's all zeros except for
36 * entry_number means "no segment at all". This never actually
37 * worked. In fact, up to Linux 3.19, a struct user_desc like
38 * this would create a 16-bit read-write segment with base and
39 * limit both equal to zero.
40 *
41 * That was close enough to "no segment at all" until we
42 * hardened this function to disallow 16-bit TLS segments. Fix
43 * it up by interpreting these zeroed segments the way that they
44 * were almost certainly intended to be interpreted.
45 *
46 * The correct way to ask for "no segment at all" is to specify
47 * a user_desc that satisfies LDT_empty. To keep everything
48 * working, we accept both.
49 *
50 * Note that there's a similar kludge in modify_ldt -- look at
51 * the distinction between modes 1 and 0x11.
52 */
53 if (LDT_empty(info) || LDT_zero(info))
33 return true; 54 return true;
34 55
35 /* 56 /*
@@ -71,7 +92,7 @@ static void set_tls_desc(struct task_struct *p, int idx,
71 cpu = get_cpu(); 92 cpu = get_cpu();
72 93
73 while (n-- > 0) { 94 while (n-- > 0) {
74 if (LDT_empty(info)) 95 if (LDT_empty(info) || LDT_zero(info))
75 desc->a = desc->b = 0; 96 desc->a = desc->b = 0;
76 else 97 else
77 fill_ldt(desc, info); 98 fill_ldt(desc, info);
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index b7e50bba3bbb..505449700e0c 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -617,7 +617,7 @@ static unsigned long quick_pit_calibrate(void)
617 goto success; 617 goto success;
618 } 618 }
619 } 619 }
620 pr_err("Fast TSC calibration failed\n"); 620 pr_info("Fast TSC calibration failed\n");
621 return 0; 621 return 0;
622 622
623success: 623success:
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 169b09d76ddd..de12c1d379f1 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2348,7 +2348,7 @@ static int em_sysenter(struct x86_emulate_ctxt *ctxt)
2348 * Not recognized on AMD in compat mode (but is recognized in legacy 2348 * Not recognized on AMD in compat mode (but is recognized in legacy
2349 * mode). 2349 * mode).
2350 */ 2350 */
2351 if ((ctxt->mode == X86EMUL_MODE_PROT32) && (efer & EFER_LMA) 2351 if ((ctxt->mode != X86EMUL_MODE_PROT64) && (efer & EFER_LMA)
2352 && !vendor_intel(ctxt)) 2352 && !vendor_intel(ctxt))
2353 return emulate_ud(ctxt); 2353 return emulate_ud(ctxt);
2354 2354
@@ -2359,25 +2359,13 @@ static int em_sysenter(struct x86_emulate_ctxt *ctxt)
2359 setup_syscalls_segments(ctxt, &cs, &ss); 2359 setup_syscalls_segments(ctxt, &cs, &ss);
2360 2360
2361 ops->get_msr(ctxt, MSR_IA32_SYSENTER_CS, &msr_data); 2361 ops->get_msr(ctxt, MSR_IA32_SYSENTER_CS, &msr_data);
2362 switch (ctxt->mode) { 2362 if ((msr_data & 0xfffc) == 0x0)
2363 case X86EMUL_MODE_PROT32: 2363 return emulate_gp(ctxt, 0);
2364 if ((msr_data & 0xfffc) == 0x0)
2365 return emulate_gp(ctxt, 0);
2366 break;
2367 case X86EMUL_MODE_PROT64:
2368 if (msr_data == 0x0)
2369 return emulate_gp(ctxt, 0);
2370 break;
2371 default:
2372 break;
2373 }
2374 2364
2375 ctxt->eflags &= ~(EFLG_VM | EFLG_IF); 2365 ctxt->eflags &= ~(EFLG_VM | EFLG_IF);
2376 cs_sel = (u16)msr_data; 2366 cs_sel = (u16)msr_data & ~SELECTOR_RPL_MASK;
2377 cs_sel &= ~SELECTOR_RPL_MASK;
2378 ss_sel = cs_sel + 8; 2367 ss_sel = cs_sel + 8;
2379 ss_sel &= ~SELECTOR_RPL_MASK; 2368 if (efer & EFER_LMA) {
2380 if (ctxt->mode == X86EMUL_MODE_PROT64 || (efer & EFER_LMA)) {
2381 cs.d = 0; 2369 cs.d = 0;
2382 cs.l = 1; 2370 cs.l = 1;
2383 } 2371 }
@@ -2386,10 +2374,11 @@ static int em_sysenter(struct x86_emulate_ctxt *ctxt)
2386 ops->set_segment(ctxt, ss_sel, &ss, 0, VCPU_SREG_SS); 2374 ops->set_segment(ctxt, ss_sel, &ss, 0, VCPU_SREG_SS);
2387 2375
2388 ops->get_msr(ctxt, MSR_IA32_SYSENTER_EIP, &msr_data); 2376 ops->get_msr(ctxt, MSR_IA32_SYSENTER_EIP, &msr_data);
2389 ctxt->_eip = msr_data; 2377 ctxt->_eip = (efer & EFER_LMA) ? msr_data : (u32)msr_data;
2390 2378
2391 ops->get_msr(ctxt, MSR_IA32_SYSENTER_ESP, &msr_data); 2379 ops->get_msr(ctxt, MSR_IA32_SYSENTER_ESP, &msr_data);
2392 *reg_write(ctxt, VCPU_REGS_RSP) = msr_data; 2380 *reg_write(ctxt, VCPU_REGS_RSP) = (efer & EFER_LMA) ? msr_data :
2381 (u32)msr_data;
2393 2382
2394 return X86EMUL_CONTINUE; 2383 return X86EMUL_CONTINUE;
2395} 2384}
@@ -3791,8 +3780,8 @@ static const struct opcode group5[] = {
3791}; 3780};
3792 3781
3793static const struct opcode group6[] = { 3782static const struct opcode group6[] = {
3794 DI(Prot, sldt), 3783 DI(Prot | DstMem, sldt),
3795 DI(Prot, str), 3784 DI(Prot | DstMem, str),
3796 II(Prot | Priv | SrcMem16, em_lldt, lldt), 3785 II(Prot | Priv | SrcMem16, em_lldt, lldt),
3797 II(Prot | Priv | SrcMem16, em_ltr, ltr), 3786 II(Prot | Priv | SrcMem16, em_ltr, ltr),
3798 N, N, N, N, 3787 N, N, N, N,
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 4f0c0b954686..d52dcf0776ea 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -192,6 +192,9 @@ static void recalculate_apic_map(struct kvm *kvm)
192 u16 cid, lid; 192 u16 cid, lid;
193 u32 ldr, aid; 193 u32 ldr, aid;
194 194
195 if (!kvm_apic_present(vcpu))
196 continue;
197
195 aid = kvm_apic_id(apic); 198 aid = kvm_apic_id(apic);
196 ldr = kvm_apic_get_reg(apic, APIC_LDR); 199 ldr = kvm_apic_get_reg(apic, APIC_LDR);
197 cid = apic_cluster_id(new, ldr); 200 cid = apic_cluster_id(new, ldr);
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 38dcec403b46..e3ff27a5b634 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -898,6 +898,8 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code,
898 if (fault & (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON| 898 if (fault & (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON|
899 VM_FAULT_HWPOISON_LARGE)) 899 VM_FAULT_HWPOISON_LARGE))
900 do_sigbus(regs, error_code, address, fault); 900 do_sigbus(regs, error_code, address, fault);
901 else if (fault & VM_FAULT_SIGSEGV)
902 bad_area_nosemaphore(regs, error_code, address);
901 else 903 else
902 BUG(); 904 BUG();
903 } 905 }
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 08a7d313538a..079c3b6a3ff1 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -43,7 +43,7 @@ uint16_t __cachemode2pte_tbl[_PAGE_CACHE_MODE_NUM] = {
43 [_PAGE_CACHE_MODE_WT] = _PAGE_PCD, 43 [_PAGE_CACHE_MODE_WT] = _PAGE_PCD,
44 [_PAGE_CACHE_MODE_WP] = _PAGE_PCD, 44 [_PAGE_CACHE_MODE_WP] = _PAGE_PCD,
45}; 45};
46EXPORT_SYMBOL_GPL(__cachemode2pte_tbl); 46EXPORT_SYMBOL(__cachemode2pte_tbl);
47uint8_t __pte2cachemode_tbl[8] = { 47uint8_t __pte2cachemode_tbl[8] = {
48 [__pte2cm_idx(0)] = _PAGE_CACHE_MODE_WB, 48 [__pte2cm_idx(0)] = _PAGE_CACHE_MODE_WB,
49 [__pte2cm_idx(_PAGE_PWT)] = _PAGE_CACHE_MODE_WC, 49 [__pte2cm_idx(_PAGE_PWT)] = _PAGE_CACHE_MODE_WC,
@@ -54,7 +54,7 @@ uint8_t __pte2cachemode_tbl[8] = {
54 [__pte2cm_idx(_PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC_MINUS, 54 [__pte2cm_idx(_PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC_MINUS,
55 [__pte2cm_idx(_PAGE_PWT | _PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC, 55 [__pte2cm_idx(_PAGE_PWT | _PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC,
56}; 56};
57EXPORT_SYMBOL_GPL(__pte2cachemode_tbl); 57EXPORT_SYMBOL(__pte2cachemode_tbl);
58 58
59static unsigned long __initdata pgt_buf_start; 59static unsigned long __initdata pgt_buf_start;
60static unsigned long __initdata pgt_buf_end; 60static unsigned long __initdata pgt_buf_end;
diff --git a/arch/x86/mm/mpx.c b/arch/x86/mm/mpx.c
index 67ebf5751222..c439ec478216 100644
--- a/arch/x86/mm/mpx.c
+++ b/arch/x86/mm/mpx.c
@@ -349,6 +349,12 @@ static __user void *task_get_bounds_dir(struct task_struct *tsk)
349 return MPX_INVALID_BOUNDS_DIR; 349 return MPX_INVALID_BOUNDS_DIR;
350 350
351 /* 351 /*
352 * 32-bit binaries on 64-bit kernels are currently
353 * unsupported.
354 */
355 if (IS_ENABLED(CONFIG_X86_64) && test_thread_flag(TIF_IA32))
356 return MPX_INVALID_BOUNDS_DIR;
357 /*
352 * The bounds directory pointer is stored in a register 358 * The bounds directory pointer is stored in a register
353 * only accessible if we first do an xsave. 359 * only accessible if we first do an xsave.
354 */ 360 */
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index edf299c8ff6c..7ac68698406c 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -234,8 +234,13 @@ void pat_init(void)
234 PAT(4, WB) | PAT(5, WC) | PAT(6, UC_MINUS) | PAT(7, UC); 234 PAT(4, WB) | PAT(5, WC) | PAT(6, UC_MINUS) | PAT(7, UC);
235 235
236 /* Boot CPU check */ 236 /* Boot CPU check */
237 if (!boot_pat_state) 237 if (!boot_pat_state) {
238 rdmsrl(MSR_IA32_CR_PAT, boot_pat_state); 238 rdmsrl(MSR_IA32_CR_PAT, boot_pat_state);
239 if (!boot_pat_state) {
240 pat_disable("PAT read returns always zero, disabled.");
241 return;
242 }
243 }
239 244
240 wrmsrl(MSR_IA32_CR_PAT, pat); 245 wrmsrl(MSR_IA32_CR_PAT, pat);
241 246
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index 9b18ef315a55..349c0d32cc0b 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -216,7 +216,7 @@ static void pcibios_allocate_bridge_resources(struct pci_dev *dev)
216 continue; 216 continue;
217 if (r->parent) /* Already allocated */ 217 if (r->parent) /* Already allocated */
218 continue; 218 continue;
219 if (!r->start || pci_claim_resource(dev, idx) < 0) { 219 if (!r->start || pci_claim_bridge_resource(dev, idx) < 0) {
220 /* 220 /*
221 * Something is wrong with the region. 221 * Something is wrong with the region.
222 * Invalidate the resource to prevent 222 * Invalidate the resource to prevent
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
index c489ef2c1a39..9098d880c476 100644
--- a/arch/x86/pci/xen.c
+++ b/arch/x86/pci/xen.c
@@ -458,6 +458,7 @@ int __init pci_xen_hvm_init(void)
458 * just how GSIs get registered. 458 * just how GSIs get registered.
459 */ 459 */
460 __acpi_register_gsi = acpi_register_gsi_xen_hvm; 460 __acpi_register_gsi = acpi_register_gsi_xen_hvm;
461 __acpi_unregister_gsi = NULL;
461#endif 462#endif
462 463
463#ifdef CONFIG_PCI_MSI 464#ifdef CONFIG_PCI_MSI
@@ -471,52 +472,6 @@ int __init pci_xen_hvm_init(void)
471} 472}
472 473
473#ifdef CONFIG_XEN_DOM0 474#ifdef CONFIG_XEN_DOM0
474static __init void xen_setup_acpi_sci(void)
475{
476 int rc;
477 int trigger, polarity;
478 int gsi = acpi_sci_override_gsi;
479 int irq = -1;
480 int gsi_override = -1;
481
482 if (!gsi)
483 return;
484
485 rc = acpi_get_override_irq(gsi, &trigger, &polarity);
486 if (rc) {
487 printk(KERN_WARNING "xen: acpi_get_override_irq failed for acpi"
488 " sci, rc=%d\n", rc);
489 return;
490 }
491 trigger = trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
492 polarity = polarity ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
493
494 printk(KERN_INFO "xen: sci override: global_irq=%d trigger=%d "
495 "polarity=%d\n", gsi, trigger, polarity);
496
497 /* Before we bind the GSI to a Linux IRQ, check whether
498 * we need to override it with bus_irq (IRQ) value. Usually for
499 * IRQs below IRQ_LEGACY_IRQ this holds IRQ == GSI, as so:
500 * ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 low level)
501 * but there are oddballs where the IRQ != GSI:
502 * ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 20 low level)
503 * which ends up being: gsi_to_irq[9] == 20
504 * (which is what acpi_gsi_to_irq ends up calling when starting the
505 * the ACPI interpreter and keels over since IRQ 9 has not been
506 * setup as we had setup IRQ 20 for it).
507 */
508 if (acpi_gsi_to_irq(gsi, &irq) == 0) {
509 /* Use the provided value if it's valid. */
510 if (irq >= 0)
511 gsi_override = irq;
512 }
513
514 gsi = xen_register_gsi(gsi, gsi_override, trigger, polarity);
515 printk(KERN_INFO "xen: acpi sci %d\n", gsi);
516
517 return;
518}
519
520int __init pci_xen_initial_domain(void) 475int __init pci_xen_initial_domain(void)
521{ 476{
522 int irq; 477 int irq;
@@ -527,8 +482,8 @@ int __init pci_xen_initial_domain(void)
527 x86_msi.restore_msi_irqs = xen_initdom_restore_msi_irqs; 482 x86_msi.restore_msi_irqs = xen_initdom_restore_msi_irqs;
528 pci_msi_ignore_mask = 1; 483 pci_msi_ignore_mask = 1;
529#endif 484#endif
530 xen_setup_acpi_sci();
531 __acpi_register_gsi = acpi_register_gsi_xen; 485 __acpi_register_gsi = acpi_register_gsi_xen;
486 __acpi_unregister_gsi = NULL;
532 /* Pre-allocate legacy irqs */ 487 /* Pre-allocate legacy irqs */
533 for (irq = 0; irq < nr_legacy_irqs(); irq++) { 488 for (irq = 0; irq < nr_legacy_irqs(); irq++) {
534 int trigger, polarity; 489 int trigger, polarity;
diff --git a/arch/x86/tools/calc_run_size.pl b/arch/x86/tools/calc_run_size.pl
deleted file mode 100644
index 23210baade2d..000000000000
--- a/arch/x86/tools/calc_run_size.pl
+++ /dev/null
@@ -1,39 +0,0 @@
1#!/usr/bin/perl
2#
3# Calculate the amount of space needed to run the kernel, including room for
4# the .bss and .brk sections.
5#
6# Usage:
7# objdump -h a.out | perl calc_run_size.pl
8use strict;
9
10my $mem_size = 0;
11my $file_offset = 0;
12
13my $sections=" *[0-9]+ \.(?:bss|brk) +";
14while (<>) {
15 if (/^$sections([0-9a-f]+) +(?:[0-9a-f]+ +){2}([0-9a-f]+)/) {
16 my $size = hex($1);
17 my $offset = hex($2);
18 $mem_size += $size;
19 if ($file_offset == 0) {
20 $file_offset = $offset;
21 } elsif ($file_offset != $offset) {
22 # BFD linker shows the same file offset in ELF.
23 # Gold linker shows them as consecutive.
24 next if ($file_offset + $mem_size == $offset + $size);
25
26 printf STDERR "file_offset: 0x%lx\n", $file_offset;
27 printf STDERR "mem_size: 0x%lx\n", $mem_size;
28 printf STDERR "offset: 0x%lx\n", $offset;
29 printf STDERR "size: 0x%lx\n", $size;
30
31 die ".bss and .brk are non-contiguous\n";
32 }
33 }
34}
35
36if ($file_offset == 0) {
37 die "Never found .bss or .brk file offset\n";
38}
39printf("%d\n", $mem_size + $file_offset);
diff --git a/arch/x86/tools/calc_run_size.sh b/arch/x86/tools/calc_run_size.sh
new file mode 100644
index 000000000000..1a4c17bb3910
--- /dev/null
+++ b/arch/x86/tools/calc_run_size.sh
@@ -0,0 +1,42 @@
1#!/bin/sh
2#
3# Calculate the amount of space needed to run the kernel, including room for
4# the .bss and .brk sections.
5#
6# Usage:
7# objdump -h a.out | sh calc_run_size.sh
8
9NUM='\([0-9a-fA-F]*[ \t]*\)'
10OUT=$(sed -n 's/^[ \t0-9]*.b[sr][sk][ \t]*'"$NUM$NUM$NUM$NUM"'.*/\1\4/p')
11if [ -z "$OUT" ] ; then
12 echo "Never found .bss or .brk file offset" >&2
13 exit 1
14fi
15
16OUT=$(echo ${OUT# })
17sizeA=$(printf "%d" 0x${OUT%% *})
18OUT=${OUT#* }
19offsetA=$(printf "%d" 0x${OUT%% *})
20OUT=${OUT#* }
21sizeB=$(printf "%d" 0x${OUT%% *})
22OUT=${OUT#* }
23offsetB=$(printf "%d" 0x${OUT%% *})
24
25run_size=$(( $offsetA + $sizeA + $sizeB ))
26
27# BFD linker shows the same file offset in ELF.
28if [ "$offsetA" -ne "$offsetB" ] ; then
29 # Gold linker shows them as consecutive.
30 endB=$(( $offsetB + $sizeB ))
31 if [ "$endB" != "$run_size" ] ; then
32 printf "sizeA: 0x%x\n" $sizeA >&2
33 printf "offsetA: 0x%x\n" $offsetA >&2
34 printf "sizeB: 0x%x\n" $sizeB >&2
35 printf "offsetB: 0x%x\n" $offsetB >&2
36 echo ".bss and .brk are non-contiguous" >&2
37 exit 1
38 fi
39fi
40
41printf "%d\n" $run_size
42exit 0
diff --git a/arch/xtensa/mm/fault.c b/arch/xtensa/mm/fault.c
index b57c4f91f487..9e3571a6535c 100644
--- a/arch/xtensa/mm/fault.c
+++ b/arch/xtensa/mm/fault.c
@@ -117,6 +117,8 @@ good_area:
117 if (unlikely(fault & VM_FAULT_ERROR)) { 117 if (unlikely(fault & VM_FAULT_ERROR)) {
118 if (fault & VM_FAULT_OOM) 118 if (fault & VM_FAULT_OOM)
119 goto out_of_memory; 119 goto out_of_memory;
120 else if (fault & VM_FAULT_SIGSEGV)
121 goto bad_area;
120 else if (fault & VM_FAULT_SIGBUS) 122 else if (fault & VM_FAULT_SIGBUS)
121 goto do_sigbus; 123 goto do_sigbus;
122 BUG(); 124 BUG();