aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/boot/dts/Makefile4
-rw-r--r--arch/arm/boot/dts/sun4i-cubieboard.dts4
-rw-r--r--arch/arm/boot/dts/sun5i-olinuxino.dts4
-rw-r--r--arch/arm/mach-davinci/board-da850-evm.c1
-rw-r--r--arch/arm/mach-davinci/da830.c2
-rw-r--r--arch/arm/mach-davinci/da850.c2
-rw-r--r--arch/arm/mach-davinci/devices-da8xx.c22
-rw-r--r--arch/arm/mach-davinci/pm_domain.c1
-rw-r--r--arch/arm/mach-exynos/common.h2
-rw-r--r--arch/arm/mach-omap2/board-rx51-video.c14
-rw-r--r--arch/arm/mach-omap2/board-rx51.c3
-rw-r--r--arch/arm/mach-omap2/display.c15
-rw-r--r--arch/arm/mach-shmobile/board-ag5evm.c198
-rw-r--r--arch/arm/mach-shmobile/board-ap4evb.c4
-rw-r--r--arch/arm/mach-shmobile/board-mackerel.c6
-rw-r--r--arch/arm/mach-tegra/common.c2
-rw-r--r--arch/arm/mach-tegra/tegra30_clocks.c4
-rw-r--r--arch/arm/mach-u300/core.c34
-rw-r--r--arch/arm/mach-ux500/devices-db8500.h1
-rw-r--r--arch/arm/mm/dma-mapping.c41
-rw-r--r--arch/arm/plat-omap/fb.c5
-rw-r--r--arch/arm/plat-omap/include/plat/vram.h43
-rw-r--r--arch/m68k/Kconfig.cpu3
-rw-r--r--arch/m68k/Makefile6
-rw-r--r--arch/m68k/include/asm/m5249sim.h269
-rw-r--r--arch/m68k/include/asm/m525xsim.h116
-rw-r--r--arch/m68k/include/asm/mcfclk.h9
-rw-r--r--arch/m68k/include/asm/mcfsim.h5
-rw-r--r--arch/m68k/include/asm/page_no.h2
-rw-r--r--arch/m68k/lib/memcpy.c3
-rw-r--r--arch/m68k/platform/68000/Makefile18
-rw-r--r--arch/m68k/platform/68000/bootlogo-vz.h (renamed from arch/m68k/platform/68VZ328/bootlogo.h)0
-rw-r--r--arch/m68k/platform/68000/bootlogo.h (renamed from arch/m68k/platform/68328/bootlogo.h)0
-rw-r--r--arch/m68k/platform/68000/entry.S (renamed from arch/m68k/platform/68328/entry.S)0
-rw-r--r--arch/m68k/platform/68000/head.S240
-rw-r--r--arch/m68k/platform/68000/ints.c (renamed from arch/m68k/platform/68328/ints.c)2
-rw-r--r--arch/m68k/platform/68000/m68328.c (renamed from arch/m68k/platform/68328/config.c)2
-rw-r--r--arch/m68k/platform/68000/m68EZ328.c (renamed from arch/m68k/platform/68EZ328/config.c)2
-rw-r--r--arch/m68k/platform/68000/m68VZ328.c (renamed from arch/m68k/platform/68VZ328/config.c)4
-rw-r--r--arch/m68k/platform/68000/romvec.S (renamed from arch/m68k/platform/68328/romvec.S)2
-rw-r--r--arch/m68k/platform/68000/timers.c (renamed from arch/m68k/platform/68328/timers.c)2
-rw-r--r--arch/m68k/platform/68328/Makefile21
-rw-r--r--arch/m68k/platform/68328/head-de2.S128
-rw-r--r--arch/m68k/platform/68328/head-pilot.S207
-rw-r--r--arch/m68k/platform/68328/head-ram.S141
-rw-r--r--arch/m68k/platform/68328/head-rom.S105
-rw-r--r--arch/m68k/platform/68EZ328/Makefile5
-rw-r--r--arch/m68k/platform/68VZ328/Makefile5
-rw-r--r--arch/m68k/platform/coldfire/clk.c100
-rw-r--r--arch/m68k/platform/coldfire/intc-5249.c8
-rw-r--r--arch/m68k/platform/coldfire/m5206.c20
-rw-r--r--arch/m68k/platform/coldfire/m523x.c28
-rw-r--r--arch/m68k/platform/coldfire/m5249.c28
-rw-r--r--arch/m68k/platform/coldfire/m525x.c20
-rw-r--r--arch/m68k/platform/coldfire/m5272.c26
-rw-r--r--arch/m68k/platform/coldfire/m527x.c30
-rw-r--r--arch/m68k/platform/coldfire/m528x.c28
-rw-r--r--arch/m68k/platform/coldfire/m5307.c20
-rw-r--r--arch/m68k/platform/coldfire/m5407.c20
-rw-r--r--arch/m68k/platform/coldfire/m54xx.c26
-rw-r--r--arch/microblaze/include/asm/Kbuild2
-rw-r--r--arch/microblaze/include/asm/elf.h97
-rw-r--r--arch/microblaze/include/asm/entry.h2
-rw-r--r--arch/microblaze/include/asm/ptrace.h62
-rw-r--r--arch/microblaze/include/asm/setup.h6
-rw-r--r--arch/microblaze/include/asm/uaccess.h3
-rw-r--r--arch/microblaze/include/asm/unistd.h390
-rw-r--r--arch/microblaze/include/uapi/asm/Kbuild32
-rw-r--r--arch/microblaze/include/uapi/asm/auxvec.h (renamed from arch/microblaze/include/asm/auxvec.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/bitsperlong.h (renamed from arch/microblaze/include/asm/bitsperlong.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/byteorder.h (renamed from arch/microblaze/include/asm/byteorder.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/elf.h121
-rw-r--r--arch/microblaze/include/uapi/asm/errno.h (renamed from arch/microblaze/include/asm/errno.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/fcntl.h (renamed from arch/microblaze/include/asm/fcntl.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/ioctl.h (renamed from arch/microblaze/include/asm/ioctl.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/ioctls.h (renamed from arch/microblaze/include/asm/ioctls.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/ipcbuf.h (renamed from arch/microblaze/include/asm/ipcbuf.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/kvm_para.h (renamed from arch/microblaze/include/asm/kvm_para.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/mman.h (renamed from arch/microblaze/include/asm/mman.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/msgbuf.h (renamed from arch/microblaze/include/asm/msgbuf.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/param.h (renamed from arch/microblaze/include/asm/param.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/poll.h (renamed from arch/microblaze/include/asm/poll.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/posix_types.h (renamed from arch/microblaze/include/asm/posix_types.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/ptrace.h72
-rw-r--r--arch/microblaze/include/uapi/asm/resource.h (renamed from arch/microblaze/include/asm/resource.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/sembuf.h (renamed from arch/microblaze/include/asm/sembuf.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/setup.h19
-rw-r--r--arch/microblaze/include/uapi/asm/shmbuf.h (renamed from arch/microblaze/include/asm/shmbuf.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/sigcontext.h (renamed from arch/microblaze/include/asm/sigcontext.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/siginfo.h (renamed from arch/microblaze/include/asm/siginfo.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/signal.h (renamed from arch/microblaze/include/asm/signal.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/socket.h (renamed from arch/microblaze/include/asm/socket.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/sockios.h (renamed from arch/microblaze/include/asm/sockios.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/stat.h (renamed from arch/microblaze/include/asm/stat.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/statfs.h (renamed from arch/microblaze/include/asm/statfs.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/swab.h (renamed from arch/microblaze/include/asm/swab.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/termbits.h (renamed from arch/microblaze/include/asm/termbits.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/termios.h (renamed from arch/microblaze/include/asm/termios.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/types.h (renamed from arch/microblaze/include/asm/types.h)0
-rw-r--r--arch/microblaze/include/uapi/asm/unistd.h401
-rw-r--r--arch/microblaze/kernel/entry-nommu.S1
-rw-r--r--arch/microblaze/kernel/intc.c5
-rw-r--r--arch/microblaze/kernel/process.c1
-rw-r--r--arch/microblaze/kernel/prom.c4
-rw-r--r--arch/microblaze/kernel/signal.c2
-rw-r--r--arch/microblaze/kernel/syscall_table.S1
-rw-r--r--arch/microblaze/lib/libgcc.h7
-rw-r--r--arch/microblaze/lib/muldi3.c28
-rw-r--r--arch/sh/boards/mach-ap325rxa/setup.c6
-rw-r--r--arch/sh/boards/mach-ecovec24/setup.c6
-rw-r--r--arch/sh/boards/mach-kfr2r09/lcd_wqvga.c16
-rw-r--r--arch/sh/boards/mach-kfr2r09/setup.c7
-rw-r--r--arch/sh/include/mach-kfr2r09/mach/kfr2r09.h6
-rw-r--r--arch/sh/mm/Kconfig1
-rw-r--r--arch/x86/Kconfig2
-rw-r--r--arch/x86/crypto/Makefile5
-rw-r--r--arch/x86/crypto/camellia-aesni-avx-asm_64.S1102
-rw-r--r--arch/x86/crypto/camellia_aesni_avx_glue.c558
-rw-r--r--arch/x86/crypto/camellia_glue.c92
-rw-r--r--arch/x86/crypto/cast5-avx-x86_64-asm_64.S348
-rw-r--r--arch/x86/crypto/cast5_avx_glue.c79
-rw-r--r--arch/x86/crypto/cast6-avx-x86_64-asm_64.S206
-rw-r--r--arch/x86/crypto/cast6_avx_glue.c77
-rw-r--r--arch/x86/crypto/crc32c-intel_glue.c (renamed from arch/x86/crypto/crc32c-intel.c)81
-rw-r--r--arch/x86/crypto/crc32c-pcl-intel-asm_64.S460
-rw-r--r--arch/x86/crypto/glue_helper-asm-avx.S91
-rw-r--r--arch/x86/crypto/glue_helper.c12
-rw-r--r--arch/x86/crypto/serpent-avx-x86_64-asm_64.S166
-rw-r--r--arch/x86/crypto/serpent_avx_glue.c49
-rw-r--r--arch/x86/crypto/serpent_sse2_glue.c12
-rw-r--r--arch/x86/crypto/twofish-avx-x86_64-asm_64.S208
-rw-r--r--arch/x86/crypto/twofish_avx_glue.c73
-rw-r--r--arch/x86/crypto/twofish_glue_3way.c20
-rw-r--r--arch/x86/include/asm/crypto/camellia.h82
-rw-r--r--arch/x86/include/asm/crypto/glue_helper.h28
-rw-r--r--arch/x86/include/asm/crypto/serpent-avx.h27
-rw-r--r--arch/x86/include/asm/crypto/twofish.h4
-rw-r--r--arch/x86/include/asm/efi.h28
-rw-r--r--arch/x86/include/asm/pgtable.h17
-rw-r--r--arch/x86/include/asm/pgtable_types.h20
-rw-r--r--arch/x86/kernel/tboot.c78
-rw-r--r--arch/x86/kernel/vsyscall_64.c110
-rw-r--r--arch/x86/mm/init_64.c9
-rw-r--r--arch/x86/mm/ioremap.c105
-rw-r--r--arch/x86/mm/pageattr.c10
-rw-r--r--arch/x86/mm/pgtable.c8
-rw-r--r--arch/x86/platform/efi/efi.c30
-rw-r--r--arch/x86/platform/efi/efi_64.c15
-rw-r--r--arch/x86/realmode/init.c17
149 files changed, 4914 insertions, 2676 deletions
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 0f441740c22a..ca6fb8e7f17d 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -131,8 +131,8 @@ dtb-$(CONFIG_ARCH_SPEAR3XX)+= spear300-evb.dtb \
131 spear320-evb.dtb \ 131 spear320-evb.dtb \
132 spear320-hmi.dtb 132 spear320-hmi.dtb
133dtb-$(CONFIG_ARCH_SPEAR6XX)+= spear600-evb.dtb 133dtb-$(CONFIG_ARCH_SPEAR6XX)+= spear600-evb.dtb
134dtb-$(CONFIG_ARCH_SUNXI) += sun4i-cubieboard.dtb \ 134dtb-$(CONFIG_ARCH_SUNXI) += sun4i-a10-cubieboard.dtb \
135 sun5i-olinuxino.dtb 135 sun5i-a13-olinuxino.dtb
136dtb-$(CONFIG_ARCH_TEGRA) += tegra20-harmony.dtb \ 136dtb-$(CONFIG_ARCH_TEGRA) += tegra20-harmony.dtb \
137 tegra20-medcom-wide.dtb \ 137 tegra20-medcom-wide.dtb \
138 tegra20-paz00.dtb \ 138 tegra20-paz00.dtb \
diff --git a/arch/arm/boot/dts/sun4i-cubieboard.dts b/arch/arm/boot/dts/sun4i-cubieboard.dts
index f4ca126ad994..5cab82540437 100644
--- a/arch/arm/boot/dts/sun4i-cubieboard.dts
+++ b/arch/arm/boot/dts/sun4i-cubieboard.dts
@@ -11,11 +11,11 @@
11 */ 11 */
12 12
13/dts-v1/; 13/dts-v1/;
14/include/ "sun4i.dtsi" 14/include/ "sun4i-a10.dtsi"
15 15
16/ { 16/ {
17 model = "Cubietech Cubieboard"; 17 model = "Cubietech Cubieboard";
18 compatible = "cubietech,cubieboard", "allwinner,sun4i"; 18 compatible = "cubietech,a10-cubieboard", "allwinner,sun4i-a10";
19 19
20 aliases { 20 aliases {
21 serial0 = &uart0; 21 serial0 = &uart0;
diff --git a/arch/arm/boot/dts/sun5i-olinuxino.dts b/arch/arm/boot/dts/sun5i-olinuxino.dts
index d6ff889a5d87..498a091a4ea2 100644
--- a/arch/arm/boot/dts/sun5i-olinuxino.dts
+++ b/arch/arm/boot/dts/sun5i-olinuxino.dts
@@ -12,11 +12,11 @@
12 */ 12 */
13 13
14/dts-v1/; 14/dts-v1/;
15/include/ "sun5i.dtsi" 15/include/ "sun5i-a13.dtsi"
16 16
17/ { 17/ {
18 model = "Olimex A13-Olinuxino"; 18 model = "Olimex A13-Olinuxino";
19 compatible = "olimex,a13-olinuxino", "allwinner,sun5i"; 19 compatible = "olimex,a13-olinuxino", "allwinner,sun5i-a13";
20 20
21 chosen { 21 chosen {
22 bootargs = "earlyprintk console=ttyS0,115200"; 22 bootargs = "earlyprintk console=ttyS0,115200";
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index 7211772edd9d..0299915575a8 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -41,6 +41,7 @@
41#include <mach/cp_intc.h> 41#include <mach/cp_intc.h>
42#include <mach/da8xx.h> 42#include <mach/da8xx.h>
43#include <mach/mux.h> 43#include <mach/mux.h>
44#include <mach/sram.h>
44 45
45#include <asm/mach-types.h> 46#include <asm/mach-types.h>
46#include <asm/mach/arch.h> 47#include <asm/mach/arch.h>
diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index 510648e0394b..678a54a64dae 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -408,7 +408,7 @@ static struct clk_lookup da830_clks[] = {
408 CLK(NULL, "pwm2", &pwm2_clk), 408 CLK(NULL, "pwm2", &pwm2_clk),
409 CLK("eqep.0", NULL, &eqep0_clk), 409 CLK("eqep.0", NULL, &eqep0_clk),
410 CLK("eqep.1", NULL, &eqep1_clk), 410 CLK("eqep.1", NULL, &eqep1_clk),
411 CLK("da8xx_lcdc.0", NULL, &lcdc_clk), 411 CLK("da8xx_lcdc.0", "fck", &lcdc_clk),
412 CLK("davinci-mcasp.0", NULL, &mcasp0_clk), 412 CLK("davinci-mcasp.0", NULL, &mcasp0_clk),
413 CLK("davinci-mcasp.1", NULL, &mcasp1_clk), 413 CLK("davinci-mcasp.1", NULL, &mcasp1_clk),
414 CLK("davinci-mcasp.2", NULL, &mcasp2_clk), 414 CLK("davinci-mcasp.2", NULL, &mcasp2_clk),
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index 68c5fe01857c..6b9154e9f908 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -403,7 +403,7 @@ static struct clk_lookup da850_clks[] = {
403 CLK(NULL, "rmii", &rmii_clk), 403 CLK(NULL, "rmii", &rmii_clk),
404 CLK("davinci_emac.1", NULL, &emac_clk), 404 CLK("davinci_emac.1", NULL, &emac_clk),
405 CLK("davinci-mcasp.0", NULL, &mcasp_clk), 405 CLK("davinci-mcasp.0", NULL, &mcasp_clk),
406 CLK("da8xx_lcdc.0", NULL, &lcdc_clk), 406 CLK("da8xx_lcdc.0", "fck", &lcdc_clk),
407 CLK("davinci_mmc.0", NULL, &mmcsd0_clk), 407 CLK("davinci_mmc.0", NULL, &mmcsd0_clk),
408 CLK("davinci_mmc.1", NULL, &mmcsd1_clk), 408 CLK("davinci_mmc.1", NULL, &mmcsd1_clk),
409 CLK(NULL, "aemif", &aemif_clk), 409 CLK(NULL, "aemif", &aemif_clk),
diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c
index 46c9a0c09ae5..fcdbe437409e 100644
--- a/arch/arm/mach-davinci/devices-da8xx.c
+++ b/arch/arm/mach-davinci/devices-da8xx.c
@@ -589,29 +589,9 @@ int __init da8xx_register_uio_pruss(void)
589 return platform_device_register(&da8xx_uio_pruss_dev); 589 return platform_device_register(&da8xx_uio_pruss_dev);
590} 590}
591 591
592static const struct display_panel disp_panel = {
593 QVGA,
594 16,
595 16,
596 COLOR_ACTIVE,
597};
598
599static struct lcd_ctrl_config lcd_cfg = { 592static struct lcd_ctrl_config lcd_cfg = {
600 &disp_panel, 593 .panel_shade = COLOR_ACTIVE,
601 .ac_bias = 255,
602 .ac_bias_intrpt = 0,
603 .dma_burst_sz = 16,
604 .bpp = 16, 594 .bpp = 16,
605 .fdd = 255,
606 .tft_alt_mode = 0,
607 .stn_565_mode = 0,
608 .mono_8bit_mode = 0,
609 .invert_line_clock = 1,
610 .invert_frm_clock = 1,
611 .sync_edge = 0,
612 .sync_ctrl = 1,
613 .raster_order = 0,
614 .fifo_th = 6,
615}; 595};
616 596
617struct da8xx_lcdc_platform_data sharp_lcd035q3dg01_pdata = { 597struct da8xx_lcdc_platform_data sharp_lcd035q3dg01_pdata = {
diff --git a/arch/arm/mach-davinci/pm_domain.c b/arch/arm/mach-davinci/pm_domain.c
index 00946e23c1ee..c90250e3bef8 100644
--- a/arch/arm/mach-davinci/pm_domain.c
+++ b/arch/arm/mach-davinci/pm_domain.c
@@ -53,6 +53,7 @@ static struct dev_pm_domain davinci_pm_domain = {
53 53
54static struct pm_clk_notifier_block platform_bus_notifier = { 54static struct pm_clk_notifier_block platform_bus_notifier = {
55 .pm_domain = &davinci_pm_domain, 55 .pm_domain = &davinci_pm_domain,
56 .con_ids = { "fck", NULL, },
56}; 57};
57 58
58static int __init davinci_pm_runtime_init(void) 59static int __init davinci_pm_runtime_init(void)
diff --git a/arch/arm/mach-exynos/common.h b/arch/arm/mach-exynos/common.h
index dac146df79ac..04744f9c120f 100644
--- a/arch/arm/mach-exynos/common.h
+++ b/arch/arm/mach-exynos/common.h
@@ -25,7 +25,7 @@ void exynos_init_late(void);
25#ifdef CONFIG_PM_GENERIC_DOMAINS 25#ifdef CONFIG_PM_GENERIC_DOMAINS
26int exynos_pm_late_initcall(void); 26int exynos_pm_late_initcall(void);
27#else 27#else
28static int exynos_pm_late_initcall(void) { return 0; } 28static inline int exynos_pm_late_initcall(void) { return 0; }
29#endif 29#endif
30 30
31#ifdef CONFIG_ARCH_EXYNOS4 31#ifdef CONFIG_ARCH_EXYNOS4
diff --git a/arch/arm/mach-omap2/board-rx51-video.c b/arch/arm/mach-omap2/board-rx51-video.c
index c22e111bcd00..46f4fc982766 100644
--- a/arch/arm/mach-omap2/board-rx51-video.c
+++ b/arch/arm/mach-omap2/board-rx51-video.c
@@ -16,7 +16,6 @@
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <asm/mach-types.h> 17#include <asm/mach-types.h>
18#include <video/omapdss.h> 18#include <video/omapdss.h>
19#include <plat/vram.h>
20#include <linux/platform_data/spi-omap2-mcspi.h> 19#include <linux/platform_data/spi-omap2-mcspi.h>
21 20
22#include "board-rx51.h" 21#include "board-rx51.h"
@@ -87,17 +86,4 @@ static int __init rx51_video_init(void)
87} 86}
88 87
89subsys_initcall(rx51_video_init); 88subsys_initcall(rx51_video_init);
90
91void __init rx51_video_mem_init(void)
92{
93 /*
94 * GFX 864x480x32bpp
95 * VID1/2 1280x720x32bpp double buffered
96 */
97 omap_vram_set_sdram_vram(PAGE_ALIGN(864 * 480 * 4) +
98 2 * PAGE_ALIGN(1280 * 720 * 4 * 2), 0);
99}
100
101#else
102void __init rx51_video_mem_init(void) { }
103#endif /* defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE) */ 89#endif /* defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE) */
diff --git a/arch/arm/mach-omap2/board-rx51.c b/arch/arm/mach-omap2/board-rx51.c
index f1d6efe079ca..d0374ea2dfb0 100644
--- a/arch/arm/mach-omap2/board-rx51.c
+++ b/arch/arm/mach-omap2/board-rx51.c
@@ -34,8 +34,6 @@
34 34
35#define RX51_GPIO_SLEEP_IND 162 35#define RX51_GPIO_SLEEP_IND 162
36 36
37extern void rx51_video_mem_init(void);
38
39static struct gpio_led gpio_leds[] = { 37static struct gpio_led gpio_leds[] = {
40 { 38 {
41 .name = "sleep_ind", 39 .name = "sleep_ind",
@@ -112,7 +110,6 @@ static void __init rx51_init(void)
112 110
113static void __init rx51_reserve(void) 111static void __init rx51_reserve(void)
114{ 112{
115 rx51_video_mem_init();
116 omap_reserve(); 113 omap_reserve();
117} 114}
118 115
diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c
index 38ba58c97628..cc75aaf6e764 100644
--- a/arch/arm/mach-omap2/display.c
+++ b/arch/arm/mach-omap2/display.c
@@ -102,17 +102,20 @@ static const struct omap_dss_hwmod_data omap4_dss_hwmod_data[] __initconst = {
102 { "dss_hdmi", "omapdss_hdmi", -1 }, 102 { "dss_hdmi", "omapdss_hdmi", -1 },
103}; 103};
104 104
105static void __init omap4_hdmi_mux_pads(enum omap_hdmi_flags flags) 105static void __init omap4_tpd12s015_mux_pads(void)
106{ 106{
107 u32 reg;
108 u16 control_i2c_1;
109
110 omap_mux_init_signal("hdmi_cec", 107 omap_mux_init_signal("hdmi_cec",
111 OMAP_PIN_INPUT_PULLUP); 108 OMAP_PIN_INPUT_PULLUP);
112 omap_mux_init_signal("hdmi_ddc_scl", 109 omap_mux_init_signal("hdmi_ddc_scl",
113 OMAP_PIN_INPUT_PULLUP); 110 OMAP_PIN_INPUT_PULLUP);
114 omap_mux_init_signal("hdmi_ddc_sda", 111 omap_mux_init_signal("hdmi_ddc_sda",
115 OMAP_PIN_INPUT_PULLUP); 112 OMAP_PIN_INPUT_PULLUP);
113}
114
115static void __init omap4_hdmi_mux_pads(enum omap_hdmi_flags flags)
116{
117 u32 reg;
118 u16 control_i2c_1;
116 119
117 /* 120 /*
118 * CONTROL_I2C_1: HDMI_DDC_SDA_PULLUPRESX (bit 28) and 121 * CONTROL_I2C_1: HDMI_DDC_SDA_PULLUPRESX (bit 28) and
@@ -163,8 +166,10 @@ static int omap4_dsi_mux_pads(int dsi_id, unsigned lanes)
163 166
164int __init omap_hdmi_init(enum omap_hdmi_flags flags) 167int __init omap_hdmi_init(enum omap_hdmi_flags flags)
165{ 168{
166 if (cpu_is_omap44xx()) 169 if (cpu_is_omap44xx()) {
167 omap4_hdmi_mux_pads(flags); 170 omap4_hdmi_mux_pads(flags);
171 omap4_tpd12s015_mux_pads();
172 }
168 173
169 return 0; 174 return 0;
170} 175}
diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
index 25eb88a923e6..032d10817e79 100644
--- a/arch/arm/mach-shmobile/board-ag5evm.c
+++ b/arch/arm/mach-shmobile/board-ag5evm.c
@@ -213,95 +213,6 @@ static struct platform_device irda_device = {
213 .num_resources = ARRAY_SIZE(irda_resources), 213 .num_resources = ARRAY_SIZE(irda_resources),
214}; 214};
215 215
216static unsigned char lcd_backlight_seq[3][2] = {
217 { 0x04, 0x07 },
218 { 0x23, 0x80 },
219 { 0x03, 0x01 },
220};
221
222static void lcd_backlight_on(void)
223{
224 struct i2c_adapter *a;
225 struct i2c_msg msg;
226 int k;
227
228 a = i2c_get_adapter(1);
229 for (k = 0; a && k < 3; k++) {
230 msg.addr = 0x6d;
231 msg.buf = &lcd_backlight_seq[k][0];
232 msg.len = 2;
233 msg.flags = 0;
234 if (i2c_transfer(a, &msg, 1) != 1)
235 break;
236 }
237}
238
239static void lcd_backlight_reset(void)
240{
241 gpio_set_value(GPIO_PORT235, 0);
242 mdelay(24);
243 gpio_set_value(GPIO_PORT235, 1);
244}
245
246/* LCDC0 */
247static const struct fb_videomode lcdc0_modes[] = {
248 {
249 .name = "R63302(QHD)",
250 .xres = 544,
251 .yres = 961,
252 .left_margin = 72,
253 .right_margin = 600,
254 .hsync_len = 16,
255 .upper_margin = 8,
256 .lower_margin = 8,
257 .vsync_len = 2,
258 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
259 },
260};
261
262static struct sh_mobile_lcdc_info lcdc0_info = {
263 .clock_source = LCDC_CLK_PERIPHERAL,
264 .ch[0] = {
265 .chan = LCDC_CHAN_MAINLCD,
266 .interface_type = RGB24,
267 .clock_divider = 1,
268 .flags = LCDC_FLAGS_DWPOL,
269 .fourcc = V4L2_PIX_FMT_RGB565,
270 .lcd_modes = lcdc0_modes,
271 .num_modes = ARRAY_SIZE(lcdc0_modes),
272 .panel_cfg = {
273 .width = 44,
274 .height = 79,
275 .display_on = lcd_backlight_on,
276 .display_off = lcd_backlight_reset,
277 },
278 }
279};
280
281static struct resource lcdc0_resources[] = {
282 [0] = {
283 .name = "LCDC0",
284 .start = 0xfe940000, /* P4-only space */
285 .end = 0xfe943fff,
286 .flags = IORESOURCE_MEM,
287 },
288 [1] = {
289 .start = intcs_evt2irq(0x580),
290 .flags = IORESOURCE_IRQ,
291 },
292};
293
294static struct platform_device lcdc0_device = {
295 .name = "sh_mobile_lcdc_fb",
296 .num_resources = ARRAY_SIZE(lcdc0_resources),
297 .resource = lcdc0_resources,
298 .id = 0,
299 .dev = {
300 .platform_data = &lcdc0_info,
301 .coherent_dma_mask = ~0,
302 },
303};
304
305/* MIPI-DSI */ 216/* MIPI-DSI */
306static struct resource mipidsi0_resources[] = { 217static struct resource mipidsi0_resources[] = {
307 [0] = { 218 [0] = {
@@ -358,7 +269,7 @@ sh_mipi_set_dot_clock_pck_err:
358 269
359static struct sh_mipi_dsi_info mipidsi0_info = { 270static struct sh_mipi_dsi_info mipidsi0_info = {
360 .data_format = MIPI_RGB888, 271 .data_format = MIPI_RGB888,
361 .lcd_chan = &lcdc0_info.ch[0], 272 .channel = LCDC_CHAN_MAINLCD,
362 .lane = 2, 273 .lane = 2,
363 .vsynw_offset = 20, 274 .vsynw_offset = 20,
364 .clksrc = 1, 275 .clksrc = 1,
@@ -378,6 +289,109 @@ static struct platform_device mipidsi0_device = {
378 }, 289 },
379}; 290};
380 291
292static unsigned char lcd_backlight_seq[3][2] = {
293 { 0x04, 0x07 },
294 { 0x23, 0x80 },
295 { 0x03, 0x01 },
296};
297
298static int lcd_backlight_set_brightness(int brightness)
299{
300 struct i2c_adapter *adap;
301 struct i2c_msg msg;
302 unsigned int i;
303 int ret;
304
305 if (brightness == 0) {
306 /* Reset the chip */
307 gpio_set_value(GPIO_PORT235, 0);
308 mdelay(24);
309 gpio_set_value(GPIO_PORT235, 1);
310 return 0;
311 }
312
313 adap = i2c_get_adapter(1);
314 if (adap == NULL)
315 return -ENODEV;
316
317 for (i = 0; i < ARRAY_SIZE(lcd_backlight_seq); i++) {
318 msg.addr = 0x6d;
319 msg.buf = &lcd_backlight_seq[i][0];
320 msg.len = 2;
321 msg.flags = 0;
322
323 ret = i2c_transfer(adap, &msg, 1);
324 if (ret < 0)
325 break;
326 }
327
328 i2c_put_adapter(adap);
329 return ret < 0 ? ret : 0;
330}
331
332/* LCDC0 */
333static const struct fb_videomode lcdc0_modes[] = {
334 {
335 .name = "R63302(QHD)",
336 .xres = 544,
337 .yres = 961,
338 .left_margin = 72,
339 .right_margin = 600,
340 .hsync_len = 16,
341 .upper_margin = 8,
342 .lower_margin = 8,
343 .vsync_len = 2,
344 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
345 },
346};
347
348static struct sh_mobile_lcdc_info lcdc0_info = {
349 .clock_source = LCDC_CLK_PERIPHERAL,
350 .ch[0] = {
351 .chan = LCDC_CHAN_MAINLCD,
352 .interface_type = RGB24,
353 .clock_divider = 1,
354 .flags = LCDC_FLAGS_DWPOL,
355 .fourcc = V4L2_PIX_FMT_RGB565,
356 .lcd_modes = lcdc0_modes,
357 .num_modes = ARRAY_SIZE(lcdc0_modes),
358 .panel_cfg = {
359 .width = 44,
360 .height = 79,
361 },
362 .bl_info = {
363 .name = "sh_mobile_lcdc_bl",
364 .max_brightness = 1,
365 .set_brightness = lcd_backlight_set_brightness,
366 },
367 .tx_dev = &mipidsi0_device,
368 }
369};
370
371static struct resource lcdc0_resources[] = {
372 [0] = {
373 .name = "LCDC0",
374 .start = 0xfe940000, /* P4-only space */
375 .end = 0xfe943fff,
376 .flags = IORESOURCE_MEM,
377 },
378 [1] = {
379 .start = intcs_evt2irq(0x580),
380 .flags = IORESOURCE_IRQ,
381 },
382};
383
384static struct platform_device lcdc0_device = {
385 .name = "sh_mobile_lcdc_fb",
386 .num_resources = ARRAY_SIZE(lcdc0_resources),
387 .resource = lcdc0_resources,
388 .id = 0,
389 .dev = {
390 .platform_data = &lcdc0_info,
391 .coherent_dma_mask = ~0,
392 },
393};
394
381/* Fixed 2.8V regulators to be used by SDHI0 */ 395/* Fixed 2.8V regulators to be used by SDHI0 */
382static struct regulator_consumer_supply fixed2v8_power_consumers[] = 396static struct regulator_consumer_supply fixed2v8_power_consumers[] =
383{ 397{
@@ -531,8 +545,8 @@ static struct platform_device *ag5evm_devices[] __initdata = {
531 &fsi_device, 545 &fsi_device,
532 &mmc_device, 546 &mmc_device,
533 &irda_device, 547 &irda_device,
534 &lcdc0_device,
535 &mipidsi0_device, 548 &mipidsi0_device,
549 &lcdc0_device,
536 &sdhi0_device, 550 &sdhi0_device,
537 &sdhi1_device, 551 &sdhi1_device,
538}; 552};
@@ -621,7 +635,7 @@ static void __init ag5evm_init(void)
621 /* LCD backlight controller */ 635 /* LCD backlight controller */
622 gpio_request(GPIO_PORT235, NULL); /* RESET */ 636 gpio_request(GPIO_PORT235, NULL); /* RESET */
623 gpio_direction_output(GPIO_PORT235, 0); 637 gpio_direction_output(GPIO_PORT235, 0);
624 lcd_backlight_reset(); 638 lcd_backlight_set_brightness(0);
625 639
626 /* enable SDHI0 on CN15 [SD I/F] */ 640 /* enable SDHI0 on CN15 [SD I/F] */
627 gpio_request(GPIO_FN_SDHIWP0, NULL); 641 gpio_request(GPIO_FN_SDHIWP0, NULL);
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index 40657854e3ad..99ef190d0909 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -552,11 +552,9 @@ static struct resource mipidsi0_resources[] = {
552 }, 552 },
553}; 553};
554 554
555static struct sh_mobile_lcdc_info lcdc_info;
556
557static struct sh_mipi_dsi_info mipidsi0_info = { 555static struct sh_mipi_dsi_info mipidsi0_info = {
558 .data_format = MIPI_RGB888, 556 .data_format = MIPI_RGB888,
559 .lcd_chan = &lcdc_info.ch[0], 557 .channel = LCDC_CHAN_MAINLCD,
560 .lane = 2, 558 .lane = 2,
561 .vsynw_offset = 17, 559 .vsynw_offset = 17,
562 .phyctrl = 0x6 << 8, 560 .phyctrl = 0x6 << 8,
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
index 3f56e70795b7..2fed62f66045 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -370,11 +370,6 @@ static int mackerel_set_brightness(int brightness)
370 return 0; 370 return 0;
371} 371}
372 372
373static int mackerel_get_brightness(void)
374{
375 return gpio_get_value(GPIO_PORT31);
376}
377
378static const struct sh_mobile_meram_cfg lcd_meram_cfg = { 373static const struct sh_mobile_meram_cfg lcd_meram_cfg = {
379 .icb[0] = { 374 .icb[0] = {
380 .meram_size = 0x40, 375 .meram_size = 0x40,
@@ -403,7 +398,6 @@ static struct sh_mobile_lcdc_info lcdc_info = {
403 .name = "sh_mobile_lcdc_bl", 398 .name = "sh_mobile_lcdc_bl",
404 .max_brightness = 1, 399 .max_brightness = 1,
405 .set_brightness = mackerel_set_brightness, 400 .set_brightness = mackerel_set_brightness,
406 .get_brightness = mackerel_get_brightness,
407 }, 401 },
408 .meram_cfg = &lcd_meram_cfg, 402 .meram_cfg = &lcd_meram_cfg,
409 } 403 }
diff --git a/arch/arm/mach-tegra/common.c b/arch/arm/mach-tegra/common.c
index 0816562725f6..d54cfc54b9fe 100644
--- a/arch/arm/mach-tegra/common.c
+++ b/arch/arm/mach-tegra/common.c
@@ -104,7 +104,7 @@ static __initdata struct tegra_clk_init_table tegra20_clk_init_table[] = {
104static __initdata struct tegra_clk_init_table tegra30_clk_init_table[] = { 104static __initdata struct tegra_clk_init_table tegra30_clk_init_table[] = {
105 /* name parent rate enabled */ 105 /* name parent rate enabled */
106 { "clk_m", NULL, 0, true }, 106 { "clk_m", NULL, 0, true },
107 { "pll_p", "clk_m", 408000000, true }, 107 { "pll_p", "pll_ref", 408000000, true },
108 { "pll_p_out1", "pll_p", 9600000, true }, 108 { "pll_p_out1", "pll_p", 9600000, true },
109 { "pll_p_out4", "pll_p", 102000000, true }, 109 { "pll_p_out4", "pll_p", 102000000, true },
110 { "sclk", "pll_p_out4", 102000000, true }, 110 { "sclk", "pll_p_out4", 102000000, true },
diff --git a/arch/arm/mach-tegra/tegra30_clocks.c b/arch/arm/mach-tegra/tegra30_clocks.c
index efc000e32e1c..d7147779f8ea 100644
--- a/arch/arm/mach-tegra/tegra30_clocks.c
+++ b/arch/arm/mach-tegra/tegra30_clocks.c
@@ -2045,9 +2045,7 @@ struct clk_ops tegra30_periph_clk_ops = {
2045static int tegra30_dsib_clk_set_parent(struct clk_hw *hw, u8 index) 2045static int tegra30_dsib_clk_set_parent(struct clk_hw *hw, u8 index)
2046{ 2046{
2047 struct clk *d = clk_get_sys(NULL, "pll_d"); 2047 struct clk *d = clk_get_sys(NULL, "pll_d");
2048 /* The DSIB parent selection bit is in PLLD base 2048 /* The DSIB parent selection bit is in PLLD base register */
2049 register - can not do direct r-m-w, must be
2050 protected by PLLD lock */
2051 tegra_clk_cfg_ex( 2049 tegra_clk_cfg_ex(
2052 d, TEGRA_CLK_PLLD_MIPI_MUX_SEL, index); 2050 d, TEGRA_CLK_PLLD_MIPI_MUX_SEL, index);
2053 2051
diff --git a/arch/arm/mach-u300/core.c b/arch/arm/mach-u300/core.c
index 12f3994c43db..0374b9863e9b 100644
--- a/arch/arm/mach-u300/core.c
+++ b/arch/arm/mach-u300/core.c
@@ -27,7 +27,6 @@
27#include <linux/mtd/nand.h> 27#include <linux/mtd/nand.h>
28#include <linux/mtd/fsmc.h> 28#include <linux/mtd/fsmc.h>
29#include <linux/pinctrl/machine.h> 29#include <linux/pinctrl/machine.h>
30#include <linux/pinctrl/consumer.h>
31#include <linux/pinctrl/pinconf-generic.h> 30#include <linux/pinctrl/pinconf-generic.h>
32#include <linux/dma-mapping.h> 31#include <linux/dma-mapping.h>
33#include <linux/platform_data/clk-u300.h> 32#include <linux/platform_data/clk-u300.h>
@@ -1543,39 +1542,6 @@ static struct pinctrl_map __initdata u300_pinmux_map[] = {
1543 pin_highz_conf), 1542 pin_highz_conf),
1544}; 1543};
1545 1544
1546struct u300_mux_hog {
1547 struct device *dev;
1548 struct pinctrl *p;
1549};
1550
1551static struct u300_mux_hog u300_mux_hogs[] = {
1552 {
1553 .dev = &uart0_device.dev,
1554 },
1555 {
1556 .dev = &mmcsd_device.dev,
1557 },
1558};
1559
1560static int __init u300_pinctrl_fetch(void)
1561{
1562 int i;
1563
1564 for (i = 0; i < ARRAY_SIZE(u300_mux_hogs); i++) {
1565 struct pinctrl *p;
1566
1567 p = pinctrl_get_select_default(u300_mux_hogs[i].dev);
1568 if (IS_ERR(p)) {
1569 pr_err("u300: could not get pinmux hog for dev %s\n",
1570 dev_name(u300_mux_hogs[i].dev));
1571 continue;
1572 }
1573 u300_mux_hogs[i].p = p;
1574 }
1575 return 0;
1576}
1577subsys_initcall(u300_pinctrl_fetch);
1578
1579/* 1545/*
1580 * Notice that AMBA devices are initialized before platform devices. 1546 * Notice that AMBA devices are initialized before platform devices.
1581 * 1547 *
diff --git a/arch/arm/mach-ux500/devices-db8500.h b/arch/arm/mach-ux500/devices-db8500.h
index 4b24c9992654..a5e05f6e256f 100644
--- a/arch/arm/mach-ux500/devices-db8500.h
+++ b/arch/arm/mach-ux500/devices-db8500.h
@@ -8,6 +8,7 @@
8#ifndef __DEVICES_DB8500_H 8#ifndef __DEVICES_DB8500_H
9#define __DEVICES_DB8500_H 9#define __DEVICES_DB8500_H
10 10
11#include <linux/platform_data/usb-musb-ux500.h>
11#include <mach/irqs.h> 12#include <mach/irqs.h>
12#include "devices-common.h" 13#include "devices-common.h"
13 14
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 5383bc018571..6b2fb87c8698 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -1034,7 +1034,8 @@ static inline void __free_iova(struct dma_iommu_mapping *mapping,
1034 spin_unlock_irqrestore(&mapping->lock, flags); 1034 spin_unlock_irqrestore(&mapping->lock, flags);
1035} 1035}
1036 1036
1037static struct page **__iommu_alloc_buffer(struct device *dev, size_t size, gfp_t gfp) 1037static struct page **__iommu_alloc_buffer(struct device *dev, size_t size,
1038 gfp_t gfp, struct dma_attrs *attrs)
1038{ 1039{
1039 struct page **pages; 1040 struct page **pages;
1040 int count = size >> PAGE_SHIFT; 1041 int count = size >> PAGE_SHIFT;
@@ -1048,6 +1049,23 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size, gfp_t
1048 if (!pages) 1049 if (!pages)
1049 return NULL; 1050 return NULL;
1050 1051
1052 if (dma_get_attr(DMA_ATTR_FORCE_CONTIGUOUS, attrs))
1053 {
1054 unsigned long order = get_order(size);
1055 struct page *page;
1056
1057 page = dma_alloc_from_contiguous(dev, count, order);
1058 if (!page)
1059 goto error;
1060
1061 __dma_clear_buffer(page, size);
1062
1063 for (i = 0; i < count; i++)
1064 pages[i] = page + i;
1065
1066 return pages;
1067 }
1068
1051 while (count) { 1069 while (count) {
1052 int j, order = __fls(count); 1070 int j, order = __fls(count);
1053 1071
@@ -1081,14 +1099,21 @@ error:
1081 return NULL; 1099 return NULL;
1082} 1100}
1083 1101
1084static int __iommu_free_buffer(struct device *dev, struct page **pages, size_t size) 1102static int __iommu_free_buffer(struct device *dev, struct page **pages,
1103 size_t size, struct dma_attrs *attrs)
1085{ 1104{
1086 int count = size >> PAGE_SHIFT; 1105 int count = size >> PAGE_SHIFT;
1087 int array_size = count * sizeof(struct page *); 1106 int array_size = count * sizeof(struct page *);
1088 int i; 1107 int i;
1089 for (i = 0; i < count; i++) 1108
1090 if (pages[i]) 1109 if (dma_get_attr(DMA_ATTR_FORCE_CONTIGUOUS, attrs)) {
1091 __free_pages(pages[i], 0); 1110 dma_release_from_contiguous(dev, pages[0], count);
1111 } else {
1112 for (i = 0; i < count; i++)
1113 if (pages[i])
1114 __free_pages(pages[i], 0);
1115 }
1116
1092 if (array_size <= PAGE_SIZE) 1117 if (array_size <= PAGE_SIZE)
1093 kfree(pages); 1118 kfree(pages);
1094 else 1119 else
@@ -1250,7 +1275,7 @@ static void *arm_iommu_alloc_attrs(struct device *dev, size_t size,
1250 if (gfp & GFP_ATOMIC) 1275 if (gfp & GFP_ATOMIC)
1251 return __iommu_alloc_atomic(dev, size, handle); 1276 return __iommu_alloc_atomic(dev, size, handle);
1252 1277
1253 pages = __iommu_alloc_buffer(dev, size, gfp); 1278 pages = __iommu_alloc_buffer(dev, size, gfp, attrs);
1254 if (!pages) 1279 if (!pages)
1255 return NULL; 1280 return NULL;
1256 1281
@@ -1271,7 +1296,7 @@ static void *arm_iommu_alloc_attrs(struct device *dev, size_t size,
1271err_mapping: 1296err_mapping:
1272 __iommu_remove_mapping(dev, *handle, size); 1297 __iommu_remove_mapping(dev, *handle, size);
1273err_buffer: 1298err_buffer:
1274 __iommu_free_buffer(dev, pages, size); 1299 __iommu_free_buffer(dev, pages, size, attrs);
1275 return NULL; 1300 return NULL;
1276} 1301}
1277 1302
@@ -1327,7 +1352,7 @@ void arm_iommu_free_attrs(struct device *dev, size_t size, void *cpu_addr,
1327 } 1352 }
1328 1353
1329 __iommu_remove_mapping(dev, handle, size); 1354 __iommu_remove_mapping(dev, handle, size);
1330 __iommu_free_buffer(dev, pages, size); 1355 __iommu_free_buffer(dev, pages, size, attrs);
1331} 1356}
1332 1357
1333static int arm_iommu_get_sgtable(struct device *dev, struct sg_table *sgt, 1358static int arm_iommu_get_sgtable(struct device *dev, struct sg_table *sgt,
diff --git a/arch/arm/plat-omap/fb.c b/arch/arm/plat-omap/fb.c
index 3a77b30f53d4..a3367b783fc7 100644
--- a/arch/arm/plat-omap/fb.c
+++ b/arch/arm/plat-omap/fb.c
@@ -29,6 +29,7 @@
29#include <linux/memblock.h> 29#include <linux/memblock.h>
30#include <linux/io.h> 30#include <linux/io.h>
31#include <linux/omapfb.h> 31#include <linux/omapfb.h>
32#include <linux/dma-mapping.h>
32 33
33#include <asm/mach/map.h> 34#include <asm/mach/map.h>
34 35
@@ -105,7 +106,7 @@ static struct platform_device omap_fb_device = {
105 .id = -1, 106 .id = -1,
106 .dev = { 107 .dev = {
107 .dma_mask = &omap_fb_dma_mask, 108 .dma_mask = &omap_fb_dma_mask,
108 .coherent_dma_mask = ~(u32)0, 109 .coherent_dma_mask = DMA_BIT_MASK(32),
109 .platform_data = &omapfb_config, 110 .platform_data = &omapfb_config,
110 }, 111 },
111 .num_resources = 0, 112 .num_resources = 0,
@@ -141,7 +142,7 @@ static struct platform_device omap_fb_device = {
141 .id = -1, 142 .id = -1,
142 .dev = { 143 .dev = {
143 .dma_mask = &omap_fb_dma_mask, 144 .dma_mask = &omap_fb_dma_mask,
144 .coherent_dma_mask = ~(u32)0, 145 .coherent_dma_mask = DMA_BIT_MASK(32),
145 .platform_data = &omapfb_config, 146 .platform_data = &omapfb_config,
146 }, 147 },
147 .num_resources = 0, 148 .num_resources = 0,
diff --git a/arch/arm/plat-omap/include/plat/vram.h b/arch/arm/plat-omap/include/plat/vram.h
deleted file mode 100644
index 4d65b7d06e6c..000000000000
--- a/arch/arm/plat-omap/include/plat/vram.h
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * VRAM manager for OMAP
3 *
4 * Copyright (C) 2009 Nokia Corporation
5 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21#ifndef __OMAP_VRAM_H__
22#define __OMAP_VRAM_H__
23
24#include <linux/types.h>
25
26extern int omap_vram_add_region(unsigned long paddr, size_t size);
27extern int omap_vram_free(unsigned long paddr, size_t size);
28extern int omap_vram_alloc(size_t size, unsigned long *paddr);
29extern int omap_vram_reserve(unsigned long paddr, size_t size);
30extern void omap_vram_get_info(unsigned long *vram, unsigned long *free_vram,
31 unsigned long *largest_free_block);
32
33#ifdef CONFIG_OMAP2_VRAM
34extern void omap_vram_set_sdram_vram(u32 size, u32 start);
35
36extern void omap_vram_reserve_sdram_memblock(void);
37#else
38static inline void omap_vram_set_sdram_vram(u32 size, u32 start) { }
39
40static inline void omap_vram_reserve_sdram_memblock(void) { }
41#endif
42
43#endif
diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
index 2f2d87b40341..b1cfff832fb5 100644
--- a/arch/m68k/Kconfig.cpu
+++ b/arch/m68k/Kconfig.cpu
@@ -35,7 +35,8 @@ endchoice
35if M68KCLASSIC 35if M68KCLASSIC
36 36
37config M68000 37config M68000
38 bool 38 bool "MC68000"
39 depends on !MMU
39 select CPU_HAS_NO_BITFIELDS 40 select CPU_HAS_NO_BITFIELDS
40 select CPU_HAS_NO_MULDIV64 41 select CPU_HAS_NO_MULDIV64
41 select CPU_HAS_NO_UNALIGNED 42 select CPU_HAS_NO_UNALIGNED
diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index 7636751f2f87..2f02acfb8edf 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -92,7 +92,7 @@ endif
92head-y := arch/m68k/kernel/head.o 92head-y := arch/m68k/kernel/head.o
93head-$(CONFIG_SUN3) := arch/m68k/kernel/sun3-head.o 93head-$(CONFIG_SUN3) := arch/m68k/kernel/sun3-head.o
94head-$(CONFIG_M68360) := arch/m68k/platform/68360/head.o 94head-$(CONFIG_M68360) := arch/m68k/platform/68360/head.o
95head-$(CONFIG_M68000) := arch/m68k/platform/68328/head.o 95head-$(CONFIG_M68000) := arch/m68k/platform/68000/head.o
96head-$(CONFIG_COLDFIRE) := arch/m68k/platform/coldfire/head.o 96head-$(CONFIG_COLDFIRE) := arch/m68k/platform/coldfire/head.o
97 97
98core-y += arch/m68k/kernel/ arch/m68k/mm/ 98core-y += arch/m68k/kernel/ arch/m68k/mm/
@@ -114,9 +114,7 @@ core-$(CONFIG_M68040) += arch/m68k/fpsp040/
114core-$(CONFIG_M68060) += arch/m68k/ifpsp060/ 114core-$(CONFIG_M68060) += arch/m68k/ifpsp060/
115core-$(CONFIG_M68KFPU_EMU) += arch/m68k/math-emu/ 115core-$(CONFIG_M68KFPU_EMU) += arch/m68k/math-emu/
116core-$(CONFIG_M68360) += arch/m68k/platform/68360/ 116core-$(CONFIG_M68360) += arch/m68k/platform/68360/
117core-$(CONFIG_M68000) += arch/m68k/platform/68328/ 117core-$(CONFIG_M68000) += arch/m68k/platform/68000/
118core-$(CONFIG_M68EZ328) += arch/m68k/platform/68EZ328/
119core-$(CONFIG_M68VZ328) += arch/m68k/platform/68VZ328/
120core-$(CONFIG_COLDFIRE) += arch/m68k/platform/coldfire/ 118core-$(CONFIG_COLDFIRE) += arch/m68k/platform/coldfire/
121 119
122 120
diff --git a/arch/m68k/include/asm/m5249sim.h b/arch/m68k/include/asm/m5249sim.h
deleted file mode 100644
index fdf45e6807c9..000000000000
--- a/arch/m68k/include/asm/m5249sim.h
+++ /dev/null
@@ -1,269 +0,0 @@
1/****************************************************************************/
2
3/*
4 * m5249sim.h -- ColdFire 5249 System Integration Module support.
5 *
6 * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com)
7 */
8
9/****************************************************************************/
10#ifndef m5249sim_h
11#define m5249sim_h
12/****************************************************************************/
13
14#define CPU_NAME "COLDFIRE(m5249)"
15#define CPU_INSTR_PER_JIFFY 3
16#define MCF_BUSCLK (MCF_CLK / 2)
17
18#include <asm/m52xxacr.h>
19
20/*
21 * The 5249 has a second MBAR region, define its address.
22 */
23#define MCF_MBAR2 0x80000000
24
25/*
26 * Define the 5249 SIM register set addresses.
27 */
28#define MCFSIM_RSR (MCF_MBAR + 0x00) /* Reset Status */
29#define MCFSIM_SYPCR (MCF_MBAR + 0x01) /* System Protection */
30#define MCFSIM_SWIVR (MCF_MBAR + 0x02) /* SW Watchdog intr */
31#define MCFSIM_SWSR (MCF_MBAR + 0x03) /* SW Watchdog srv */
32#define MCFSIM_PAR (MCF_MBAR + 0x04) /* Pin Assignment */
33#define MCFSIM_IRQPAR (MCF_MBAR + 0x06) /* Intr Assignment */
34#define MCFSIM_MPARK (MCF_MBAR + 0x0C) /* BUS Master Ctrl */
35#define MCFSIM_IPR (MCF_MBAR + 0x40) /* Interrupt Pending */
36#define MCFSIM_IMR (MCF_MBAR + 0x44) /* Interrupt Mask */
37#define MCFSIM_AVR (MCF_MBAR + 0x4b) /* Autovector Ctrl */
38#define MCFSIM_ICR0 (MCF_MBAR + 0x4c) /* Intr Ctrl reg 0 */
39#define MCFSIM_ICR1 (MCF_MBAR + 0x4d) /* Intr Ctrl reg 1 */
40#define MCFSIM_ICR2 (MCF_MBAR + 0x4e) /* Intr Ctrl reg 2 */
41#define MCFSIM_ICR3 (MCF_MBAR + 0x4f) /* Intr Ctrl reg 3 */
42#define MCFSIM_ICR4 (MCF_MBAR + 0x50) /* Intr Ctrl reg 4 */
43#define MCFSIM_ICR5 (MCF_MBAR + 0x51) /* Intr Ctrl reg 5 */
44#define MCFSIM_ICR6 (MCF_MBAR + 0x52) /* Intr Ctrl reg 6 */
45#define MCFSIM_ICR7 (MCF_MBAR + 0x53) /* Intr Ctrl reg 7 */
46#define MCFSIM_ICR8 (MCF_MBAR + 0x54) /* Intr Ctrl reg 8 */
47#define MCFSIM_ICR9 (MCF_MBAR + 0x55) /* Intr Ctrl reg 9 */
48#define MCFSIM_ICR10 (MCF_MBAR + 0x56) /* Intr Ctrl reg 10 */
49#define MCFSIM_ICR11 (MCF_MBAR + 0x57) /* Intr Ctrl reg 11 */
50
51#define MCFSIM_CSAR0 (MCF_MBAR + 0x80) /* CS 0 Address reg */
52#define MCFSIM_CSMR0 (MCF_MBAR + 0x84) /* CS 0 Mask reg */
53#define MCFSIM_CSCR0 (MCF_MBAR + 0x8a) /* CS 0 Control reg */
54#define MCFSIM_CSAR1 (MCF_MBAR + 0x8c) /* CS 1 Address reg */
55#define MCFSIM_CSMR1 (MCF_MBAR + 0x90) /* CS 1 Mask reg */
56#define MCFSIM_CSCR1 (MCF_MBAR + 0x96) /* CS 1 Control reg */
57#define MCFSIM_CSAR2 (MCF_MBAR + 0x98) /* CS 2 Address reg */
58#define MCFSIM_CSMR2 (MCF_MBAR + 0x9c) /* CS 2 Mask reg */
59#define MCFSIM_CSCR2 (MCF_MBAR + 0xa2) /* CS 2 Control reg */
60#define MCFSIM_CSAR3 (MCF_MBAR + 0xa4) /* CS 3 Address reg */
61#define MCFSIM_CSMR3 (MCF_MBAR + 0xa8) /* CS 3 Mask reg */
62#define MCFSIM_CSCR3 (MCF_MBAR + 0xae) /* CS 3 Control reg */
63
64#define MCFSIM_DCR (MCF_MBAR + 0x100) /* DRAM Control */
65#define MCFSIM_DACR0 (MCF_MBAR + 0x108) /* DRAM 0 Addr/Ctrl */
66#define MCFSIM_DMR0 (MCF_MBAR + 0x10c) /* DRAM 0 Mask */
67#define MCFSIM_DACR1 (MCF_MBAR + 0x110) /* DRAM 1 Addr/Ctrl */
68#define MCFSIM_DMR1 (MCF_MBAR + 0x114) /* DRAM 1 Mask */
69
70/*
71 * Timer module.
72 */
73#define MCFTIMER_BASE1 (MCF_MBAR + 0x140) /* Base of TIMER1 */
74#define MCFTIMER_BASE2 (MCF_MBAR + 0x180) /* Base of TIMER2 */
75
76/*
77 * UART module.
78 */
79#define MCFUART_BASE0 (MCF_MBAR + 0x1c0) /* Base address UART0 */
80#define MCFUART_BASE1 (MCF_MBAR + 0x200) /* Base address UART1 */
81
82/*
83 * QSPI module.
84 */
85#define MCFQSPI_BASE (MCF_MBAR + 0x300) /* Base address QSPI */
86#define MCFQSPI_SIZE 0x40 /* Register set size */
87
88#define MCFQSPI_CS0 29
89#define MCFQSPI_CS1 24
90#define MCFQSPI_CS2 21
91#define MCFQSPI_CS3 22
92
93/*
94 * DMA unit base addresses.
95 */
96#define MCFDMA_BASE0 (MCF_MBAR + 0x300) /* Base address DMA 0 */
97#define MCFDMA_BASE1 (MCF_MBAR + 0x340) /* Base address DMA 1 */
98#define MCFDMA_BASE2 (MCF_MBAR + 0x380) /* Base address DMA 2 */
99#define MCFDMA_BASE3 (MCF_MBAR + 0x3C0) /* Base address DMA 3 */
100
101/*
102 * Some symbol defines for the above...
103 */
104#define MCFSIM_SWDICR MCFSIM_ICR0 /* Watchdog timer ICR */
105#define MCFSIM_TIMER1ICR MCFSIM_ICR1 /* Timer 1 ICR */
106#define MCFSIM_TIMER2ICR MCFSIM_ICR2 /* Timer 2 ICR */
107#define MCFSIM_UART1ICR MCFSIM_ICR4 /* UART 1 ICR */
108#define MCFSIM_UART2ICR MCFSIM_ICR5 /* UART 2 ICR */
109#define MCFSIM_DMA0ICR MCFSIM_ICR6 /* DMA 0 ICR */
110#define MCFSIM_DMA1ICR MCFSIM_ICR7 /* DMA 1 ICR */
111#define MCFSIM_DMA2ICR MCFSIM_ICR8 /* DMA 2 ICR */
112#define MCFSIM_DMA3ICR MCFSIM_ICR9 /* DMA 3 ICR */
113#define MCFSIM_QSPIICR MCFSIM_ICR10 /* QSPI ICR */
114
115/*
116 * Define system peripheral IRQ usage.
117 */
118#define MCF_IRQ_QSPI 28 /* QSPI, Level 4 */
119#define MCF_IRQ_TIMER 30 /* Timer0, Level 6 */
120#define MCF_IRQ_PROFILER 31 /* Timer1, Level 7 */
121
122#define MCF_IRQ_UART0 73 /* UART0 */
123#define MCF_IRQ_UART1 74 /* UART1 */
124
125/*
126 * General purpose IO registers (in MBAR2).
127 */
128#define MCFSIM2_GPIOREAD (MCF_MBAR2 + 0x000) /* GPIO read values */
129#define MCFSIM2_GPIOWRITE (MCF_MBAR2 + 0x004) /* GPIO write values */
130#define MCFSIM2_GPIOENABLE (MCF_MBAR2 + 0x008) /* GPIO enabled */
131#define MCFSIM2_GPIOFUNC (MCF_MBAR2 + 0x00C) /* GPIO function */
132#define MCFSIM2_GPIO1READ (MCF_MBAR2 + 0x0B0) /* GPIO1 read values */
133#define MCFSIM2_GPIO1WRITE (MCF_MBAR2 + 0x0B4) /* GPIO1 write values */
134#define MCFSIM2_GPIO1ENABLE (MCF_MBAR2 + 0x0B8) /* GPIO1 enabled */
135#define MCFSIM2_GPIO1FUNC (MCF_MBAR2 + 0x0BC) /* GPIO1 function */
136
137#define MCFSIM2_GPIOINTSTAT (MCF_MBAR2 + 0xc0) /* GPIO intr status */
138#define MCFSIM2_GPIOINTCLEAR (MCF_MBAR2 + 0xc0) /* GPIO intr clear */
139#define MCFSIM2_GPIOINTENABLE (MCF_MBAR2 + 0xc4) /* GPIO intr enable */
140
141#define MCFSIM2_INTLEVEL1 (MCF_MBAR2 + 0x140) /* Intr level reg 1 */
142#define MCFSIM2_INTLEVEL2 (MCF_MBAR2 + 0x144) /* Intr level reg 2 */
143#define MCFSIM2_INTLEVEL3 (MCF_MBAR2 + 0x148) /* Intr level reg 3 */
144#define MCFSIM2_INTLEVEL4 (MCF_MBAR2 + 0x14c) /* Intr level reg 4 */
145#define MCFSIM2_INTLEVEL5 (MCF_MBAR2 + 0x150) /* Intr level reg 5 */
146#define MCFSIM2_INTLEVEL6 (MCF_MBAR2 + 0x154) /* Intr level reg 6 */
147#define MCFSIM2_INTLEVEL7 (MCF_MBAR2 + 0x158) /* Intr level reg 7 */
148#define MCFSIM2_INTLEVEL8 (MCF_MBAR2 + 0x15c) /* Intr level reg 8 */
149
150#define MCFSIM2_DMAROUTE (MCF_MBAR2 + 0x188) /* DMA routing */
151
152#define MCFSIM2_IDECONFIG1 (MCF_MBAR2 + 0x18c) /* IDEconfig1 */
153#define MCFSIM2_IDECONFIG2 (MCF_MBAR2 + 0x190) /* IDEconfig2 */
154
155/*
156 * Define the base interrupt for the second interrupt controller.
157 * We set it to 128, out of the way of the base interrupts, and plenty
158 * of room for its 64 interrupts.
159 */
160#define MCFINTC2_VECBASE 128
161
162#define MCFINTC2_GPIOIRQ0 (MCFINTC2_VECBASE + 32)
163#define MCFINTC2_GPIOIRQ1 (MCFINTC2_VECBASE + 33)
164#define MCFINTC2_GPIOIRQ2 (MCFINTC2_VECBASE + 34)
165#define MCFINTC2_GPIOIRQ3 (MCFINTC2_VECBASE + 35)
166#define MCFINTC2_GPIOIRQ4 (MCFINTC2_VECBASE + 36)
167#define MCFINTC2_GPIOIRQ5 (MCFINTC2_VECBASE + 37)
168#define MCFINTC2_GPIOIRQ6 (MCFINTC2_VECBASE + 38)
169#define MCFINTC2_GPIOIRQ7 (MCFINTC2_VECBASE + 39)
170
171/*
172 * Generic GPIO support
173 */
174#define MCFGPIO_PIN_MAX 64
175#define MCFGPIO_IRQ_MAX -1
176#define MCFGPIO_IRQ_VECBASE -1
177
178/****************************************************************************/
179
180#ifdef __ASSEMBLER__
181
182/*
183 * The M5249C3 board needs a little help getting all its SIM devices
184 * initialized at kernel start time. dBUG doesn't set much up, so
185 * we need to do it manually.
186 */
187.macro m5249c3_setup
188 /*
189 * Set MBAR1 and MBAR2, just incase they are not set.
190 */
191 movel #0x10000001,%a0
192 movec %a0,%MBAR /* map MBAR region */
193 subql #1,%a0 /* get MBAR address in a0 */
194
195 movel #0x80000001,%a1
196 movec %a1,#3086 /* map MBAR2 region */
197 subql #1,%a1 /* get MBAR2 address in a1 */
198
199 /*
200 * Move secondary interrupts to their base (128).
201 */
202 moveb #MCFINTC2_VECBASE,%d0
203 moveb %d0,0x16b(%a1) /* interrupt base register */
204
205 /*
206 * Work around broken CSMR0/DRAM vector problem.
207 */
208 movel #0x001F0021,%d0 /* disable C/I bit */
209 movel %d0,0x84(%a0) /* set CSMR0 */
210
211 /*
212 * Disable the PLL firstly. (Who knows what state it is
213 * in here!).
214 */
215 movel 0x180(%a1),%d0 /* get current PLL value */
216 andl #0xfffffffe,%d0 /* PLL bypass first */
217 movel %d0,0x180(%a1) /* set PLL register */
218 nop
219
220#if CONFIG_CLOCK_FREQ == 140000000
221 /*
222 * Set initial clock frequency. This assumes M5249C3 board
223 * is fitted with 11.2896MHz crystal. It will program the
224 * PLL for 140MHz. Lets go fast :-)
225 */
226 movel #0x125a40f0,%d0 /* set for 140MHz */
227 movel %d0,0x180(%a1) /* set PLL register */
228 orl #0x1,%d0
229 movel %d0,0x180(%a1) /* set PLL register */
230#endif
231
232 /*
233 * Setup CS1 for ethernet controller.
234 * (Setup as per M5249C3 doco).
235 */
236 movel #0xe0000000,%d0 /* CS1 mapped at 0xe0000000 */
237 movel %d0,0x8c(%a0)
238 movel #0x001f0021,%d0 /* CS1 size of 1Mb */
239 movel %d0,0x90(%a0)
240 movew #0x0080,%d0 /* CS1 = 16bit port, AA */
241 movew %d0,0x96(%a0)
242
243 /*
244 * Setup CS2 for IDE interface.
245 */
246 movel #0x50000000,%d0 /* CS2 mapped at 0x50000000 */
247 movel %d0,0x98(%a0)
248 movel #0x001f0001,%d0 /* CS2 size of 1MB */
249 movel %d0,0x9c(%a0)
250 movew #0x0080,%d0 /* CS2 = 16bit, TA */
251 movew %d0,0xa2(%a0)
252
253 movel #0x00107000,%d0 /* IDEconfig1 */
254 movel %d0,0x18c(%a1)
255 movel #0x000c0400,%d0 /* IDEconfig2 */
256 movel %d0,0x190(%a1)
257
258 movel #0x00080000,%d0 /* GPIO19, IDE reset bit */
259 orl %d0,0xc(%a1) /* function GPIO19 */
260 orl %d0,0x8(%a1) /* enable GPIO19 as output */
261 orl %d0,0x4(%a1) /* de-assert IDE reset */
262.endm
263
264#define PLATFORM_SETUP m5249c3_setup
265
266#endif /* __ASSEMBLER__ */
267
268/****************************************************************************/
269#endif /* m5249sim_h */
diff --git a/arch/m68k/include/asm/m525xsim.h b/arch/m68k/include/asm/m525xsim.h
index acab61cb91ed..e33f5bb6aca8 100644
--- a/arch/m68k/include/asm/m525xsim.h
+++ b/arch/m68k/include/asm/m525xsim.h
@@ -12,6 +12,11 @@
12#define m525xsim_h 12#define m525xsim_h
13/****************************************************************************/ 13/****************************************************************************/
14 14
15/*
16 * This header supports ColdFire 5249, 5251 and 5253. There are a few
17 * little differences between them, but most of the peripheral support
18 * can be used by all of them.
19 */
15#define CPU_NAME "COLDFIRE(m525x)" 20#define CPU_NAME "COLDFIRE(m525x)"
16#define CPU_INSTR_PER_JIFFY 3 21#define CPU_INSTR_PER_JIFFY 3
17#define MCF_BUSCLK (MCF_CLK / 2) 22#define MCF_BUSCLK (MCF_CLK / 2)
@@ -65,6 +70,8 @@
65#define MCFSIM_DCR (MCF_MBAR + 0x100) /* DRAM Control */ 70#define MCFSIM_DCR (MCF_MBAR + 0x100) /* DRAM Control */
66#define MCFSIM_DACR0 (MCF_MBAR + 0x108) /* DRAM 0 Addr/Ctrl */ 71#define MCFSIM_DACR0 (MCF_MBAR + 0x108) /* DRAM 0 Addr/Ctrl */
67#define MCFSIM_DMR0 (MCF_MBAR + 0x10c) /* DRAM 0 Mask */ 72#define MCFSIM_DMR0 (MCF_MBAR + 0x10c) /* DRAM 0 Mask */
73#define MCFSIM_DACR1 (MCF_MBAR + 0x110) /* DRAM 1 Addr/Ctrl */
74#define MCFSIM_DMR1 (MCF_MBAR + 0x114) /* DRAM 1 Mask */
68 75
69/* 76/*
70 * Secondary Interrupt Controller (in MBAR2) 77 * Secondary Interrupt Controller (in MBAR2)
@@ -101,11 +108,17 @@
101#define MCFQSPI_BASE (MCF_MBAR + 0x300) /* Base address QSPI */ 108#define MCFQSPI_BASE (MCF_MBAR + 0x300) /* Base address QSPI */
102#define MCFQSPI_SIZE 0x40 /* Register set size */ 109#define MCFQSPI_SIZE 0x40 /* Register set size */
103 110
104 111#ifdef CONFIG_M5249
112#define MCFQSPI_CS0 29
113#define MCFQSPI_CS1 24
114#define MCFQSPI_CS2 21
115#define MCFQSPI_CS3 22
116#else
105#define MCFQSPI_CS0 15 117#define MCFQSPI_CS0 15
106#define MCFQSPI_CS1 16 118#define MCFQSPI_CS1 16
107#define MCFQSPI_CS2 24 119#define MCFQSPI_CS2 24
108#define MCFQSPI_CS3 28 120#define MCFQSPI_CS3 28
121#endif
109 122
110/* 123/*
111 * I2C module. 124 * I2C module.
@@ -115,6 +128,7 @@
115 128
116#define MCFI2C_BASE1 (MCF_MBAR2 + 0x440) /* Base addreess I2C1 */ 129#define MCFI2C_BASE1 (MCF_MBAR2 + 0x440) /* Base addreess I2C1 */
117#define MCFI2C_SIZE1 0x20 /* Register set size */ 130#define MCFI2C_SIZE1 0x20 /* Register set size */
131
118/* 132/*
119 * DMA unit base addresses. 133 * DMA unit base addresses.
120 */ 134 */
@@ -163,6 +177,7 @@
163#define MCF_IRQ_GPIO4 (MCFINTC2_VECBASE + 36) 177#define MCF_IRQ_GPIO4 (MCFINTC2_VECBASE + 36)
164#define MCF_IRQ_GPIO5 (MCFINTC2_VECBASE + 37) 178#define MCF_IRQ_GPIO5 (MCFINTC2_VECBASE + 37)
165#define MCF_IRQ_GPIO6 (MCFINTC2_VECBASE + 38) 179#define MCF_IRQ_GPIO6 (MCFINTC2_VECBASE + 38)
180#define MCF_IRQ_GPIO7 (MCFINTC2_VECBASE + 39)
166 181
167#define MCF_IRQ_USBWUP (MCFINTC2_VECBASE + 40) 182#define MCF_IRQ_USBWUP (MCFINTC2_VECBASE + 40)
168#define MCF_IRQ_I2C1 (MCFINTC2_VECBASE + 62) 183#define MCF_IRQ_I2C1 (MCFINTC2_VECBASE + 62)
@@ -183,12 +198,111 @@
183#define MCFSIM2_GPIOINTCLEAR (MCF_MBAR2 + 0xc0) /* GPIO intr clear */ 198#define MCFSIM2_GPIOINTCLEAR (MCF_MBAR2 + 0xc0) /* GPIO intr clear */
184#define MCFSIM2_GPIOINTENABLE (MCF_MBAR2 + 0xc4) /* GPIO intr enable */ 199#define MCFSIM2_GPIOINTENABLE (MCF_MBAR2 + 0xc4) /* GPIO intr enable */
185 200
201#define MCFSIM2_DMAROUTE (MCF_MBAR2 + 0x188) /* DMA routing */
202#define MCFSIM2_IDECONFIG1 (MCF_MBAR2 + 0x18c) /* IDEconfig1 */
203#define MCFSIM2_IDECONFIG2 (MCF_MBAR2 + 0x190) /* IDEconfig2 */
204
186/* 205/*
187 * Generic GPIO support 206 * Generic GPIO support
188 */ 207 */
189#define MCFGPIO_PIN_MAX 64 208#define MCFGPIO_PIN_MAX 64
209#ifdef CONFIG_M5249
210#define MCFGPIO_IRQ_MAX -1
211#define MCFGPIO_IRQ_VECBASE -1
212#else
190#define MCFGPIO_IRQ_MAX 7 213#define MCFGPIO_IRQ_MAX 7
191#define MCFGPIO_IRQ_VECBASE MCF_IRQ_GPIO0 214#define MCFGPIO_IRQ_VECBASE MCF_IRQ_GPIO0
215#endif
216
217/****************************************************************************/
218
219#ifdef __ASSEMBLER__
220#ifdef CONFIG_M5249C3
221/*
222 * The M5249C3 board needs a little help getting all its SIM devices
223 * initialized at kernel start time. dBUG doesn't set much up, so
224 * we need to do it manually.
225 */
226.macro m5249c3_setup
227 /*
228 * Set MBAR1 and MBAR2, just incase they are not set.
229 */
230 movel #0x10000001,%a0
231 movec %a0,%MBAR /* map MBAR region */
232 subql #1,%a0 /* get MBAR address in a0 */
233
234 movel #0x80000001,%a1
235 movec %a1,#3086 /* map MBAR2 region */
236 subql #1,%a1 /* get MBAR2 address in a1 */
237
238 /*
239 * Move secondary interrupts to their base (128).
240 */
241 moveb #MCFINTC2_VECBASE,%d0
242 moveb %d0,0x16b(%a1) /* interrupt base register */
243
244 /*
245 * Work around broken CSMR0/DRAM vector problem.
246 */
247 movel #0x001F0021,%d0 /* disable C/I bit */
248 movel %d0,0x84(%a0) /* set CSMR0 */
249
250 /*
251 * Disable the PLL firstly. (Who knows what state it is
252 * in here!).
253 */
254 movel 0x180(%a1),%d0 /* get current PLL value */
255 andl #0xfffffffe,%d0 /* PLL bypass first */
256 movel %d0,0x180(%a1) /* set PLL register */
257 nop
258
259#if CONFIG_CLOCK_FREQ == 140000000
260 /*
261 * Set initial clock frequency. This assumes M5249C3 board
262 * is fitted with 11.2896MHz crystal. It will program the
263 * PLL for 140MHz. Lets go fast :-)
264 */
265 movel #0x125a40f0,%d0 /* set for 140MHz */
266 movel %d0,0x180(%a1) /* set PLL register */
267 orl #0x1,%d0
268 movel %d0,0x180(%a1) /* set PLL register */
269#endif
270
271 /*
272 * Setup CS1 for ethernet controller.
273 * (Setup as per M5249C3 doco).
274 */
275 movel #0xe0000000,%d0 /* CS1 mapped at 0xe0000000 */
276 movel %d0,0x8c(%a0)
277 movel #0x001f0021,%d0 /* CS1 size of 1Mb */
278 movel %d0,0x90(%a0)
279 movew #0x0080,%d0 /* CS1 = 16bit port, AA */
280 movew %d0,0x96(%a0)
281
282 /*
283 * Setup CS2 for IDE interface.
284 */
285 movel #0x50000000,%d0 /* CS2 mapped at 0x50000000 */
286 movel %d0,0x98(%a0)
287 movel #0x001f0001,%d0 /* CS2 size of 1MB */
288 movel %d0,0x9c(%a0)
289 movew #0x0080,%d0 /* CS2 = 16bit, TA */
290 movew %d0,0xa2(%a0)
291
292 movel #0x00107000,%d0 /* IDEconfig1 */
293 movel %d0,0x18c(%a1)
294 movel #0x000c0400,%d0 /* IDEconfig2 */
295 movel %d0,0x190(%a1)
296
297 movel #0x00080000,%d0 /* GPIO19, IDE reset bit */
298 orl %d0,0xc(%a1) /* function GPIO19 */
299 orl %d0,0x8(%a1) /* enable GPIO19 as output */
300 orl %d0,0x4(%a1) /* de-assert IDE reset */
301.endm
302
303#define PLATFORM_SETUP m5249c3_setup
192 304
305#endif /* CONFIG_M5249C3 */
306#endif /* __ASSEMBLER__ */
193/****************************************************************************/ 307/****************************************************************************/
194#endif /* m525xsim_h */ 308#endif /* m525xsim_h */
diff --git a/arch/m68k/include/asm/mcfclk.h b/arch/m68k/include/asm/mcfclk.h
index b676a02bb392..ea4791e3a557 100644
--- a/arch/m68k/include/asm/mcfclk.h
+++ b/arch/m68k/include/asm/mcfclk.h
@@ -8,7 +8,6 @@
8 8
9struct clk; 9struct clk;
10 10
11#ifdef MCFPM_PPMCR0
12struct clk_ops { 11struct clk_ops {
13 void (*enable)(struct clk *); 12 void (*enable)(struct clk *);
14 void (*disable)(struct clk *); 13 void (*disable)(struct clk *);
@@ -23,6 +22,8 @@ struct clk {
23}; 22};
24 23
25extern struct clk *mcf_clks[]; 24extern struct clk *mcf_clks[];
25
26#ifdef MCFPM_PPMCR0
26extern struct clk_ops clk_ops0; 27extern struct clk_ops clk_ops0;
27#ifdef MCFPM_PPMCR1 28#ifdef MCFPM_PPMCR1
28extern struct clk_ops clk_ops1; 29extern struct clk_ops clk_ops1;
@@ -38,6 +39,12 @@ static struct clk __clk_##clk_bank##_##clk_slot = { \
38 39
39void __clk_init_enabled(struct clk *); 40void __clk_init_enabled(struct clk *);
40void __clk_init_disabled(struct clk *); 41void __clk_init_disabled(struct clk *);
42#else
43#define DEFINE_CLK(clk_ref, clk_name, clk_rate) \
44 static struct clk clk_##clk_ref = { \
45 .name = clk_name, \
46 .rate = clk_rate, \
47 }
41#endif /* MCFPM_PPMCR0 */ 48#endif /* MCFPM_PPMCR0 */
42 49
43#endif /* mcfclk_h */ 50#endif /* mcfclk_h */
diff --git a/arch/m68k/include/asm/mcfsim.h b/arch/m68k/include/asm/mcfsim.h
index 7a83e619e73b..a04fd9b2714c 100644
--- a/arch/m68k/include/asm/mcfsim.h
+++ b/arch/m68k/include/asm/mcfsim.h
@@ -24,10 +24,7 @@
24#elif defined(CONFIG_M523x) 24#elif defined(CONFIG_M523x)
25#include <asm/m523xsim.h> 25#include <asm/m523xsim.h>
26#include <asm/mcfintc.h> 26#include <asm/mcfintc.h>
27#elif defined(CONFIG_M5249) 27#elif defined(CONFIG_M5249) || defined(CONFIG_M525x)
28#include <asm/m5249sim.h>
29#include <asm/mcfintc.h>
30#elif defined(CONFIG_M525x)
31#include <asm/m525xsim.h> 28#include <asm/m525xsim.h>
32#include <asm/mcfintc.h> 29#include <asm/mcfintc.h>
33#elif defined(CONFIG_M527x) 30#elif defined(CONFIG_M527x)
diff --git a/arch/m68k/include/asm/page_no.h b/arch/m68k/include/asm/page_no.h
index 90595721185f..ef209169579a 100644
--- a/arch/m68k/include/asm/page_no.h
+++ b/arch/m68k/include/asm/page_no.h
@@ -26,7 +26,7 @@ extern unsigned long memory_end;
26#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT) 26#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
27 27
28#define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)) 28#define virt_to_page(addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT))
29#define page_to_virt(page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET) 29#define page_to_virt(page) __va(((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET))
30 30
31#define pfn_to_page(pfn) virt_to_page(pfn_to_virt(pfn)) 31#define pfn_to_page(pfn) virt_to_page(pfn_to_virt(pfn))
32#define page_to_pfn(page) virt_to_pfn(page_to_virt(page)) 32#define page_to_pfn(page) virt_to_pfn(page_to_virt(page))
diff --git a/arch/m68k/lib/memcpy.c b/arch/m68k/lib/memcpy.c
index 10ca051d56b8..c1e2dfb206f3 100644
--- a/arch/m68k/lib/memcpy.c
+++ b/arch/m68k/lib/memcpy.c
@@ -10,7 +10,7 @@
10void *memcpy(void *to, const void *from, size_t n) 10void *memcpy(void *to, const void *from, size_t n)
11{ 11{
12 void *xto = to; 12 void *xto = to;
13 size_t temp, temp1; 13 size_t temp;
14 14
15 if (!n) 15 if (!n)
16 return xto; 16 return xto;
@@ -47,6 +47,7 @@ void *memcpy(void *to, const void *from, size_t n)
47 for (; temp; temp--) 47 for (; temp; temp--)
48 *lto++ = *lfrom++; 48 *lto++ = *lfrom++;
49#else 49#else
50 size_t temp1;
50 asm volatile ( 51 asm volatile (
51 " movel %2,%3\n" 52 " movel %2,%3\n"
52 " andw #7,%3\n" 53 " andw #7,%3\n"
diff --git a/arch/m68k/platform/68000/Makefile b/arch/m68k/platform/68000/Makefile
new file mode 100644
index 000000000000..1eab70c7194b
--- /dev/null
+++ b/arch/m68k/platform/68000/Makefile
@@ -0,0 +1,18 @@
1##################################################
2#
3# Makefile for 68000 core based cpus
4#
5# 2012.10.21, Luis Alves <ljalvs@gmail.com>
6# Merged all 68000 based cpu's config
7# files into a single directory.
8#
9
10# 68328, 68EZ328, 68VZ328
11
12obj-y += entry.o ints.o timers.o
13obj-$(CONFIG_M68328) += m68328.o
14obj-$(CONFIG_M68EZ328) += m68EZ328.o
15obj-$(CONFIG_M68VZ328) += m68VZ328.o
16obj-$(CONFIG_ROM) += romvec.o
17
18extra-y := head.o
diff --git a/arch/m68k/platform/68VZ328/bootlogo.h b/arch/m68k/platform/68000/bootlogo-vz.h
index b38e2b255142..b38e2b255142 100644
--- a/arch/m68k/platform/68VZ328/bootlogo.h
+++ b/arch/m68k/platform/68000/bootlogo-vz.h
diff --git a/arch/m68k/platform/68328/bootlogo.h b/arch/m68k/platform/68000/bootlogo.h
index b896c933fafc..b896c933fafc 100644
--- a/arch/m68k/platform/68328/bootlogo.h
+++ b/arch/m68k/platform/68000/bootlogo.h
diff --git a/arch/m68k/platform/68328/entry.S b/arch/m68k/platform/68000/entry.S
index 7f91c2fde509..7f91c2fde509 100644
--- a/arch/m68k/platform/68328/entry.S
+++ b/arch/m68k/platform/68000/entry.S
diff --git a/arch/m68k/platform/68000/head.S b/arch/m68k/platform/68000/head.S
new file mode 100644
index 000000000000..536ef9616dad
--- /dev/null
+++ b/arch/m68k/platform/68000/head.S
@@ -0,0 +1,240 @@
1/*
2 * head.S - Common startup code for 68000 core based CPU's
3 *
4 * 2012.10.21, Luis Alves <ljalvs@gmail.com>, Single head.S file for all
5 * 68000 core based CPU's. Based on the sources from:
6 * Coldfire by Greg Ungerer <gerg@snapgear.com>
7 * 68328 by D. Jeff Dionne <jeff@ryeham.ee.ryerson.ca>,
8 * Kenneth Albanowski <kjahds@kjahds.com>,
9 * The Silver Hammer Group, Ltd.
10 *
11 */
12
13#include <linux/linkage.h>
14#include <linux/init.h>
15#include <asm/asm-offsets.h>
16#include <asm/thread_info.h>
17
18
19/*****************************************************************************
20 * UCSIMM and UCDIMM use CONFIG_MEMORY_RESERVE to reserve some RAM
21 *****************************************************************************/
22#ifdef CONFIG_MEMORY_RESERVE
23#define RAMEND (CONFIG_RAMBASE+CONFIG_RAMSIZE)-(CONFIG_MEMORY_RESERVE*0x100000)
24#else
25#define RAMEND (CONFIG_RAMBASE+CONFIG_RAMSIZE)
26#endif
27/*****************************************************************************/
28
29.global _start
30.global _rambase
31.global _ramvec
32.global _ramstart
33.global _ramend
34
35#if defined(CONFIG_PILOT) || defined(CONFIG_INIT_LCD)
36.global bootlogo_bits
37#endif
38
39/* Defining DEBUG_HEAD_CODE, serial port in 68x328 is inited */
40/* #define DEBUG_HEAD_CODE */
41#undef DEBUG_HEAD_CODE
42
43.data
44
45/*****************************************************************************
46 * RAM setup pointers. Used by the kernel to determine RAM location and size.
47 *****************************************************************************/
48
49_rambase:
50 .long 0
51_ramvec:
52 .long 0
53_ramstart:
54 .long 0
55_ramend:
56 .long 0
57
58__HEAD
59
60/*****************************************************************************
61 * Entry point, where all begins!
62 *****************************************************************************/
63
64_start:
65
66/* Pilot need this specific signature at the start of ROM */
67#ifdef CONFIG_PILOT
68 .byte 0x4e, 0xfa, 0x00, 0x0a /* bra opcode (jmp 10 bytes) */
69 .byte 'b', 'o', 'o', 't'
70 .word 10000
71 nop
72 moveq #0, %d0
73 movew %d0, 0xfffff618 /* Watchdog off */
74 movel #0x00011f07, 0xfffff114 /* CS A1 Mask */
75#endif /* CONFIG_PILOT */
76
77 movew #0x2700, %sr /* disable all interrupts */
78
79/*****************************************************************************
80 * Setup PLL and wait for it to settle (in 68x328 cpu's).
81 * Also, if enabled, init serial port.
82 *****************************************************************************/
83#if defined(CONFIG_M68328) || \
84 defined(CONFIG_M68EZ328) || \
85 defined(CONFIG_M68VZ328)
86
87/* Serial port setup. Should only be needed if debugging this startup code. */
88#ifdef DEBUG_HEAD_CODE
89 movew #0x0800, 0xfffff906 /* Ignore CTS */
90 movew #0x010b, 0xfffff902 /* BAUD to 9600 */
91 movew #0xe100, 0xfffff900 /* enable */
92#endif /* DEBUG_HEAD */
93
94#ifdef CONFIG_PILOT
95 movew #0x2410, 0xfffff200 /* PLLCR */
96#else
97 movew #0x2400, 0xfffff200 /* PLLCR */
98#endif
99 movew #0x0123, 0xfffff202 /* PLLFSR */
100 moveq #0, %d0
101 movew #16384, %d0 /* PLL settle wait loop */
102_pll_settle:
103 subw #1, %d0
104 bne _pll_settle
105#endif /* CONFIG_M68x328 */
106
107
108/*****************************************************************************
109 * If running kernel from ROM some specific initialization has to be done.
110 * (Assuming that everything is already init'ed when running from RAM)
111 *****************************************************************************/
112#ifdef CONFIG_ROMKERNEL
113
114/*****************************************************************************
115 * Init chip registers (uCsimm specific)
116 *****************************************************************************/
117#ifdef CONFIG_UCSIMM
118 moveb #0x00, 0xfffffb0b /* Watchdog off */
119 moveb #0x10, 0xfffff000 /* SCR */
120 moveb #0x00, 0xfffff40b /* enable chip select */
121 moveb #0x00, 0xfffff423 /* enable /DWE */
122 moveb #0x08, 0xfffffd0d /* disable hardmap */
123 moveb #0x07, 0xfffffd0e /* level 7 interrupt clear */
124 movew #0x8600, 0xfffff100 /* FLASH at 0x10c00000 */
125 movew #0x018b, 0xfffff110 /* 2Meg, enable, 0ws */
126 movew #0x8f00, 0xfffffc00 /* DRAM configuration */
127 movew #0x9667, 0xfffffc02 /* DRAM control */
128 movew #0x0000, 0xfffff106 /* DRAM at 0x00000000 */
129 movew #0x068f, 0xfffff116 /* 8Meg, enable, 0ws */
130 moveb #0x40, 0xfffff300 /* IVR */
131 movel #0x007FFFFF, %d0 /* IMR */
132 movel %d0, 0xfffff304
133 moveb 0xfffff42b, %d0
134 andb #0xe0, %d0
135 moveb %d0, 0xfffff42b
136#endif
137
138/*****************************************************************************
139 * Init LCD controller.
140 * (Assuming that LCD controller is already init'ed when running from RAM)
141 *****************************************************************************/
142#ifdef CONFIG_INIT_LCD
143#ifdef CONFIG_PILOT
144 moveb #0, 0xfffffA27 /* LCKCON */
145 movel #_start, 0xfffffA00 /* LSSA */
146 moveb #0xa, 0xfffffA05 /* LVPW */
147 movew #0x9f, 0xFFFFFa08 /* LXMAX */
148 movew #0x9f, 0xFFFFFa0a /* LYMAX */
149 moveb #9, 0xfffffa29 /* LBAR */
150 moveb #0, 0xfffffa25 /* LPXCD */
151 moveb #0x04, 0xFFFFFa20 /* LPICF */
152 moveb #0x58, 0xfffffA27 /* LCKCON */
153 moveb #0x85, 0xfffff429 /* PFDATA */
154 moveb #0xd8, 0xfffffA27 /* LCKCON */
155 moveb #0xc5, 0xfffff429 /* PFDATA */
156 moveb #0xd5, 0xfffff429 /* PFDATA */
157 movel #bootlogo_bits, 0xFFFFFA00 /* LSSA */
158 moveb #10, 0xFFFFFA05 /* LVPW */
159 movew #160, 0xFFFFFA08 /* LXMAX */
160 movew #160, 0xFFFFFA0A /* LYMAX */
161#else /* CONFIG_PILOT */
162 movel #bootlogo_bits, 0xfffffA00 /* LSSA */
163 moveb #0x28, 0xfffffA05 /* LVPW */
164 movew #0x280, 0xFFFFFa08 /* LXMAX */
165 movew #0x1df, 0xFFFFFa0a /* LYMAX */
166 moveb #0, 0xfffffa29 /* LBAR */
167 moveb #0, 0xfffffa25 /* LPXCD */
168 moveb #0x08, 0xFFFFFa20 /* LPICF */
169 moveb #0x01, 0xFFFFFA21 /* -ve pol */
170 moveb #0x81, 0xfffffA27 /* LCKCON */
171 movew #0xff00, 0xfffff412 /* LCD pins */
172#endif /* CONFIG_PILOT */
173#endif /* CONFIG_INIT_LCD */
174
175/*****************************************************************************
176 * Kernel is running from FLASH/ROM (XIP)
177 * Copy init text & data to RAM
178 *****************************************************************************/
179 moveal #_etext, %a0
180 moveal #_sdata, %a1
181 moveal #__bss_start, %a2
182_copy_initmem:
183 movel %a0@+, %a1@+
184 cmpal %a1, %a2
185 bhi _copy_initmem
186#endif /* CONFIG_ROMKERNEL */
187
188/*****************************************************************************
189 * Setup basic memory information for kernel
190 *****************************************************************************/
191 movel #CONFIG_VECTORBASE,_ramvec /* set vector base location */
192 movel #CONFIG_RAMBASE,_rambase /* set the base of RAM */
193 movel #RAMEND, _ramend /* set end ram addr */
194 lea __bss_stop,%a1
195 movel %a1,_ramstart
196
197/*****************************************************************************
198 * If the kernel is in RAM, move romfs to right above bss and
199 * adjust _ramstart to where romfs ends.
200 *
201 * (Do this only if CONFIG_MTD_UCLINUX is true)
202 *****************************************************************************/
203
204#if defined(CONFIG_ROMFS_FS) && defined(CONFIG_RAMKERNEL) && \
205 defined(CONFIG_MTD_UCLINUX)
206 lea __bss_start, %a0 /* get start of bss */
207 lea __bss_stop, %a1 /* set up destination */
208 movel %a0, %a2 /* copy of bss start */
209
210 movel 8(%a0), %d0 /* get size of ROMFS */
211 addql #8, %d0 /* allow for rounding */
212 andl #0xfffffffc, %d0 /* whole words */
213
214 addl %d0, %a0 /* copy from end */
215 addl %d0, %a1 /* copy from end */
216 movel %a1, _ramstart /* set start of ram */
217_copy_romfs:
218 movel -(%a0), -(%a1) /* copy dword */
219 cmpl %a0, %a2 /* check if at end */
220 bne _copy_romfs
221#endif /* CONFIG_ROMFS_FS && CONFIG_RAMKERNEL && CONFIG_MTD_UCLINUX */
222
223/*****************************************************************************
224 * Clear bss region
225 *****************************************************************************/
226 lea __bss_start, %a0 /* get start of bss */
227 lea __bss_stop, %a1 /* get end of bss */
228_clear_bss:
229 movel #0, (%a0)+ /* clear each word */
230 cmpl %a0, %a1 /* check if at end */
231 bne _clear_bss
232
233/*****************************************************************************
234 * Load the current task pointer and stack.
235 *****************************************************************************/
236 lea init_thread_union,%a0
237 lea THREAD_SIZE(%a0),%sp
238 jsr start_kernel /* start Linux kernel */
239_exit:
240 jmp _exit /* should never get here */
diff --git a/arch/m68k/platform/68328/ints.c b/arch/m68k/platform/68000/ints.c
index b3810febb3e3..cda49b12d7be 100644
--- a/arch/m68k/platform/68328/ints.c
+++ b/arch/m68k/platform/68000/ints.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/arch/m68knommu/platform/68328/ints.c 2 * ints.c - Generic interrupt controller support
3 * 3 *
4 * This file is subject to the terms and conditions of the GNU General Public 4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file COPYING in the main directory of this archive 5 * License. See the file COPYING in the main directory of this archive
diff --git a/arch/m68k/platform/68328/config.c b/arch/m68k/platform/68000/m68328.c
index 8c20e891e981..a86eb66835aa 100644
--- a/arch/m68k/platform/68328/config.c
+++ b/arch/m68k/platform/68000/m68328.c
@@ -1,7 +1,7 @@
1/***************************************************************************/ 1/***************************************************************************/
2 2
3/* 3/*
4 * linux/arch/m68knommu/platform/68328/config.c 4 * m68328.c - 68328 specific config
5 * 5 *
6 * Copyright (C) 1993 Hamish Macdonald 6 * Copyright (C) 1993 Hamish Macdonald
7 * Copyright (C) 1999 D. Jeff Dionne 7 * Copyright (C) 1999 D. Jeff Dionne
diff --git a/arch/m68k/platform/68EZ328/config.c b/arch/m68k/platform/68000/m68EZ328.c
index 4f158d551f02..a6eb72d75008 100644
--- a/arch/m68k/platform/68EZ328/config.c
+++ b/arch/m68k/platform/68000/m68EZ328.c
@@ -1,7 +1,7 @@
1/***************************************************************************/ 1/***************************************************************************/
2 2
3/* 3/*
4 * linux/arch/m68knommu/platform/68EZ328/config.c 4 * m68EZ328.c - 68EZ328 specific config
5 * 5 *
6 * Copyright (C) 1993 Hamish Macdonald 6 * Copyright (C) 1993 Hamish Macdonald
7 * Copyright (C) 1999 D. Jeff Dionne 7 * Copyright (C) 1999 D. Jeff Dionne
diff --git a/arch/m68k/platform/68VZ328/config.c b/arch/m68k/platform/68000/m68VZ328.c
index 2ed8dc305e42..eb6964fbec09 100644
--- a/arch/m68k/platform/68VZ328/config.c
+++ b/arch/m68k/platform/68000/m68VZ328.c
@@ -1,7 +1,7 @@
1/***************************************************************************/ 1/***************************************************************************/
2 2
3/* 3/*
4 * linux/arch/m68knommu/platform/68VZ328/config.c 4 * m68VZ328.c - 68VZ328 specific config
5 * 5 *
6 * Copyright (C) 1993 Hamish Macdonald 6 * Copyright (C) 1993 Hamish Macdonald
7 * Copyright (C) 1999 D. Jeff Dionne 7 * Copyright (C) 1999 D. Jeff Dionne
@@ -28,7 +28,7 @@
28#include <asm/bootstd.h> 28#include <asm/bootstd.h>
29 29
30#ifdef CONFIG_INIT_LCD 30#ifdef CONFIG_INIT_LCD
31#include "bootlogo.h" 31#include "bootlogo-vz.h"
32#endif 32#endif
33 33
34/***************************************************************************/ 34/***************************************************************************/
diff --git a/arch/m68k/platform/68328/romvec.S b/arch/m68k/platform/68000/romvec.S
index 31084466eae8..15c70cd6453f 100644
--- a/arch/m68k/platform/68328/romvec.S
+++ b/arch/m68k/platform/68000/romvec.S
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/arch/m68knommu/platform/68328/romvec.S 2 * romvec.S - Vector table for 68000 cpus
3 * 3 *
4 * This file is subject to the terms and conditions of the GNU General Public 4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file COPYING in the main directory of this archive 5 * License. See the file COPYING in the main directory of this archive
diff --git a/arch/m68k/platform/68328/timers.c b/arch/m68k/platform/68000/timers.c
index f4dc9b295609..ec30acbfe6db 100644
--- a/arch/m68k/platform/68328/timers.c
+++ b/arch/m68k/platform/68000/timers.c
@@ -1,7 +1,7 @@
1/***************************************************************************/ 1/***************************************************************************/
2 2
3/* 3/*
4 * linux/arch/m68knommu/platform/68328/timers.c 4 * timers.c - Generic hardware timer support.
5 * 5 *
6 * Copyright (C) 1993 Hamish Macdonald 6 * Copyright (C) 1993 Hamish Macdonald
7 * Copyright (C) 1999 D. Jeff Dionne 7 * Copyright (C) 1999 D. Jeff Dionne
diff --git a/arch/m68k/platform/68328/Makefile b/arch/m68k/platform/68328/Makefile
deleted file mode 100644
index ee61bf84d4a0..000000000000
--- a/arch/m68k/platform/68328/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
1#
2# Makefile for arch/m68knommu/platform/68328.
3#
4
5model-y := ram
6model-$(CONFIG_ROMKERNEL) := rom
7
8head-y = head-$(model-y).o
9head-$(CONFIG_PILOT) = head-pilot.o
10head-$(CONFIG_DRAGEN2) = head-de2.o
11
12obj-y += entry.o ints.o timers.o
13obj-$(CONFIG_M68328) += config.o
14obj-$(CONFIG_ROM) += romvec.o
15
16extra-y := head.o
17
18$(obj)/head.o: $(obj)/$(head-y)
19 ln -sf $(head-y) $(obj)/head.o
20
21clean-files := $(obj)/head.o $(head-y)
diff --git a/arch/m68k/platform/68328/head-de2.S b/arch/m68k/platform/68328/head-de2.S
deleted file mode 100644
index 537d3245b539..000000000000
--- a/arch/m68k/platform/68328/head-de2.S
+++ /dev/null
@@ -1,128 +0,0 @@
1
2#define MEM_END 0x00800000 /* Memory size 8Mb */
3
4#undef CRT_DEBUG
5
6.macro PUTC CHAR
7#ifdef CRT_DEBUG
8 moveq #\CHAR, %d7
9 jsr putc
10#endif
11.endm
12
13 .global _start
14 .global _rambase
15 .global _ramvec
16 .global _ramstart
17 .global _ramend
18
19 .data
20
21/*
22 * Set up the usable of RAM stuff
23 */
24_rambase:
25 .long 0
26_ramvec:
27 .long 0
28_ramstart:
29 .long 0
30_ramend:
31 .long 0
32
33 .text
34
35_start:
36
37/*
38 * Setup initial stack
39 */
40 /* disable all interrupts */
41 movew #0x2700, %sr
42 movel #-1, 0xfffff304
43 movel #MEM_END-4, %sp
44
45 PUTC '\r'
46 PUTC '\n'
47 PUTC 'A'
48 PUTC 'B'
49
50/*
51 * Determine end of RAM
52 */
53
54 movel #MEM_END, %a0
55 movel %a0, _ramend
56
57 PUTC 'C'
58
59/*
60 * Move ROM filesystem above bss :-)
61 */
62
63 moveal #__bss_start, %a0 /* romfs at the start of bss */
64 moveal #__bss_stop, %a1 /* Set up destination */
65 movel %a0, %a2 /* Copy of bss start */
66
67 movel 8(%a0), %d1 /* Get size of ROMFS */
68 addql #8, %d1 /* Allow for rounding */
69 andl #0xfffffffc, %d1 /* Whole words */
70
71 addl %d1, %a0 /* Copy from end */
72 addl %d1, %a1 /* Copy from end */
73 movel %a1, _ramstart /* Set start of ram */
74
751:
76 movel -(%a0), %d0 /* Copy dword */
77 movel %d0, -(%a1)
78 cmpl %a0, %a2 /* Check if at end */
79 bne 1b
80
81 PUTC 'D'
82
83/*
84 * Initialize BSS segment to 0
85 */
86
87 lea __bss_start, %a0
88 lea __bss_stop, %a1
89
90 /* Copy 0 to %a0 until %a0 == %a1 */
912: cmpal %a0, %a1
92 beq 1f
93 clrl (%a0)+
94 bra 2b
951:
96
97 PUTC 'E'
98
99/*
100 * Load the current task pointer and stack
101 */
102
103 lea init_thread_union, %a0
104 lea 0x2000(%a0), %sp
105
106 PUTC 'F'
107 PUTC '\r'
108 PUTC '\n'
109
110/*
111 * Go
112 */
113
114 jmp start_kernel
115
116/*
117 * Local functions
118 */
119
120#ifdef CRT_DEBUG
121putc:
122 moveb %d7, 0xfffff907
1231:
124 movew 0xfffff906, %d7
125 andw #0x2000, %d7
126 beq 1b
127 rts
128#endif
diff --git a/arch/m68k/platform/68328/head-pilot.S b/arch/m68k/platform/68328/head-pilot.S
deleted file mode 100644
index 45a9dad29e3d..000000000000
--- a/arch/m68k/platform/68328/head-pilot.S
+++ /dev/null
@@ -1,207 +0,0 @@
1/*
2 * linux/arch/m68knommu/platform/68328/head-pilot.S
3 * - A startup file for the MC68328
4 *
5 * Copyright (C) 1998 D. Jeff Dionne <jeff@ryeham.ee.ryerson.ca>,
6 * Kenneth Albanowski <kjahds@kjahds.com>,
7 * The Silver Hammer Group, Ltd.
8 *
9 * (c) 1995, Dionne & Associates
10 * (c) 1995, DKG Display Tech.
11 */
12
13#define ASSEMBLY
14
15#define IMMED #
16#define DBG_PUTC(x) moveb IMMED x, 0xfffff907
17
18
19.global _stext
20.global _start
21
22.global _rambase
23.global _ramvec
24.global _ramstart
25.global _ramend
26
27.global bootlogo_bits
28
29/*****************************************************************************/
30
31.data
32
33/*
34 * Set up the usable of RAM stuff. Size of RAM is determined then
35 * an initial stack set up at the end.
36 */
37.align 4
38_ramvec:
39.long 0
40_rambase:
41.long 0
42_ramstart:
43.long 0
44_ramend:
45.long 0
46
47.text
48
49_start:
50_stext:
51
52
53#ifdef CONFIG_M68328
54
55#ifdef CONFIG_PILOT
56 .byte 0x4e, 0xfa, 0x00, 0x0a /* Jmp +X bytes */
57 .byte 'b', 'o', 'o', 't'
58 .word 10000
59
60 nop
61#endif
62
63 moveq #0, %d0
64 movew %d0, 0xfffff618 /* Watchdog off */
65 movel #0x00011f07, 0xfffff114 /* CS A1 Mask */
66
67 movew #0x0800, 0xfffff906 /* Ignore CTS */
68 movew #0x010b, 0xfffff902 /* BAUD to 9600 */
69
70 movew #0x2410, 0xfffff200 /* PLLCR */
71 movew #0x123, 0xfffff202 /* PLLFSR */
72
73#ifdef CONFIG_PILOT
74 moveb #0, 0xfffffA27 /* LCKCON */
75 movel #_start, 0xfffffA00 /* LSSA */
76 moveb #0xa, 0xfffffA05 /* LVPW */
77 movew #0x9f, 0xFFFFFa08 /* LXMAX */
78 movew #0x9f, 0xFFFFFa0a /* LYMAX */
79 moveb #9, 0xfffffa29 /* LBAR */
80 moveb #0, 0xfffffa25 /* LPXCD */
81 moveb #0x04, 0xFFFFFa20 /* LPICF */
82 moveb #0x58, 0xfffffA27 /* LCKCON */
83 moveb #0x85, 0xfffff429 /* PFDATA */
84 moveb #0xd8, 0xfffffA27 /* LCKCON */
85 moveb #0xc5, 0xfffff429 /* PFDATA */
86 moveb #0xd5, 0xfffff429 /* PFDATA */
87
88 moveal #0x00100000, %a3
89 moveal #0x100ffc00, %a4
90#endif /* CONFIG_PILOT */
91
92#endif /* CONFIG_M68328 */
93
94 movew #0x2700, %sr
95 lea %a4@(-4), %sp
96
97 DBG_PUTC('\r')
98 DBG_PUTC('\n')
99 DBG_PUTC('A')
100
101 moveq #0,%d0
102 movew #16384, %d0 /* PLL settle wait loop */
103L0:
104 subw #1, %d0
105 bne L0
106
107 DBG_PUTC('B')
108
109 /* Copy command line from beginning of RAM (+16) to end of bss */
110 movel #CONFIG_VECTORBASE, %d7
111 addl #16, %d7
112 moveal %d7, %a0
113 moveal #__bss_stop, %a1
114 lea %a1@(512), %a2
115
116 DBG_PUTC('C')
117
118 /* Copy %a0 to %a1 until %a1 == %a2 */
119L2:
120 movel %a0@+, %d0
121 movel %d0, %a1@+
122 cmpal %a1, %a2
123 bhi L2
124
125 /* Copy data+init segment from ROM to RAM */
126 moveal #_etext, %a0
127 moveal #_sdata, %a1
128 moveal #__init_end, %a2
129
130 DBG_PUTC('D')
131
132 /* Copy %a0 to %a1 until %a1 == %a2 */
133LD1:
134 movel %a0@+, %d0
135 movel %d0, %a1@+
136 cmpal %a1, %a2
137 bhi LD1
138
139 DBG_PUTC('E')
140
141 moveal #__bss_start, %a0
142 moveal #__bss_stop, %a1
143
144 /* Copy 0 to %a0 until %a0 == %a1 */
145L1:
146 movel #0, %a0@+
147 cmpal %a0, %a1
148 bhi L1
149
150 DBG_PUTC('F')
151
152 /* Copy command line from end of bss to command line */
153 moveal #__bss_stop, %a0
154 moveal #command_line, %a1
155 lea %a1@(512), %a2
156
157 DBG_PUTC('G')
158
159 /* Copy %a0 to %a1 until %a1 == %a2 */
160L3:
161 movel %a0@+, %d0
162 movel %d0, %a1@+
163 cmpal %a1, %a2
164 bhi L3
165
166 movel #_sdata, %d0
167 movel %d0, _rambase
168 movel #__bss_stop, %d0
169 movel %d0, _ramstart
170
171 movel %a4, %d0
172 subl #4096, %d0 /* Reserve 4K of stack */
173 moveq #79, %d7
174 movel %d0, _ramend
175
176 pea 0
177 pea env
178 pea %sp@(4)
179 pea 0
180
181 DBG_PUTC('H')
182
183#ifdef CONFIG_PILOT
184 movel #bootlogo_bits, 0xFFFFFA00
185 moveb #10, 0xFFFFFA05
186 movew #160, 0xFFFFFA08
187 movew #160, 0xFFFFFA0A
188#endif /* CONFIG_PILOT */
189
190 DBG_PUTC('I')
191
192 lea init_thread_union, %a0
193 lea 0x2000(%a0), %sp
194
195 DBG_PUTC('J')
196 DBG_PUTC('\r')
197 DBG_PUTC('\n')
198
199 jsr start_kernel
200_exit:
201
202 jmp _exit
203
204
205 .data
206env:
207 .long 0
diff --git a/arch/m68k/platform/68328/head-ram.S b/arch/m68k/platform/68328/head-ram.S
deleted file mode 100644
index 5189ef926098..000000000000
--- a/arch/m68k/platform/68328/head-ram.S
+++ /dev/null
@@ -1,141 +0,0 @@
1
2 .global __main
3 .global __rom_start
4
5 .global _rambase
6 .global _ramstart
7
8 .global splash_bits
9 .global _start
10 .global _stext
11 .global _edata
12
13#define DEBUG
14#define ROM_OFFSET 0x10C00000
15#define STACK_GAURD 0x10
16
17 .text
18
19_start:
20_stext:
21 movew #0x2700, %sr /* Exceptions off! */
22
23#if 0
24 /* Init chip registers. uCsimm specific */
25 moveb #0x00, 0xfffffb0b /* Watchdog off */
26 moveb #0x10, 0xfffff000 /* SCR */
27
28 movew #0x2400, 0xfffff200 /* PLLCR */
29 movew #0x0123, 0xfffff202 /* PLLFSR */
30
31 moveb #0x00, 0xfffff40b /* enable chip select */
32 moveb #0x00, 0xfffff423 /* enable /DWE */
33 moveb #0x08, 0xfffffd0d /* disable hardmap */
34 moveb #0x07, 0xfffffd0e /* level 7 interrupt clear */
35
36 movew #0x8600, 0xfffff100 /* FLASH at 0x10c00000 */
37 movew #0x018b, 0xfffff110 /* 2Meg, enable, 0ws */
38
39 movew #0x8f00, 0xfffffc00 /* DRAM configuration */
40 movew #0x9667, 0xfffffc02 /* DRAM control */
41 movew #0x0000, 0xfffff106 /* DRAM at 0x00000000 */
42 movew #0x068f, 0xfffff116 /* 8Meg, enable, 0ws */
43
44 moveb #0x40, 0xfffff300 /* IVR */
45 movel #0x007FFFFF, %d0 /* IMR */
46 movel %d0, 0xfffff304
47
48 moveb 0xfffff42b, %d0
49 andb #0xe0, %d0
50 moveb %d0, 0xfffff42b
51
52 moveb #0x08, 0xfffff907 /* Ignore CTS */
53 movew #0x010b, 0xfffff902 /* BAUD to 9600 */
54 movew #0xe100, 0xfffff900 /* enable */
55#endif
56
57 movew #16384, %d0 /* PLL settle wait loop */
58L0:
59 subw #1, %d0
60 bne L0
61#ifdef DEBUG
62 moveq #70, %d7 /* 'F' */
63 moveb %d7,0xfffff907 /* No absolute addresses */
64pclp1:
65 movew 0xfffff906, %d7
66 andw #0x2000, %d7
67 beq pclp1
68#endif /* DEBUG */
69
70#ifdef DEBUG
71 moveq #82, %d7 /* 'R' */
72 moveb %d7,0xfffff907 /* No absolute addresses */
73pclp3:
74 movew 0xfffff906, %d7
75 andw #0x2000, %d7
76 beq pclp3
77#endif /* DEBUG */
78 moveal #0x007ffff0, %ssp
79 moveal #__bss_start, %a0
80 moveal #__bss_stop, %a1
81
82 /* Copy 0 to %a0 until %a0 >= %a1 */
83L1:
84 movel #0, %a0@+
85 cmpal %a0, %a1
86 bhi L1
87
88#ifdef DEBUG
89 moveq #67, %d7 /* 'C' */
90 jsr putc
91#endif /* DEBUG */
92
93 pea 0
94 pea env
95 pea %sp@(4)
96 pea 0
97
98#ifdef DEBUG
99 moveq #70, %d7 /* 'F' */
100 jsr putc
101#endif /* DEBUG */
102
103lp:
104 jsr start_kernel
105 jmp lp
106_exit:
107
108 jmp _exit
109
110__main:
111 /* nothing */
112 rts
113
114#ifdef DEBUG
115putc:
116 moveb %d7,0xfffff907
117pclp:
118 movew 0xfffff906, %d7
119 andw #0x2000, %d7
120 beq pclp
121 rts
122#endif /* DEBUG */
123
124 .data
125
126/*
127 * Set up the usable of RAM stuff. Size of RAM is determined then
128 * an initial stack set up at the end.
129 */
130.align 4
131_ramvec:
132.long 0
133_rambase:
134.long 0
135_ramstart:
136.long 0
137_ramend:
138.long 0
139
140env:
141 .long 0
diff --git a/arch/m68k/platform/68328/head-rom.S b/arch/m68k/platform/68328/head-rom.S
deleted file mode 100644
index 3dff98ba2e97..000000000000
--- a/arch/m68k/platform/68328/head-rom.S
+++ /dev/null
@@ -1,105 +0,0 @@
1
2 .global _start
3 .global _stext
4
5 .global _rambase
6 .global _ramvec
7 .global _ramstart
8 .global _ramend
9
10#ifdef CONFIG_INIT_LCD
11 .global bootlogo_bits
12#endif
13
14 .data
15
16/*
17 * Set up the usable of RAM stuff. Size of RAM is determined then
18 * an initial stack set up at the end.
19 */
20.align 4
21_ramvec:
22.long 0
23_rambase:
24.long 0
25_ramstart:
26.long 0
27_ramend:
28.long 0
29
30#define RAMEND (CONFIG_RAMBASE + CONFIG_RAMSIZE)
31
32 .text
33_start:
34_stext: movew #0x2700,%sr
35#ifdef CONFIG_INIT_LCD
36 movel #bootlogo_bits, 0xfffffA00 /* LSSA */
37 moveb #0x28, 0xfffffA05 /* LVPW */
38 movew #0x280, 0xFFFFFa08 /* LXMAX */
39 movew #0x1df, 0xFFFFFa0a /* LYMAX */
40 moveb #0, 0xfffffa29 /* LBAR */
41 moveb #0, 0xfffffa25 /* LPXCD */
42 moveb #0x08, 0xFFFFFa20 /* LPICF */
43 moveb #0x01, 0xFFFFFA21 /* -ve pol */
44 moveb #0x81, 0xfffffA27 /* LCKCON */
45 movew #0xff00, 0xfffff412 /* LCD pins */
46#endif
47 moveal #RAMEND-CONFIG_MEMORY_RESERVE*0x100000 - 0x10, %sp
48 movew #32767, %d0 /* PLL settle wait loop */
491: subq #1, %d0
50 bne 1b
51
52 /* Copy data segment from ROM to RAM */
53 moveal #_etext, %a0
54 moveal #_sdata, %a1
55 moveal #_edata, %a2
56
57 /* Copy %a0 to %a1 until %a1 == %a2 */
581: movel %a0@+, %a1@+
59 cmpal %a1, %a2
60 bhi 1b
61
62 moveal #__bss_start, %a0
63 moveal #__bss_stop, %a1
64 /* Copy 0 to %a0 until %a0 == %a1 */
65
661:
67 clrl %a0@+
68 cmpal %a0, %a1
69 bhi 1b
70
71 movel #_sdata, %d0
72 movel %d0, _rambase
73 movel #__bss_stop, %d0
74 movel %d0, _ramstart
75 movel #RAMEND-CONFIG_MEMORY_RESERVE*0x100000, %d0
76 movel %d0, _ramend
77 movel #CONFIG_VECTORBASE, %d0
78 movel %d0, _ramvec
79
80/*
81 * load the current task pointer and stack
82 */
83 lea init_thread_union, %a0
84 lea 0x2000(%a0), %sp
85
861: jsr start_kernel
87 bra 1b
88_exit:
89
90 jmp _exit
91
92
93putc:
94 moveb %d7,0xfffff907
951:
96 movew 0xfffff906, %d7
97 andw #0x2000, %d7
98 beq 1b
99 rts
100
101 .data
102env:
103 .long 0
104 .text
105
diff --git a/arch/m68k/platform/68EZ328/Makefile b/arch/m68k/platform/68EZ328/Makefile
deleted file mode 100644
index b44d799b1115..000000000000
--- a/arch/m68k/platform/68EZ328/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1#
2# Makefile for arch/m68knommu/platform/68EZ328.
3#
4
5obj-y := config.o
diff --git a/arch/m68k/platform/68VZ328/Makefile b/arch/m68k/platform/68VZ328/Makefile
deleted file mode 100644
index 816674164682..000000000000
--- a/arch/m68k/platform/68VZ328/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1#
2# Makefile for arch/m68k/platform/68VZ328.
3#
4
5obj-y := config.o
diff --git a/arch/m68k/platform/coldfire/clk.c b/arch/m68k/platform/coldfire/clk.c
index 9cd13b4ce42b..fddfdccae63b 100644
--- a/arch/m68k/platform/coldfire/clk.c
+++ b/arch/m68k/platform/coldfire/clk.c
@@ -19,37 +19,58 @@
19#include <asm/mcfsim.h> 19#include <asm/mcfsim.h>
20#include <asm/mcfclk.h> 20#include <asm/mcfclk.h>
21 21
22/***************************************************************************/ 22static DEFINE_SPINLOCK(clk_lock);
23#ifndef MCFPM_PPMCR0 23
24struct clk *clk_get(struct device *dev, const char *id) 24#ifdef MCFPM_PPMCR0
25/*
26 * For more advanced ColdFire parts that have clocks that can be enabled
27 * we supply enable/disable functions. These must properly define their
28 * clocks in their platform specific code.
29 */
30void __clk_init_enabled(struct clk *clk)
25{ 31{
26 return NULL; 32 clk->enabled = 1;
33 clk->clk_ops->enable(clk);
27} 34}
28EXPORT_SYMBOL(clk_get);
29 35
30int clk_enable(struct clk *clk) 36void __clk_init_disabled(struct clk *clk)
31{ 37{
32 return 0; 38 clk->enabled = 0;
39 clk->clk_ops->disable(clk);
33} 40}
34EXPORT_SYMBOL(clk_enable);
35 41
36void clk_disable(struct clk *clk) 42static void __clk_enable0(struct clk *clk)
37{ 43{
44 __raw_writeb(clk->slot, MCFPM_PPMCR0);
38} 45}
39EXPORT_SYMBOL(clk_disable);
40 46
41void clk_put(struct clk *clk) 47static void __clk_disable0(struct clk *clk)
48{
49 __raw_writeb(clk->slot, MCFPM_PPMSR0);
50}
51
52struct clk_ops clk_ops0 = {
53 .enable = __clk_enable0,
54 .disable = __clk_disable0,
55};
56
57#ifdef MCFPM_PPMCR1
58static void __clk_enable1(struct clk *clk)
42{ 59{
60 __raw_writeb(clk->slot, MCFPM_PPMCR1);
43} 61}
44EXPORT_SYMBOL(clk_put);
45 62
46unsigned long clk_get_rate(struct clk *clk) 63static void __clk_disable1(struct clk *clk)
47{ 64{
48 return MCF_CLK; 65 __raw_writeb(clk->slot, MCFPM_PPMSR1);
49} 66}
50EXPORT_SYMBOL(clk_get_rate); 67
51#else 68struct clk_ops clk_ops1 = {
52static DEFINE_SPINLOCK(clk_lock); 69 .enable = __clk_enable1,
70 .disable = __clk_disable1,
71};
72#endif /* MCFPM_PPMCR1 */
73#endif /* MCFPM_PPMCR0 */
53 74
54struct clk *clk_get(struct device *dev, const char *id) 75struct clk *clk_get(struct device *dev, const char *id)
55{ 76{
@@ -101,48 +122,3 @@ unsigned long clk_get_rate(struct clk *clk)
101EXPORT_SYMBOL(clk_get_rate); 122EXPORT_SYMBOL(clk_get_rate);
102 123
103/***************************************************************************/ 124/***************************************************************************/
104
105void __clk_init_enabled(struct clk *clk)
106{
107 clk->enabled = 1;
108 clk->clk_ops->enable(clk);
109}
110
111void __clk_init_disabled(struct clk *clk)
112{
113 clk->enabled = 0;
114 clk->clk_ops->disable(clk);
115}
116
117static void __clk_enable0(struct clk *clk)
118{
119 __raw_writeb(clk->slot, MCFPM_PPMCR0);
120}
121
122static void __clk_disable0(struct clk *clk)
123{
124 __raw_writeb(clk->slot, MCFPM_PPMSR0);
125}
126
127struct clk_ops clk_ops0 = {
128 .enable = __clk_enable0,
129 .disable = __clk_disable0,
130};
131
132#ifdef MCFPM_PPMCR1
133static void __clk_enable1(struct clk *clk)
134{
135 __raw_writeb(clk->slot, MCFPM_PPMCR1);
136}
137
138static void __clk_disable1(struct clk *clk)
139{
140 __raw_writeb(clk->slot, MCFPM_PPMSR1);
141}
142
143struct clk_ops clk_ops1 = {
144 .enable = __clk_enable1,
145 .disable = __clk_disable1,
146};
147#endif /* MCFPM_PPMCR1 */
148#endif /* MCFPM_PPMCR0 */
diff --git a/arch/m68k/platform/coldfire/intc-5249.c b/arch/m68k/platform/coldfire/intc-5249.c
index 0864b836699a..b0d1641053e4 100644
--- a/arch/m68k/platform/coldfire/intc-5249.c
+++ b/arch/m68k/platform/coldfire/intc-5249.c
@@ -21,7 +21,7 @@ static void intc2_irq_gpio_mask(struct irq_data *d)
21{ 21{
22 u32 imr; 22 u32 imr;
23 imr = readl(MCFSIM2_GPIOINTENABLE); 23 imr = readl(MCFSIM2_GPIOINTENABLE);
24 imr &= ~(0x1 << (d->irq - MCFINTC2_GPIOIRQ0)); 24 imr &= ~(0x1 << (d->irq - MCF_IRQ_GPIO0));
25 writel(imr, MCFSIM2_GPIOINTENABLE); 25 writel(imr, MCFSIM2_GPIOINTENABLE);
26} 26}
27 27
@@ -29,13 +29,13 @@ static void intc2_irq_gpio_unmask(struct irq_data *d)
29{ 29{
30 u32 imr; 30 u32 imr;
31 imr = readl(MCFSIM2_GPIOINTENABLE); 31 imr = readl(MCFSIM2_GPIOINTENABLE);
32 imr |= (0x1 << (d->irq - MCFINTC2_GPIOIRQ0)); 32 imr |= (0x1 << (d->irq - MCF_IRQ_GPIO0));
33 writel(imr, MCFSIM2_GPIOINTENABLE); 33 writel(imr, MCFSIM2_GPIOINTENABLE);
34} 34}
35 35
36static void intc2_irq_gpio_ack(struct irq_data *d) 36static void intc2_irq_gpio_ack(struct irq_data *d)
37{ 37{
38 writel(0x1 << (d->irq - MCFINTC2_GPIOIRQ0), MCFSIM2_GPIOINTCLEAR); 38 writel(0x1 << (d->irq - MCF_IRQ_GPIO0), MCFSIM2_GPIOINTCLEAR);
39} 39}
40 40
41static struct irq_chip intc2_irq_gpio_chip = { 41static struct irq_chip intc2_irq_gpio_chip = {
@@ -50,7 +50,7 @@ static int __init mcf_intc2_init(void)
50 int irq; 50 int irq;
51 51
52 /* GPIO interrupt sources */ 52 /* GPIO interrupt sources */
53 for (irq = MCFINTC2_GPIOIRQ0; (irq <= MCFINTC2_GPIOIRQ7); irq++) { 53 for (irq = MCF_IRQ_GPIO0; (irq <= MCF_IRQ_GPIO7); irq++) {
54 irq_set_chip(irq, &intc2_irq_gpio_chip); 54 irq_set_chip(irq, &intc2_irq_gpio_chip);
55 irq_set_handler(irq, handle_edge_irq); 55 irq_set_handler(irq, handle_edge_irq);
56 } 56 }
diff --git a/arch/m68k/platform/coldfire/m5206.c b/arch/m68k/platform/coldfire/m5206.c
index 6bfbeebd231b..0e55f449a88c 100644
--- a/arch/m68k/platform/coldfire/m5206.c
+++ b/arch/m68k/platform/coldfire/m5206.c
@@ -16,6 +16,26 @@
16#include <asm/machdep.h> 16#include <asm/machdep.h>
17#include <asm/coldfire.h> 17#include <asm/coldfire.h>
18#include <asm/mcfsim.h> 18#include <asm/mcfsim.h>
19#include <asm/mcfclk.h>
20
21/***************************************************************************/
22
23DEFINE_CLK(pll, "pll.0", MCF_CLK);
24DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
25DEFINE_CLK(mcftmr0, "mcftmr.0", MCF_BUSCLK);
26DEFINE_CLK(mcftmr1, "mcftmr.1", MCF_BUSCLK);
27DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
28DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
29
30struct clk *mcf_clks[] = {
31 &clk_pll,
32 &clk_sys,
33 &clk_mcftmr0,
34 &clk_mcftmr1,
35 &clk_mcfuart0,
36 &clk_mcfuart1,
37 NULL
38};
19 39
20/***************************************************************************/ 40/***************************************************************************/
21 41
diff --git a/arch/m68k/platform/coldfire/m523x.c b/arch/m68k/platform/coldfire/m523x.c
index ff37fe9553ea..2b10e9f198cd 100644
--- a/arch/m68k/platform/coldfire/m523x.c
+++ b/arch/m68k/platform/coldfire/m523x.c
@@ -19,6 +19,34 @@
19#include <asm/machdep.h> 19#include <asm/machdep.h>
20#include <asm/coldfire.h> 20#include <asm/coldfire.h>
21#include <asm/mcfsim.h> 21#include <asm/mcfsim.h>
22#include <asm/mcfclk.h>
23
24/***************************************************************************/
25
26DEFINE_CLK(pll, "pll.0", MCF_CLK);
27DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
28DEFINE_CLK(mcfpit0, "mcfpit.0", MCF_CLK);
29DEFINE_CLK(mcfpit1, "mcfpit.1", MCF_CLK);
30DEFINE_CLK(mcfpit2, "mcfpit.2", MCF_CLK);
31DEFINE_CLK(mcfpit3, "mcfpit.3", MCF_CLK);
32DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
33DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
34DEFINE_CLK(mcfuart2, "mcfuart.2", MCF_BUSCLK);
35DEFINE_CLK(fec0, "fec.0", MCF_BUSCLK);
36
37struct clk *mcf_clks[] = {
38 &clk_pll,
39 &clk_sys,
40 &clk_mcfpit0,
41 &clk_mcfpit1,
42 &clk_mcfpit2,
43 &clk_mcfpit3,
44 &clk_mcfuart0,
45 &clk_mcfuart1,
46 &clk_mcfuart2,
47 &clk_fec0,
48 NULL
49};
22 50
23/***************************************************************************/ 51/***************************************************************************/
24 52
diff --git a/arch/m68k/platform/coldfire/m5249.c b/arch/m68k/platform/coldfire/m5249.c
index 23b19cb7ab50..c80b5e51d29a 100644
--- a/arch/m68k/platform/coldfire/m5249.c
+++ b/arch/m68k/platform/coldfire/m5249.c
@@ -16,6 +16,26 @@
16#include <asm/machdep.h> 16#include <asm/machdep.h>
17#include <asm/coldfire.h> 17#include <asm/coldfire.h>
18#include <asm/mcfsim.h> 18#include <asm/mcfsim.h>
19#include <asm/mcfclk.h>
20
21/***************************************************************************/
22
23DEFINE_CLK(pll, "pll.0", MCF_CLK);
24DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
25DEFINE_CLK(mcftmr0, "mcftmr.0", MCF_BUSCLK);
26DEFINE_CLK(mcftmr1, "mcftmr.1", MCF_BUSCLK);
27DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
28DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
29
30struct clk *mcf_clks[] = {
31 &clk_pll,
32 &clk_sys,
33 &clk_mcftmr0,
34 &clk_mcftmr1,
35 &clk_mcfuart0,
36 &clk_mcfuart1,
37 NULL
38};
19 39
20/***************************************************************************/ 40/***************************************************************************/
21 41
@@ -28,8 +48,8 @@ static struct resource m5249_smc91x_resources[] = {
28 .flags = IORESOURCE_MEM, 48 .flags = IORESOURCE_MEM,
29 }, 49 },
30 { 50 {
31 .start = MCFINTC2_GPIOIRQ6, 51 .start = MCF_IRQ_GPIO6,
32 .end = MCFINTC2_GPIOIRQ6, 52 .end = MCF_IRQ_GPIO6,
33 .flags = IORESOURCE_IRQ, 53 .flags = IORESOURCE_IRQ,
34 }, 54 },
35}; 55};
@@ -75,8 +95,8 @@ static void __init m5249_smc91x_init(void)
75 gpio = readl(MCFSIM2_GPIOINTENABLE); 95 gpio = readl(MCFSIM2_GPIOINTENABLE);
76 writel(gpio | 0x40, MCFSIM2_GPIOINTENABLE); 96 writel(gpio | 0x40, MCFSIM2_GPIOINTENABLE);
77 97
78 gpio = readl(MCFSIM2_INTLEVEL5); 98 gpio = readl(MCFINTC2_INTPRI5);
79 writel(gpio | 0x04000000, MCFSIM2_INTLEVEL5); 99 writel(gpio | 0x04000000, MCFINTC2_INTPRI5);
80} 100}
81 101
82#endif /* CONFIG_M5249C3 */ 102#endif /* CONFIG_M5249C3 */
diff --git a/arch/m68k/platform/coldfire/m525x.c b/arch/m68k/platform/coldfire/m525x.c
index fce8f8a45bf0..5b9f657b2df0 100644
--- a/arch/m68k/platform/coldfire/m525x.c
+++ b/arch/m68k/platform/coldfire/m525x.c
@@ -16,6 +16,26 @@
16#include <asm/machdep.h> 16#include <asm/machdep.h>
17#include <asm/coldfire.h> 17#include <asm/coldfire.h>
18#include <asm/mcfsim.h> 18#include <asm/mcfsim.h>
19#include <asm/mcfclk.h>
20
21/***************************************************************************/
22
23DEFINE_CLK(pll, "pll.0", MCF_CLK);
24DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
25DEFINE_CLK(mcftmr0, "mcftmr.0", MCF_BUSCLK);
26DEFINE_CLK(mcftmr1, "mcftmr.1", MCF_BUSCLK);
27DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
28DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
29
30struct clk *mcf_clks[] = {
31 &clk_pll,
32 &clk_sys,
33 &clk_mcftmr0,
34 &clk_mcftmr1,
35 &clk_mcfuart0,
36 &clk_mcfuart1,
37 NULL
38};
19 39
20/***************************************************************************/ 40/***************************************************************************/
21 41
diff --git a/arch/m68k/platform/coldfire/m5272.c b/arch/m68k/platform/coldfire/m5272.c
index 45b246d052ef..a8c5856fe5ec 100644
--- a/arch/m68k/platform/coldfire/m5272.c
+++ b/arch/m68k/platform/coldfire/m5272.c
@@ -19,6 +19,7 @@
19#include <asm/coldfire.h> 19#include <asm/coldfire.h>
20#include <asm/mcfsim.h> 20#include <asm/mcfsim.h>
21#include <asm/mcfuart.h> 21#include <asm/mcfuart.h>
22#include <asm/mcfclk.h>
22 23
23/***************************************************************************/ 24/***************************************************************************/
24 25
@@ -30,6 +31,31 @@ unsigned char ledbank = 0xff;
30 31
31/***************************************************************************/ 32/***************************************************************************/
32 33
34DEFINE_CLK(pll, "pll.0", MCF_CLK);
35DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
36DEFINE_CLK(mcftmr0, "mcftmr.0", MCF_BUSCLK);
37DEFINE_CLK(mcftmr1, "mcftmr.1", MCF_BUSCLK);
38DEFINE_CLK(mcftmr2, "mcftmr.2", MCF_BUSCLK);
39DEFINE_CLK(mcftmr3, "mcftmr.3", MCF_BUSCLK);
40DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
41DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
42DEFINE_CLK(fec0, "fec.0", MCF_BUSCLK);
43
44struct clk *mcf_clks[] = {
45 &clk_pll,
46 &clk_sys,
47 &clk_mcftmr0,
48 &clk_mcftmr1,
49 &clk_mcftmr2,
50 &clk_mcftmr3,
51 &clk_mcfuart0,
52 &clk_mcfuart1,
53 &clk_fec0,
54 NULL
55};
56
57/***************************************************************************/
58
33static void __init m5272_uarts_init(void) 59static void __init m5272_uarts_init(void)
34{ 60{
35 u32 v; 61 u32 v;
diff --git a/arch/m68k/platform/coldfire/m527x.c b/arch/m68k/platform/coldfire/m527x.c
index 1431ba03c602..6fbfe9096c3e 100644
--- a/arch/m68k/platform/coldfire/m527x.c
+++ b/arch/m68k/platform/coldfire/m527x.c
@@ -20,6 +20,36 @@
20#include <asm/coldfire.h> 20#include <asm/coldfire.h>
21#include <asm/mcfsim.h> 21#include <asm/mcfsim.h>
22#include <asm/mcfuart.h> 22#include <asm/mcfuart.h>
23#include <asm/mcfclk.h>
24
25/***************************************************************************/
26
27DEFINE_CLK(pll, "pll.0", MCF_CLK);
28DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
29DEFINE_CLK(mcfpit0, "mcfpit.0", MCF_CLK);
30DEFINE_CLK(mcfpit1, "mcfpit.1", MCF_CLK);
31DEFINE_CLK(mcfpit2, "mcfpit.2", MCF_CLK);
32DEFINE_CLK(mcfpit3, "mcfpit.3", MCF_CLK);
33DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
34DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
35DEFINE_CLK(mcfuart2, "mcfuart.2", MCF_BUSCLK);
36DEFINE_CLK(fec0, "fec.0", MCF_BUSCLK);
37DEFINE_CLK(fec1, "fec.1", MCF_BUSCLK);
38
39struct clk *mcf_clks[] = {
40 &clk_pll,
41 &clk_sys,
42 &clk_mcfpit0,
43 &clk_mcfpit1,
44 &clk_mcfpit2,
45 &clk_mcfpit3,
46 &clk_mcfuart0,
47 &clk_mcfuart1,
48 &clk_mcfuart2,
49 &clk_fec0,
50 &clk_fec1,
51 NULL
52};
23 53
24/***************************************************************************/ 54/***************************************************************************/
25 55
diff --git a/arch/m68k/platform/coldfire/m528x.c b/arch/m68k/platform/coldfire/m528x.c
index f9f7e6a13d04..83b7dad7a84e 100644
--- a/arch/m68k/platform/coldfire/m528x.c
+++ b/arch/m68k/platform/coldfire/m528x.c
@@ -21,6 +21,34 @@
21#include <asm/coldfire.h> 21#include <asm/coldfire.h>
22#include <asm/mcfsim.h> 22#include <asm/mcfsim.h>
23#include <asm/mcfuart.h> 23#include <asm/mcfuart.h>
24#include <asm/mcfclk.h>
25
26/***************************************************************************/
27
28DEFINE_CLK(pll, "pll.0", MCF_CLK);
29DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
30DEFINE_CLK(mcfpit0, "mcfpit.0", MCF_CLK);
31DEFINE_CLK(mcfpit1, "mcfpit.1", MCF_CLK);
32DEFINE_CLK(mcfpit2, "mcfpit.2", MCF_CLK);
33DEFINE_CLK(mcfpit3, "mcfpit.3", MCF_CLK);
34DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
35DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
36DEFINE_CLK(mcfuart2, "mcfuart.2", MCF_BUSCLK);
37DEFINE_CLK(fec0, "fec.0", MCF_BUSCLK);
38
39struct clk *mcf_clks[] = {
40 &clk_pll,
41 &clk_sys,
42 &clk_mcfpit0,
43 &clk_mcfpit1,
44 &clk_mcfpit2,
45 &clk_mcfpit3,
46 &clk_mcfuart0,
47 &clk_mcfuart1,
48 &clk_mcfuart2,
49 &clk_fec0,
50 NULL
51};
24 52
25/***************************************************************************/ 53/***************************************************************************/
26 54
diff --git a/arch/m68k/platform/coldfire/m5307.c b/arch/m68k/platform/coldfire/m5307.c
index a568d2870d15..887435361386 100644
--- a/arch/m68k/platform/coldfire/m5307.c
+++ b/arch/m68k/platform/coldfire/m5307.c
@@ -17,6 +17,7 @@
17#include <asm/coldfire.h> 17#include <asm/coldfire.h>
18#include <asm/mcfsim.h> 18#include <asm/mcfsim.h>
19#include <asm/mcfwdebug.h> 19#include <asm/mcfwdebug.h>
20#include <asm/mcfclk.h>
20 21
21/***************************************************************************/ 22/***************************************************************************/
22 23
@@ -28,6 +29,25 @@ unsigned char ledbank = 0xff;
28 29
29/***************************************************************************/ 30/***************************************************************************/
30 31
32DEFINE_CLK(pll, "pll.0", MCF_CLK);
33DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
34DEFINE_CLK(mcftmr0, "mcftmr.0", MCF_BUSCLK);
35DEFINE_CLK(mcftmr1, "mcftmr.1", MCF_BUSCLK);
36DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
37DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
38
39struct clk *mcf_clks[] = {
40 &clk_pll,
41 &clk_sys,
42 &clk_mcftmr0,
43 &clk_mcftmr1,
44 &clk_mcfuart0,
45 &clk_mcfuart1,
46 NULL
47};
48
49/***************************************************************************/
50
31void __init config_BSP(char *commandp, int size) 51void __init config_BSP(char *commandp, int size)
32{ 52{
33#if defined(CONFIG_NETtel) || \ 53#if defined(CONFIG_NETtel) || \
diff --git a/arch/m68k/platform/coldfire/m5407.c b/arch/m68k/platform/coldfire/m5407.c
index bb6c746ae819..2fb3cdbfde30 100644
--- a/arch/m68k/platform/coldfire/m5407.c
+++ b/arch/m68k/platform/coldfire/m5407.c
@@ -16,6 +16,26 @@
16#include <asm/machdep.h> 16#include <asm/machdep.h>
17#include <asm/coldfire.h> 17#include <asm/coldfire.h>
18#include <asm/mcfsim.h> 18#include <asm/mcfsim.h>
19#include <asm/mcfclk.h>
20
21/***************************************************************************/
22
23DEFINE_CLK(pll, "pll.0", MCF_CLK);
24DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
25DEFINE_CLK(mcftmr0, "mcftmr.0", MCF_BUSCLK);
26DEFINE_CLK(mcftmr1, "mcftmr.1", MCF_BUSCLK);
27DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
28DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
29
30struct clk *mcf_clks[] = {
31 &clk_pll,
32 &clk_sys,
33 &clk_mcftmr0,
34 &clk_mcftmr1,
35 &clk_mcfuart0,
36 &clk_mcfuart1,
37 NULL
38};
19 39
20/***************************************************************************/ 40/***************************************************************************/
21 41
diff --git a/arch/m68k/platform/coldfire/m54xx.c b/arch/m68k/platform/coldfire/m54xx.c
index b587bf35175b..952da53aa0bc 100644
--- a/arch/m68k/platform/coldfire/m54xx.c
+++ b/arch/m68k/platform/coldfire/m54xx.c
@@ -14,19 +14,45 @@
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/io.h> 15#include <linux/io.h>
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/clk.h>
17#include <linux/bootmem.h> 18#include <linux/bootmem.h>
18#include <asm/pgalloc.h> 19#include <asm/pgalloc.h>
19#include <asm/machdep.h> 20#include <asm/machdep.h>
20#include <asm/coldfire.h> 21#include <asm/coldfire.h>
21#include <asm/m54xxsim.h> 22#include <asm/m54xxsim.h>
22#include <asm/mcfuart.h> 23#include <asm/mcfuart.h>
24#include <asm/mcfclk.h>
23#include <asm/m54xxgpt.h> 25#include <asm/m54xxgpt.h>
26#include <asm/mcfclk.h>
24#ifdef CONFIG_MMU 27#ifdef CONFIG_MMU
25#include <asm/mmu_context.h> 28#include <asm/mmu_context.h>
26#endif 29#endif
27 30
28/***************************************************************************/ 31/***************************************************************************/
29 32
33DEFINE_CLK(pll, "pll.0", MCF_CLK);
34DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
35DEFINE_CLK(mcfslt0, "mcfslt.0", MCF_BUSCLK);
36DEFINE_CLK(mcfslt1, "mcfslt.1", MCF_BUSCLK);
37DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
38DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
39DEFINE_CLK(mcfuart2, "mcfuart.2", MCF_BUSCLK);
40DEFINE_CLK(mcfuart3, "mcfuart.3", MCF_BUSCLK);
41
42struct clk *mcf_clks[] = {
43 &clk_pll,
44 &clk_sys,
45 &clk_mcfslt0,
46 &clk_mcfslt1,
47 &clk_mcfuart0,
48 &clk_mcfuart1,
49 &clk_mcfuart2,
50 &clk_mcfuart3,
51 NULL
52};
53
54/***************************************************************************/
55
30static void __init m54xx_uarts_init(void) 56static void __init m54xx_uarts_init(void)
31{ 57{
32 /* enable io pins */ 58 /* enable io pins */
diff --git a/arch/microblaze/include/asm/Kbuild b/arch/microblaze/include/asm/Kbuild
index eb3a46c096fe..d3c51a6a601d 100644
--- a/arch/microblaze/include/asm/Kbuild
+++ b/arch/microblaze/include/asm/Kbuild
@@ -1,6 +1,4 @@
1include include/asm-generic/Kbuild.asm
2 1
3header-y += elf.h
4generic-y += clkdev.h 2generic-y += clkdev.h
5generic-y += exec.h 3generic-y += exec.h
6generic-y += trace_clock.h 4generic-y += trace_clock.h
diff --git a/arch/microblaze/include/asm/elf.h b/arch/microblaze/include/asm/elf.h
index 640ddd4b6a9b..659024449064 100644
--- a/arch/microblaze/include/asm/elf.h
+++ b/arch/microblaze/include/asm/elf.h
@@ -7,119 +7,24 @@
7 * License. See the file "COPYING" in the main directory of this archive 7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details. 8 * for more details.
9 */ 9 */
10
11#ifndef _ASM_MICROBLAZE_ELF_H 10#ifndef _ASM_MICROBLAZE_ELF_H
12#define _ASM_MICROBLAZE_ELF_H 11#define _ASM_MICROBLAZE_ELF_H
13 12
14/* 13#include <uapi/asm/elf.h>
15 * Note there is no "official" ELF designation for Microblaze.
16 * I've snaffled the value from the microblaze binutils source code
17 * /binutils/microblaze/include/elf/microblaze.h
18 */
19#define EM_MICROBLAZE 189
20#define EM_MICROBLAZE_OLD 0xbaab
21#define ELF_ARCH EM_MICROBLAZE
22
23/*
24 * This is used to ensure we don't load something for the wrong architecture.
25 */
26#define elf_check_arch(x) ((x)->e_machine == EM_MICROBLAZE \
27 || (x)->e_machine == EM_MICROBLAZE_OLD)
28
29/*
30 * These are used to set parameters in the core dumps.
31 */
32#define ELF_CLASS ELFCLASS32
33 14
34#ifndef __uClinux__ 15#ifndef __uClinux__
35
36/*
37 * ELF register definitions..
38 */
39
40#include <asm/ptrace.h>
41#include <asm/byteorder.h>
42
43#ifndef ELF_GREG_T 16#ifndef ELF_GREG_T
44#define ELF_GREG_T
45typedef unsigned long elf_greg_t;
46#endif 17#endif
47
48#ifndef ELF_NGREG 18#ifndef ELF_NGREG
49#define ELF_NGREG (sizeof(struct pt_regs) / sizeof(elf_greg_t))
50#endif 19#endif
51
52#ifndef ELF_GREGSET_T 20#ifndef ELF_GREGSET_T
53#define ELF_GREGSET_T
54typedef elf_greg_t elf_gregset_t[ELF_NGREG];
55#endif 21#endif
56
57#ifndef ELF_FPREGSET_T 22#ifndef ELF_FPREGSET_T
58#define ELF_FPREGSET_T
59
60/* TBD */
61#define ELF_NFPREG 33 /* includes fsr */
62typedef unsigned long elf_fpreg_t;
63typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
64
65/* typedef struct user_fpu_struct elf_fpregset_t; */
66#endif 23#endif
67
68/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
69 * use of this is to invoke "./ld.so someprog" to test out a new version of
70 * the loader. We need to make sure that it is out of the way of the program
71 * that it will "exec", and that there is sufficient room for the brk.
72 */
73
74#define ELF_ET_DYN_BASE (0x08000000)
75
76#ifdef __MICROBLAZEEL__ 24#ifdef __MICROBLAZEEL__
77#define ELF_DATA ELFDATA2LSB
78#else 25#else
79#define ELF_DATA ELFDATA2MSB
80#endif 26#endif
81
82#define ELF_EXEC_PAGESIZE PAGE_SIZE
83
84
85#define ELF_CORE_COPY_REGS(_dest, _regs) \
86 memcpy((char *) &_dest, (char *) _regs, \
87 sizeof(struct pt_regs));
88
89/* This yields a mask that user programs can use to figure out what
90 * instruction set this CPU supports. This could be done in user space,
91 * but it's not easy, and we've already done it here.
92 */
93#define ELF_HWCAP (0)
94
95/* This yields a string that ld.so will use to load implementation
96 * specific libraries for optimization. This is more specific in
97 * intent than poking at uname or /proc/cpuinfo.
98
99 * For the moment, we have only optimizations for the Intel generations,
100 * but that could change...
101 */
102#define ELF_PLATFORM (NULL)
103
104/* Added _f parameter. Is this definition correct: TBD */
105#define ELF_PLAT_INIT(_r, _f) \
106do { \
107 _r->r1 = _r->r1 = _r->r2 = _r->r3 = \
108 _r->r4 = _r->r5 = _r->r6 = _r->r7 = \
109 _r->r8 = _r->r9 = _r->r10 = _r->r11 = \
110 _r->r12 = _r->r13 = _r->r14 = _r->r15 = \
111 _r->r16 = _r->r17 = _r->r18 = _r->r19 = \
112 _r->r20 = _r->r21 = _r->r22 = _r->r23 = \
113 _r->r24 = _r->r25 = _r->r26 = _r->r27 = \
114 _r->r28 = _r->r29 = _r->r30 = _r->r31 = \
115 0; \
116} while (0)
117
118#ifdef __KERNEL__
119#define SET_PERSONALITY(ex) \ 27#define SET_PERSONALITY(ex) \
120 set_personality(PER_LINUX_32BIT | (current->personality & (~PER_MASK))) 28 set_personality(PER_LINUX_32BIT | (current->personality & (~PER_MASK)))
121#endif
122
123#endif /* __uClinux__ */ 29#endif /* __uClinux__ */
124
125#endif /* _ASM_MICROBLAZE_ELF_H */ 30#endif /* _ASM_MICROBLAZE_ELF_H */
diff --git a/arch/microblaze/include/asm/entry.h b/arch/microblaze/include/asm/entry.h
index af0144b91b79..b4a4cb150aa9 100644
--- a/arch/microblaze/include/asm/entry.h
+++ b/arch/microblaze/include/asm/entry.h
@@ -29,6 +29,8 @@ DECLARE_PER_CPU(unsigned int, KM); /* Kernel/user mode */
29DECLARE_PER_CPU(unsigned int, ENTRY_SP); /* Saved SP on kernel entry */ 29DECLARE_PER_CPU(unsigned int, ENTRY_SP); /* Saved SP on kernel entry */
30DECLARE_PER_CPU(unsigned int, R11_SAVE); /* Temp variable for entry */ 30DECLARE_PER_CPU(unsigned int, R11_SAVE); /* Temp variable for entry */
31DECLARE_PER_CPU(unsigned int, CURRENT_SAVE); /* Saved current pointer */ 31DECLARE_PER_CPU(unsigned int, CURRENT_SAVE); /* Saved current pointer */
32
33extern asmlinkage void do_notify_resume(struct pt_regs *regs, int in_syscall);
32# endif /* __ASSEMBLY__ */ 34# endif /* __ASSEMBLY__ */
33 35
34#endif /* _ASM_MICROBLAZE_ENTRY_H */ 36#endif /* _ASM_MICROBLAZE_ENTRY_H */
diff --git a/arch/microblaze/include/asm/ptrace.h b/arch/microblaze/include/asm/ptrace.h
index 94e92c805859..3732bcf186fd 100644
--- a/arch/microblaze/include/asm/ptrace.h
+++ b/arch/microblaze/include/asm/ptrace.h
@@ -5,56 +5,12 @@
5 * License. See the file "COPYING" in the main directory of this archive 5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details. 6 * for more details.
7 */ 7 */
8
9#ifndef _ASM_MICROBLAZE_PTRACE_H 8#ifndef _ASM_MICROBLAZE_PTRACE_H
10#define _ASM_MICROBLAZE_PTRACE_H 9#define _ASM_MICROBLAZE_PTRACE_H
11 10
12#ifndef __ASSEMBLY__ 11#include <uapi/asm/ptrace.h>
13
14typedef unsigned long microblaze_reg_t;
15 12
16struct pt_regs { 13#ifndef __ASSEMBLY__
17 microblaze_reg_t r0;
18 microblaze_reg_t r1;
19 microblaze_reg_t r2;
20 microblaze_reg_t r3;
21 microblaze_reg_t r4;
22 microblaze_reg_t r5;
23 microblaze_reg_t r6;
24 microblaze_reg_t r7;
25 microblaze_reg_t r8;
26 microblaze_reg_t r9;
27 microblaze_reg_t r10;
28 microblaze_reg_t r11;
29 microblaze_reg_t r12;
30 microblaze_reg_t r13;
31 microblaze_reg_t r14;
32 microblaze_reg_t r15;
33 microblaze_reg_t r16;
34 microblaze_reg_t r17;
35 microblaze_reg_t r18;
36 microblaze_reg_t r19;
37 microblaze_reg_t r20;
38 microblaze_reg_t r21;
39 microblaze_reg_t r22;
40 microblaze_reg_t r23;
41 microblaze_reg_t r24;
42 microblaze_reg_t r25;
43 microblaze_reg_t r26;
44 microblaze_reg_t r27;
45 microblaze_reg_t r28;
46 microblaze_reg_t r29;
47 microblaze_reg_t r30;
48 microblaze_reg_t r31;
49 microblaze_reg_t pc;
50 microblaze_reg_t msr;
51 microblaze_reg_t ear;
52 microblaze_reg_t esr;
53 microblaze_reg_t fsr;
54 int pt_mode;
55};
56
57#ifdef __KERNEL__
58#define kernel_mode(regs) ((regs)->pt_mode) 14#define kernel_mode(regs) ((regs)->pt_mode)
59#define user_mode(regs) (!kernel_mode(regs)) 15#define user_mode(regs) (!kernel_mode(regs))
60 16
@@ -66,19 +22,5 @@ static inline long regs_return_value(struct pt_regs *regs)
66 return regs->r3; 22 return regs->r3;
67} 23}
68 24
69#else /* __KERNEL__ */
70
71/* pt_regs offsets used by gdbserver etc in ptrace syscalls */
72#define PT_GPR(n) ((n) * sizeof(microblaze_reg_t))
73#define PT_PC (32 * sizeof(microblaze_reg_t))
74#define PT_MSR (33 * sizeof(microblaze_reg_t))
75#define PT_EAR (34 * sizeof(microblaze_reg_t))
76#define PT_ESR (35 * sizeof(microblaze_reg_t))
77#define PT_FSR (36 * sizeof(microblaze_reg_t))
78#define PT_KERNEL_MODE (37 * sizeof(microblaze_reg_t))
79
80#endif /* __KERNEL */
81
82#endif /* __ASSEMBLY__ */ 25#endif /* __ASSEMBLY__ */
83
84#endif /* _ASM_MICROBLAZE_PTRACE_H */ 26#endif /* _ASM_MICROBLAZE_PTRACE_H */
diff --git a/arch/microblaze/include/asm/setup.h b/arch/microblaze/include/asm/setup.h
index 0061aa13a340..0e0b0a5ec756 100644
--- a/arch/microblaze/include/asm/setup.h
+++ b/arch/microblaze/include/asm/setup.h
@@ -7,15 +7,12 @@
7 * License. See the file "COPYING" in the main directory of this archive 7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details. 8 * for more details.
9 */ 9 */
10
11#ifndef _ASM_MICROBLAZE_SETUP_H 10#ifndef _ASM_MICROBLAZE_SETUP_H
12#define _ASM_MICROBLAZE_SETUP_H 11#define _ASM_MICROBLAZE_SETUP_H
13 12
14#define COMMAND_LINE_SIZE 256 13#include <uapi/asm/setup.h>
15 14
16# ifndef __ASSEMBLY__ 15# ifndef __ASSEMBLY__
17
18# ifdef __KERNEL__
19extern unsigned int boot_cpuid; /* move to smp.h */ 16extern unsigned int boot_cpuid; /* move to smp.h */
20 17
21extern char cmd_line[COMMAND_LINE_SIZE]; 18extern char cmd_line[COMMAND_LINE_SIZE];
@@ -53,6 +50,5 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end);
53extern void *alloc_maybe_bootmem(size_t size, gfp_t mask); 50extern void *alloc_maybe_bootmem(size_t size, gfp_t mask);
54extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask); 51extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask);
55 52
56# endif/* __KERNEL__ */
57# endif /* __ASSEMBLY__ */ 53# endif /* __ASSEMBLY__ */
58#endif /* _ASM_MICROBLAZE_SETUP_H */ 54#endif /* _ASM_MICROBLAZE_SETUP_H */
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
index ef25f7538d4a..927540d3cb7d 100644
--- a/arch/microblaze/include/asm/uaccess.h
+++ b/arch/microblaze/include/asm/uaccess.h
@@ -298,11 +298,10 @@ extern long __user_bad(void);
298 298
299#define __put_user_check(x, ptr, size) \ 299#define __put_user_check(x, ptr, size) \
300({ \ 300({ \
301 typeof(*(ptr)) __pu_val; \ 301 typeof(*(ptr)) volatile __pu_val = x; \
302 typeof(*(ptr)) __user *__pu_addr = (ptr); \ 302 typeof(*(ptr)) __user *__pu_addr = (ptr); \
303 int __pu_err = 0; \ 303 int __pu_err = 0; \
304 \ 304 \
305 __pu_val = (x); \
306 if (access_ok(VERIFY_WRITE, __pu_addr, size)) { \ 305 if (access_ok(VERIFY_WRITE, __pu_addr, size)) { \
307 switch (size) { \ 306 switch (size) { \
308 case 1: \ 307 case 1: \
diff --git a/arch/microblaze/include/asm/unistd.h b/arch/microblaze/include/asm/unistd.h
index 94d978986b75..99e23937a31a 100644
--- a/arch/microblaze/include/asm/unistd.h
+++ b/arch/microblaze/include/asm/unistd.h
@@ -6,398 +6,11 @@
6 * License. See the file "COPYING" in the main directory of this archive 6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details. 7 * for more details.
8 */ 8 */
9
10#ifndef _ASM_MICROBLAZE_UNISTD_H 9#ifndef _ASM_MICROBLAZE_UNISTD_H
11#define _ASM_MICROBLAZE_UNISTD_H 10#define _ASM_MICROBLAZE_UNISTD_H
12 11
13#define __NR_restart_syscall 0 /* ok */ 12#include <uapi/asm/unistd.h>
14#define __NR_exit 1 /* ok */
15#define __NR_fork 2 /* not for no MMU - weird */
16#define __NR_read 3 /* ok */
17#define __NR_write 4 /* ok */
18#define __NR_open 5 /* openat */
19#define __NR_close 6 /* ok */
20#define __NR_waitpid 7 /* waitid */
21#define __NR_creat 8 /* openat */
22#define __NR_link 9 /* linkat */
23#define __NR_unlink 10 /* unlinkat */
24#define __NR_execve 11 /* ok */
25#define __NR_chdir 12 /* ok */
26#define __NR_time 13 /* obsolete -> sys_gettimeofday */
27#define __NR_mknod 14 /* mknodat */
28#define __NR_chmod 15 /* fchmodat */
29#define __NR_lchown 16 /* ok */
30#define __NR_break 17 /* don't know */
31#define __NR_oldstat 18 /* remove */
32#define __NR_lseek 19 /* ok */
33#define __NR_getpid 20 /* ok */
34#define __NR_mount 21 /* ok */
35#define __NR_umount 22 /* ok */ /* use only umount2 */
36#define __NR_setuid 23 /* ok */
37#define __NR_getuid 24 /* ok */
38#define __NR_stime 25 /* obsolete -> sys_settimeofday */
39#define __NR_ptrace 26 /* ok */
40#define __NR_alarm 27 /* obsolete -> sys_setitimer */
41#define __NR_oldfstat 28 /* remove */
42#define __NR_pause 29 /* obsolete -> sys_rt_sigtimedwait */
43#define __NR_utime 30 /* obsolete -> sys_utimesat */
44#define __NR_stty 31 /* remove */
45#define __NR_gtty 32 /* remove */
46#define __NR_access 33 /* faccessat */
47/* can be implemented by sys_setpriority */
48#define __NR_nice 34
49#define __NR_ftime 35 /* remove */
50#define __NR_sync 36 /* ok */
51#define __NR_kill 37 /* ok */
52#define __NR_rename 38 /* renameat */
53#define __NR_mkdir 39 /* mkdirat */
54#define __NR_rmdir 40 /* unlinkat */
55#define __NR_dup 41 /* ok */
56#define __NR_pipe 42 /* ok */
57#define __NR_times 43 /* ok */
58#define __NR_prof 44 /* remove */
59#define __NR_brk 45 /* ok -mmu, nommu specific */
60#define __NR_setgid 46 /* ok */
61#define __NR_getgid 47 /* ok */
62#define __NR_signal 48 /* obsolete -> sys_rt_sigaction */
63#define __NR_geteuid 49 /* ok */
64#define __NR_getegid 50 /* ok */
65#define __NR_acct 51 /* add it and then I can disable it */
66#define __NR_umount2 52 /* remove */
67#define __NR_lock 53 /* remove */
68#define __NR_ioctl 54 /* ok */
69#define __NR_fcntl 55 /* ok -> 64bit version*/
70#define __NR_mpx 56 /* remove */
71#define __NR_setpgid 57 /* ok */
72#define __NR_ulimit 58 /* remove */
73#define __NR_oldolduname 59 /* remove */
74#define __NR_umask 60 /* ok */
75#define __NR_chroot 61 /* ok */
76#define __NR_ustat 62 /* obsolete -> statfs64 */
77#define __NR_dup2 63 /* ok */
78#define __NR_getppid 64 /* ok */
79#define __NR_getpgrp 65 /* obsolete -> sys_getpgid */
80#define __NR_setsid 66 /* ok */
81#define __NR_sigaction 67 /* obsolete -> rt_sigaction */
82#define __NR_sgetmask 68 /* obsolete -> sys_rt_sigprocmask */
83#define __NR_ssetmask 69 /* obsolete ->sys_rt_sigprocmask */
84#define __NR_setreuid 70 /* ok */
85#define __NR_setregid 71 /* ok */
86#define __NR_sigsuspend 72 /* obsolete -> rt_sigsuspend */
87#define __NR_sigpending 73 /* obsolete -> sys_rt_sigpending */
88#define __NR_sethostname 74 /* ok */
89#define __NR_setrlimit 75 /* ok */
90#define __NR_getrlimit 76 /* ok Back compatible 2G limited rlimit */
91#define __NR_getrusage 77 /* ok */
92#define __NR_gettimeofday 78 /* ok */
93#define __NR_settimeofday 79 /* ok */
94#define __NR_getgroups 80 /* ok */
95#define __NR_setgroups 81 /* ok */
96#define __NR_select 82 /* obsolete -> sys_pselect7 */
97#define __NR_symlink 83 /* symlinkat */
98#define __NR_oldlstat 84 /* remove */
99#define __NR_readlink 85 /* obsolete -> sys_readlinkat */
100#define __NR_uselib 86 /* remove */
101#define __NR_swapon 87 /* ok */
102#define __NR_reboot 88 /* ok */
103#define __NR_readdir 89 /* remove ? */
104#define __NR_mmap 90 /* obsolete -> sys_mmap2 */
105#define __NR_munmap 91 /* ok - mmu and nommu */
106#define __NR_truncate 92 /* ok or truncate64 */
107#define __NR_ftruncate 93 /* ok or ftruncate64 */
108#define __NR_fchmod 94 /* ok */
109#define __NR_fchown 95 /* ok */
110#define __NR_getpriority 96 /* ok */
111#define __NR_setpriority 97 /* ok */
112#define __NR_profil 98 /* remove */
113#define __NR_statfs 99 /* ok or statfs64 */
114#define __NR_fstatfs 100 /* ok or fstatfs64 */
115#define __NR_ioperm 101 /* remove */
116#define __NR_socketcall 102 /* remove */
117#define __NR_syslog 103 /* ok */
118#define __NR_setitimer 104 /* ok */
119#define __NR_getitimer 105 /* ok */
120#define __NR_stat 106 /* remove */
121#define __NR_lstat 107 /* remove */
122#define __NR_fstat 108 /* remove */
123#define __NR_olduname 109 /* remove */
124#define __NR_iopl 110 /* remove */
125#define __NR_vhangup 111 /* ok */
126#define __NR_idle 112 /* remove */
127#define __NR_vm86old 113 /* remove */
128#define __NR_wait4 114 /* obsolete -> waitid */
129#define __NR_swapoff 115 /* ok */
130#define __NR_sysinfo 116 /* ok */
131#define __NR_ipc 117 /* remove - direct call */
132#define __NR_fsync 118 /* ok */
133#define __NR_sigreturn 119 /* obsolete -> sys_rt_sigreturn */
134#define __NR_clone 120 /* ok */
135#define __NR_setdomainname 121 /* ok */
136#define __NR_uname 122 /* remove */
137#define __NR_modify_ldt 123 /* remove */
138#define __NR_adjtimex 124 /* ok */
139#define __NR_mprotect 125 /* remove */
140#define __NR_sigprocmask 126 /* obsolete -> sys_rt_sigprocmask */
141#define __NR_create_module 127 /* remove */
142#define __NR_init_module 128 /* ok */
143#define __NR_delete_module 129 /* ok */
144#define __NR_get_kernel_syms 130 /* remove */
145#define __NR_quotactl 131 /* ok */
146#define __NR_getpgid 132 /* ok */
147#define __NR_fchdir 133 /* ok */
148#define __NR_bdflush 134 /* remove */
149#define __NR_sysfs 135 /* needed for busybox */
150#define __NR_personality 136 /* ok */
151#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
152#define __NR_setfsuid 138 /* ok */
153#define __NR_setfsgid 139 /* ok */
154#define __NR__llseek 140 /* remove only lseek */
155#define __NR_getdents 141 /* ok or getdents64 */
156#define __NR__newselect 142 /* remove */
157#define __NR_flock 143 /* ok */
158#define __NR_msync 144 /* remove */
159#define __NR_readv 145 /* ok */
160#define __NR_writev 146 /* ok */
161#define __NR_getsid 147 /* ok */
162#define __NR_fdatasync 148 /* ok */
163#define __NR__sysctl 149 /* remove */
164#define __NR_mlock 150 /* ok - nommu or mmu */
165#define __NR_munlock 151 /* ok - nommu or mmu */
166#define __NR_mlockall 152 /* ok - nommu or mmu */
167#define __NR_munlockall 153 /* ok - nommu or mmu */
168#define __NR_sched_setparam 154 /* ok */
169#define __NR_sched_getparam 155 /* ok */
170#define __NR_sched_setscheduler 156 /* ok */
171#define __NR_sched_getscheduler 157 /* ok */
172#define __NR_sched_yield 158 /* ok */
173#define __NR_sched_get_priority_max 159 /* ok */
174#define __NR_sched_get_priority_min 160 /* ok */
175#define __NR_sched_rr_get_interval 161 /* ok */
176#define __NR_nanosleep 162 /* ok */
177#define __NR_mremap 163 /* ok - nommu or mmu */
178#define __NR_setresuid 164 /* ok */
179#define __NR_getresuid 165 /* ok */
180#define __NR_vm86 166 /* remove */
181#define __NR_query_module 167 /* ok */
182#define __NR_poll 168 /* obsolete -> sys_ppoll */
183#define __NR_nfsservctl 169 /* ok */
184#define __NR_setresgid 170 /* ok */
185#define __NR_getresgid 171 /* ok */
186#define __NR_prctl 172 /* ok */
187#define __NR_rt_sigreturn 173 /* ok */
188#define __NR_rt_sigaction 174 /* ok */
189#define __NR_rt_sigprocmask 175 /* ok */
190#define __NR_rt_sigpending 176 /* ok */
191#define __NR_rt_sigtimedwait 177 /* ok */
192#define __NR_rt_sigqueueinfo 178 /* ok */
193#define __NR_rt_sigsuspend 179 /* ok */
194#define __NR_pread64 180 /* ok */
195#define __NR_pwrite64 181 /* ok */
196#define __NR_chown 182 /* obsolete -> fchownat */
197#define __NR_getcwd 183 /* ok */
198#define __NR_capget 184 /* ok */
199#define __NR_capset 185 /* ok */
200#define __NR_sigaltstack 186 /* remove */
201#define __NR_sendfile 187 /* ok -> exist 64bit version*/
202#define __NR_getpmsg 188 /* remove */
203/* remove - some people actually want streams */
204#define __NR_putpmsg 189
205/* for noMMU - group with clone -> maybe remove */
206#define __NR_vfork 190
207#define __NR_ugetrlimit 191 /* remove - SuS compliant getrlimit */
208#define __NR_mmap2 192 /* ok */
209#define __NR_truncate64 193 /* ok */
210#define __NR_ftruncate64 194 /* ok */
211#define __NR_stat64 195 /* remove _ARCH_WANT_STAT64 */
212#define __NR_lstat64 196 /* remove _ARCH_WANT_STAT64 */
213#define __NR_fstat64 197 /* remove _ARCH_WANT_STAT64 */
214#define __NR_lchown32 198 /* ok - without 32 */
215#define __NR_getuid32 199 /* ok - without 32 */
216#define __NR_getgid32 200 /* ok - without 32 */
217#define __NR_geteuid32 201 /* ok - without 32 */
218#define __NR_getegid32 202 /* ok - without 32 */
219#define __NR_setreuid32 203 /* ok - without 32 */
220#define __NR_setregid32 204 /* ok - without 32 */
221#define __NR_getgroups32 205 /* ok - without 32 */
222#define __NR_setgroups32 206 /* ok - without 32 */
223#define __NR_fchown32 207 /* ok - without 32 */
224#define __NR_setresuid32 208 /* ok - without 32 */
225#define __NR_getresuid32 209 /* ok - without 32 */
226#define __NR_setresgid32 210 /* ok - without 32 */
227#define __NR_getresgid32 211 /* ok - without 32 */
228#define __NR_chown32 212 /* ok - without 32 -obsolete -> fchownat */
229#define __NR_setuid32 213 /* ok - without 32 */
230#define __NR_setgid32 214 /* ok - without 32 */
231#define __NR_setfsuid32 215 /* ok - without 32 */
232#define __NR_setfsgid32 216 /* ok - without 32 */
233#define __NR_pivot_root 217 /* ok */
234#define __NR_mincore 218 /* ok */
235#define __NR_madvise 219 /* ok */
236#define __NR_getdents64 220 /* ok */
237#define __NR_fcntl64 221 /* ok */
238/* 223 is unused */
239#define __NR_gettid 224 /* ok */
240#define __NR_readahead 225 /* ok */
241#define __NR_setxattr 226 /* ok */
242#define __NR_lsetxattr 227 /* ok */
243#define __NR_fsetxattr 228 /* ok */
244#define __NR_getxattr 229 /* ok */
245#define __NR_lgetxattr 230 /* ok */
246#define __NR_fgetxattr 231 /* ok */
247#define __NR_listxattr 232 /* ok */
248#define __NR_llistxattr 233 /* ok */
249#define __NR_flistxattr 234 /* ok */
250#define __NR_removexattr 235 /* ok */
251#define __NR_lremovexattr 236 /* ok */
252#define __NR_fremovexattr 237 /* ok */
253#define __NR_tkill 238 /* ok */
254#define __NR_sendfile64 239 /* ok */
255#define __NR_futex 240 /* ok */
256#define __NR_sched_setaffinity 241 /* ok */
257#define __NR_sched_getaffinity 242 /* ok */
258#define __NR_set_thread_area 243 /* remove */
259#define __NR_get_thread_area 244 /* remove */
260#define __NR_io_setup 245 /* ok */
261#define __NR_io_destroy 246 /* ok */
262#define __NR_io_getevents 247 /* ok */
263#define __NR_io_submit 248 /* ok */
264#define __NR_io_cancel 249 /* ok */
265#define __NR_fadvise64 250 /* remove -> sys_fadvise64_64 */
266/* 251 is available for reuse (was briefly sys_set_zone_reclaim) */
267#define __NR_exit_group 252 /* ok */
268#define __NR_lookup_dcookie 253 /* ok */
269#define __NR_epoll_create 254 /* ok */
270#define __NR_epoll_ctl 255 /* ok */
271#define __NR_epoll_wait 256 /* obsolete -> sys_epoll_pwait */
272#define __NR_remap_file_pages 257 /* only for mmu */
273#define __NR_set_tid_address 258 /* ok */
274#define __NR_timer_create 259 /* ok */
275#define __NR_timer_settime (__NR_timer_create+1) /* 260 */ /* ok */
276#define __NR_timer_gettime (__NR_timer_create+2) /* 261 */ /* ok */
277#define __NR_timer_getoverrun (__NR_timer_create+3) /* 262 */ /* ok */
278#define __NR_timer_delete (__NR_timer_create+4) /* 263 */ /* ok */
279#define __NR_clock_settime (__NR_timer_create+5) /* 264 */ /* ok */
280#define __NR_clock_gettime (__NR_timer_create+6) /* 265 */ /* ok */
281#define __NR_clock_getres (__NR_timer_create+7) /* 266 */ /* ok */
282#define __NR_clock_nanosleep (__NR_timer_create+8) /* 267 */ /* ok */
283#define __NR_statfs64 268 /* ok */
284#define __NR_fstatfs64 269 /* ok */
285#define __NR_tgkill 270 /* ok */
286#define __NR_utimes 271 /* obsolete -> sys_futimesat */
287#define __NR_fadvise64_64 272 /* ok */
288#define __NR_vserver 273 /* ok */
289#define __NR_mbind 274 /* only for mmu */
290#define __NR_get_mempolicy 275 /* only for mmu */
291#define __NR_set_mempolicy 276 /* only for mmu */
292#define __NR_mq_open 277 /* ok */
293#define __NR_mq_unlink (__NR_mq_open+1) /* 278 */ /* ok */
294#define __NR_mq_timedsend (__NR_mq_open+2) /* 279 */ /* ok */
295#define __NR_mq_timedreceive (__NR_mq_open+3) /* 280 */ /* ok */
296#define __NR_mq_notify (__NR_mq_open+4) /* 281 */ /* ok */
297#define __NR_mq_getsetattr (__NR_mq_open+5) /* 282 */ /* ok */
298#define __NR_kexec_load 283 /* ok */
299#define __NR_waitid 284 /* ok */
300/* #define __NR_sys_setaltroot 285 */
301#define __NR_add_key 286 /* ok */
302#define __NR_request_key 287 /* ok */
303#define __NR_keyctl 288 /* ok */
304#define __NR_ioprio_set 289 /* ok */
305#define __NR_ioprio_get 290 /* ok */
306#define __NR_inotify_init 291 /* ok */
307#define __NR_inotify_add_watch 292 /* ok */
308#define __NR_inotify_rm_watch 293 /* ok */
309#define __NR_migrate_pages 294 /* mmu */
310#define __NR_openat 295 /* ok */
311#define __NR_mkdirat 296 /* ok */
312#define __NR_mknodat 297 /* ok */
313#define __NR_fchownat 298 /* ok */
314#define __NR_futimesat 299 /* obsolete -> sys_utimesat */
315#define __NR_fstatat64 300 /* stat64 */
316#define __NR_unlinkat 301 /* ok */
317#define __NR_renameat 302 /* ok */
318#define __NR_linkat 303 /* ok */
319#define __NR_symlinkat 304 /* ok */
320#define __NR_readlinkat 305 /* ok */
321#define __NR_fchmodat 306 /* ok */
322#define __NR_faccessat 307 /* ok */
323#define __NR_pselect6 308 /* obsolete -> sys_pselect7 */
324#define __NR_ppoll 309 /* ok */
325#define __NR_unshare 310 /* ok */
326#define __NR_set_robust_list 311 /* ok */
327#define __NR_get_robust_list 312 /* ok */
328#define __NR_splice 313 /* ok */
329#define __NR_sync_file_range 314 /* ok */
330#define __NR_tee 315 /* ok */
331#define __NR_vmsplice 316 /* ok */
332#define __NR_move_pages 317 /* mmu */
333#define __NR_getcpu 318 /* ok */
334#define __NR_epoll_pwait 319 /* ok */
335#define __NR_utimensat 320 /* ok */
336#define __NR_signalfd 321 /* ok */
337#define __NR_timerfd_create 322 /* ok */
338#define __NR_eventfd 323 /* ok */
339#define __NR_fallocate 324 /* ok */
340#define __NR_semtimedop 325 /* ok - semaphore group */
341#define __NR_timerfd_settime 326 /* ok */
342#define __NR_timerfd_gettime 327 /* ok */
343/* sysv ipc syscalls */
344#define __NR_semctl 328 /* ok */
345#define __NR_semget 329 /* ok */
346#define __NR_semop 330 /* ok */
347#define __NR_msgctl 331 /* ok */
348#define __NR_msgget 332 /* ok */
349#define __NR_msgrcv 333 /* ok */
350#define __NR_msgsnd 334 /* ok */
351#define __NR_shmat 335 /* ok */
352#define __NR_shmctl 336 /* ok */
353#define __NR_shmdt 337 /* ok */
354#define __NR_shmget 338 /* ok */
355
356
357#define __NR_signalfd4 339 /* new */
358#define __NR_eventfd2 340 /* new */
359#define __NR_epoll_create1 341 /* new */
360#define __NR_dup3 342 /* new */
361#define __NR_pipe2 343 /* new */
362#define __NR_inotify_init1 344 /* new */
363#define __NR_socket 345 /* new */
364#define __NR_socketpair 346 /* new */
365#define __NR_bind 347 /* new */
366#define __NR_listen 348 /* new */
367#define __NR_accept 349 /* new */
368#define __NR_connect 350 /* new */
369#define __NR_getsockname 351 /* new */
370#define __NR_getpeername 352 /* new */
371#define __NR_sendto 353 /* new */
372#define __NR_send 354 /* new */
373#define __NR_recvfrom 355 /* new */
374#define __NR_recv 356 /* new */
375#define __NR_setsockopt 357 /* new */
376#define __NR_getsockopt 358 /* new */
377#define __NR_shutdown 359 /* new */
378#define __NR_sendmsg 360 /* new */
379#define __NR_recvmsg 361 /* new */
380#define __NR_accept4 362 /* new */
381#define __NR_preadv 363 /* new */
382#define __NR_pwritev 364 /* new */
383#define __NR_rt_tgsigqueueinfo 365 /* new */
384#define __NR_perf_event_open 366 /* new */
385#define __NR_recvmmsg 367 /* new */
386#define __NR_fanotify_init 368
387#define __NR_fanotify_mark 369
388#define __NR_prlimit64 370
389#define __NR_name_to_handle_at 371
390#define __NR_open_by_handle_at 372
391#define __NR_clock_adjtime 373
392#define __NR_syncfs 374
393#define __NR_setns 375
394#define __NR_sendmmsg 376
395#define __NR_process_vm_readv 377
396#define __NR_process_vm_writev 378
397
398#define __NR_syscalls 379
399 13
400#ifdef __KERNEL__
401#ifndef __ASSEMBLY__ 14#ifndef __ASSEMBLY__
402 15
403/* #define __ARCH_WANT_OLD_READDIR */ 16/* #define __ARCH_WANT_OLD_READDIR */
@@ -438,5 +51,4 @@
438#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall"); 51#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall");
439 52
440#endif /* __ASSEMBLY__ */ 53#endif /* __ASSEMBLY__ */
441#endif /* __KERNEL__ */
442#endif /* _ASM_MICROBLAZE_UNISTD_H */ 54#endif /* _ASM_MICROBLAZE_UNISTD_H */
diff --git a/arch/microblaze/include/uapi/asm/Kbuild b/arch/microblaze/include/uapi/asm/Kbuild
index baebb3da1d44..6d7d7f4aaae8 100644
--- a/arch/microblaze/include/uapi/asm/Kbuild
+++ b/arch/microblaze/include/uapi/asm/Kbuild
@@ -1,3 +1,35 @@
1# UAPI Header export list 1# UAPI Header export list
2include include/uapi/asm-generic/Kbuild.asm 2include include/uapi/asm-generic/Kbuild.asm
3 3
4header-y += auxvec.h
5header-y += bitsperlong.h
6header-y += byteorder.h
7header-y += elf.h
8header-y += errno.h
9header-y += fcntl.h
10header-y += ioctl.h
11header-y += ioctls.h
12header-y += ipcbuf.h
13header-y += kvm_para.h
14header-y += mman.h
15header-y += msgbuf.h
16header-y += param.h
17header-y += poll.h
18header-y += posix_types.h
19header-y += ptrace.h
20header-y += resource.h
21header-y += sembuf.h
22header-y += setup.h
23header-y += shmbuf.h
24header-y += sigcontext.h
25header-y += siginfo.h
26header-y += signal.h
27header-y += socket.h
28header-y += sockios.h
29header-y += stat.h
30header-y += statfs.h
31header-y += swab.h
32header-y += termbits.h
33header-y += termios.h
34header-y += types.h
35header-y += unistd.h
diff --git a/arch/microblaze/include/asm/auxvec.h b/arch/microblaze/include/uapi/asm/auxvec.h
index 8b137891791f..8b137891791f 100644
--- a/arch/microblaze/include/asm/auxvec.h
+++ b/arch/microblaze/include/uapi/asm/auxvec.h
diff --git a/arch/microblaze/include/asm/bitsperlong.h b/arch/microblaze/include/uapi/asm/bitsperlong.h
index 6dc0bb0c13b2..6dc0bb0c13b2 100644
--- a/arch/microblaze/include/asm/bitsperlong.h
+++ b/arch/microblaze/include/uapi/asm/bitsperlong.h
diff --git a/arch/microblaze/include/asm/byteorder.h b/arch/microblaze/include/uapi/asm/byteorder.h
index 31902762a426..31902762a426 100644
--- a/arch/microblaze/include/asm/byteorder.h
+++ b/arch/microblaze/include/uapi/asm/byteorder.h
diff --git a/arch/microblaze/include/uapi/asm/elf.h b/arch/microblaze/include/uapi/asm/elf.h
new file mode 100644
index 000000000000..be1731d5e2fa
--- /dev/null
+++ b/arch/microblaze/include/uapi/asm/elf.h
@@ -0,0 +1,121 @@
1/*
2 * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2008-2009 PetaLogix
4 * Copyright (C) 2006 Atmark Techno, Inc.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#ifndef _UAPI_ASM_MICROBLAZE_ELF_H
12#define _UAPI_ASM_MICROBLAZE_ELF_H
13
14/*
15 * Note there is no "official" ELF designation for Microblaze.
16 * I've snaffled the value from the microblaze binutils source code
17 * /binutils/microblaze/include/elf/microblaze.h
18 */
19#define EM_MICROBLAZE 189
20#define EM_MICROBLAZE_OLD 0xbaab
21#define ELF_ARCH EM_MICROBLAZE
22
23/*
24 * This is used to ensure we don't load something for the wrong architecture.
25 */
26#define elf_check_arch(x) ((x)->e_machine == EM_MICROBLAZE \
27 || (x)->e_machine == EM_MICROBLAZE_OLD)
28
29/*
30 * These are used to set parameters in the core dumps.
31 */
32#define ELF_CLASS ELFCLASS32
33
34#ifndef __uClinux__
35
36/*
37 * ELF register definitions..
38 */
39
40#include <asm/ptrace.h>
41#include <asm/byteorder.h>
42
43#ifndef ELF_GREG_T
44#define ELF_GREG_T
45typedef unsigned long elf_greg_t;
46#endif
47
48#ifndef ELF_NGREG
49#define ELF_NGREG (sizeof(struct pt_regs) / sizeof(elf_greg_t))
50#endif
51
52#ifndef ELF_GREGSET_T
53#define ELF_GREGSET_T
54typedef elf_greg_t elf_gregset_t[ELF_NGREG];
55#endif
56
57#ifndef ELF_FPREGSET_T
58#define ELF_FPREGSET_T
59
60/* TBD */
61#define ELF_NFPREG 33 /* includes fsr */
62typedef unsigned long elf_fpreg_t;
63typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
64
65/* typedef struct user_fpu_struct elf_fpregset_t; */
66#endif
67
68/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
69 * use of this is to invoke "./ld.so someprog" to test out a new version of
70 * the loader. We need to make sure that it is out of the way of the program
71 * that it will "exec", and that there is sufficient room for the brk.
72 */
73
74#define ELF_ET_DYN_BASE (0x08000000)
75
76#ifdef __MICROBLAZEEL__
77#define ELF_DATA ELFDATA2LSB
78#else
79#define ELF_DATA ELFDATA2MSB
80#endif
81
82#define ELF_EXEC_PAGESIZE PAGE_SIZE
83
84
85#define ELF_CORE_COPY_REGS(_dest, _regs) \
86 memcpy((char *) &_dest, (char *) _regs, \
87 sizeof(struct pt_regs));
88
89/* This yields a mask that user programs can use to figure out what
90 * instruction set this CPU supports. This could be done in user space,
91 * but it's not easy, and we've already done it here.
92 */
93#define ELF_HWCAP (0)
94
95/* This yields a string that ld.so will use to load implementation
96 * specific libraries for optimization. This is more specific in
97 * intent than poking at uname or /proc/cpuinfo.
98
99 * For the moment, we have only optimizations for the Intel generations,
100 * but that could change...
101 */
102#define ELF_PLATFORM (NULL)
103
104/* Added _f parameter. Is this definition correct: TBD */
105#define ELF_PLAT_INIT(_r, _f) \
106do { \
107 _r->r0 = _r->r1 = _r->r2 = _r->r3 = \
108 _r->r4 = _r->r5 = _r->r6 = _r->r7 = \
109 _r->r8 = _r->r9 = _r->r10 = _r->r11 = \
110 _r->r12 = _r->r13 = _r->r14 = _r->r15 = \
111 _r->r16 = _r->r17 = _r->r18 = _r->r19 = \
112 _r->r20 = _r->r21 = _r->r22 = _r->r23 = \
113 _r->r24 = _r->r25 = _r->r26 = _r->r27 = \
114 _r->r28 = _r->r29 = _r->r30 = _r->r31 = \
115 0; \
116} while (0)
117
118
119#endif /* __uClinux__ */
120
121#endif /* _UAPI_ASM_MICROBLAZE_ELF_H */
diff --git a/arch/microblaze/include/asm/errno.h b/arch/microblaze/include/uapi/asm/errno.h
index 4c82b503d92f..4c82b503d92f 100644
--- a/arch/microblaze/include/asm/errno.h
+++ b/arch/microblaze/include/uapi/asm/errno.h
diff --git a/arch/microblaze/include/asm/fcntl.h b/arch/microblaze/include/uapi/asm/fcntl.h
index 46ab12db5739..46ab12db5739 100644
--- a/arch/microblaze/include/asm/fcntl.h
+++ b/arch/microblaze/include/uapi/asm/fcntl.h
diff --git a/arch/microblaze/include/asm/ioctl.h b/arch/microblaze/include/uapi/asm/ioctl.h
index b279fe06dfe5..b279fe06dfe5 100644
--- a/arch/microblaze/include/asm/ioctl.h
+++ b/arch/microblaze/include/uapi/asm/ioctl.h
diff --git a/arch/microblaze/include/asm/ioctls.h b/arch/microblaze/include/uapi/asm/ioctls.h
index ec34c760665e..ec34c760665e 100644
--- a/arch/microblaze/include/asm/ioctls.h
+++ b/arch/microblaze/include/uapi/asm/ioctls.h
diff --git a/arch/microblaze/include/asm/ipcbuf.h b/arch/microblaze/include/uapi/asm/ipcbuf.h
index 84c7e51cb6d0..84c7e51cb6d0 100644
--- a/arch/microblaze/include/asm/ipcbuf.h
+++ b/arch/microblaze/include/uapi/asm/ipcbuf.h
diff --git a/arch/microblaze/include/asm/kvm_para.h b/arch/microblaze/include/uapi/asm/kvm_para.h
index 14fab8f0b957..14fab8f0b957 100644
--- a/arch/microblaze/include/asm/kvm_para.h
+++ b/arch/microblaze/include/uapi/asm/kvm_para.h
diff --git a/arch/microblaze/include/asm/mman.h b/arch/microblaze/include/uapi/asm/mman.h
index 8eebf89f5ab1..8eebf89f5ab1 100644
--- a/arch/microblaze/include/asm/mman.h
+++ b/arch/microblaze/include/uapi/asm/mman.h
diff --git a/arch/microblaze/include/asm/msgbuf.h b/arch/microblaze/include/uapi/asm/msgbuf.h
index 809134c644a6..809134c644a6 100644
--- a/arch/microblaze/include/asm/msgbuf.h
+++ b/arch/microblaze/include/uapi/asm/msgbuf.h
diff --git a/arch/microblaze/include/asm/param.h b/arch/microblaze/include/uapi/asm/param.h
index 965d45427975..965d45427975 100644
--- a/arch/microblaze/include/asm/param.h
+++ b/arch/microblaze/include/uapi/asm/param.h
diff --git a/arch/microblaze/include/asm/poll.h b/arch/microblaze/include/uapi/asm/poll.h
index c98509d3149e..c98509d3149e 100644
--- a/arch/microblaze/include/asm/poll.h
+++ b/arch/microblaze/include/uapi/asm/poll.h
diff --git a/arch/microblaze/include/asm/posix_types.h b/arch/microblaze/include/uapi/asm/posix_types.h
index 0e15039673e3..0e15039673e3 100644
--- a/arch/microblaze/include/asm/posix_types.h
+++ b/arch/microblaze/include/uapi/asm/posix_types.h
diff --git a/arch/microblaze/include/uapi/asm/ptrace.h b/arch/microblaze/include/uapi/asm/ptrace.h
new file mode 100644
index 000000000000..d31238a5f946
--- /dev/null
+++ b/arch/microblaze/include/uapi/asm/ptrace.h
@@ -0,0 +1,72 @@
1/*
2 * Copyright (C) 2006 Atmark Techno, Inc.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _UAPI_ASM_MICROBLAZE_PTRACE_H
10#define _UAPI_ASM_MICROBLAZE_PTRACE_H
11
12#ifndef __ASSEMBLY__
13
14typedef unsigned long microblaze_reg_t;
15
16struct pt_regs {
17 microblaze_reg_t r0;
18 microblaze_reg_t r1;
19 microblaze_reg_t r2;
20 microblaze_reg_t r3;
21 microblaze_reg_t r4;
22 microblaze_reg_t r5;
23 microblaze_reg_t r6;
24 microblaze_reg_t r7;
25 microblaze_reg_t r8;
26 microblaze_reg_t r9;
27 microblaze_reg_t r10;
28 microblaze_reg_t r11;
29 microblaze_reg_t r12;
30 microblaze_reg_t r13;
31 microblaze_reg_t r14;
32 microblaze_reg_t r15;
33 microblaze_reg_t r16;
34 microblaze_reg_t r17;
35 microblaze_reg_t r18;
36 microblaze_reg_t r19;
37 microblaze_reg_t r20;
38 microblaze_reg_t r21;
39 microblaze_reg_t r22;
40 microblaze_reg_t r23;
41 microblaze_reg_t r24;
42 microblaze_reg_t r25;
43 microblaze_reg_t r26;
44 microblaze_reg_t r27;
45 microblaze_reg_t r28;
46 microblaze_reg_t r29;
47 microblaze_reg_t r30;
48 microblaze_reg_t r31;
49 microblaze_reg_t pc;
50 microblaze_reg_t msr;
51 microblaze_reg_t ear;
52 microblaze_reg_t esr;
53 microblaze_reg_t fsr;
54 int pt_mode;
55};
56
57#ifndef __KERNEL__
58
59/* pt_regs offsets used by gdbserver etc in ptrace syscalls */
60#define PT_GPR(n) ((n) * sizeof(microblaze_reg_t))
61#define PT_PC (32 * sizeof(microblaze_reg_t))
62#define PT_MSR (33 * sizeof(microblaze_reg_t))
63#define PT_EAR (34 * sizeof(microblaze_reg_t))
64#define PT_ESR (35 * sizeof(microblaze_reg_t))
65#define PT_FSR (36 * sizeof(microblaze_reg_t))
66#define PT_KERNEL_MODE (37 * sizeof(microblaze_reg_t))
67
68#endif /* __KERNEL */
69
70#endif /* __ASSEMBLY__ */
71
72#endif /* _UAPI_ASM_MICROBLAZE_PTRACE_H */
diff --git a/arch/microblaze/include/asm/resource.h b/arch/microblaze/include/uapi/asm/resource.h
index 04bc4db8921b..04bc4db8921b 100644
--- a/arch/microblaze/include/asm/resource.h
+++ b/arch/microblaze/include/uapi/asm/resource.h
diff --git a/arch/microblaze/include/asm/sembuf.h b/arch/microblaze/include/uapi/asm/sembuf.h
index 7673b83cfef7..7673b83cfef7 100644
--- a/arch/microblaze/include/asm/sembuf.h
+++ b/arch/microblaze/include/uapi/asm/sembuf.h
diff --git a/arch/microblaze/include/uapi/asm/setup.h b/arch/microblaze/include/uapi/asm/setup.h
new file mode 100644
index 000000000000..76bc2acee6af
--- /dev/null
+++ b/arch/microblaze/include/uapi/asm/setup.h
@@ -0,0 +1,19 @@
1/*
2 * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2007-2009 PetaLogix
4 * Copyright (C) 2006 Atmark Techno, Inc.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#ifndef _UAPI_ASM_MICROBLAZE_SETUP_H
12#define _UAPI_ASM_MICROBLAZE_SETUP_H
13
14#define COMMAND_LINE_SIZE 256
15
16# ifndef __ASSEMBLY__
17
18# endif /* __ASSEMBLY__ */
19#endif /* _UAPI_ASM_MICROBLAZE_SETUP_H */
diff --git a/arch/microblaze/include/asm/shmbuf.h b/arch/microblaze/include/uapi/asm/shmbuf.h
index 83c05fc2de38..83c05fc2de38 100644
--- a/arch/microblaze/include/asm/shmbuf.h
+++ b/arch/microblaze/include/uapi/asm/shmbuf.h
diff --git a/arch/microblaze/include/asm/sigcontext.h b/arch/microblaze/include/uapi/asm/sigcontext.h
index 55873c80c917..55873c80c917 100644
--- a/arch/microblaze/include/asm/sigcontext.h
+++ b/arch/microblaze/include/uapi/asm/sigcontext.h
diff --git a/arch/microblaze/include/asm/siginfo.h b/arch/microblaze/include/uapi/asm/siginfo.h
index 0815d29d82e5..0815d29d82e5 100644
--- a/arch/microblaze/include/asm/siginfo.h
+++ b/arch/microblaze/include/uapi/asm/siginfo.h
diff --git a/arch/microblaze/include/asm/signal.h b/arch/microblaze/include/uapi/asm/signal.h
index 7b1573ce19de..7b1573ce19de 100644
--- a/arch/microblaze/include/asm/signal.h
+++ b/arch/microblaze/include/uapi/asm/signal.h
diff --git a/arch/microblaze/include/asm/socket.h b/arch/microblaze/include/uapi/asm/socket.h
index 6b71384b9d8b..6b71384b9d8b 100644
--- a/arch/microblaze/include/asm/socket.h
+++ b/arch/microblaze/include/uapi/asm/socket.h
diff --git a/arch/microblaze/include/asm/sockios.h b/arch/microblaze/include/uapi/asm/sockios.h
index def6d4746ee7..def6d4746ee7 100644
--- a/arch/microblaze/include/asm/sockios.h
+++ b/arch/microblaze/include/uapi/asm/sockios.h
diff --git a/arch/microblaze/include/asm/stat.h b/arch/microblaze/include/uapi/asm/stat.h
index 3dc90fa92c70..3dc90fa92c70 100644
--- a/arch/microblaze/include/asm/stat.h
+++ b/arch/microblaze/include/uapi/asm/stat.h
diff --git a/arch/microblaze/include/asm/statfs.h b/arch/microblaze/include/uapi/asm/statfs.h
index 0b91fe198c20..0b91fe198c20 100644
--- a/arch/microblaze/include/asm/statfs.h
+++ b/arch/microblaze/include/uapi/asm/statfs.h
diff --git a/arch/microblaze/include/asm/swab.h b/arch/microblaze/include/uapi/asm/swab.h
index 7847e563ab66..7847e563ab66 100644
--- a/arch/microblaze/include/asm/swab.h
+++ b/arch/microblaze/include/uapi/asm/swab.h
diff --git a/arch/microblaze/include/asm/termbits.h b/arch/microblaze/include/uapi/asm/termbits.h
index 3935b106de79..3935b106de79 100644
--- a/arch/microblaze/include/asm/termbits.h
+++ b/arch/microblaze/include/uapi/asm/termbits.h
diff --git a/arch/microblaze/include/asm/termios.h b/arch/microblaze/include/uapi/asm/termios.h
index 280d78a9d966..280d78a9d966 100644
--- a/arch/microblaze/include/asm/termios.h
+++ b/arch/microblaze/include/uapi/asm/termios.h
diff --git a/arch/microblaze/include/asm/types.h b/arch/microblaze/include/uapi/asm/types.h
index b9e79bc580dd..b9e79bc580dd 100644
--- a/arch/microblaze/include/asm/types.h
+++ b/arch/microblaze/include/uapi/asm/types.h
diff --git a/arch/microblaze/include/uapi/asm/unistd.h b/arch/microblaze/include/uapi/asm/unistd.h
new file mode 100644
index 000000000000..ccb6920f3b33
--- /dev/null
+++ b/arch/microblaze/include/uapi/asm/unistd.h
@@ -0,0 +1,401 @@
1/*
2 * Copyright (C) 2007-2008 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2006 Atmark Techno, Inc.
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 */
9
10#ifndef _UAPI_ASM_MICROBLAZE_UNISTD_H
11#define _UAPI_ASM_MICROBLAZE_UNISTD_H
12
13#define __NR_restart_syscall 0 /* ok */
14#define __NR_exit 1 /* ok */
15#define __NR_fork 2 /* not for no MMU - weird */
16#define __NR_read 3 /* ok */
17#define __NR_write 4 /* ok */
18#define __NR_open 5 /* openat */
19#define __NR_close 6 /* ok */
20#define __NR_waitpid 7 /* waitid */
21#define __NR_creat 8 /* openat */
22#define __NR_link 9 /* linkat */
23#define __NR_unlink 10 /* unlinkat */
24#define __NR_execve 11 /* ok */
25#define __NR_chdir 12 /* ok */
26#define __NR_time 13 /* obsolete -> sys_gettimeofday */
27#define __NR_mknod 14 /* mknodat */
28#define __NR_chmod 15 /* fchmodat */
29#define __NR_lchown 16 /* ok */
30#define __NR_break 17 /* don't know */
31#define __NR_oldstat 18 /* remove */
32#define __NR_lseek 19 /* ok */
33#define __NR_getpid 20 /* ok */
34#define __NR_mount 21 /* ok */
35#define __NR_umount 22 /* ok */ /* use only umount2 */
36#define __NR_setuid 23 /* ok */
37#define __NR_getuid 24 /* ok */
38#define __NR_stime 25 /* obsolete -> sys_settimeofday */
39#define __NR_ptrace 26 /* ok */
40#define __NR_alarm 27 /* obsolete -> sys_setitimer */
41#define __NR_oldfstat 28 /* remove */
42#define __NR_pause 29 /* obsolete -> sys_rt_sigtimedwait */
43#define __NR_utime 30 /* obsolete -> sys_utimesat */
44#define __NR_stty 31 /* remove */
45#define __NR_gtty 32 /* remove */
46#define __NR_access 33 /* faccessat */
47/* can be implemented by sys_setpriority */
48#define __NR_nice 34
49#define __NR_ftime 35 /* remove */
50#define __NR_sync 36 /* ok */
51#define __NR_kill 37 /* ok */
52#define __NR_rename 38 /* renameat */
53#define __NR_mkdir 39 /* mkdirat */
54#define __NR_rmdir 40 /* unlinkat */
55#define __NR_dup 41 /* ok */
56#define __NR_pipe 42 /* ok */
57#define __NR_times 43 /* ok */
58#define __NR_prof 44 /* remove */
59#define __NR_brk 45 /* ok -mmu, nommu specific */
60#define __NR_setgid 46 /* ok */
61#define __NR_getgid 47 /* ok */
62#define __NR_signal 48 /* obsolete -> sys_rt_sigaction */
63#define __NR_geteuid 49 /* ok */
64#define __NR_getegid 50 /* ok */
65#define __NR_acct 51 /* add it and then I can disable it */
66#define __NR_umount2 52 /* remove */
67#define __NR_lock 53 /* remove */
68#define __NR_ioctl 54 /* ok */
69#define __NR_fcntl 55 /* ok -> 64bit version*/
70#define __NR_mpx 56 /* remove */
71#define __NR_setpgid 57 /* ok */
72#define __NR_ulimit 58 /* remove */
73#define __NR_oldolduname 59 /* remove */
74#define __NR_umask 60 /* ok */
75#define __NR_chroot 61 /* ok */
76#define __NR_ustat 62 /* obsolete -> statfs64 */
77#define __NR_dup2 63 /* ok */
78#define __NR_getppid 64 /* ok */
79#define __NR_getpgrp 65 /* obsolete -> sys_getpgid */
80#define __NR_setsid 66 /* ok */
81#define __NR_sigaction 67 /* obsolete -> rt_sigaction */
82#define __NR_sgetmask 68 /* obsolete -> sys_rt_sigprocmask */
83#define __NR_ssetmask 69 /* obsolete ->sys_rt_sigprocmask */
84#define __NR_setreuid 70 /* ok */
85#define __NR_setregid 71 /* ok */
86#define __NR_sigsuspend 72 /* obsolete -> rt_sigsuspend */
87#define __NR_sigpending 73 /* obsolete -> sys_rt_sigpending */
88#define __NR_sethostname 74 /* ok */
89#define __NR_setrlimit 75 /* ok */
90#define __NR_getrlimit 76 /* ok Back compatible 2G limited rlimit */
91#define __NR_getrusage 77 /* ok */
92#define __NR_gettimeofday 78 /* ok */
93#define __NR_settimeofday 79 /* ok */
94#define __NR_getgroups 80 /* ok */
95#define __NR_setgroups 81 /* ok */
96#define __NR_select 82 /* obsolete -> sys_pselect7 */
97#define __NR_symlink 83 /* symlinkat */
98#define __NR_oldlstat 84 /* remove */
99#define __NR_readlink 85 /* obsolete -> sys_readlinkat */
100#define __NR_uselib 86 /* remove */
101#define __NR_swapon 87 /* ok */
102#define __NR_reboot 88 /* ok */
103#define __NR_readdir 89 /* remove ? */
104#define __NR_mmap 90 /* obsolete -> sys_mmap2 */
105#define __NR_munmap 91 /* ok - mmu and nommu */
106#define __NR_truncate 92 /* ok or truncate64 */
107#define __NR_ftruncate 93 /* ok or ftruncate64 */
108#define __NR_fchmod 94 /* ok */
109#define __NR_fchown 95 /* ok */
110#define __NR_getpriority 96 /* ok */
111#define __NR_setpriority 97 /* ok */
112#define __NR_profil 98 /* remove */
113#define __NR_statfs 99 /* ok or statfs64 */
114#define __NR_fstatfs 100 /* ok or fstatfs64 */
115#define __NR_ioperm 101 /* remove */
116#define __NR_socketcall 102 /* remove */
117#define __NR_syslog 103 /* ok */
118#define __NR_setitimer 104 /* ok */
119#define __NR_getitimer 105 /* ok */
120#define __NR_stat 106 /* remove */
121#define __NR_lstat 107 /* remove */
122#define __NR_fstat 108 /* remove */
123#define __NR_olduname 109 /* remove */
124#define __NR_iopl 110 /* remove */
125#define __NR_vhangup 111 /* ok */
126#define __NR_idle 112 /* remove */
127#define __NR_vm86old 113 /* remove */
128#define __NR_wait4 114 /* obsolete -> waitid */
129#define __NR_swapoff 115 /* ok */
130#define __NR_sysinfo 116 /* ok */
131#define __NR_ipc 117 /* remove - direct call */
132#define __NR_fsync 118 /* ok */
133#define __NR_sigreturn 119 /* obsolete -> sys_rt_sigreturn */
134#define __NR_clone 120 /* ok */
135#define __NR_setdomainname 121 /* ok */
136#define __NR_uname 122 /* remove */
137#define __NR_modify_ldt 123 /* remove */
138#define __NR_adjtimex 124 /* ok */
139#define __NR_mprotect 125 /* remove */
140#define __NR_sigprocmask 126 /* obsolete -> sys_rt_sigprocmask */
141#define __NR_create_module 127 /* remove */
142#define __NR_init_module 128 /* ok */
143#define __NR_delete_module 129 /* ok */
144#define __NR_get_kernel_syms 130 /* remove */
145#define __NR_quotactl 131 /* ok */
146#define __NR_getpgid 132 /* ok */
147#define __NR_fchdir 133 /* ok */
148#define __NR_bdflush 134 /* remove */
149#define __NR_sysfs 135 /* needed for busybox */
150#define __NR_personality 136 /* ok */
151#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
152#define __NR_setfsuid 138 /* ok */
153#define __NR_setfsgid 139 /* ok */
154#define __NR__llseek 140 /* remove only lseek */
155#define __NR_getdents 141 /* ok or getdents64 */
156#define __NR__newselect 142 /* remove */
157#define __NR_flock 143 /* ok */
158#define __NR_msync 144 /* remove */
159#define __NR_readv 145 /* ok */
160#define __NR_writev 146 /* ok */
161#define __NR_getsid 147 /* ok */
162#define __NR_fdatasync 148 /* ok */
163#define __NR__sysctl 149 /* remove */
164#define __NR_mlock 150 /* ok - nommu or mmu */
165#define __NR_munlock 151 /* ok - nommu or mmu */
166#define __NR_mlockall 152 /* ok - nommu or mmu */
167#define __NR_munlockall 153 /* ok - nommu or mmu */
168#define __NR_sched_setparam 154 /* ok */
169#define __NR_sched_getparam 155 /* ok */
170#define __NR_sched_setscheduler 156 /* ok */
171#define __NR_sched_getscheduler 157 /* ok */
172#define __NR_sched_yield 158 /* ok */
173#define __NR_sched_get_priority_max 159 /* ok */
174#define __NR_sched_get_priority_min 160 /* ok */
175#define __NR_sched_rr_get_interval 161 /* ok */
176#define __NR_nanosleep 162 /* ok */
177#define __NR_mremap 163 /* ok - nommu or mmu */
178#define __NR_setresuid 164 /* ok */
179#define __NR_getresuid 165 /* ok */
180#define __NR_vm86 166 /* remove */
181#define __NR_query_module 167 /* ok */
182#define __NR_poll 168 /* obsolete -> sys_ppoll */
183#define __NR_nfsservctl 169 /* ok */
184#define __NR_setresgid 170 /* ok */
185#define __NR_getresgid 171 /* ok */
186#define __NR_prctl 172 /* ok */
187#define __NR_rt_sigreturn 173 /* ok */
188#define __NR_rt_sigaction 174 /* ok */
189#define __NR_rt_sigprocmask 175 /* ok */
190#define __NR_rt_sigpending 176 /* ok */
191#define __NR_rt_sigtimedwait 177 /* ok */
192#define __NR_rt_sigqueueinfo 178 /* ok */
193#define __NR_rt_sigsuspend 179 /* ok */
194#define __NR_pread64 180 /* ok */
195#define __NR_pwrite64 181 /* ok */
196#define __NR_chown 182 /* obsolete -> fchownat */
197#define __NR_getcwd 183 /* ok */
198#define __NR_capget 184 /* ok */
199#define __NR_capset 185 /* ok */
200#define __NR_sigaltstack 186 /* remove */
201#define __NR_sendfile 187 /* ok -> exist 64bit version*/
202#define __NR_getpmsg 188 /* remove */
203/* remove - some people actually want streams */
204#define __NR_putpmsg 189
205/* for noMMU - group with clone -> maybe remove */
206#define __NR_vfork 190
207#define __NR_ugetrlimit 191 /* remove - SuS compliant getrlimit */
208#define __NR_mmap2 192 /* ok */
209#define __NR_truncate64 193 /* ok */
210#define __NR_ftruncate64 194 /* ok */
211#define __NR_stat64 195 /* remove _ARCH_WANT_STAT64 */
212#define __NR_lstat64 196 /* remove _ARCH_WANT_STAT64 */
213#define __NR_fstat64 197 /* remove _ARCH_WANT_STAT64 */
214#define __NR_lchown32 198 /* ok - without 32 */
215#define __NR_getuid32 199 /* ok - without 32 */
216#define __NR_getgid32 200 /* ok - without 32 */
217#define __NR_geteuid32 201 /* ok - without 32 */
218#define __NR_getegid32 202 /* ok - without 32 */
219#define __NR_setreuid32 203 /* ok - without 32 */
220#define __NR_setregid32 204 /* ok - without 32 */
221#define __NR_getgroups32 205 /* ok - without 32 */
222#define __NR_setgroups32 206 /* ok - without 32 */
223#define __NR_fchown32 207 /* ok - without 32 */
224#define __NR_setresuid32 208 /* ok - without 32 */
225#define __NR_getresuid32 209 /* ok - without 32 */
226#define __NR_setresgid32 210 /* ok - without 32 */
227#define __NR_getresgid32 211 /* ok - without 32 */
228#define __NR_chown32 212 /* ok - without 32 -obsolete -> fchownat */
229#define __NR_setuid32 213 /* ok - without 32 */
230#define __NR_setgid32 214 /* ok - without 32 */
231#define __NR_setfsuid32 215 /* ok - without 32 */
232#define __NR_setfsgid32 216 /* ok - without 32 */
233#define __NR_pivot_root 217 /* ok */
234#define __NR_mincore 218 /* ok */
235#define __NR_madvise 219 /* ok */
236#define __NR_getdents64 220 /* ok */
237#define __NR_fcntl64 221 /* ok */
238/* 223 is unused */
239#define __NR_gettid 224 /* ok */
240#define __NR_readahead 225 /* ok */
241#define __NR_setxattr 226 /* ok */
242#define __NR_lsetxattr 227 /* ok */
243#define __NR_fsetxattr 228 /* ok */
244#define __NR_getxattr 229 /* ok */
245#define __NR_lgetxattr 230 /* ok */
246#define __NR_fgetxattr 231 /* ok */
247#define __NR_listxattr 232 /* ok */
248#define __NR_llistxattr 233 /* ok */
249#define __NR_flistxattr 234 /* ok */
250#define __NR_removexattr 235 /* ok */
251#define __NR_lremovexattr 236 /* ok */
252#define __NR_fremovexattr 237 /* ok */
253#define __NR_tkill 238 /* ok */
254#define __NR_sendfile64 239 /* ok */
255#define __NR_futex 240 /* ok */
256#define __NR_sched_setaffinity 241 /* ok */
257#define __NR_sched_getaffinity 242 /* ok */
258#define __NR_set_thread_area 243 /* remove */
259#define __NR_get_thread_area 244 /* remove */
260#define __NR_io_setup 245 /* ok */
261#define __NR_io_destroy 246 /* ok */
262#define __NR_io_getevents 247 /* ok */
263#define __NR_io_submit 248 /* ok */
264#define __NR_io_cancel 249 /* ok */
265#define __NR_fadvise64 250 /* remove -> sys_fadvise64_64 */
266/* 251 is available for reuse (was briefly sys_set_zone_reclaim) */
267#define __NR_exit_group 252 /* ok */
268#define __NR_lookup_dcookie 253 /* ok */
269#define __NR_epoll_create 254 /* ok */
270#define __NR_epoll_ctl 255 /* ok */
271#define __NR_epoll_wait 256 /* obsolete -> sys_epoll_pwait */
272#define __NR_remap_file_pages 257 /* only for mmu */
273#define __NR_set_tid_address 258 /* ok */
274#define __NR_timer_create 259 /* ok */
275#define __NR_timer_settime (__NR_timer_create+1) /* 260 */ /* ok */
276#define __NR_timer_gettime (__NR_timer_create+2) /* 261 */ /* ok */
277#define __NR_timer_getoverrun (__NR_timer_create+3) /* 262 */ /* ok */
278#define __NR_timer_delete (__NR_timer_create+4) /* 263 */ /* ok */
279#define __NR_clock_settime (__NR_timer_create+5) /* 264 */ /* ok */
280#define __NR_clock_gettime (__NR_timer_create+6) /* 265 */ /* ok */
281#define __NR_clock_getres (__NR_timer_create+7) /* 266 */ /* ok */
282#define __NR_clock_nanosleep (__NR_timer_create+8) /* 267 */ /* ok */
283#define __NR_statfs64 268 /* ok */
284#define __NR_fstatfs64 269 /* ok */
285#define __NR_tgkill 270 /* ok */
286#define __NR_utimes 271 /* obsolete -> sys_futimesat */
287#define __NR_fadvise64_64 272 /* ok */
288#define __NR_vserver 273 /* ok */
289#define __NR_mbind 274 /* only for mmu */
290#define __NR_get_mempolicy 275 /* only for mmu */
291#define __NR_set_mempolicy 276 /* only for mmu */
292#define __NR_mq_open 277 /* ok */
293#define __NR_mq_unlink (__NR_mq_open+1) /* 278 */ /* ok */
294#define __NR_mq_timedsend (__NR_mq_open+2) /* 279 */ /* ok */
295#define __NR_mq_timedreceive (__NR_mq_open+3) /* 280 */ /* ok */
296#define __NR_mq_notify (__NR_mq_open+4) /* 281 */ /* ok */
297#define __NR_mq_getsetattr (__NR_mq_open+5) /* 282 */ /* ok */
298#define __NR_kexec_load 283 /* ok */
299#define __NR_waitid 284 /* ok */
300/* #define __NR_sys_setaltroot 285 */
301#define __NR_add_key 286 /* ok */
302#define __NR_request_key 287 /* ok */
303#define __NR_keyctl 288 /* ok */
304#define __NR_ioprio_set 289 /* ok */
305#define __NR_ioprio_get 290 /* ok */
306#define __NR_inotify_init 291 /* ok */
307#define __NR_inotify_add_watch 292 /* ok */
308#define __NR_inotify_rm_watch 293 /* ok */
309#define __NR_migrate_pages 294 /* mmu */
310#define __NR_openat 295 /* ok */
311#define __NR_mkdirat 296 /* ok */
312#define __NR_mknodat 297 /* ok */
313#define __NR_fchownat 298 /* ok */
314#define __NR_futimesat 299 /* obsolete -> sys_utimesat */
315#define __NR_fstatat64 300 /* stat64 */
316#define __NR_unlinkat 301 /* ok */
317#define __NR_renameat 302 /* ok */
318#define __NR_linkat 303 /* ok */
319#define __NR_symlinkat 304 /* ok */
320#define __NR_readlinkat 305 /* ok */
321#define __NR_fchmodat 306 /* ok */
322#define __NR_faccessat 307 /* ok */
323#define __NR_pselect6 308 /* obsolete -> sys_pselect7 */
324#define __NR_ppoll 309 /* ok */
325#define __NR_unshare 310 /* ok */
326#define __NR_set_robust_list 311 /* ok */
327#define __NR_get_robust_list 312 /* ok */
328#define __NR_splice 313 /* ok */
329#define __NR_sync_file_range 314 /* ok */
330#define __NR_tee 315 /* ok */
331#define __NR_vmsplice 316 /* ok */
332#define __NR_move_pages 317 /* mmu */
333#define __NR_getcpu 318 /* ok */
334#define __NR_epoll_pwait 319 /* ok */
335#define __NR_utimensat 320 /* ok */
336#define __NR_signalfd 321 /* ok */
337#define __NR_timerfd_create 322 /* ok */
338#define __NR_eventfd 323 /* ok */
339#define __NR_fallocate 324 /* ok */
340#define __NR_semtimedop 325 /* ok - semaphore group */
341#define __NR_timerfd_settime 326 /* ok */
342#define __NR_timerfd_gettime 327 /* ok */
343/* sysv ipc syscalls */
344#define __NR_semctl 328 /* ok */
345#define __NR_semget 329 /* ok */
346#define __NR_semop 330 /* ok */
347#define __NR_msgctl 331 /* ok */
348#define __NR_msgget 332 /* ok */
349#define __NR_msgrcv 333 /* ok */
350#define __NR_msgsnd 334 /* ok */
351#define __NR_shmat 335 /* ok */
352#define __NR_shmctl 336 /* ok */
353#define __NR_shmdt 337 /* ok */
354#define __NR_shmget 338 /* ok */
355
356
357#define __NR_signalfd4 339 /* new */
358#define __NR_eventfd2 340 /* new */
359#define __NR_epoll_create1 341 /* new */
360#define __NR_dup3 342 /* new */
361#define __NR_pipe2 343 /* new */
362#define __NR_inotify_init1 344 /* new */
363#define __NR_socket 345 /* new */
364#define __NR_socketpair 346 /* new */
365#define __NR_bind 347 /* new */
366#define __NR_listen 348 /* new */
367#define __NR_accept 349 /* new */
368#define __NR_connect 350 /* new */
369#define __NR_getsockname 351 /* new */
370#define __NR_getpeername 352 /* new */
371#define __NR_sendto 353 /* new */
372#define __NR_send 354 /* new */
373#define __NR_recvfrom 355 /* new */
374#define __NR_recv 356 /* new */
375#define __NR_setsockopt 357 /* new */
376#define __NR_getsockopt 358 /* new */
377#define __NR_shutdown 359 /* new */
378#define __NR_sendmsg 360 /* new */
379#define __NR_recvmsg 361 /* new */
380#define __NR_accept4 362 /* new */
381#define __NR_preadv 363 /* new */
382#define __NR_pwritev 364 /* new */
383#define __NR_rt_tgsigqueueinfo 365 /* new */
384#define __NR_perf_event_open 366 /* new */
385#define __NR_recvmmsg 367 /* new */
386#define __NR_fanotify_init 368
387#define __NR_fanotify_mark 369
388#define __NR_prlimit64 370
389#define __NR_name_to_handle_at 371
390#define __NR_open_by_handle_at 372
391#define __NR_clock_adjtime 373
392#define __NR_syncfs 374
393#define __NR_setns 375
394#define __NR_sendmmsg 376
395#define __NR_process_vm_readv 377
396#define __NR_process_vm_writev 378
397#define __NR_kcmp 379
398
399#define __NR_syscalls 380
400
401#endif /* _UAPI_ASM_MICROBLAZE_UNISTD_H */
diff --git a/arch/microblaze/kernel/entry-nommu.S b/arch/microblaze/kernel/entry-nommu.S
index cb0327f204ab..70da83a49670 100644
--- a/arch/microblaze/kernel/entry-nommu.S
+++ b/arch/microblaze/kernel/entry-nommu.S
@@ -465,7 +465,6 @@ ENTRY(_switch_to)
465 465
466ENTRY(ret_from_fork) 466ENTRY(ret_from_fork)
467 addk r5, r0, r3 467 addk r5, r0, r3
468 addk r6, r0, r1
469 brlid r15, schedule_tail 468 brlid r15, schedule_tail
470 nop 469 nop
471 swi r31, r1, PT_R31 /* save r31 in user context. */ 470 swi r31, r1, PT_R31 /* save r31 in user context. */
diff --git a/arch/microblaze/kernel/intc.c b/arch/microblaze/kernel/intc.c
index 6c54d4dcdec3..7a1a8d4354fe 100644
--- a/arch/microblaze/kernel/intc.c
+++ b/arch/microblaze/kernel/intc.c
@@ -44,7 +44,6 @@ static void intc_enable_or_unmask(struct irq_data *d)
44 unsigned long mask = 1 << d->hwirq; 44 unsigned long mask = 1 << d->hwirq;
45 45
46 pr_debug("enable_or_unmask: %ld\n", d->hwirq); 46 pr_debug("enable_or_unmask: %ld\n", d->hwirq);
47 out_be32(INTC_BASE + SIE, mask);
48 47
49 /* ack level irqs because they can't be acked during 48 /* ack level irqs because they can't be acked during
50 * ack function since the handle_level_irq function 49 * ack function since the handle_level_irq function
@@ -52,6 +51,8 @@ static void intc_enable_or_unmask(struct irq_data *d)
52 */ 51 */
53 if (irqd_is_level_type(d)) 52 if (irqd_is_level_type(d))
54 out_be32(INTC_BASE + IAR, mask); 53 out_be32(INTC_BASE + IAR, mask);
54
55 out_be32(INTC_BASE + SIE, mask);
55} 56}
56 57
57static void intc_disable_or_mask(struct irq_data *d) 58static void intc_disable_or_mask(struct irq_data *d)
@@ -98,7 +99,7 @@ unsigned int get_irq(void)
98 return irq; 99 return irq;
99} 100}
100 101
101int xintc_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw) 102static int xintc_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw)
102{ 103{
103 u32 intr_mask = (u32)d->host_data; 104 u32 intr_mask = (u32)d->host_data;
104 105
diff --git a/arch/microblaze/kernel/process.c b/arch/microblaze/kernel/process.c
index 40823fd1db0b..a5b74f729e5b 100644
--- a/arch/microblaze/kernel/process.c
+++ b/arch/microblaze/kernel/process.c
@@ -162,7 +162,6 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
162 * excepting for VM and UMS 162 * excepting for VM and UMS
163 * don't touch UMS , CARRY and cache bits 163 * don't touch UMS , CARRY and cache bits
164 * right now MSR is a copy of parent one */ 164 * right now MSR is a copy of parent one */
165 childregs->msr |= MSR_BIP;
166 childregs->msr &= ~MSR_EIP; 165 childregs->msr &= ~MSR_EIP;
167 childregs->msr |= MSR_IE; 166 childregs->msr |= MSR_IE;
168 childregs->msr &= ~MSR_VM; 167 childregs->msr &= ~MSR_VM;
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 4a764ccb9f26..a744e3f18883 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -52,9 +52,9 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
52} 52}
53 53
54#ifdef CONFIG_EARLY_PRINTK 54#ifdef CONFIG_EARLY_PRINTK
55char *stdout; 55static char *stdout;
56 56
57int __init early_init_dt_scan_chosen_serial(unsigned long node, 57static int __init early_init_dt_scan_chosen_serial(unsigned long node,
58 const char *uname, int depth, void *data) 58 const char *uname, int depth, void *data)
59{ 59{
60 unsigned long l; 60 unsigned long l;
diff --git a/arch/microblaze/kernel/signal.c b/arch/microblaze/kernel/signal.c
index 3903e3d11f5a..ac3d0a0f4814 100644
--- a/arch/microblaze/kernel/signal.c
+++ b/arch/microblaze/kernel/signal.c
@@ -354,7 +354,7 @@ static void do_signal(struct pt_regs *regs, int in_syscall)
354 restore_saved_sigmask(); 354 restore_saved_sigmask();
355} 355}
356 356
357void do_notify_resume(struct pt_regs *regs, int in_syscall) 357asmlinkage void do_notify_resume(struct pt_regs *regs, int in_syscall)
358{ 358{
359 /* 359 /*
360 * We want the common case to go fast, which 360 * We want the common case to go fast, which
diff --git a/arch/microblaze/kernel/syscall_table.S b/arch/microblaze/kernel/syscall_table.S
index ff6431e54680..1cbace29b5e2 100644
--- a/arch/microblaze/kernel/syscall_table.S
+++ b/arch/microblaze/kernel/syscall_table.S
@@ -379,3 +379,4 @@ ENTRY(sys_call_table)
379 .long sys_sendmmsg 379 .long sys_sendmmsg
380 .long sys_process_vm_readv 380 .long sys_process_vm_readv
381 .long sys_process_vm_writev 381 .long sys_process_vm_writev
382 .long sys_kcmp
diff --git a/arch/microblaze/lib/libgcc.h b/arch/microblaze/lib/libgcc.h
index 05909d58e2fe..ab077ef7e14b 100644
--- a/arch/microblaze/lib/libgcc.h
+++ b/arch/microblaze/lib/libgcc.h
@@ -22,4 +22,11 @@ typedef union {
22 long long ll; 22 long long ll;
23} DWunion; 23} DWunion;
24 24
25extern long long __ashldi3(long long u, word_type b);
26extern long long __ashrdi3(long long u, word_type b);
27extern word_type __cmpdi2(long long a, long long b);
28extern long long __lshrdi3(long long u, word_type b);
29extern long long __muldi3(long long u, long long v);
30extern word_type __ucmpdi2(unsigned long long a, unsigned long long b);
31
25#endif /* __ASM_LIBGCC_H */ 32#endif /* __ASM_LIBGCC_H */
diff --git a/arch/microblaze/lib/muldi3.c b/arch/microblaze/lib/muldi3.c
index 0585bccb7fad..d3659244ab6f 100644
--- a/arch/microblaze/lib/muldi3.c
+++ b/arch/microblaze/lib/muldi3.c
@@ -2,32 +2,28 @@
2 2
3#include "libgcc.h" 3#include "libgcc.h"
4 4
5#define DWtype long long
6#define UWtype unsigned long
7#define UHWtype unsigned short
8
9#define W_TYPE_SIZE 32 5#define W_TYPE_SIZE 32
10 6
11#define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2)) 7#define __ll_B ((unsigned long) 1 << (W_TYPE_SIZE / 2))
12#define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1)) 8#define __ll_lowpart(t) ((unsigned long) (t) & (__ll_B - 1))
13#define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2)) 9#define __ll_highpart(t) ((unsigned long) (t) >> (W_TYPE_SIZE / 2))
14 10
15/* If we still don't have umul_ppmm, define it using plain C. */ 11/* If we still don't have umul_ppmm, define it using plain C. */
16#if !defined(umul_ppmm) 12#if !defined(umul_ppmm)
17#define umul_ppmm(w1, w0, u, v) \ 13#define umul_ppmm(w1, w0, u, v) \
18 do { \ 14 do { \
19 UWtype __x0, __x1, __x2, __x3; \ 15 unsigned long __x0, __x1, __x2, __x3; \
20 UHWtype __ul, __vl, __uh, __vh; \ 16 unsigned short __ul, __vl, __uh, __vh; \
21 \ 17 \
22 __ul = __ll_lowpart(u); \ 18 __ul = __ll_lowpart(u); \
23 __uh = __ll_highpart(u); \ 19 __uh = __ll_highpart(u); \
24 __vl = __ll_lowpart(v); \ 20 __vl = __ll_lowpart(v); \
25 __vh = __ll_highpart(v); \ 21 __vh = __ll_highpart(v); \
26 \ 22 \
27 __x0 = (UWtype) __ul * __vl; \ 23 __x0 = (unsigned long) __ul * __vl; \
28 __x1 = (UWtype) __ul * __vh; \ 24 __x1 = (unsigned long) __ul * __vh; \
29 __x2 = (UWtype) __uh * __vl; \ 25 __x2 = (unsigned long) __uh * __vl; \
30 __x3 = (UWtype) __uh * __vh; \ 26 __x3 = (unsigned long) __uh * __vh; \
31 \ 27 \
32 __x1 += __ll_highpart(__x0); /* this can't give carry */\ 28 __x1 += __ll_highpart(__x0); /* this can't give carry */\
33 __x1 += __x2; /* but this indeed can */ \ 29 __x1 += __x2; /* but this indeed can */ \
@@ -47,14 +43,14 @@
47 }) 43 })
48#endif 44#endif
49 45
50DWtype __muldi3(DWtype u, DWtype v) 46long long __muldi3(long long u, long long v)
51{ 47{
52 const DWunion uu = {.ll = u}; 48 const DWunion uu = {.ll = u};
53 const DWunion vv = {.ll = v}; 49 const DWunion vv = {.ll = v};
54 DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)}; 50 DWunion w = {.ll = __umulsidi3(uu.s.low, vv.s.low)};
55 51
56 w.s.high += ((UWtype) uu.s.low * (UWtype) vv.s.high 52 w.s.high += ((unsigned long) uu.s.low * (unsigned long) vv.s.high
57 + (UWtype) uu.s.high * (UWtype) vv.s.low); 53 + (unsigned long) uu.s.high * (unsigned long) vv.s.low);
58 54
59 return w.ll; 55 return w.ll;
60} 56}
diff --git a/arch/sh/boards/mach-ap325rxa/setup.c b/arch/sh/boards/mach-ap325rxa/setup.c
index 9e963c1d1447..5620e33c18a0 100644
--- a/arch/sh/boards/mach-ap325rxa/setup.c
+++ b/arch/sh/boards/mach-ap325rxa/setup.c
@@ -179,11 +179,6 @@ static int ap320_wvga_set_brightness(int brightness)
179 return 0; 179 return 0;
180} 180}
181 181
182static int ap320_wvga_get_brightness(void)
183{
184 return gpio_get_value(GPIO_PTS3);
185}
186
187static void ap320_wvga_power_on(void) 182static void ap320_wvga_power_on(void)
188{ 183{
189 msleep(100); 184 msleep(100);
@@ -232,7 +227,6 @@ static struct sh_mobile_lcdc_info lcdc_info = {
232 .name = "sh_mobile_lcdc_bl", 227 .name = "sh_mobile_lcdc_bl",
233 .max_brightness = 1, 228 .max_brightness = 1,
234 .set_brightness = ap320_wvga_set_brightness, 229 .set_brightness = ap320_wvga_set_brightness,
235 .get_brightness = ap320_wvga_get_brightness,
236 }, 230 },
237 } 231 }
238}; 232};
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index 64559e8af14b..3fede4556c91 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -329,11 +329,6 @@ static int ecovec24_set_brightness(int brightness)
329 return 0; 329 return 0;
330} 330}
331 331
332static int ecovec24_get_brightness(void)
333{
334 return gpio_get_value(GPIO_PTR1);
335}
336
337static struct sh_mobile_lcdc_info lcdc_info = { 332static struct sh_mobile_lcdc_info lcdc_info = {
338 .ch[0] = { 333 .ch[0] = {
339 .interface_type = RGB18, 334 .interface_type = RGB18,
@@ -347,7 +342,6 @@ static struct sh_mobile_lcdc_info lcdc_info = {
347 .name = "sh_mobile_lcdc_bl", 342 .name = "sh_mobile_lcdc_bl",
348 .max_brightness = 1, 343 .max_brightness = 1,
349 .set_brightness = ecovec24_set_brightness, 344 .set_brightness = ecovec24_set_brightness,
350 .get_brightness = ecovec24_get_brightness,
351 }, 345 },
352 } 346 }
353}; 347};
diff --git a/arch/sh/boards/mach-kfr2r09/lcd_wqvga.c b/arch/sh/boards/mach-kfr2r09/lcd_wqvga.c
index c148b36ecb65..c62050332629 100644
--- a/arch/sh/boards/mach-kfr2r09/lcd_wqvga.c
+++ b/arch/sh/boards/mach-kfr2r09/lcd_wqvga.c
@@ -283,7 +283,7 @@ void kfr2r09_lcd_start(void *sohandle, struct sh_mobile_lcdc_sys_bus_ops *so)
283#define MAIN_MLED4 0x40 283#define MAIN_MLED4 0x40
284#define MAIN_MSW 0x80 284#define MAIN_MSW 0x80
285 285
286static int kfr2r09_lcd_backlight(int on) 286int kfr2r09_lcd_set_brightness(int brightness)
287{ 287{
288 struct i2c_adapter *a; 288 struct i2c_adapter *a;
289 struct i2c_msg msg; 289 struct i2c_msg msg;
@@ -295,7 +295,7 @@ static int kfr2r09_lcd_backlight(int on)
295 return -ENODEV; 295 return -ENODEV;
296 296
297 buf[0] = 0x00; 297 buf[0] = 0x00;
298 if (on) 298 if (brightness)
299 buf[1] = CTRL_CPSW | CTRL_C10 | CTRL_CKSW; 299 buf[1] = CTRL_CPSW | CTRL_C10 | CTRL_CKSW;
300 else 300 else
301 buf[1] = 0; 301 buf[1] = 0;
@@ -309,7 +309,7 @@ static int kfr2r09_lcd_backlight(int on)
309 return -ENODEV; 309 return -ENODEV;
310 310
311 buf[0] = 0x01; 311 buf[0] = 0x01;
312 if (on) 312 if (brightness)
313 buf[1] = MAIN_MSW | MAIN_MLED4 | 0x0c; 313 buf[1] = MAIN_MSW | MAIN_MLED4 | 0x0c;
314 else 314 else
315 buf[1] = 0; 315 buf[1] = 0;
@@ -324,13 +324,3 @@ static int kfr2r09_lcd_backlight(int on)
324 324
325 return 0; 325 return 0;
326} 326}
327
328void kfr2r09_lcd_on(void)
329{
330 kfr2r09_lcd_backlight(1);
331}
332
333void kfr2r09_lcd_off(void)
334{
335 kfr2r09_lcd_backlight(0);
336}
diff --git a/arch/sh/boards/mach-kfr2r09/setup.c b/arch/sh/boards/mach-kfr2r09/setup.c
index f2a4304fbe23..ab502f12ef57 100644
--- a/arch/sh/boards/mach-kfr2r09/setup.c
+++ b/arch/sh/boards/mach-kfr2r09/setup.c
@@ -158,8 +158,11 @@ static struct sh_mobile_lcdc_info kfr2r09_sh_lcdc_info = {
158 .height = 58, 158 .height = 58,
159 .setup_sys = kfr2r09_lcd_setup, 159 .setup_sys = kfr2r09_lcd_setup,
160 .start_transfer = kfr2r09_lcd_start, 160 .start_transfer = kfr2r09_lcd_start,
161 .display_on = kfr2r09_lcd_on, 161 },
162 .display_off = kfr2r09_lcd_off, 162 .bl_info = {
163 .name = "sh_mobile_lcdc_bl",
164 .max_brightness = 1,
165 .set_brightness = kfr2r09_lcd_set_brightness,
163 }, 166 },
164 .sys_bus_cfg = { 167 .sys_bus_cfg = {
165 .ldmt2r = 0x07010904, 168 .ldmt2r = 0x07010904,
diff --git a/arch/sh/include/mach-kfr2r09/mach/kfr2r09.h b/arch/sh/include/mach-kfr2r09/mach/kfr2r09.h
index ba3d93d333f8..c20c9e5f5eab 100644
--- a/arch/sh/include/mach-kfr2r09/mach/kfr2r09.h
+++ b/arch/sh/include/mach-kfr2r09/mach/kfr2r09.h
@@ -4,15 +4,13 @@
4#include <video/sh_mobile_lcdc.h> 4#include <video/sh_mobile_lcdc.h>
5 5
6#if defined(CONFIG_FB_SH_MOBILE_LCDC) || defined(CONFIG_FB_SH_MOBILE_LCDC_MODULE) 6#if defined(CONFIG_FB_SH_MOBILE_LCDC) || defined(CONFIG_FB_SH_MOBILE_LCDC_MODULE)
7void kfr2r09_lcd_on(void); 7int kfr2r09_lcd_set_brightness(int brightness);
8void kfr2r09_lcd_off(void);
9int kfr2r09_lcd_setup(void *sys_ops_handle, 8int kfr2r09_lcd_setup(void *sys_ops_handle,
10 struct sh_mobile_lcdc_sys_bus_ops *sys_ops); 9 struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
11void kfr2r09_lcd_start(void *sys_ops_handle, 10void kfr2r09_lcd_start(void *sys_ops_handle,
12 struct sh_mobile_lcdc_sys_bus_ops *sys_ops); 11 struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
13#else 12#else
14static void kfr2r09_lcd_on(void) {} 13static int kfr2r09_lcd_set_brightness(int brightness) {}
15static void kfr2r09_lcd_off(void) {}
16static int kfr2r09_lcd_setup(void *sys_ops_handle, 14static int kfr2r09_lcd_setup(void *sys_ops_handle,
17 struct sh_mobile_lcdc_sys_bus_ops *sys_ops) 15 struct sh_mobile_lcdc_sys_bus_ops *sys_ops)
18{ 16{
diff --git a/arch/sh/mm/Kconfig b/arch/sh/mm/Kconfig
index cb8f9920f4dd..0f7c852f355c 100644
--- a/arch/sh/mm/Kconfig
+++ b/arch/sh/mm/Kconfig
@@ -111,6 +111,7 @@ config VSYSCALL
111config NUMA 111config NUMA
112 bool "Non Uniform Memory Access (NUMA) Support" 112 bool "Non Uniform Memory Access (NUMA) Support"
113 depends on MMU && SYS_SUPPORTS_NUMA && EXPERIMENTAL 113 depends on MMU && SYS_SUPPORTS_NUMA && EXPERIMENTAL
114 select ARCH_WANT_NUMA_VARIABLE_LOCALITY
114 default n 115 default n
115 help 116 help
116 Some SH systems have many various memories scattered around 117 Some SH systems have many various memories scattered around
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 65a872bf72f9..97f8c5ad8c2d 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -22,6 +22,8 @@ config X86
22 def_bool y 22 def_bool y
23 select HAVE_AOUT if X86_32 23 select HAVE_AOUT if X86_32
24 select HAVE_UNSTABLE_SCHED_CLOCK 24 select HAVE_UNSTABLE_SCHED_CLOCK
25 select ARCH_SUPPORTS_NUMA_BALANCING
26 select ARCH_WANTS_PROT_NUMA_PROT_NONE
25 select HAVE_IDE 27 select HAVE_IDE
26 select HAVE_OPROFILE 28 select HAVE_OPROFILE
27 select HAVE_PCSPKR_PLATFORM 29 select HAVE_PCSPKR_PLATFORM
diff --git a/arch/x86/crypto/Makefile b/arch/x86/crypto/Makefile
index 5bacb4a226ac..e0ca7c9ac383 100644
--- a/arch/x86/crypto/Makefile
+++ b/arch/x86/crypto/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_CRYPTO_SERPENT_SSE2_586) += serpent-sse2-i586.o
12 12
13obj-$(CONFIG_CRYPTO_AES_X86_64) += aes-x86_64.o 13obj-$(CONFIG_CRYPTO_AES_X86_64) += aes-x86_64.o
14obj-$(CONFIG_CRYPTO_CAMELLIA_X86_64) += camellia-x86_64.o 14obj-$(CONFIG_CRYPTO_CAMELLIA_X86_64) += camellia-x86_64.o
15obj-$(CONFIG_CRYPTO_CAMELLIA_AESNI_AVX_X86_64) += camellia-aesni-avx-x86_64.o
15obj-$(CONFIG_CRYPTO_CAST5_AVX_X86_64) += cast5-avx-x86_64.o 16obj-$(CONFIG_CRYPTO_CAST5_AVX_X86_64) += cast5-avx-x86_64.o
16obj-$(CONFIG_CRYPTO_CAST6_AVX_X86_64) += cast6-avx-x86_64.o 17obj-$(CONFIG_CRYPTO_CAST6_AVX_X86_64) += cast6-avx-x86_64.o
17obj-$(CONFIG_CRYPTO_BLOWFISH_X86_64) += blowfish-x86_64.o 18obj-$(CONFIG_CRYPTO_BLOWFISH_X86_64) += blowfish-x86_64.o
@@ -34,6 +35,8 @@ serpent-sse2-i586-y := serpent-sse2-i586-asm_32.o serpent_sse2_glue.o
34 35
35aes-x86_64-y := aes-x86_64-asm_64.o aes_glue.o 36aes-x86_64-y := aes-x86_64-asm_64.o aes_glue.o
36camellia-x86_64-y := camellia-x86_64-asm_64.o camellia_glue.o 37camellia-x86_64-y := camellia-x86_64-asm_64.o camellia_glue.o
38camellia-aesni-avx-x86_64-y := camellia-aesni-avx-asm_64.o \
39 camellia_aesni_avx_glue.o
37cast5-avx-x86_64-y := cast5-avx-x86_64-asm_64.o cast5_avx_glue.o 40cast5-avx-x86_64-y := cast5-avx-x86_64-asm_64.o cast5_avx_glue.o
38cast6-avx-x86_64-y := cast6-avx-x86_64-asm_64.o cast6_avx_glue.o 41cast6-avx-x86_64-y := cast6-avx-x86_64-asm_64.o cast6_avx_glue.o
39blowfish-x86_64-y := blowfish-x86_64-asm_64.o blowfish_glue.o 42blowfish-x86_64-y := blowfish-x86_64-asm_64.o blowfish_glue.o
@@ -47,3 +50,5 @@ serpent-avx-x86_64-y := serpent-avx-x86_64-asm_64.o serpent_avx_glue.o
47aesni-intel-y := aesni-intel_asm.o aesni-intel_glue.o fpu.o 50aesni-intel-y := aesni-intel_asm.o aesni-intel_glue.o fpu.o
48ghash-clmulni-intel-y := ghash-clmulni-intel_asm.o ghash-clmulni-intel_glue.o 51ghash-clmulni-intel-y := ghash-clmulni-intel_asm.o ghash-clmulni-intel_glue.o
49sha1-ssse3-y := sha1_ssse3_asm.o sha1_ssse3_glue.o 52sha1-ssse3-y := sha1_ssse3_asm.o sha1_ssse3_glue.o
53crc32c-intel-y := crc32c-intel_glue.o
54crc32c-intel-$(CONFIG_CRYPTO_CRC32C_X86_64) += crc32c-pcl-intel-asm_64.o
diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
new file mode 100644
index 000000000000..2306d2e4816f
--- /dev/null
+++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
@@ -0,0 +1,1102 @@
1/*
2 * x86_64/AVX/AES-NI assembler implementation of Camellia
3 *
4 * Copyright © 2012 Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 */
12
13/*
14 * Version licensed under 2-clause BSD License is available at:
15 * http://koti.mbnet.fi/axh/crypto/camellia-BSD-1.2.0-aesni1.tar.xz
16 */
17
18#define CAMELLIA_TABLE_BYTE_LEN 272
19
20/* struct camellia_ctx: */
21#define key_table 0
22#define key_length CAMELLIA_TABLE_BYTE_LEN
23
24/* register macros */
25#define CTX %rdi
26
27/**********************************************************************
28 16-way camellia
29 **********************************************************************/
30#define filter_8bit(x, lo_t, hi_t, mask4bit, tmp0) \
31 vpand x, mask4bit, tmp0; \
32 vpandn x, mask4bit, x; \
33 vpsrld $4, x, x; \
34 \
35 vpshufb tmp0, lo_t, tmp0; \
36 vpshufb x, hi_t, x; \
37 vpxor tmp0, x, x;
38
39/*
40 * IN:
41 * x0..x7: byte-sliced AB state
42 * mem_cd: register pointer storing CD state
43 * key: index for key material
44 * OUT:
45 * x0..x7: new byte-sliced CD state
46 */
47#define roundsm16(x0, x1, x2, x3, x4, x5, x6, x7, t0, t1, t2, t3, t4, t5, t6, \
48 t7, mem_cd, key) \
49 /* \
50 * S-function with AES subbytes \
51 */ \
52 vmovdqa .Linv_shift_row, t4; \
53 vbroadcastss .L0f0f0f0f, t7; \
54 vmovdqa .Lpre_tf_lo_s1, t0; \
55 vmovdqa .Lpre_tf_hi_s1, t1; \
56 \
57 /* AES inverse shift rows */ \
58 vpshufb t4, x0, x0; \
59 vpshufb t4, x7, x7; \
60 vpshufb t4, x1, x1; \
61 vpshufb t4, x4, x4; \
62 vpshufb t4, x2, x2; \
63 vpshufb t4, x5, x5; \
64 vpshufb t4, x3, x3; \
65 vpshufb t4, x6, x6; \
66 \
67 /* prefilter sboxes 1, 2 and 3 */ \
68 vmovdqa .Lpre_tf_lo_s4, t2; \
69 vmovdqa .Lpre_tf_hi_s4, t3; \
70 filter_8bit(x0, t0, t1, t7, t6); \
71 filter_8bit(x7, t0, t1, t7, t6); \
72 filter_8bit(x1, t0, t1, t7, t6); \
73 filter_8bit(x4, t0, t1, t7, t6); \
74 filter_8bit(x2, t0, t1, t7, t6); \
75 filter_8bit(x5, t0, t1, t7, t6); \
76 \
77 /* prefilter sbox 4 */ \
78 vpxor t4, t4, t4; \
79 filter_8bit(x3, t2, t3, t7, t6); \
80 filter_8bit(x6, t2, t3, t7, t6); \
81 \
82 /* AES subbytes + AES shift rows */ \
83 vmovdqa .Lpost_tf_lo_s1, t0; \
84 vmovdqa .Lpost_tf_hi_s1, t1; \
85 vaesenclast t4, x0, x0; \
86 vaesenclast t4, x7, x7; \
87 vaesenclast t4, x1, x1; \
88 vaesenclast t4, x4, x4; \
89 vaesenclast t4, x2, x2; \
90 vaesenclast t4, x5, x5; \
91 vaesenclast t4, x3, x3; \
92 vaesenclast t4, x6, x6; \
93 \
94 /* postfilter sboxes 1 and 4 */ \
95 vmovdqa .Lpost_tf_lo_s3, t2; \
96 vmovdqa .Lpost_tf_hi_s3, t3; \
97 filter_8bit(x0, t0, t1, t7, t6); \
98 filter_8bit(x7, t0, t1, t7, t6); \
99 filter_8bit(x3, t0, t1, t7, t6); \
100 filter_8bit(x6, t0, t1, t7, t6); \
101 \
102 /* postfilter sbox 3 */ \
103 vmovdqa .Lpost_tf_lo_s2, t4; \
104 vmovdqa .Lpost_tf_hi_s2, t5; \
105 filter_8bit(x2, t2, t3, t7, t6); \
106 filter_8bit(x5, t2, t3, t7, t6); \
107 \
108 vpxor t6, t6, t6; \
109 vmovq key, t0; \
110 \
111 /* postfilter sbox 2 */ \
112 filter_8bit(x1, t4, t5, t7, t2); \
113 filter_8bit(x4, t4, t5, t7, t2); \
114 \
115 vpsrldq $5, t0, t5; \
116 vpsrldq $1, t0, t1; \
117 vpsrldq $2, t0, t2; \
118 vpsrldq $3, t0, t3; \
119 vpsrldq $4, t0, t4; \
120 vpshufb t6, t0, t0; \
121 vpshufb t6, t1, t1; \
122 vpshufb t6, t2, t2; \
123 vpshufb t6, t3, t3; \
124 vpshufb t6, t4, t4; \
125 vpsrldq $2, t5, t7; \
126 vpshufb t6, t7, t7; \
127 \
128 /* \
129 * P-function \
130 */ \
131 vpxor x5, x0, x0; \
132 vpxor x6, x1, x1; \
133 vpxor x7, x2, x2; \
134 vpxor x4, x3, x3; \
135 \
136 vpxor x2, x4, x4; \
137 vpxor x3, x5, x5; \
138 vpxor x0, x6, x6; \
139 vpxor x1, x7, x7; \
140 \
141 vpxor x7, x0, x0; \
142 vpxor x4, x1, x1; \
143 vpxor x5, x2, x2; \
144 vpxor x6, x3, x3; \
145 \
146 vpxor x3, x4, x4; \
147 vpxor x0, x5, x5; \
148 vpxor x1, x6, x6; \
149 vpxor x2, x7, x7; /* note: high and low parts swapped */ \
150 \
151 /* \
152 * Add key material and result to CD (x becomes new CD) \
153 */ \
154 \
155 vpxor t3, x4, x4; \
156 vpxor 0 * 16(mem_cd), x4, x4; \
157 \
158 vpxor t2, x5, x5; \
159 vpxor 1 * 16(mem_cd), x5, x5; \
160 \
161 vpsrldq $1, t5, t3; \
162 vpshufb t6, t5, t5; \
163 vpshufb t6, t3, t6; \
164 \
165 vpxor t1, x6, x6; \
166 vpxor 2 * 16(mem_cd), x6, x6; \
167 \
168 vpxor t0, x7, x7; \
169 vpxor 3 * 16(mem_cd), x7, x7; \
170 \
171 vpxor t7, x0, x0; \
172 vpxor 4 * 16(mem_cd), x0, x0; \
173 \
174 vpxor t6, x1, x1; \
175 vpxor 5 * 16(mem_cd), x1, x1; \
176 \
177 vpxor t5, x2, x2; \
178 vpxor 6 * 16(mem_cd), x2, x2; \
179 \
180 vpxor t4, x3, x3; \
181 vpxor 7 * 16(mem_cd), x3, x3;
182
183/*
184 * Size optimization... with inlined roundsm16, binary would be over 5 times
185 * larger and would only be 0.5% faster (on sandy-bridge).
186 */
187.align 8
188roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
189 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
190 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
191 %rcx, (%r9));
192 ret;
193
194.align 8
195roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
196 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
197 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
198 %rax, (%r9));
199 ret;
200
201/*
202 * IN/OUT:
203 * x0..x7: byte-sliced AB state preloaded
204 * mem_ab: byte-sliced AB state in memory
205 * mem_cb: byte-sliced CD state in memory
206 */
207#define two_roundsm16(x0, x1, x2, x3, x4, x5, x6, x7, y0, y1, y2, y3, y4, y5, \
208 y6, y7, mem_ab, mem_cd, i, dir, store_ab) \
209 leaq (key_table + (i) * 8)(CTX), %r9; \
210 call roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd; \
211 \
212 vmovdqu x4, 0 * 16(mem_cd); \
213 vmovdqu x5, 1 * 16(mem_cd); \
214 vmovdqu x6, 2 * 16(mem_cd); \
215 vmovdqu x7, 3 * 16(mem_cd); \
216 vmovdqu x0, 4 * 16(mem_cd); \
217 vmovdqu x1, 5 * 16(mem_cd); \
218 vmovdqu x2, 6 * 16(mem_cd); \
219 vmovdqu x3, 7 * 16(mem_cd); \
220 \
221 leaq (key_table + ((i) + (dir)) * 8)(CTX), %r9; \
222 call roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab; \
223 \
224 store_ab(x0, x1, x2, x3, x4, x5, x6, x7, mem_ab);
225
226#define dummy_store(x0, x1, x2, x3, x4, x5, x6, x7, mem_ab) /* do nothing */
227
228#define store_ab_state(x0, x1, x2, x3, x4, x5, x6, x7, mem_ab) \
229 /* Store new AB state */ \
230 vmovdqu x0, 0 * 16(mem_ab); \
231 vmovdqu x1, 1 * 16(mem_ab); \
232 vmovdqu x2, 2 * 16(mem_ab); \
233 vmovdqu x3, 3 * 16(mem_ab); \
234 vmovdqu x4, 4 * 16(mem_ab); \
235 vmovdqu x5, 5 * 16(mem_ab); \
236 vmovdqu x6, 6 * 16(mem_ab); \
237 vmovdqu x7, 7 * 16(mem_ab);
238
239#define enc_rounds16(x0, x1, x2, x3, x4, x5, x6, x7, y0, y1, y2, y3, y4, y5, \
240 y6, y7, mem_ab, mem_cd, i) \
241 two_roundsm16(x0, x1, x2, x3, x4, x5, x6, x7, y0, y1, y2, y3, y4, y5, \
242 y6, y7, mem_ab, mem_cd, (i) + 2, 1, store_ab_state); \
243 two_roundsm16(x0, x1, x2, x3, x4, x5, x6, x7, y0, y1, y2, y3, y4, y5, \
244 y6, y7, mem_ab, mem_cd, (i) + 4, 1, store_ab_state); \
245 two_roundsm16(x0, x1, x2, x3, x4, x5, x6, x7, y0, y1, y2, y3, y4, y5, \
246 y6, y7, mem_ab, mem_cd, (i) + 6, 1, dummy_store);
247
248#define dec_rounds16(x0, x1, x2, x3, x4, x5, x6, x7, y0, y1, y2, y3, y4, y5, \
249 y6, y7, mem_ab, mem_cd, i) \
250 two_roundsm16(x0, x1, x2, x3, x4, x5, x6, x7, y0, y1, y2, y3, y4, y5, \
251 y6, y7, mem_ab, mem_cd, (i) + 7, -1, store_ab_state); \
252 two_roundsm16(x0, x1, x2, x3, x4, x5, x6, x7, y0, y1, y2, y3, y4, y5, \
253 y6, y7, mem_ab, mem_cd, (i) + 5, -1, store_ab_state); \
254 two_roundsm16(x0, x1, x2, x3, x4, x5, x6, x7, y0, y1, y2, y3, y4, y5, \
255 y6, y7, mem_ab, mem_cd, (i) + 3, -1, dummy_store);
256
257/*
258 * IN:
259 * v0..3: byte-sliced 32-bit integers
260 * OUT:
261 * v0..3: (IN <<< 1)
262 */
263#define rol32_1_16(v0, v1, v2, v3, t0, t1, t2, zero) \
264 vpcmpgtb v0, zero, t0; \
265 vpaddb v0, v0, v0; \
266 vpabsb t0, t0; \
267 \
268 vpcmpgtb v1, zero, t1; \
269 vpaddb v1, v1, v1; \
270 vpabsb t1, t1; \
271 \
272 vpcmpgtb v2, zero, t2; \
273 vpaddb v2, v2, v2; \
274 vpabsb t2, t2; \
275 \
276 vpor t0, v1, v1; \
277 \
278 vpcmpgtb v3, zero, t0; \
279 vpaddb v3, v3, v3; \
280 vpabsb t0, t0; \
281 \
282 vpor t1, v2, v2; \
283 vpor t2, v3, v3; \
284 vpor t0, v0, v0;
285
286/*
287 * IN:
288 * r: byte-sliced AB state in memory
289 * l: byte-sliced CD state in memory
290 * OUT:
291 * x0..x7: new byte-sliced CD state
292 */
293#define fls16(l, l0, l1, l2, l3, l4, l5, l6, l7, r, t0, t1, t2, t3, tt0, \
294 tt1, tt2, tt3, kll, klr, krl, krr) \
295 /* \
296 * t0 = kll; \
297 * t0 &= ll; \
298 * lr ^= rol32(t0, 1); \
299 */ \
300 vpxor tt0, tt0, tt0; \
301 vmovd kll, t0; \
302 vpshufb tt0, t0, t3; \
303 vpsrldq $1, t0, t0; \
304 vpshufb tt0, t0, t2; \
305 vpsrldq $1, t0, t0; \
306 vpshufb tt0, t0, t1; \
307 vpsrldq $1, t0, t0; \
308 vpshufb tt0, t0, t0; \
309 \
310 vpand l0, t0, t0; \
311 vpand l1, t1, t1; \
312 vpand l2, t2, t2; \
313 vpand l3, t3, t3; \
314 \
315 rol32_1_16(t3, t2, t1, t0, tt1, tt2, tt3, tt0); \
316 \
317 vpxor l4, t0, l4; \
318 vmovdqu l4, 4 * 16(l); \
319 vpxor l5, t1, l5; \
320 vmovdqu l5, 5 * 16(l); \
321 vpxor l6, t2, l6; \
322 vmovdqu l6, 6 * 16(l); \
323 vpxor l7, t3, l7; \
324 vmovdqu l7, 7 * 16(l); \
325 \
326 /* \
327 * t2 = krr; \
328 * t2 |= rr; \
329 * rl ^= t2; \
330 */ \
331 \
332 vmovd krr, t0; \
333 vpshufb tt0, t0, t3; \
334 vpsrldq $1, t0, t0; \
335 vpshufb tt0, t0, t2; \
336 vpsrldq $1, t0, t0; \
337 vpshufb tt0, t0, t1; \
338 vpsrldq $1, t0, t0; \
339 vpshufb tt0, t0, t0; \
340 \
341 vpor 4 * 16(r), t0, t0; \
342 vpor 5 * 16(r), t1, t1; \
343 vpor 6 * 16(r), t2, t2; \
344 vpor 7 * 16(r), t3, t3; \
345 \
346 vpxor 0 * 16(r), t0, t0; \
347 vpxor 1 * 16(r), t1, t1; \
348 vpxor 2 * 16(r), t2, t2; \
349 vpxor 3 * 16(r), t3, t3; \
350 vmovdqu t0, 0 * 16(r); \
351 vmovdqu t1, 1 * 16(r); \
352 vmovdqu t2, 2 * 16(r); \
353 vmovdqu t3, 3 * 16(r); \
354 \
355 /* \
356 * t2 = krl; \
357 * t2 &= rl; \
358 * rr ^= rol32(t2, 1); \
359 */ \
360 vmovd krl, t0; \
361 vpshufb tt0, t0, t3; \
362 vpsrldq $1, t0, t0; \
363 vpshufb tt0, t0, t2; \
364 vpsrldq $1, t0, t0; \
365 vpshufb tt0, t0, t1; \
366 vpsrldq $1, t0, t0; \
367 vpshufb tt0, t0, t0; \
368 \
369 vpand 0 * 16(r), t0, t0; \
370 vpand 1 * 16(r), t1, t1; \
371 vpand 2 * 16(r), t2, t2; \
372 vpand 3 * 16(r), t3, t3; \
373 \
374 rol32_1_16(t3, t2, t1, t0, tt1, tt2, tt3, tt0); \
375 \
376 vpxor 4 * 16(r), t0, t0; \
377 vpxor 5 * 16(r), t1, t1; \
378 vpxor 6 * 16(r), t2, t2; \
379 vpxor 7 * 16(r), t3, t3; \
380 vmovdqu t0, 4 * 16(r); \
381 vmovdqu t1, 5 * 16(r); \
382 vmovdqu t2, 6 * 16(r); \
383 vmovdqu t3, 7 * 16(r); \
384 \
385 /* \
386 * t0 = klr; \
387 * t0 |= lr; \
388 * ll ^= t0; \
389 */ \
390 \
391 vmovd klr, t0; \
392 vpshufb tt0, t0, t3; \
393 vpsrldq $1, t0, t0; \
394 vpshufb tt0, t0, t2; \
395 vpsrldq $1, t0, t0; \
396 vpshufb tt0, t0, t1; \
397 vpsrldq $1, t0, t0; \
398 vpshufb tt0, t0, t0; \
399 \
400 vpor l4, t0, t0; \
401 vpor l5, t1, t1; \
402 vpor l6, t2, t2; \
403 vpor l7, t3, t3; \
404 \
405 vpxor l0, t0, l0; \
406 vmovdqu l0, 0 * 16(l); \
407 vpxor l1, t1, l1; \
408 vmovdqu l1, 1 * 16(l); \
409 vpxor l2, t2, l2; \
410 vmovdqu l2, 2 * 16(l); \
411 vpxor l3, t3, l3; \
412 vmovdqu l3, 3 * 16(l);
413
414#define transpose_4x4(x0, x1, x2, x3, t1, t2) \
415 vpunpckhdq x1, x0, t2; \
416 vpunpckldq x1, x0, x0; \
417 \
418 vpunpckldq x3, x2, t1; \
419 vpunpckhdq x3, x2, x2; \
420 \
421 vpunpckhqdq t1, x0, x1; \
422 vpunpcklqdq t1, x0, x0; \
423 \
424 vpunpckhqdq x2, t2, x3; \
425 vpunpcklqdq x2, t2, x2;
426
427#define byteslice_16x16b(a0, b0, c0, d0, a1, b1, c1, d1, a2, b2, c2, d2, a3, \
428 b3, c3, d3, st0, st1) \
429 vmovdqu d2, st0; \
430 vmovdqu d3, st1; \
431 transpose_4x4(a0, a1, a2, a3, d2, d3); \
432 transpose_4x4(b0, b1, b2, b3, d2, d3); \
433 vmovdqu st0, d2; \
434 vmovdqu st1, d3; \
435 \
436 vmovdqu a0, st0; \
437 vmovdqu a1, st1; \
438 transpose_4x4(c0, c1, c2, c3, a0, a1); \
439 transpose_4x4(d0, d1, d2, d3, a0, a1); \
440 \
441 vmovdqu .Lshufb_16x16b, a0; \
442 vmovdqu st1, a1; \
443 vpshufb a0, a2, a2; \
444 vpshufb a0, a3, a3; \
445 vpshufb a0, b0, b0; \
446 vpshufb a0, b1, b1; \
447 vpshufb a0, b2, b2; \
448 vpshufb a0, b3, b3; \
449 vpshufb a0, a1, a1; \
450 vpshufb a0, c0, c0; \
451 vpshufb a0, c1, c1; \
452 vpshufb a0, c2, c2; \
453 vpshufb a0, c3, c3; \
454 vpshufb a0, d0, d0; \
455 vpshufb a0, d1, d1; \
456 vpshufb a0, d2, d2; \
457 vpshufb a0, d3, d3; \
458 vmovdqu d3, st1; \
459 vmovdqu st0, d3; \
460 vpshufb a0, d3, a0; \
461 vmovdqu d2, st0; \
462 \
463 transpose_4x4(a0, b0, c0, d0, d2, d3); \
464 transpose_4x4(a1, b1, c1, d1, d2, d3); \
465 vmovdqu st0, d2; \
466 vmovdqu st1, d3; \
467 \
468 vmovdqu b0, st0; \
469 vmovdqu b1, st1; \
470 transpose_4x4(a2, b2, c2, d2, b0, b1); \
471 transpose_4x4(a3, b3, c3, d3, b0, b1); \
472 vmovdqu st0, b0; \
473 vmovdqu st1, b1; \
474 /* does not adjust output bytes inside vectors */
475
476/* load blocks to registers and apply pre-whitening */
477#define inpack16_pre(x0, x1, x2, x3, x4, x5, x6, x7, y0, y1, y2, y3, y4, y5, \
478 y6, y7, rio, key) \
479 vmovq key, x0; \
480 vpshufb .Lpack_bswap, x0, x0; \
481 \
482 vpxor 0 * 16(rio), x0, y7; \
483 vpxor 1 * 16(rio), x0, y6; \
484 vpxor 2 * 16(rio), x0, y5; \
485 vpxor 3 * 16(rio), x0, y4; \
486 vpxor 4 * 16(rio), x0, y3; \
487 vpxor 5 * 16(rio), x0, y2; \
488 vpxor 6 * 16(rio), x0, y1; \
489 vpxor 7 * 16(rio), x0, y0; \
490 vpxor 8 * 16(rio), x0, x7; \
491 vpxor 9 * 16(rio), x0, x6; \
492 vpxor 10 * 16(rio), x0, x5; \
493 vpxor 11 * 16(rio), x0, x4; \
494 vpxor 12 * 16(rio), x0, x3; \
495 vpxor 13 * 16(rio), x0, x2; \
496 vpxor 14 * 16(rio), x0, x1; \
497 vpxor 15 * 16(rio), x0, x0;
498
499/* byteslice pre-whitened blocks and store to temporary memory */
500#define inpack16_post(x0, x1, x2, x3, x4, x5, x6, x7, y0, y1, y2, y3, y4, y5, \
501 y6, y7, mem_ab, mem_cd) \
502 byteslice_16x16b(x0, x1, x2, x3, x4, x5, x6, x7, y0, y1, y2, y3, y4, \
503 y5, y6, y7, (mem_ab), (mem_cd)); \
504 \
505 vmovdqu x0, 0 * 16(mem_ab); \
506 vmovdqu x1, 1 * 16(mem_ab); \
507 vmovdqu x2, 2 * 16(mem_ab); \
508 vmovdqu x3, 3 * 16(mem_ab); \
509 vmovdqu x4, 4 * 16(mem_ab); \
510 vmovdqu x5, 5 * 16(mem_ab); \
511 vmovdqu x6, 6 * 16(mem_ab); \
512 vmovdqu x7, 7 * 16(mem_ab); \
513 vmovdqu y0, 0 * 16(mem_cd); \
514 vmovdqu y1, 1 * 16(mem_cd); \
515 vmovdqu y2, 2 * 16(mem_cd); \
516 vmovdqu y3, 3 * 16(mem_cd); \
517 vmovdqu y4, 4 * 16(mem_cd); \
518 vmovdqu y5, 5 * 16(mem_cd); \
519 vmovdqu y6, 6 * 16(mem_cd); \
520 vmovdqu y7, 7 * 16(mem_cd);
521
522/* de-byteslice, apply post-whitening and store blocks */
523#define outunpack16(x0, x1, x2, x3, x4, x5, x6, x7, y0, y1, y2, y3, y4, \
524 y5, y6, y7, key, stack_tmp0, stack_tmp1) \
525 byteslice_16x16b(y0, y4, x0, x4, y1, y5, x1, x5, y2, y6, x2, x6, y3, \
526 y7, x3, x7, stack_tmp0, stack_tmp1); \
527 \
528 vmovdqu x0, stack_tmp0; \
529 \
530 vmovq key, x0; \
531 vpshufb .Lpack_bswap, x0, x0; \
532 \
533 vpxor x0, y7, y7; \
534 vpxor x0, y6, y6; \
535 vpxor x0, y5, y5; \
536 vpxor x0, y4, y4; \
537 vpxor x0, y3, y3; \
538 vpxor x0, y2, y2; \
539 vpxor x0, y1, y1; \
540 vpxor x0, y0, y0; \
541 vpxor x0, x7, x7; \
542 vpxor x0, x6, x6; \
543 vpxor x0, x5, x5; \
544 vpxor x0, x4, x4; \
545 vpxor x0, x3, x3; \
546 vpxor x0, x2, x2; \
547 vpxor x0, x1, x1; \
548 vpxor stack_tmp0, x0, x0;
549
550#define write_output(x0, x1, x2, x3, x4, x5, x6, x7, y0, y1, y2, y3, y4, y5, \
551 y6, y7, rio) \
552 vmovdqu x0, 0 * 16(rio); \
553 vmovdqu x1, 1 * 16(rio); \
554 vmovdqu x2, 2 * 16(rio); \
555 vmovdqu x3, 3 * 16(rio); \
556 vmovdqu x4, 4 * 16(rio); \
557 vmovdqu x5, 5 * 16(rio); \
558 vmovdqu x6, 6 * 16(rio); \
559 vmovdqu x7, 7 * 16(rio); \
560 vmovdqu y0, 8 * 16(rio); \
561 vmovdqu y1, 9 * 16(rio); \
562 vmovdqu y2, 10 * 16(rio); \
563 vmovdqu y3, 11 * 16(rio); \
564 vmovdqu y4, 12 * 16(rio); \
565 vmovdqu y5, 13 * 16(rio); \
566 vmovdqu y6, 14 * 16(rio); \
567 vmovdqu y7, 15 * 16(rio);
568
569.data
570.align 16
571
572#define SHUFB_BYTES(idx) \
573 0 + (idx), 4 + (idx), 8 + (idx), 12 + (idx)
574
575.Lshufb_16x16b:
576 .byte SHUFB_BYTES(0), SHUFB_BYTES(1), SHUFB_BYTES(2), SHUFB_BYTES(3);
577
578.Lpack_bswap:
579 .long 0x00010203
580 .long 0x04050607
581 .long 0x80808080
582 .long 0x80808080
583
584/* For CTR-mode IV byteswap */
585.Lbswap128_mask:
586 .byte 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
587
588/*
589 * pre-SubByte transform
590 *
591 * pre-lookup for sbox1, sbox2, sbox3:
592 * swap_bitendianness(
593 * isom_map_camellia_to_aes(
594 * camellia_f(
595 * swap_bitendianess(in)
596 * )
597 * )
598 * )
599 *
600 * (note: '⊕ 0xc5' inside camellia_f())
601 */
602.Lpre_tf_lo_s1:
603 .byte 0x45, 0xe8, 0x40, 0xed, 0x2e, 0x83, 0x2b, 0x86
604 .byte 0x4b, 0xe6, 0x4e, 0xe3, 0x20, 0x8d, 0x25, 0x88
605.Lpre_tf_hi_s1:
606 .byte 0x00, 0x51, 0xf1, 0xa0, 0x8a, 0xdb, 0x7b, 0x2a
607 .byte 0x09, 0x58, 0xf8, 0xa9, 0x83, 0xd2, 0x72, 0x23
608
609/*
610 * pre-SubByte transform
611 *
612 * pre-lookup for sbox4:
613 * swap_bitendianness(
614 * isom_map_camellia_to_aes(
615 * camellia_f(
616 * swap_bitendianess(in <<< 1)
617 * )
618 * )
619 * )
620 *
621 * (note: '⊕ 0xc5' inside camellia_f())
622 */
623.Lpre_tf_lo_s4:
624 .byte 0x45, 0x40, 0x2e, 0x2b, 0x4b, 0x4e, 0x20, 0x25
625 .byte 0x14, 0x11, 0x7f, 0x7a, 0x1a, 0x1f, 0x71, 0x74
626.Lpre_tf_hi_s4:
627 .byte 0x00, 0xf1, 0x8a, 0x7b, 0x09, 0xf8, 0x83, 0x72
628 .byte 0xad, 0x5c, 0x27, 0xd6, 0xa4, 0x55, 0x2e, 0xdf
629
630/*
631 * post-SubByte transform
632 *
633 * post-lookup for sbox1, sbox4:
634 * swap_bitendianness(
635 * camellia_h(
636 * isom_map_aes_to_camellia(
637 * swap_bitendianness(
638 * aes_inverse_affine_transform(in)
639 * )
640 * )
641 * )
642 * )
643 *
644 * (note: '⊕ 0x6e' inside camellia_h())
645 */
646.Lpost_tf_lo_s1:
647 .byte 0x3c, 0xcc, 0xcf, 0x3f, 0x32, 0xc2, 0xc1, 0x31
648 .byte 0xdc, 0x2c, 0x2f, 0xdf, 0xd2, 0x22, 0x21, 0xd1
649.Lpost_tf_hi_s1:
650 .byte 0x00, 0xf9, 0x86, 0x7f, 0xd7, 0x2e, 0x51, 0xa8
651 .byte 0xa4, 0x5d, 0x22, 0xdb, 0x73, 0x8a, 0xf5, 0x0c
652
653/*
654 * post-SubByte transform
655 *
656 * post-lookup for sbox2:
657 * swap_bitendianness(
658 * camellia_h(
659 * isom_map_aes_to_camellia(
660 * swap_bitendianness(
661 * aes_inverse_affine_transform(in)
662 * )
663 * )
664 * )
665 * ) <<< 1
666 *
667 * (note: '⊕ 0x6e' inside camellia_h())
668 */
669.Lpost_tf_lo_s2:
670 .byte 0x78, 0x99, 0x9f, 0x7e, 0x64, 0x85, 0x83, 0x62
671 .byte 0xb9, 0x58, 0x5e, 0xbf, 0xa5, 0x44, 0x42, 0xa3
672.Lpost_tf_hi_s2:
673 .byte 0x00, 0xf3, 0x0d, 0xfe, 0xaf, 0x5c, 0xa2, 0x51
674 .byte 0x49, 0xba, 0x44, 0xb7, 0xe6, 0x15, 0xeb, 0x18
675
676/*
677 * post-SubByte transform
678 *
679 * post-lookup for sbox3:
680 * swap_bitendianness(
681 * camellia_h(
682 * isom_map_aes_to_camellia(
683 * swap_bitendianness(
684 * aes_inverse_affine_transform(in)
685 * )
686 * )
687 * )
688 * ) >>> 1
689 *
690 * (note: '⊕ 0x6e' inside camellia_h())
691 */
692.Lpost_tf_lo_s3:
693 .byte 0x1e, 0x66, 0xe7, 0x9f, 0x19, 0x61, 0xe0, 0x98
694 .byte 0x6e, 0x16, 0x97, 0xef, 0x69, 0x11, 0x90, 0xe8
695.Lpost_tf_hi_s3:
696 .byte 0x00, 0xfc, 0x43, 0xbf, 0xeb, 0x17, 0xa8, 0x54
697 .byte 0x52, 0xae, 0x11, 0xed, 0xb9, 0x45, 0xfa, 0x06
698
699/* For isolating SubBytes from AESENCLAST, inverse shift row */
700.Linv_shift_row:
701 .byte 0x00, 0x0d, 0x0a, 0x07, 0x04, 0x01, 0x0e, 0x0b
702 .byte 0x08, 0x05, 0x02, 0x0f, 0x0c, 0x09, 0x06, 0x03
703
704/* 4-bit mask */
705.align 4
706.L0f0f0f0f:
707 .long 0x0f0f0f0f
708
709.text
710
711.align 8
712.type __camellia_enc_blk16,@function;
713
714__camellia_enc_blk16:
715 /* input:
716 * %rdi: ctx, CTX
717 * %rax: temporary storage, 256 bytes
718 * %xmm0..%xmm15: 16 plaintext blocks
719 * output:
720 * %xmm0..%xmm15: 16 encrypted blocks, order swapped:
721 * 7, 8, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8
722 */
723
724 leaq 8 * 16(%rax), %rcx;
725
726 inpack16_post(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
727 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
728 %xmm15, %rax, %rcx);
729
730 enc_rounds16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
731 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
732 %xmm15, %rax, %rcx, 0);
733
734 fls16(%rax, %xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
735 %rcx, %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
736 %xmm15,
737 ((key_table + (8) * 8) + 0)(CTX),
738 ((key_table + (8) * 8) + 4)(CTX),
739 ((key_table + (8) * 8) + 8)(CTX),
740 ((key_table + (8) * 8) + 12)(CTX));
741
742 enc_rounds16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
743 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
744 %xmm15, %rax, %rcx, 8);
745
746 fls16(%rax, %xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
747 %rcx, %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
748 %xmm15,
749 ((key_table + (16) * 8) + 0)(CTX),
750 ((key_table + (16) * 8) + 4)(CTX),
751 ((key_table + (16) * 8) + 8)(CTX),
752 ((key_table + (16) * 8) + 12)(CTX));
753
754 enc_rounds16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
755 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
756 %xmm15, %rax, %rcx, 16);
757
758 movl $24, %r8d;
759 cmpl $16, key_length(CTX);
760 jne .Lenc_max32;
761
762.Lenc_done:
763 /* load CD for output */
764 vmovdqu 0 * 16(%rcx), %xmm8;
765 vmovdqu 1 * 16(%rcx), %xmm9;
766 vmovdqu 2 * 16(%rcx), %xmm10;
767 vmovdqu 3 * 16(%rcx), %xmm11;
768 vmovdqu 4 * 16(%rcx), %xmm12;
769 vmovdqu 5 * 16(%rcx), %xmm13;
770 vmovdqu 6 * 16(%rcx), %xmm14;
771 vmovdqu 7 * 16(%rcx), %xmm15;
772
773 outunpack16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
774 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
775 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
776
777 ret;
778
779.align 8
780.Lenc_max32:
781 movl $32, %r8d;
782
783 fls16(%rax, %xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
784 %rcx, %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
785 %xmm15,
786 ((key_table + (24) * 8) + 0)(CTX),
787 ((key_table + (24) * 8) + 4)(CTX),
788 ((key_table + (24) * 8) + 8)(CTX),
789 ((key_table + (24) * 8) + 12)(CTX));
790
791 enc_rounds16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
792 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
793 %xmm15, %rax, %rcx, 24);
794
795 jmp .Lenc_done;
796
797.align 8
798.type __camellia_dec_blk16,@function;
799
800__camellia_dec_blk16:
801 /* input:
802 * %rdi: ctx, CTX
803 * %rax: temporary storage, 256 bytes
804 * %r8d: 24 for 16 byte key, 32 for larger
805 * %xmm0..%xmm15: 16 encrypted blocks
806 * output:
807 * %xmm0..%xmm15: 16 plaintext blocks, order swapped:
808 * 7, 8, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8
809 */
810
811 leaq 8 * 16(%rax), %rcx;
812
813 inpack16_post(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
814 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
815 %xmm15, %rax, %rcx);
816
817 cmpl $32, %r8d;
818 je .Ldec_max32;
819
820.Ldec_max24:
821 dec_rounds16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
822 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
823 %xmm15, %rax, %rcx, 16);
824
825 fls16(%rax, %xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
826 %rcx, %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
827 %xmm15,
828 ((key_table + (16) * 8) + 8)(CTX),
829 ((key_table + (16) * 8) + 12)(CTX),
830 ((key_table + (16) * 8) + 0)(CTX),
831 ((key_table + (16) * 8) + 4)(CTX));
832
833 dec_rounds16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
834 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
835 %xmm15, %rax, %rcx, 8);
836
837 fls16(%rax, %xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
838 %rcx, %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
839 %xmm15,
840 ((key_table + (8) * 8) + 8)(CTX),
841 ((key_table + (8) * 8) + 12)(CTX),
842 ((key_table + (8) * 8) + 0)(CTX),
843 ((key_table + (8) * 8) + 4)(CTX));
844
845 dec_rounds16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
846 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
847 %xmm15, %rax, %rcx, 0);
848
849 /* load CD for output */
850 vmovdqu 0 * 16(%rcx), %xmm8;
851 vmovdqu 1 * 16(%rcx), %xmm9;
852 vmovdqu 2 * 16(%rcx), %xmm10;
853 vmovdqu 3 * 16(%rcx), %xmm11;
854 vmovdqu 4 * 16(%rcx), %xmm12;
855 vmovdqu 5 * 16(%rcx), %xmm13;
856 vmovdqu 6 * 16(%rcx), %xmm14;
857 vmovdqu 7 * 16(%rcx), %xmm15;
858
859 outunpack16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
860 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
861 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
862
863 ret;
864
865.align 8
866.Ldec_max32:
867 dec_rounds16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
868 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
869 %xmm15, %rax, %rcx, 24);
870
871 fls16(%rax, %xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
872 %rcx, %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
873 %xmm15,
874 ((key_table + (24) * 8) + 8)(CTX),
875 ((key_table + (24) * 8) + 12)(CTX),
876 ((key_table + (24) * 8) + 0)(CTX),
877 ((key_table + (24) * 8) + 4)(CTX));
878
879 jmp .Ldec_max24;
880
881.align 8
882.global camellia_ecb_enc_16way
883.type camellia_ecb_enc_16way,@function;
884
885camellia_ecb_enc_16way:
886 /* input:
887 * %rdi: ctx, CTX
888 * %rsi: dst (16 blocks)
889 * %rdx: src (16 blocks)
890 */
891
892 inpack16_pre(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
893 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
894 %xmm15, %rdx, (key_table)(CTX));
895
896 /* now dst can be used as temporary buffer (even in src == dst case) */
897 movq %rsi, %rax;
898
899 call __camellia_enc_blk16;
900
901 write_output(%xmm7, %xmm6, %xmm5, %xmm4, %xmm3, %xmm2, %xmm1, %xmm0,
902 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
903 %xmm8, %rsi);
904
905 ret;
906
907.align 8
908.global camellia_ecb_dec_16way
909.type camellia_ecb_dec_16way,@function;
910
911camellia_ecb_dec_16way:
912 /* input:
913 * %rdi: ctx, CTX
914 * %rsi: dst (16 blocks)
915 * %rdx: src (16 blocks)
916 */
917
918 cmpl $16, key_length(CTX);
919 movl $32, %r8d;
920 movl $24, %eax;
921 cmovel %eax, %r8d; /* max */
922
923 inpack16_pre(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
924 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
925 %xmm15, %rdx, (key_table)(CTX, %r8, 8));
926
927 /* now dst can be used as temporary buffer (even in src == dst case) */
928 movq %rsi, %rax;
929
930 call __camellia_dec_blk16;
931
932 write_output(%xmm7, %xmm6, %xmm5, %xmm4, %xmm3, %xmm2, %xmm1, %xmm0,
933 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
934 %xmm8, %rsi);
935
936 ret;
937
938.align 8
939.global camellia_cbc_dec_16way
940.type camellia_cbc_dec_16way,@function;
941
942camellia_cbc_dec_16way:
943 /* input:
944 * %rdi: ctx, CTX
945 * %rsi: dst (16 blocks)
946 * %rdx: src (16 blocks)
947 */
948
949 cmpl $16, key_length(CTX);
950 movl $32, %r8d;
951 movl $24, %eax;
952 cmovel %eax, %r8d; /* max */
953
954 inpack16_pre(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
955 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
956 %xmm15, %rdx, (key_table)(CTX, %r8, 8));
957
958 /*
959 * dst might still be in-use (in case dst == src), so use stack for
960 * temporary storage.
961 */
962 subq $(16 * 16), %rsp;
963 movq %rsp, %rax;
964
965 call __camellia_dec_blk16;
966
967 addq $(16 * 16), %rsp;
968
969 vpxor (0 * 16)(%rdx), %xmm6, %xmm6;
970 vpxor (1 * 16)(%rdx), %xmm5, %xmm5;
971 vpxor (2 * 16)(%rdx), %xmm4, %xmm4;
972 vpxor (3 * 16)(%rdx), %xmm3, %xmm3;
973 vpxor (4 * 16)(%rdx), %xmm2, %xmm2;
974 vpxor (5 * 16)(%rdx), %xmm1, %xmm1;
975 vpxor (6 * 16)(%rdx), %xmm0, %xmm0;
976 vpxor (7 * 16)(%rdx), %xmm15, %xmm15;
977 vpxor (8 * 16)(%rdx), %xmm14, %xmm14;
978 vpxor (9 * 16)(%rdx), %xmm13, %xmm13;
979 vpxor (10 * 16)(%rdx), %xmm12, %xmm12;
980 vpxor (11 * 16)(%rdx), %xmm11, %xmm11;
981 vpxor (12 * 16)(%rdx), %xmm10, %xmm10;
982 vpxor (13 * 16)(%rdx), %xmm9, %xmm9;
983 vpxor (14 * 16)(%rdx), %xmm8, %xmm8;
984 write_output(%xmm7, %xmm6, %xmm5, %xmm4, %xmm3, %xmm2, %xmm1, %xmm0,
985 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
986 %xmm8, %rsi);
987
988 ret;
989
990#define inc_le128(x, minus_one, tmp) \
991 vpcmpeqq minus_one, x, tmp; \
992 vpsubq minus_one, x, x; \
993 vpslldq $8, tmp, tmp; \
994 vpsubq tmp, x, x;
995
996.align 8
997.global camellia_ctr_16way
998.type camellia_ctr_16way,@function;
999
1000camellia_ctr_16way:
1001 /* input:
1002 * %rdi: ctx, CTX
1003 * %rsi: dst (16 blocks)
1004 * %rdx: src (16 blocks)
1005 * %rcx: iv (little endian, 128bit)
1006 */
1007
1008 subq $(16 * 16), %rsp;
1009 movq %rsp, %rax;
1010
1011 vmovdqa .Lbswap128_mask, %xmm14;
1012
1013 /* load IV and byteswap */
1014 vmovdqu (%rcx), %xmm0;
1015 vpshufb %xmm14, %xmm0, %xmm15;
1016 vmovdqu %xmm15, 15 * 16(%rax);
1017
1018 vpcmpeqd %xmm15, %xmm15, %xmm15;
1019 vpsrldq $8, %xmm15, %xmm15; /* low: -1, high: 0 */
1020
1021 /* construct IVs */
1022 inc_le128(%xmm0, %xmm15, %xmm13);
1023 vpshufb %xmm14, %xmm0, %xmm13;
1024 vmovdqu %xmm13, 14 * 16(%rax);
1025 inc_le128(%xmm0, %xmm15, %xmm13);
1026 vpshufb %xmm14, %xmm0, %xmm13;
1027 vmovdqu %xmm13, 13 * 16(%rax);
1028 inc_le128(%xmm0, %xmm15, %xmm13);
1029 vpshufb %xmm14, %xmm0, %xmm12;
1030 inc_le128(%xmm0, %xmm15, %xmm13);
1031 vpshufb %xmm14, %xmm0, %xmm11;
1032 inc_le128(%xmm0, %xmm15, %xmm13);
1033 vpshufb %xmm14, %xmm0, %xmm10;
1034 inc_le128(%xmm0, %xmm15, %xmm13);
1035 vpshufb %xmm14, %xmm0, %xmm9;
1036 inc_le128(%xmm0, %xmm15, %xmm13);
1037 vpshufb %xmm14, %xmm0, %xmm8;
1038 inc_le128(%xmm0, %xmm15, %xmm13);
1039 vpshufb %xmm14, %xmm0, %xmm7;
1040 inc_le128(%xmm0, %xmm15, %xmm13);
1041 vpshufb %xmm14, %xmm0, %xmm6;
1042 inc_le128(%xmm0, %xmm15, %xmm13);
1043 vpshufb %xmm14, %xmm0, %xmm5;
1044 inc_le128(%xmm0, %xmm15, %xmm13);
1045 vpshufb %xmm14, %xmm0, %xmm4;
1046 inc_le128(%xmm0, %xmm15, %xmm13);
1047 vpshufb %xmm14, %xmm0, %xmm3;
1048 inc_le128(%xmm0, %xmm15, %xmm13);
1049 vpshufb %xmm14, %xmm0, %xmm2;
1050 inc_le128(%xmm0, %xmm15, %xmm13);
1051 vpshufb %xmm14, %xmm0, %xmm1;
1052 inc_le128(%xmm0, %xmm15, %xmm13);
1053 vmovdqa %xmm0, %xmm13;
1054 vpshufb %xmm14, %xmm0, %xmm0;
1055 inc_le128(%xmm13, %xmm15, %xmm14);
1056 vmovdqu %xmm13, (%rcx);
1057
1058 /* inpack16_pre: */
1059 vmovq (key_table)(CTX), %xmm15;
1060 vpshufb .Lpack_bswap, %xmm15, %xmm15;
1061 vpxor %xmm0, %xmm15, %xmm0;
1062 vpxor %xmm1, %xmm15, %xmm1;
1063 vpxor %xmm2, %xmm15, %xmm2;
1064 vpxor %xmm3, %xmm15, %xmm3;
1065 vpxor %xmm4, %xmm15, %xmm4;
1066 vpxor %xmm5, %xmm15, %xmm5;
1067 vpxor %xmm6, %xmm15, %xmm6;
1068 vpxor %xmm7, %xmm15, %xmm7;
1069 vpxor %xmm8, %xmm15, %xmm8;
1070 vpxor %xmm9, %xmm15, %xmm9;
1071 vpxor %xmm10, %xmm15, %xmm10;
1072 vpxor %xmm11, %xmm15, %xmm11;
1073 vpxor %xmm12, %xmm15, %xmm12;
1074 vpxor 13 * 16(%rax), %xmm15, %xmm13;
1075 vpxor 14 * 16(%rax), %xmm15, %xmm14;
1076 vpxor 15 * 16(%rax), %xmm15, %xmm15;
1077
1078 call __camellia_enc_blk16;
1079
1080 addq $(16 * 16), %rsp;
1081
1082 vpxor 0 * 16(%rdx), %xmm7, %xmm7;
1083 vpxor 1 * 16(%rdx), %xmm6, %xmm6;
1084 vpxor 2 * 16(%rdx), %xmm5, %xmm5;
1085 vpxor 3 * 16(%rdx), %xmm4, %xmm4;
1086 vpxor 4 * 16(%rdx), %xmm3, %xmm3;
1087 vpxor 5 * 16(%rdx), %xmm2, %xmm2;
1088 vpxor 6 * 16(%rdx), %xmm1, %xmm1;
1089 vpxor 7 * 16(%rdx), %xmm0, %xmm0;
1090 vpxor 8 * 16(%rdx), %xmm15, %xmm15;
1091 vpxor 9 * 16(%rdx), %xmm14, %xmm14;
1092 vpxor 10 * 16(%rdx), %xmm13, %xmm13;
1093 vpxor 11 * 16(%rdx), %xmm12, %xmm12;
1094 vpxor 12 * 16(%rdx), %xmm11, %xmm11;
1095 vpxor 13 * 16(%rdx), %xmm10, %xmm10;
1096 vpxor 14 * 16(%rdx), %xmm9, %xmm9;
1097 vpxor 15 * 16(%rdx), %xmm8, %xmm8;
1098 write_output(%xmm7, %xmm6, %xmm5, %xmm4, %xmm3, %xmm2, %xmm1, %xmm0,
1099 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
1100 %xmm8, %rsi);
1101
1102 ret;
diff --git a/arch/x86/crypto/camellia_aesni_avx_glue.c b/arch/x86/crypto/camellia_aesni_avx_glue.c
new file mode 100644
index 000000000000..96cbb6068fce
--- /dev/null
+++ b/arch/x86/crypto/camellia_aesni_avx_glue.c
@@ -0,0 +1,558 @@
1/*
2 * Glue Code for x86_64/AVX/AES-NI assembler optimized version of Camellia
3 *
4 * Copyright © 2012 Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 */
12
13#include <linux/module.h>
14#include <linux/types.h>
15#include <linux/crypto.h>
16#include <linux/err.h>
17#include <crypto/algapi.h>
18#include <crypto/ctr.h>
19#include <crypto/lrw.h>
20#include <crypto/xts.h>
21#include <asm/xcr.h>
22#include <asm/xsave.h>
23#include <asm/crypto/camellia.h>
24#include <asm/crypto/ablk_helper.h>
25#include <asm/crypto/glue_helper.h>
26
27#define CAMELLIA_AESNI_PARALLEL_BLOCKS 16
28
29/* 16-way AES-NI parallel cipher functions */
30asmlinkage void camellia_ecb_enc_16way(struct camellia_ctx *ctx, u8 *dst,
31 const u8 *src);
32asmlinkage void camellia_ecb_dec_16way(struct camellia_ctx *ctx, u8 *dst,
33 const u8 *src);
34
35asmlinkage void camellia_cbc_dec_16way(struct camellia_ctx *ctx, u8 *dst,
36 const u8 *src);
37asmlinkage void camellia_ctr_16way(struct camellia_ctx *ctx, u8 *dst,
38 const u8 *src, le128 *iv);
39
40static const struct common_glue_ctx camellia_enc = {
41 .num_funcs = 3,
42 .fpu_blocks_limit = CAMELLIA_AESNI_PARALLEL_BLOCKS,
43
44 .funcs = { {
45 .num_blocks = CAMELLIA_AESNI_PARALLEL_BLOCKS,
46 .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_ecb_enc_16way) }
47 }, {
48 .num_blocks = 2,
49 .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_enc_blk_2way) }
50 }, {
51 .num_blocks = 1,
52 .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_enc_blk) }
53 } }
54};
55
56static const struct common_glue_ctx camellia_ctr = {
57 .num_funcs = 3,
58 .fpu_blocks_limit = CAMELLIA_AESNI_PARALLEL_BLOCKS,
59
60 .funcs = { {
61 .num_blocks = CAMELLIA_AESNI_PARALLEL_BLOCKS,
62 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(camellia_ctr_16way) }
63 }, {
64 .num_blocks = 2,
65 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(camellia_crypt_ctr_2way) }
66 }, {
67 .num_blocks = 1,
68 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(camellia_crypt_ctr) }
69 } }
70};
71
72static const struct common_glue_ctx camellia_dec = {
73 .num_funcs = 3,
74 .fpu_blocks_limit = CAMELLIA_AESNI_PARALLEL_BLOCKS,
75
76 .funcs = { {
77 .num_blocks = CAMELLIA_AESNI_PARALLEL_BLOCKS,
78 .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_ecb_dec_16way) }
79 }, {
80 .num_blocks = 2,
81 .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_dec_blk_2way) }
82 }, {
83 .num_blocks = 1,
84 .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_dec_blk) }
85 } }
86};
87
88static const struct common_glue_ctx camellia_dec_cbc = {
89 .num_funcs = 3,
90 .fpu_blocks_limit = CAMELLIA_AESNI_PARALLEL_BLOCKS,
91
92 .funcs = { {
93 .num_blocks = CAMELLIA_AESNI_PARALLEL_BLOCKS,
94 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(camellia_cbc_dec_16way) }
95 }, {
96 .num_blocks = 2,
97 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(camellia_decrypt_cbc_2way) }
98 }, {
99 .num_blocks = 1,
100 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(camellia_dec_blk) }
101 } }
102};
103
104static int ecb_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
105 struct scatterlist *src, unsigned int nbytes)
106{
107 return glue_ecb_crypt_128bit(&camellia_enc, desc, dst, src, nbytes);
108}
109
110static int ecb_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
111 struct scatterlist *src, unsigned int nbytes)
112{
113 return glue_ecb_crypt_128bit(&camellia_dec, desc, dst, src, nbytes);
114}
115
116static int cbc_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
117 struct scatterlist *src, unsigned int nbytes)
118{
119 return glue_cbc_encrypt_128bit(GLUE_FUNC_CAST(camellia_enc_blk), desc,
120 dst, src, nbytes);
121}
122
123static int cbc_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
124 struct scatterlist *src, unsigned int nbytes)
125{
126 return glue_cbc_decrypt_128bit(&camellia_dec_cbc, desc, dst, src,
127 nbytes);
128}
129
130static int ctr_crypt(struct blkcipher_desc *desc, struct scatterlist *dst,
131 struct scatterlist *src, unsigned int nbytes)
132{
133 return glue_ctr_crypt_128bit(&camellia_ctr, desc, dst, src, nbytes);
134}
135
136static inline bool camellia_fpu_begin(bool fpu_enabled, unsigned int nbytes)
137{
138 return glue_fpu_begin(CAMELLIA_BLOCK_SIZE,
139 CAMELLIA_AESNI_PARALLEL_BLOCKS, NULL, fpu_enabled,
140 nbytes);
141}
142
143static inline void camellia_fpu_end(bool fpu_enabled)
144{
145 glue_fpu_end(fpu_enabled);
146}
147
148static int camellia_setkey(struct crypto_tfm *tfm, const u8 *in_key,
149 unsigned int key_len)
150{
151 return __camellia_setkey(crypto_tfm_ctx(tfm), in_key, key_len,
152 &tfm->crt_flags);
153}
154
155struct crypt_priv {
156 struct camellia_ctx *ctx;
157 bool fpu_enabled;
158};
159
160static void encrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes)
161{
162 const unsigned int bsize = CAMELLIA_BLOCK_SIZE;
163 struct crypt_priv *ctx = priv;
164 int i;
165
166 ctx->fpu_enabled = camellia_fpu_begin(ctx->fpu_enabled, nbytes);
167
168 if (nbytes >= CAMELLIA_AESNI_PARALLEL_BLOCKS * bsize) {
169 camellia_ecb_enc_16way(ctx->ctx, srcdst, srcdst);
170 srcdst += bsize * CAMELLIA_AESNI_PARALLEL_BLOCKS;
171 nbytes -= bsize * CAMELLIA_AESNI_PARALLEL_BLOCKS;
172 }
173
174 while (nbytes >= CAMELLIA_PARALLEL_BLOCKS * bsize) {
175 camellia_enc_blk_2way(ctx->ctx, srcdst, srcdst);
176 srcdst += bsize * CAMELLIA_PARALLEL_BLOCKS;
177 nbytes -= bsize * CAMELLIA_PARALLEL_BLOCKS;
178 }
179
180 for (i = 0; i < nbytes / bsize; i++, srcdst += bsize)
181 camellia_enc_blk(ctx->ctx, srcdst, srcdst);
182}
183
184static void decrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes)
185{
186 const unsigned int bsize = CAMELLIA_BLOCK_SIZE;
187 struct crypt_priv *ctx = priv;
188 int i;
189
190 ctx->fpu_enabled = camellia_fpu_begin(ctx->fpu_enabled, nbytes);
191
192 if (nbytes >= CAMELLIA_AESNI_PARALLEL_BLOCKS * bsize) {
193 camellia_ecb_dec_16way(ctx->ctx, srcdst, srcdst);
194 srcdst += bsize * CAMELLIA_AESNI_PARALLEL_BLOCKS;
195 nbytes -= bsize * CAMELLIA_AESNI_PARALLEL_BLOCKS;
196 }
197
198 while (nbytes >= CAMELLIA_PARALLEL_BLOCKS * bsize) {
199 camellia_dec_blk_2way(ctx->ctx, srcdst, srcdst);
200 srcdst += bsize * CAMELLIA_PARALLEL_BLOCKS;
201 nbytes -= bsize * CAMELLIA_PARALLEL_BLOCKS;
202 }
203
204 for (i = 0; i < nbytes / bsize; i++, srcdst += bsize)
205 camellia_dec_blk(ctx->ctx, srcdst, srcdst);
206}
207
208static int lrw_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
209 struct scatterlist *src, unsigned int nbytes)
210{
211 struct camellia_lrw_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
212 be128 buf[CAMELLIA_AESNI_PARALLEL_BLOCKS];
213 struct crypt_priv crypt_ctx = {
214 .ctx = &ctx->camellia_ctx,
215 .fpu_enabled = false,
216 };
217 struct lrw_crypt_req req = {
218 .tbuf = buf,
219 .tbuflen = sizeof(buf),
220
221 .table_ctx = &ctx->lrw_table,
222 .crypt_ctx = &crypt_ctx,
223 .crypt_fn = encrypt_callback,
224 };
225 int ret;
226
227 desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
228 ret = lrw_crypt(desc, dst, src, nbytes, &req);
229 camellia_fpu_end(crypt_ctx.fpu_enabled);
230
231 return ret;
232}
233
234static int lrw_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
235 struct scatterlist *src, unsigned int nbytes)
236{
237 struct camellia_lrw_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
238 be128 buf[CAMELLIA_AESNI_PARALLEL_BLOCKS];
239 struct crypt_priv crypt_ctx = {
240 .ctx = &ctx->camellia_ctx,
241 .fpu_enabled = false,
242 };
243 struct lrw_crypt_req req = {
244 .tbuf = buf,
245 .tbuflen = sizeof(buf),
246
247 .table_ctx = &ctx->lrw_table,
248 .crypt_ctx = &crypt_ctx,
249 .crypt_fn = decrypt_callback,
250 };
251 int ret;
252
253 desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
254 ret = lrw_crypt(desc, dst, src, nbytes, &req);
255 camellia_fpu_end(crypt_ctx.fpu_enabled);
256
257 return ret;
258}
259
260static int xts_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
261 struct scatterlist *src, unsigned int nbytes)
262{
263 struct camellia_xts_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
264 be128 buf[CAMELLIA_AESNI_PARALLEL_BLOCKS];
265 struct crypt_priv crypt_ctx = {
266 .ctx = &ctx->crypt_ctx,
267 .fpu_enabled = false,
268 };
269 struct xts_crypt_req req = {
270 .tbuf = buf,
271 .tbuflen = sizeof(buf),
272
273 .tweak_ctx = &ctx->tweak_ctx,
274 .tweak_fn = XTS_TWEAK_CAST(camellia_enc_blk),
275 .crypt_ctx = &crypt_ctx,
276 .crypt_fn = encrypt_callback,
277 };
278 int ret;
279
280 desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
281 ret = xts_crypt(desc, dst, src, nbytes, &req);
282 camellia_fpu_end(crypt_ctx.fpu_enabled);
283
284 return ret;
285}
286
287static int xts_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
288 struct scatterlist *src, unsigned int nbytes)
289{
290 struct camellia_xts_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
291 be128 buf[CAMELLIA_AESNI_PARALLEL_BLOCKS];
292 struct crypt_priv crypt_ctx = {
293 .ctx = &ctx->crypt_ctx,
294 .fpu_enabled = false,
295 };
296 struct xts_crypt_req req = {
297 .tbuf = buf,
298 .tbuflen = sizeof(buf),
299
300 .tweak_ctx = &ctx->tweak_ctx,
301 .tweak_fn = XTS_TWEAK_CAST(camellia_enc_blk),
302 .crypt_ctx = &crypt_ctx,
303 .crypt_fn = decrypt_callback,
304 };
305 int ret;
306
307 desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
308 ret = xts_crypt(desc, dst, src, nbytes, &req);
309 camellia_fpu_end(crypt_ctx.fpu_enabled);
310
311 return ret;
312}
313
314static struct crypto_alg cmll_algs[10] = { {
315 .cra_name = "__ecb-camellia-aesni",
316 .cra_driver_name = "__driver-ecb-camellia-aesni",
317 .cra_priority = 0,
318 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
319 .cra_blocksize = CAMELLIA_BLOCK_SIZE,
320 .cra_ctxsize = sizeof(struct camellia_ctx),
321 .cra_alignmask = 0,
322 .cra_type = &crypto_blkcipher_type,
323 .cra_module = THIS_MODULE,
324 .cra_u = {
325 .blkcipher = {
326 .min_keysize = CAMELLIA_MIN_KEY_SIZE,
327 .max_keysize = CAMELLIA_MAX_KEY_SIZE,
328 .setkey = camellia_setkey,
329 .encrypt = ecb_encrypt,
330 .decrypt = ecb_decrypt,
331 },
332 },
333}, {
334 .cra_name = "__cbc-camellia-aesni",
335 .cra_driver_name = "__driver-cbc-camellia-aesni",
336 .cra_priority = 0,
337 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
338 .cra_blocksize = CAMELLIA_BLOCK_SIZE,
339 .cra_ctxsize = sizeof(struct camellia_ctx),
340 .cra_alignmask = 0,
341 .cra_type = &crypto_blkcipher_type,
342 .cra_module = THIS_MODULE,
343 .cra_u = {
344 .blkcipher = {
345 .min_keysize = CAMELLIA_MIN_KEY_SIZE,
346 .max_keysize = CAMELLIA_MAX_KEY_SIZE,
347 .setkey = camellia_setkey,
348 .encrypt = cbc_encrypt,
349 .decrypt = cbc_decrypt,
350 },
351 },
352}, {
353 .cra_name = "__ctr-camellia-aesni",
354 .cra_driver_name = "__driver-ctr-camellia-aesni",
355 .cra_priority = 0,
356 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
357 .cra_blocksize = 1,
358 .cra_ctxsize = sizeof(struct camellia_ctx),
359 .cra_alignmask = 0,
360 .cra_type = &crypto_blkcipher_type,
361 .cra_module = THIS_MODULE,
362 .cra_u = {
363 .blkcipher = {
364 .min_keysize = CAMELLIA_MIN_KEY_SIZE,
365 .max_keysize = CAMELLIA_MAX_KEY_SIZE,
366 .ivsize = CAMELLIA_BLOCK_SIZE,
367 .setkey = camellia_setkey,
368 .encrypt = ctr_crypt,
369 .decrypt = ctr_crypt,
370 },
371 },
372}, {
373 .cra_name = "__lrw-camellia-aesni",
374 .cra_driver_name = "__driver-lrw-camellia-aesni",
375 .cra_priority = 0,
376 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
377 .cra_blocksize = CAMELLIA_BLOCK_SIZE,
378 .cra_ctxsize = sizeof(struct camellia_lrw_ctx),
379 .cra_alignmask = 0,
380 .cra_type = &crypto_blkcipher_type,
381 .cra_module = THIS_MODULE,
382 .cra_exit = lrw_camellia_exit_tfm,
383 .cra_u = {
384 .blkcipher = {
385 .min_keysize = CAMELLIA_MIN_KEY_SIZE +
386 CAMELLIA_BLOCK_SIZE,
387 .max_keysize = CAMELLIA_MAX_KEY_SIZE +
388 CAMELLIA_BLOCK_SIZE,
389 .ivsize = CAMELLIA_BLOCK_SIZE,
390 .setkey = lrw_camellia_setkey,
391 .encrypt = lrw_encrypt,
392 .decrypt = lrw_decrypt,
393 },
394 },
395}, {
396 .cra_name = "__xts-camellia-aesni",
397 .cra_driver_name = "__driver-xts-camellia-aesni",
398 .cra_priority = 0,
399 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
400 .cra_blocksize = CAMELLIA_BLOCK_SIZE,
401 .cra_ctxsize = sizeof(struct camellia_xts_ctx),
402 .cra_alignmask = 0,
403 .cra_type = &crypto_blkcipher_type,
404 .cra_module = THIS_MODULE,
405 .cra_u = {
406 .blkcipher = {
407 .min_keysize = CAMELLIA_MIN_KEY_SIZE * 2,
408 .max_keysize = CAMELLIA_MAX_KEY_SIZE * 2,
409 .ivsize = CAMELLIA_BLOCK_SIZE,
410 .setkey = xts_camellia_setkey,
411 .encrypt = xts_encrypt,
412 .decrypt = xts_decrypt,
413 },
414 },
415}, {
416 .cra_name = "ecb(camellia)",
417 .cra_driver_name = "ecb-camellia-aesni",
418 .cra_priority = 400,
419 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
420 .cra_blocksize = CAMELLIA_BLOCK_SIZE,
421 .cra_ctxsize = sizeof(struct async_helper_ctx),
422 .cra_alignmask = 0,
423 .cra_type = &crypto_ablkcipher_type,
424 .cra_module = THIS_MODULE,
425 .cra_init = ablk_init,
426 .cra_exit = ablk_exit,
427 .cra_u = {
428 .ablkcipher = {
429 .min_keysize = CAMELLIA_MIN_KEY_SIZE,
430 .max_keysize = CAMELLIA_MAX_KEY_SIZE,
431 .setkey = ablk_set_key,
432 .encrypt = ablk_encrypt,
433 .decrypt = ablk_decrypt,
434 },
435 },
436}, {
437 .cra_name = "cbc(camellia)",
438 .cra_driver_name = "cbc-camellia-aesni",
439 .cra_priority = 400,
440 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
441 .cra_blocksize = CAMELLIA_BLOCK_SIZE,
442 .cra_ctxsize = sizeof(struct async_helper_ctx),
443 .cra_alignmask = 0,
444 .cra_type = &crypto_ablkcipher_type,
445 .cra_module = THIS_MODULE,
446 .cra_init = ablk_init,
447 .cra_exit = ablk_exit,
448 .cra_u = {
449 .ablkcipher = {
450 .min_keysize = CAMELLIA_MIN_KEY_SIZE,
451 .max_keysize = CAMELLIA_MAX_KEY_SIZE,
452 .ivsize = CAMELLIA_BLOCK_SIZE,
453 .setkey = ablk_set_key,
454 .encrypt = __ablk_encrypt,
455 .decrypt = ablk_decrypt,
456 },
457 },
458}, {
459 .cra_name = "ctr(camellia)",
460 .cra_driver_name = "ctr-camellia-aesni",
461 .cra_priority = 400,
462 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
463 .cra_blocksize = 1,
464 .cra_ctxsize = sizeof(struct async_helper_ctx),
465 .cra_alignmask = 0,
466 .cra_type = &crypto_ablkcipher_type,
467 .cra_module = THIS_MODULE,
468 .cra_init = ablk_init,
469 .cra_exit = ablk_exit,
470 .cra_u = {
471 .ablkcipher = {
472 .min_keysize = CAMELLIA_MIN_KEY_SIZE,
473 .max_keysize = CAMELLIA_MAX_KEY_SIZE,
474 .ivsize = CAMELLIA_BLOCK_SIZE,
475 .setkey = ablk_set_key,
476 .encrypt = ablk_encrypt,
477 .decrypt = ablk_encrypt,
478 .geniv = "chainiv",
479 },
480 },
481}, {
482 .cra_name = "lrw(camellia)",
483 .cra_driver_name = "lrw-camellia-aesni",
484 .cra_priority = 400,
485 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
486 .cra_blocksize = CAMELLIA_BLOCK_SIZE,
487 .cra_ctxsize = sizeof(struct async_helper_ctx),
488 .cra_alignmask = 0,
489 .cra_type = &crypto_ablkcipher_type,
490 .cra_module = THIS_MODULE,
491 .cra_init = ablk_init,
492 .cra_exit = ablk_exit,
493 .cra_u = {
494 .ablkcipher = {
495 .min_keysize = CAMELLIA_MIN_KEY_SIZE +
496 CAMELLIA_BLOCK_SIZE,
497 .max_keysize = CAMELLIA_MAX_KEY_SIZE +
498 CAMELLIA_BLOCK_SIZE,
499 .ivsize = CAMELLIA_BLOCK_SIZE,
500 .setkey = ablk_set_key,
501 .encrypt = ablk_encrypt,
502 .decrypt = ablk_decrypt,
503 },
504 },
505}, {
506 .cra_name = "xts(camellia)",
507 .cra_driver_name = "xts-camellia-aesni",
508 .cra_priority = 400,
509 .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
510 .cra_blocksize = CAMELLIA_BLOCK_SIZE,
511 .cra_ctxsize = sizeof(struct async_helper_ctx),
512 .cra_alignmask = 0,
513 .cra_type = &crypto_ablkcipher_type,
514 .cra_module = THIS_MODULE,
515 .cra_init = ablk_init,
516 .cra_exit = ablk_exit,
517 .cra_u = {
518 .ablkcipher = {
519 .min_keysize = CAMELLIA_MIN_KEY_SIZE * 2,
520 .max_keysize = CAMELLIA_MAX_KEY_SIZE * 2,
521 .ivsize = CAMELLIA_BLOCK_SIZE,
522 .setkey = ablk_set_key,
523 .encrypt = ablk_encrypt,
524 .decrypt = ablk_decrypt,
525 },
526 },
527} };
528
529static int __init camellia_aesni_init(void)
530{
531 u64 xcr0;
532
533 if (!cpu_has_avx || !cpu_has_aes || !cpu_has_osxsave) {
534 pr_info("AVX or AES-NI instructions are not detected.\n");
535 return -ENODEV;
536 }
537
538 xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK);
539 if ((xcr0 & (XSTATE_SSE | XSTATE_YMM)) != (XSTATE_SSE | XSTATE_YMM)) {
540 pr_info("AVX detected but unusable.\n");
541 return -ENODEV;
542 }
543
544 return crypto_register_algs(cmll_algs, ARRAY_SIZE(cmll_algs));
545}
546
547static void __exit camellia_aesni_fini(void)
548{
549 crypto_unregister_algs(cmll_algs, ARRAY_SIZE(cmll_algs));
550}
551
552module_init(camellia_aesni_init);
553module_exit(camellia_aesni_fini);
554
555MODULE_LICENSE("GPL");
556MODULE_DESCRIPTION("Camellia Cipher Algorithm, AES-NI/AVX optimized");
557MODULE_ALIAS("camellia");
558MODULE_ALIAS("camellia-asm");
diff --git a/arch/x86/crypto/camellia_glue.c b/arch/x86/crypto/camellia_glue.c
index 42ffd2bbab5b..5cb86ccd4acb 100644
--- a/arch/x86/crypto/camellia_glue.c
+++ b/arch/x86/crypto/camellia_glue.c
@@ -32,53 +32,24 @@
32#include <crypto/algapi.h> 32#include <crypto/algapi.h>
33#include <crypto/lrw.h> 33#include <crypto/lrw.h>
34#include <crypto/xts.h> 34#include <crypto/xts.h>
35#include <asm/crypto/camellia.h>
35#include <asm/crypto/glue_helper.h> 36#include <asm/crypto/glue_helper.h>
36 37
37#define CAMELLIA_MIN_KEY_SIZE 16
38#define CAMELLIA_MAX_KEY_SIZE 32
39#define CAMELLIA_BLOCK_SIZE 16
40#define CAMELLIA_TABLE_BYTE_LEN 272
41
42struct camellia_ctx {
43 u64 key_table[CAMELLIA_TABLE_BYTE_LEN / sizeof(u64)];
44 u32 key_length;
45};
46
47/* regular block cipher functions */ 38/* regular block cipher functions */
48asmlinkage void __camellia_enc_blk(struct camellia_ctx *ctx, u8 *dst, 39asmlinkage void __camellia_enc_blk(struct camellia_ctx *ctx, u8 *dst,
49 const u8 *src, bool xor); 40 const u8 *src, bool xor);
41EXPORT_SYMBOL_GPL(__camellia_enc_blk);
50asmlinkage void camellia_dec_blk(struct camellia_ctx *ctx, u8 *dst, 42asmlinkage void camellia_dec_blk(struct camellia_ctx *ctx, u8 *dst,
51 const u8 *src); 43 const u8 *src);
44EXPORT_SYMBOL_GPL(camellia_dec_blk);
52 45
53/* 2-way parallel cipher functions */ 46/* 2-way parallel cipher functions */
54asmlinkage void __camellia_enc_blk_2way(struct camellia_ctx *ctx, u8 *dst, 47asmlinkage void __camellia_enc_blk_2way(struct camellia_ctx *ctx, u8 *dst,
55 const u8 *src, bool xor); 48 const u8 *src, bool xor);
49EXPORT_SYMBOL_GPL(__camellia_enc_blk_2way);
56asmlinkage void camellia_dec_blk_2way(struct camellia_ctx *ctx, u8 *dst, 50asmlinkage void camellia_dec_blk_2way(struct camellia_ctx *ctx, u8 *dst,
57 const u8 *src); 51 const u8 *src);
58 52EXPORT_SYMBOL_GPL(camellia_dec_blk_2way);
59static inline void camellia_enc_blk(struct camellia_ctx *ctx, u8 *dst,
60 const u8 *src)
61{
62 __camellia_enc_blk(ctx, dst, src, false);
63}
64
65static inline void camellia_enc_blk_xor(struct camellia_ctx *ctx, u8 *dst,
66 const u8 *src)
67{
68 __camellia_enc_blk(ctx, dst, src, true);
69}
70
71static inline void camellia_enc_blk_2way(struct camellia_ctx *ctx, u8 *dst,
72 const u8 *src)
73{
74 __camellia_enc_blk_2way(ctx, dst, src, false);
75}
76
77static inline void camellia_enc_blk_xor_2way(struct camellia_ctx *ctx, u8 *dst,
78 const u8 *src)
79{
80 __camellia_enc_blk_2way(ctx, dst, src, true);
81}
82 53
83static void camellia_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) 54static void camellia_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
84{ 55{
@@ -1275,9 +1246,8 @@ static void camellia_setup192(const unsigned char *key, u64 *subkey)
1275 camellia_setup256(kk, subkey); 1246 camellia_setup256(kk, subkey);
1276} 1247}
1277 1248
1278static int __camellia_setkey(struct camellia_ctx *cctx, 1249int __camellia_setkey(struct camellia_ctx *cctx, const unsigned char *key,
1279 const unsigned char *key, 1250 unsigned int key_len, u32 *flags)
1280 unsigned int key_len, u32 *flags)
1281{ 1251{
1282 if (key_len != 16 && key_len != 24 && key_len != 32) { 1252 if (key_len != 16 && key_len != 24 && key_len != 32) {
1283 *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; 1253 *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
@@ -1300,6 +1270,7 @@ static int __camellia_setkey(struct camellia_ctx *cctx,
1300 1270
1301 return 0; 1271 return 0;
1302} 1272}
1273EXPORT_SYMBOL_GPL(__camellia_setkey);
1303 1274
1304static int camellia_setkey(struct crypto_tfm *tfm, const u8 *in_key, 1275static int camellia_setkey(struct crypto_tfm *tfm, const u8 *in_key,
1305 unsigned int key_len) 1276 unsigned int key_len)
@@ -1308,7 +1279,7 @@ static int camellia_setkey(struct crypto_tfm *tfm, const u8 *in_key,
1308 &tfm->crt_flags); 1279 &tfm->crt_flags);
1309} 1280}
1310 1281
1311static void camellia_decrypt_cbc_2way(void *ctx, u128 *dst, const u128 *src) 1282void camellia_decrypt_cbc_2way(void *ctx, u128 *dst, const u128 *src)
1312{ 1283{
1313 u128 iv = *src; 1284 u128 iv = *src;
1314 1285
@@ -1316,22 +1287,23 @@ static void camellia_decrypt_cbc_2way(void *ctx, u128 *dst, const u128 *src)
1316 1287
1317 u128_xor(&dst[1], &dst[1], &iv); 1288 u128_xor(&dst[1], &dst[1], &iv);
1318} 1289}
1290EXPORT_SYMBOL_GPL(camellia_decrypt_cbc_2way);
1319 1291
1320static void camellia_crypt_ctr(void *ctx, u128 *dst, const u128 *src, u128 *iv) 1292void camellia_crypt_ctr(void *ctx, u128 *dst, const u128 *src, le128 *iv)
1321{ 1293{
1322 be128 ctrblk; 1294 be128 ctrblk;
1323 1295
1324 if (dst != src) 1296 if (dst != src)
1325 *dst = *src; 1297 *dst = *src;
1326 1298
1327 u128_to_be128(&ctrblk, iv); 1299 le128_to_be128(&ctrblk, iv);
1328 u128_inc(iv); 1300 le128_inc(iv);
1329 1301
1330 camellia_enc_blk_xor(ctx, (u8 *)dst, (u8 *)&ctrblk); 1302 camellia_enc_blk_xor(ctx, (u8 *)dst, (u8 *)&ctrblk);
1331} 1303}
1304EXPORT_SYMBOL_GPL(camellia_crypt_ctr);
1332 1305
1333static void camellia_crypt_ctr_2way(void *ctx, u128 *dst, const u128 *src, 1306void camellia_crypt_ctr_2way(void *ctx, u128 *dst, const u128 *src, le128 *iv)
1334 u128 *iv)
1335{ 1307{
1336 be128 ctrblks[2]; 1308 be128 ctrblks[2];
1337 1309
@@ -1340,13 +1312,14 @@ static void camellia_crypt_ctr_2way(void *ctx, u128 *dst, const u128 *src,
1340 dst[1] = src[1]; 1312 dst[1] = src[1];
1341 } 1313 }
1342 1314
1343 u128_to_be128(&ctrblks[0], iv); 1315 le128_to_be128(&ctrblks[0], iv);
1344 u128_inc(iv); 1316 le128_inc(iv);
1345 u128_to_be128(&ctrblks[1], iv); 1317 le128_to_be128(&ctrblks[1], iv);
1346 u128_inc(iv); 1318 le128_inc(iv);
1347 1319
1348 camellia_enc_blk_xor_2way(ctx, (u8 *)dst, (u8 *)ctrblks); 1320 camellia_enc_blk_xor_2way(ctx, (u8 *)dst, (u8 *)ctrblks);
1349} 1321}
1322EXPORT_SYMBOL_GPL(camellia_crypt_ctr_2way);
1350 1323
1351static const struct common_glue_ctx camellia_enc = { 1324static const struct common_glue_ctx camellia_enc = {
1352 .num_funcs = 2, 1325 .num_funcs = 2,
@@ -1464,13 +1437,8 @@ static void decrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes)
1464 camellia_dec_blk(ctx, srcdst, srcdst); 1437 camellia_dec_blk(ctx, srcdst, srcdst);
1465} 1438}
1466 1439
1467struct camellia_lrw_ctx { 1440int lrw_camellia_setkey(struct crypto_tfm *tfm, const u8 *key,
1468 struct lrw_table_ctx lrw_table; 1441 unsigned int keylen)
1469 struct camellia_ctx camellia_ctx;
1470};
1471
1472static int lrw_camellia_setkey(struct crypto_tfm *tfm, const u8 *key,
1473 unsigned int keylen)
1474{ 1442{
1475 struct camellia_lrw_ctx *ctx = crypto_tfm_ctx(tfm); 1443 struct camellia_lrw_ctx *ctx = crypto_tfm_ctx(tfm);
1476 int err; 1444 int err;
@@ -1484,6 +1452,7 @@ static int lrw_camellia_setkey(struct crypto_tfm *tfm, const u8 *key,
1484 return lrw_init_table(&ctx->lrw_table, 1452 return lrw_init_table(&ctx->lrw_table,
1485 key + keylen - CAMELLIA_BLOCK_SIZE); 1453 key + keylen - CAMELLIA_BLOCK_SIZE);
1486} 1454}
1455EXPORT_SYMBOL_GPL(lrw_camellia_setkey);
1487 1456
1488static int lrw_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, 1457static int lrw_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
1489 struct scatterlist *src, unsigned int nbytes) 1458 struct scatterlist *src, unsigned int nbytes)
@@ -1519,20 +1488,16 @@ static int lrw_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
1519 return lrw_crypt(desc, dst, src, nbytes, &req); 1488 return lrw_crypt(desc, dst, src, nbytes, &req);
1520} 1489}
1521 1490
1522static void lrw_exit_tfm(struct crypto_tfm *tfm) 1491void lrw_camellia_exit_tfm(struct crypto_tfm *tfm)
1523{ 1492{
1524 struct camellia_lrw_ctx *ctx = crypto_tfm_ctx(tfm); 1493 struct camellia_lrw_ctx *ctx = crypto_tfm_ctx(tfm);
1525 1494
1526 lrw_free_table(&ctx->lrw_table); 1495 lrw_free_table(&ctx->lrw_table);
1527} 1496}
1497EXPORT_SYMBOL_GPL(lrw_camellia_exit_tfm);
1528 1498
1529struct camellia_xts_ctx { 1499int xts_camellia_setkey(struct crypto_tfm *tfm, const u8 *key,
1530 struct camellia_ctx tweak_ctx; 1500 unsigned int keylen)
1531 struct camellia_ctx crypt_ctx;
1532};
1533
1534static int xts_camellia_setkey(struct crypto_tfm *tfm, const u8 *key,
1535 unsigned int keylen)
1536{ 1501{
1537 struct camellia_xts_ctx *ctx = crypto_tfm_ctx(tfm); 1502 struct camellia_xts_ctx *ctx = crypto_tfm_ctx(tfm);
1538 u32 *flags = &tfm->crt_flags; 1503 u32 *flags = &tfm->crt_flags;
@@ -1555,6 +1520,7 @@ static int xts_camellia_setkey(struct crypto_tfm *tfm, const u8 *key,
1555 return __camellia_setkey(&ctx->tweak_ctx, key + keylen / 2, keylen / 2, 1520 return __camellia_setkey(&ctx->tweak_ctx, key + keylen / 2, keylen / 2,
1556 flags); 1521 flags);
1557} 1522}
1523EXPORT_SYMBOL_GPL(xts_camellia_setkey);
1558 1524
1559static int xts_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, 1525static int xts_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
1560 struct scatterlist *src, unsigned int nbytes) 1526 struct scatterlist *src, unsigned int nbytes)
@@ -1679,7 +1645,7 @@ static struct crypto_alg camellia_algs[6] = { {
1679 .cra_alignmask = 0, 1645 .cra_alignmask = 0,
1680 .cra_type = &crypto_blkcipher_type, 1646 .cra_type = &crypto_blkcipher_type,
1681 .cra_module = THIS_MODULE, 1647 .cra_module = THIS_MODULE,
1682 .cra_exit = lrw_exit_tfm, 1648 .cra_exit = lrw_camellia_exit_tfm,
1683 .cra_u = { 1649 .cra_u = {
1684 .blkcipher = { 1650 .blkcipher = {
1685 .min_keysize = CAMELLIA_MIN_KEY_SIZE + 1651 .min_keysize = CAMELLIA_MIN_KEY_SIZE +
diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
index a41a3aaba220..15b00ac7cbd3 100644
--- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
+++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
@@ -25,10 +25,10 @@
25 25
26.file "cast5-avx-x86_64-asm_64.S" 26.file "cast5-avx-x86_64-asm_64.S"
27 27
28.extern cast5_s1 28.extern cast_s1
29.extern cast5_s2 29.extern cast_s2
30.extern cast5_s3 30.extern cast_s3
31.extern cast5_s4 31.extern cast_s4
32 32
33/* structure of crypto context */ 33/* structure of crypto context */
34#define km 0 34#define km 0
@@ -36,10 +36,10 @@
36#define rr ((16*4)+16) 36#define rr ((16*4)+16)
37 37
38/* s-boxes */ 38/* s-boxes */
39#define s1 cast5_s1 39#define s1 cast_s1
40#define s2 cast5_s2 40#define s2 cast_s2
41#define s3 cast5_s3 41#define s3 cast_s3
42#define s4 cast5_s4 42#define s4 cast_s4
43 43
44/********************************************************************** 44/**********************************************************************
45 16-way AVX cast5 45 16-way AVX cast5
@@ -180,31 +180,17 @@
180 vpunpcklqdq t1, t0, x0; \ 180 vpunpcklqdq t1, t0, x0; \
181 vpunpckhqdq t1, t0, x1; 181 vpunpckhqdq t1, t0, x1;
182 182
183#define inpack_blocks(in, x0, x1, t0, t1, rmask) \ 183#define inpack_blocks(x0, x1, t0, t1, rmask) \
184 vmovdqu (0*4*4)(in), x0; \
185 vmovdqu (1*4*4)(in), x1; \
186 vpshufb rmask, x0, x0; \ 184 vpshufb rmask, x0, x0; \
187 vpshufb rmask, x1, x1; \ 185 vpshufb rmask, x1, x1; \
188 \ 186 \
189 transpose_2x4(x0, x1, t0, t1) 187 transpose_2x4(x0, x1, t0, t1)
190 188
191#define outunpack_blocks(out, x0, x1, t0, t1, rmask) \ 189#define outunpack_blocks(x0, x1, t0, t1, rmask) \
192 transpose_2x4(x0, x1, t0, t1) \ 190 transpose_2x4(x0, x1, t0, t1) \
193 \ 191 \
194 vpshufb rmask, x0, x0; \ 192 vpshufb rmask, x0, x0; \
195 vpshufb rmask, x1, x1; \ 193 vpshufb rmask, x1, x1;
196 vmovdqu x0, (0*4*4)(out); \
197 vmovdqu x1, (1*4*4)(out);
198
199#define outunpack_xor_blocks(out, x0, x1, t0, t1, rmask) \
200 transpose_2x4(x0, x1, t0, t1) \
201 \
202 vpshufb rmask, x0, x0; \
203 vpshufb rmask, x1, x1; \
204 vpxor (0*4*4)(out), x0, x0; \
205 vmovdqu x0, (0*4*4)(out); \
206 vpxor (1*4*4)(out), x1, x1; \
207 vmovdqu x1, (1*4*4)(out);
208 194
209.data 195.data
210 196
@@ -213,6 +199,8 @@
213 .byte 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 199 .byte 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12
214.Lbswap128_mask: 200.Lbswap128_mask:
215 .byte 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 201 .byte 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
202.Lbswap_iv_mask:
203 .byte 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0
216.L16_mask: 204.L16_mask:
217 .byte 16, 16, 16, 16 205 .byte 16, 16, 16, 16
218.L32_mask: 206.L32_mask:
@@ -223,35 +211,42 @@
223.text 211.text
224 212
225.align 16 213.align 16
226.global __cast5_enc_blk_16way 214.type __cast5_enc_blk16,@function;
227.type __cast5_enc_blk_16way,@function;
228 215
229__cast5_enc_blk_16way: 216__cast5_enc_blk16:
230 /* input: 217 /* input:
231 * %rdi: ctx, CTX 218 * %rdi: ctx, CTX
232 * %rsi: dst 219 * RL1: blocks 1 and 2
233 * %rdx: src 220 * RR1: blocks 3 and 4
234 * %rcx: bool, if true: xor output 221 * RL2: blocks 5 and 6
222 * RR2: blocks 7 and 8
223 * RL3: blocks 9 and 10
224 * RR3: blocks 11 and 12
225 * RL4: blocks 13 and 14
226 * RR4: blocks 15 and 16
227 * output:
228 * RL1: encrypted blocks 1 and 2
229 * RR1: encrypted blocks 3 and 4
230 * RL2: encrypted blocks 5 and 6
231 * RR2: encrypted blocks 7 and 8
232 * RL3: encrypted blocks 9 and 10
233 * RR3: encrypted blocks 11 and 12
234 * RL4: encrypted blocks 13 and 14
235 * RR4: encrypted blocks 15 and 16
235 */ 236 */
236 237
237 pushq %rbp; 238 pushq %rbp;
238 pushq %rbx; 239 pushq %rbx;
239 pushq %rcx;
240 240
241 vmovdqa .Lbswap_mask, RKM; 241 vmovdqa .Lbswap_mask, RKM;
242 vmovd .Lfirst_mask, R1ST; 242 vmovd .Lfirst_mask, R1ST;
243 vmovd .L32_mask, R32; 243 vmovd .L32_mask, R32;
244 enc_preload_rkr(); 244 enc_preload_rkr();
245 245
246 leaq 1*(2*4*4)(%rdx), %rax; 246 inpack_blocks(RL1, RR1, RTMP, RX, RKM);
247 inpack_blocks(%rdx, RL1, RR1, RTMP, RX, RKM); 247 inpack_blocks(RL2, RR2, RTMP, RX, RKM);
248 inpack_blocks(%rax, RL2, RR2, RTMP, RX, RKM); 248 inpack_blocks(RL3, RR3, RTMP, RX, RKM);
249 leaq 2*(2*4*4)(%rdx), %rax; 249 inpack_blocks(RL4, RR4, RTMP, RX, RKM);
250 inpack_blocks(%rax, RL3, RR3, RTMP, RX, RKM);
251 leaq 3*(2*4*4)(%rdx), %rax;
252 inpack_blocks(%rax, RL4, RR4, RTMP, RX, RKM);
253
254 movq %rsi, %r11;
255 250
256 round(RL, RR, 0, 1); 251 round(RL, RR, 0, 1);
257 round(RR, RL, 1, 2); 252 round(RR, RL, 1, 2);
@@ -276,44 +271,41 @@ __cast5_enc_blk_16way:
276 round(RR, RL, 15, 1); 271 round(RR, RL, 15, 1);
277 272
278__skip_enc: 273__skip_enc:
279 popq %rcx;
280 popq %rbx; 274 popq %rbx;
281 popq %rbp; 275 popq %rbp;
282 276
283 vmovdqa .Lbswap_mask, RKM; 277 vmovdqa .Lbswap_mask, RKM;
284 leaq 1*(2*4*4)(%r11), %rax;
285 278
286 testb %cl, %cl; 279 outunpack_blocks(RR1, RL1, RTMP, RX, RKM);
287 jnz __enc_xor16; 280 outunpack_blocks(RR2, RL2, RTMP, RX, RKM);
288 281 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
289 outunpack_blocks(%r11, RR1, RL1, RTMP, RX, RKM); 282 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
290 outunpack_blocks(%rax, RR2, RL2, RTMP, RX, RKM);
291 leaq 2*(2*4*4)(%r11), %rax;
292 outunpack_blocks(%rax, RR3, RL3, RTMP, RX, RKM);
293 leaq 3*(2*4*4)(%r11), %rax;
294 outunpack_blocks(%rax, RR4, RL4, RTMP, RX, RKM);
295
296 ret;
297
298__enc_xor16:
299 outunpack_xor_blocks(%r11, RR1, RL1, RTMP, RX, RKM);
300 outunpack_xor_blocks(%rax, RR2, RL2, RTMP, RX, RKM);
301 leaq 2*(2*4*4)(%r11), %rax;
302 outunpack_xor_blocks(%rax, RR3, RL3, RTMP, RX, RKM);
303 leaq 3*(2*4*4)(%r11), %rax;
304 outunpack_xor_blocks(%rax, RR4, RL4, RTMP, RX, RKM);
305 283
306 ret; 284 ret;
307 285
308.align 16 286.align 16
309.global cast5_dec_blk_16way 287.type __cast5_dec_blk16,@function;
310.type cast5_dec_blk_16way,@function;
311 288
312cast5_dec_blk_16way: 289__cast5_dec_blk16:
313 /* input: 290 /* input:
314 * %rdi: ctx, CTX 291 * %rdi: ctx, CTX
315 * %rsi: dst 292 * RL1: encrypted blocks 1 and 2
316 * %rdx: src 293 * RR1: encrypted blocks 3 and 4
294 * RL2: encrypted blocks 5 and 6
295 * RR2: encrypted blocks 7 and 8
296 * RL3: encrypted blocks 9 and 10
297 * RR3: encrypted blocks 11 and 12
298 * RL4: encrypted blocks 13 and 14
299 * RR4: encrypted blocks 15 and 16
300 * output:
301 * RL1: decrypted blocks 1 and 2
302 * RR1: decrypted blocks 3 and 4
303 * RL2: decrypted blocks 5 and 6
304 * RR2: decrypted blocks 7 and 8
305 * RL3: decrypted blocks 9 and 10
306 * RR3: decrypted blocks 11 and 12
307 * RL4: decrypted blocks 13 and 14
308 * RR4: decrypted blocks 15 and 16
317 */ 309 */
318 310
319 pushq %rbp; 311 pushq %rbp;
@@ -324,15 +316,10 @@ cast5_dec_blk_16way:
324 vmovd .L32_mask, R32; 316 vmovd .L32_mask, R32;
325 dec_preload_rkr(); 317 dec_preload_rkr();
326 318
327 leaq 1*(2*4*4)(%rdx), %rax; 319 inpack_blocks(RL1, RR1, RTMP, RX, RKM);
328 inpack_blocks(%rdx, RL1, RR1, RTMP, RX, RKM); 320 inpack_blocks(RL2, RR2, RTMP, RX, RKM);
329 inpack_blocks(%rax, RL2, RR2, RTMP, RX, RKM); 321 inpack_blocks(RL3, RR3, RTMP, RX, RKM);
330 leaq 2*(2*4*4)(%rdx), %rax; 322 inpack_blocks(RL4, RR4, RTMP, RX, RKM);
331 inpack_blocks(%rax, RL3, RR3, RTMP, RX, RKM);
332 leaq 3*(2*4*4)(%rdx), %rax;
333 inpack_blocks(%rax, RL4, RR4, RTMP, RX, RKM);
334
335 movq %rsi, %r11;
336 323
337 movzbl rr(CTX), %eax; 324 movzbl rr(CTX), %eax;
338 testl %eax, %eax; 325 testl %eax, %eax;
@@ -361,16 +348,211 @@ __dec_tail:
361 popq %rbx; 348 popq %rbx;
362 popq %rbp; 349 popq %rbp;
363 350
364 leaq 1*(2*4*4)(%r11), %rax; 351 outunpack_blocks(RR1, RL1, RTMP, RX, RKM);
365 outunpack_blocks(%r11, RR1, RL1, RTMP, RX, RKM); 352 outunpack_blocks(RR2, RL2, RTMP, RX, RKM);
366 outunpack_blocks(%rax, RR2, RL2, RTMP, RX, RKM); 353 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
367 leaq 2*(2*4*4)(%r11), %rax; 354 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
368 outunpack_blocks(%rax, RR3, RL3, RTMP, RX, RKM);
369 leaq 3*(2*4*4)(%r11), %rax;
370 outunpack_blocks(%rax, RR4, RL4, RTMP, RX, RKM);
371 355
372 ret; 356 ret;
373 357
374__skip_dec: 358__skip_dec:
375 vpsrldq $4, RKR, RKR; 359 vpsrldq $4, RKR, RKR;
376 jmp __dec_tail; 360 jmp __dec_tail;
361
362.align 16
363.global cast5_ecb_enc_16way
364.type cast5_ecb_enc_16way,@function;
365
366cast5_ecb_enc_16way:
367 /* input:
368 * %rdi: ctx, CTX
369 * %rsi: dst
370 * %rdx: src
371 */
372
373 movq %rsi, %r11;
374
375 vmovdqu (0*4*4)(%rdx), RL1;
376 vmovdqu (1*4*4)(%rdx), RR1;
377 vmovdqu (2*4*4)(%rdx), RL2;
378 vmovdqu (3*4*4)(%rdx), RR2;
379 vmovdqu (4*4*4)(%rdx), RL3;
380 vmovdqu (5*4*4)(%rdx), RR3;
381 vmovdqu (6*4*4)(%rdx), RL4;
382 vmovdqu (7*4*4)(%rdx), RR4;
383
384 call __cast5_enc_blk16;
385
386 vmovdqu RR1, (0*4*4)(%r11);
387 vmovdqu RL1, (1*4*4)(%r11);
388 vmovdqu RR2, (2*4*4)(%r11);
389 vmovdqu RL2, (3*4*4)(%r11);
390 vmovdqu RR3, (4*4*4)(%r11);
391 vmovdqu RL3, (5*4*4)(%r11);
392 vmovdqu RR4, (6*4*4)(%r11);
393 vmovdqu RL4, (7*4*4)(%r11);
394
395 ret;
396
397.align 16
398.global cast5_ecb_dec_16way
399.type cast5_ecb_dec_16way,@function;
400
401cast5_ecb_dec_16way:
402 /* input:
403 * %rdi: ctx, CTX
404 * %rsi: dst
405 * %rdx: src
406 */
407
408 movq %rsi, %r11;
409
410 vmovdqu (0*4*4)(%rdx), RL1;
411 vmovdqu (1*4*4)(%rdx), RR1;
412 vmovdqu (2*4*4)(%rdx), RL2;
413 vmovdqu (3*4*4)(%rdx), RR2;
414 vmovdqu (4*4*4)(%rdx), RL3;
415 vmovdqu (5*4*4)(%rdx), RR3;
416 vmovdqu (6*4*4)(%rdx), RL4;
417 vmovdqu (7*4*4)(%rdx), RR4;
418
419 call __cast5_dec_blk16;
420
421 vmovdqu RR1, (0*4*4)(%r11);
422 vmovdqu RL1, (1*4*4)(%r11);
423 vmovdqu RR2, (2*4*4)(%r11);
424 vmovdqu RL2, (3*4*4)(%r11);
425 vmovdqu RR3, (4*4*4)(%r11);
426 vmovdqu RL3, (5*4*4)(%r11);
427 vmovdqu RR4, (6*4*4)(%r11);
428 vmovdqu RL4, (7*4*4)(%r11);
429
430 ret;
431
432.align 16
433.global cast5_cbc_dec_16way
434.type cast5_cbc_dec_16way,@function;
435
436cast5_cbc_dec_16way:
437 /* input:
438 * %rdi: ctx, CTX
439 * %rsi: dst
440 * %rdx: src
441 */
442
443 pushq %r12;
444
445 movq %rsi, %r11;
446 movq %rdx, %r12;
447
448 vmovdqu (0*16)(%rdx), RL1;
449 vmovdqu (1*16)(%rdx), RR1;
450 vmovdqu (2*16)(%rdx), RL2;
451 vmovdqu (3*16)(%rdx), RR2;
452 vmovdqu (4*16)(%rdx), RL3;
453 vmovdqu (5*16)(%rdx), RR3;
454 vmovdqu (6*16)(%rdx), RL4;
455 vmovdqu (7*16)(%rdx), RR4;
456
457 call __cast5_dec_blk16;
458
459 /* xor with src */
460 vmovq (%r12), RX;
461 vpshufd $0x4f, RX, RX;
462 vpxor RX, RR1, RR1;
463 vpxor 0*16+8(%r12), RL1, RL1;
464 vpxor 1*16+8(%r12), RR2, RR2;
465 vpxor 2*16+8(%r12), RL2, RL2;
466 vpxor 3*16+8(%r12), RR3, RR3;
467 vpxor 4*16+8(%r12), RL3, RL3;
468 vpxor 5*16+8(%r12), RR4, RR4;
469 vpxor 6*16+8(%r12), RL4, RL4;
470
471 vmovdqu RR1, (0*16)(%r11);
472 vmovdqu RL1, (1*16)(%r11);
473 vmovdqu RR2, (2*16)(%r11);
474 vmovdqu RL2, (3*16)(%r11);
475 vmovdqu RR3, (4*16)(%r11);
476 vmovdqu RL3, (5*16)(%r11);
477 vmovdqu RR4, (6*16)(%r11);
478 vmovdqu RL4, (7*16)(%r11);
479
480 popq %r12;
481
482 ret;
483
484.align 16
485.global cast5_ctr_16way
486.type cast5_ctr_16way,@function;
487
488cast5_ctr_16way:
489 /* input:
490 * %rdi: ctx, CTX
491 * %rsi: dst
492 * %rdx: src
493 * %rcx: iv (big endian, 64bit)
494 */
495
496 pushq %r12;
497
498 movq %rsi, %r11;
499 movq %rdx, %r12;
500
501 vpcmpeqd RTMP, RTMP, RTMP;
502 vpsrldq $8, RTMP, RTMP; /* low: -1, high: 0 */
503
504 vpcmpeqd RKR, RKR, RKR;
505 vpaddq RKR, RKR, RKR; /* low: -2, high: -2 */
506 vmovdqa .Lbswap_iv_mask, R1ST;
507 vmovdqa .Lbswap128_mask, RKM;
508
509 /* load IV and byteswap */
510 vmovq (%rcx), RX;
511 vpshufb R1ST, RX, RX;
512
513 /* construct IVs */
514 vpsubq RTMP, RX, RX; /* le: IV1, IV0 */
515 vpshufb RKM, RX, RL1; /* be: IV0, IV1 */
516 vpsubq RKR, RX, RX;
517 vpshufb RKM, RX, RR1; /* be: IV2, IV3 */
518 vpsubq RKR, RX, RX;
519 vpshufb RKM, RX, RL2; /* be: IV4, IV5 */
520 vpsubq RKR, RX, RX;
521 vpshufb RKM, RX, RR2; /* be: IV6, IV7 */
522 vpsubq RKR, RX, RX;
523 vpshufb RKM, RX, RL3; /* be: IV8, IV9 */
524 vpsubq RKR, RX, RX;
525 vpshufb RKM, RX, RR3; /* be: IV10, IV11 */
526 vpsubq RKR, RX, RX;
527 vpshufb RKM, RX, RL4; /* be: IV12, IV13 */
528 vpsubq RKR, RX, RX;
529 vpshufb RKM, RX, RR4; /* be: IV14, IV15 */
530
531 /* store last IV */
532 vpsubq RTMP, RX, RX; /* le: IV16, IV14 */
533 vpshufb R1ST, RX, RX; /* be: IV16, IV16 */
534 vmovq RX, (%rcx);
535
536 call __cast5_enc_blk16;
537
538 /* dst = src ^ iv */
539 vpxor (0*16)(%r12), RR1, RR1;
540 vpxor (1*16)(%r12), RL1, RL1;
541 vpxor (2*16)(%r12), RR2, RR2;
542 vpxor (3*16)(%r12), RL2, RL2;
543 vpxor (4*16)(%r12), RR3, RR3;
544 vpxor (5*16)(%r12), RL3, RL3;
545 vpxor (6*16)(%r12), RR4, RR4;
546 vpxor (7*16)(%r12), RL4, RL4;
547 vmovdqu RR1, (0*16)(%r11);
548 vmovdqu RL1, (1*16)(%r11);
549 vmovdqu RR2, (2*16)(%r11);
550 vmovdqu RL2, (3*16)(%r11);
551 vmovdqu RR3, (4*16)(%r11);
552 vmovdqu RL3, (5*16)(%r11);
553 vmovdqu RR4, (6*16)(%r11);
554 vmovdqu RL4, (7*16)(%r11);
555
556 popq %r12;
557
558 ret;
diff --git a/arch/x86/crypto/cast5_avx_glue.c b/arch/x86/crypto/cast5_avx_glue.c
index e0ea14f9547f..c6631813dc11 100644
--- a/arch/x86/crypto/cast5_avx_glue.c
+++ b/arch/x86/crypto/cast5_avx_glue.c
@@ -37,29 +37,14 @@
37 37
38#define CAST5_PARALLEL_BLOCKS 16 38#define CAST5_PARALLEL_BLOCKS 16
39 39
40asmlinkage void __cast5_enc_blk_16way(struct cast5_ctx *ctx, u8 *dst, 40asmlinkage void cast5_ecb_enc_16way(struct cast5_ctx *ctx, u8 *dst,
41 const u8 *src, bool xor);
42asmlinkage void cast5_dec_blk_16way(struct cast5_ctx *ctx, u8 *dst,
43 const u8 *src); 41 const u8 *src);
44 42asmlinkage void cast5_ecb_dec_16way(struct cast5_ctx *ctx, u8 *dst,
45static inline void cast5_enc_blk_xway(struct cast5_ctx *ctx, u8 *dst, 43 const u8 *src);
46 const u8 *src) 44asmlinkage void cast5_cbc_dec_16way(struct cast5_ctx *ctx, u8 *dst,
47{ 45 const u8 *src);
48 __cast5_enc_blk_16way(ctx, dst, src, false); 46asmlinkage void cast5_ctr_16way(struct cast5_ctx *ctx, u8 *dst, const u8 *src,
49} 47 __be64 *iv);
50
51static inline void cast5_enc_blk_xway_xor(struct cast5_ctx *ctx, u8 *dst,
52 const u8 *src)
53{
54 __cast5_enc_blk_16way(ctx, dst, src, true);
55}
56
57static inline void cast5_dec_blk_xway(struct cast5_ctx *ctx, u8 *dst,
58 const u8 *src)
59{
60 cast5_dec_blk_16way(ctx, dst, src);
61}
62
63 48
64static inline bool cast5_fpu_begin(bool fpu_enabled, unsigned int nbytes) 49static inline bool cast5_fpu_begin(bool fpu_enabled, unsigned int nbytes)
65{ 50{
@@ -79,8 +64,11 @@ static int ecb_crypt(struct blkcipher_desc *desc, struct blkcipher_walk *walk,
79 struct cast5_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); 64 struct cast5_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
80 const unsigned int bsize = CAST5_BLOCK_SIZE; 65 const unsigned int bsize = CAST5_BLOCK_SIZE;
81 unsigned int nbytes; 66 unsigned int nbytes;
67 void (*fn)(struct cast5_ctx *ctx, u8 *dst, const u8 *src);
82 int err; 68 int err;
83 69
70 fn = (enc) ? cast5_ecb_enc_16way : cast5_ecb_dec_16way;
71
84 err = blkcipher_walk_virt(desc, walk); 72 err = blkcipher_walk_virt(desc, walk);
85 desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; 73 desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
86 74
@@ -93,10 +81,7 @@ static int ecb_crypt(struct blkcipher_desc *desc, struct blkcipher_walk *walk,
93 /* Process multi-block batch */ 81 /* Process multi-block batch */
94 if (nbytes >= bsize * CAST5_PARALLEL_BLOCKS) { 82 if (nbytes >= bsize * CAST5_PARALLEL_BLOCKS) {
95 do { 83 do {
96 if (enc) 84 fn(ctx, wdst, wsrc);
97 cast5_enc_blk_xway(ctx, wdst, wsrc);
98 else
99 cast5_dec_blk_xway(ctx, wdst, wsrc);
100 85
101 wsrc += bsize * CAST5_PARALLEL_BLOCKS; 86 wsrc += bsize * CAST5_PARALLEL_BLOCKS;
102 wdst += bsize * CAST5_PARALLEL_BLOCKS; 87 wdst += bsize * CAST5_PARALLEL_BLOCKS;
@@ -107,12 +92,11 @@ static int ecb_crypt(struct blkcipher_desc *desc, struct blkcipher_walk *walk,
107 goto done; 92 goto done;
108 } 93 }
109 94
95 fn = (enc) ? __cast5_encrypt : __cast5_decrypt;
96
110 /* Handle leftovers */ 97 /* Handle leftovers */
111 do { 98 do {
112 if (enc) 99 fn(ctx, wdst, wsrc);
113 __cast5_encrypt(ctx, wdst, wsrc);
114 else
115 __cast5_decrypt(ctx, wdst, wsrc);
116 100
117 wsrc += bsize; 101 wsrc += bsize;
118 wdst += bsize; 102 wdst += bsize;
@@ -194,9 +178,7 @@ static unsigned int __cbc_decrypt(struct blkcipher_desc *desc,
194 unsigned int nbytes = walk->nbytes; 178 unsigned int nbytes = walk->nbytes;
195 u64 *src = (u64 *)walk->src.virt.addr; 179 u64 *src = (u64 *)walk->src.virt.addr;
196 u64 *dst = (u64 *)walk->dst.virt.addr; 180 u64 *dst = (u64 *)walk->dst.virt.addr;
197 u64 ivs[CAST5_PARALLEL_BLOCKS - 1];
198 u64 last_iv; 181 u64 last_iv;
199 int i;
200 182
201 /* Start of the last block. */ 183 /* Start of the last block. */
202 src += nbytes / bsize - 1; 184 src += nbytes / bsize - 1;
@@ -211,13 +193,7 @@ static unsigned int __cbc_decrypt(struct blkcipher_desc *desc,
211 src -= CAST5_PARALLEL_BLOCKS - 1; 193 src -= CAST5_PARALLEL_BLOCKS - 1;
212 dst -= CAST5_PARALLEL_BLOCKS - 1; 194 dst -= CAST5_PARALLEL_BLOCKS - 1;
213 195
214 for (i = 0; i < CAST5_PARALLEL_BLOCKS - 1; i++) 196 cast5_cbc_dec_16way(ctx, (u8 *)dst, (u8 *)src);
215 ivs[i] = src[i];
216
217 cast5_dec_blk_xway(ctx, (u8 *)dst, (u8 *)src);
218
219 for (i = 0; i < CAST5_PARALLEL_BLOCKS - 1; i++)
220 *(dst + (i + 1)) ^= *(ivs + i);
221 197
222 nbytes -= bsize; 198 nbytes -= bsize;
223 if (nbytes < bsize) 199 if (nbytes < bsize)
@@ -298,23 +274,12 @@ static unsigned int __ctr_crypt(struct blkcipher_desc *desc,
298 unsigned int nbytes = walk->nbytes; 274 unsigned int nbytes = walk->nbytes;
299 u64 *src = (u64 *)walk->src.virt.addr; 275 u64 *src = (u64 *)walk->src.virt.addr;
300 u64 *dst = (u64 *)walk->dst.virt.addr; 276 u64 *dst = (u64 *)walk->dst.virt.addr;
301 u64 ctrblk = be64_to_cpu(*(__be64 *)walk->iv);
302 __be64 ctrblocks[CAST5_PARALLEL_BLOCKS];
303 int i;
304 277
305 /* Process multi-block batch */ 278 /* Process multi-block batch */
306 if (nbytes >= bsize * CAST5_PARALLEL_BLOCKS) { 279 if (nbytes >= bsize * CAST5_PARALLEL_BLOCKS) {
307 do { 280 do {
308 /* create ctrblks for parallel encrypt */ 281 cast5_ctr_16way(ctx, (u8 *)dst, (u8 *)src,
309 for (i = 0; i < CAST5_PARALLEL_BLOCKS; i++) { 282 (__be64 *)walk->iv);
310 if (dst != src)
311 dst[i] = src[i];
312
313 ctrblocks[i] = cpu_to_be64(ctrblk++);
314 }
315
316 cast5_enc_blk_xway_xor(ctx, (u8 *)dst,
317 (u8 *)ctrblocks);
318 283
319 src += CAST5_PARALLEL_BLOCKS; 284 src += CAST5_PARALLEL_BLOCKS;
320 dst += CAST5_PARALLEL_BLOCKS; 285 dst += CAST5_PARALLEL_BLOCKS;
@@ -327,13 +292,16 @@ static unsigned int __ctr_crypt(struct blkcipher_desc *desc,
327 292
328 /* Handle leftovers */ 293 /* Handle leftovers */
329 do { 294 do {
295 u64 ctrblk;
296
330 if (dst != src) 297 if (dst != src)
331 *dst = *src; 298 *dst = *src;
332 299
333 ctrblocks[0] = cpu_to_be64(ctrblk++); 300 ctrblk = *(u64 *)walk->iv;
301 be64_add_cpu((__be64 *)walk->iv, 1);
334 302
335 __cast5_encrypt(ctx, (u8 *)ctrblocks, (u8 *)ctrblocks); 303 __cast5_encrypt(ctx, (u8 *)&ctrblk, (u8 *)&ctrblk);
336 *dst ^= ctrblocks[0]; 304 *dst ^= ctrblk;
337 305
338 src += 1; 306 src += 1;
339 dst += 1; 307 dst += 1;
@@ -341,7 +309,6 @@ static unsigned int __ctr_crypt(struct blkcipher_desc *desc,
341 } while (nbytes >= bsize); 309 } while (nbytes >= bsize);
342 310
343done: 311done:
344 *(__be64 *)walk->iv = cpu_to_be64(ctrblk);
345 return nbytes; 312 return nbytes;
346} 313}
347 314
diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
index 218d283772f4..2569d0da841f 100644
--- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
+++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
@@ -23,22 +23,24 @@
23 * 23 *
24 */ 24 */
25 25
26#include "glue_helper-asm-avx.S"
27
26.file "cast6-avx-x86_64-asm_64.S" 28.file "cast6-avx-x86_64-asm_64.S"
27 29
28.extern cast6_s1 30.extern cast_s1
29.extern cast6_s2 31.extern cast_s2
30.extern cast6_s3 32.extern cast_s3
31.extern cast6_s4 33.extern cast_s4
32 34
33/* structure of crypto context */ 35/* structure of crypto context */
34#define km 0 36#define km 0
35#define kr (12*4*4) 37#define kr (12*4*4)
36 38
37/* s-boxes */ 39/* s-boxes */
38#define s1 cast6_s1 40#define s1 cast_s1
39#define s2 cast6_s2 41#define s2 cast_s2
40#define s3 cast6_s3 42#define s3 cast_s3
41#define s4 cast6_s4 43#define s4 cast_s4
42 44
43/********************************************************************** 45/**********************************************************************
44 8-way AVX cast6 46 8-way AVX cast6
@@ -205,11 +207,7 @@
205 vpunpcklqdq x3, t2, x2; \ 207 vpunpcklqdq x3, t2, x2; \
206 vpunpckhqdq x3, t2, x3; 208 vpunpckhqdq x3, t2, x3;
207 209
208#define inpack_blocks(in, x0, x1, x2, x3, t0, t1, t2, rmask) \ 210#define inpack_blocks(x0, x1, x2, x3, t0, t1, t2, rmask) \
209 vmovdqu (0*4*4)(in), x0; \
210 vmovdqu (1*4*4)(in), x1; \
211 vmovdqu (2*4*4)(in), x2; \
212 vmovdqu (3*4*4)(in), x3; \
213 vpshufb rmask, x0, x0; \ 211 vpshufb rmask, x0, x0; \
214 vpshufb rmask, x1, x1; \ 212 vpshufb rmask, x1, x1; \
215 vpshufb rmask, x2, x2; \ 213 vpshufb rmask, x2, x2; \
@@ -217,39 +215,21 @@
217 \ 215 \
218 transpose_4x4(x0, x1, x2, x3, t0, t1, t2) 216 transpose_4x4(x0, x1, x2, x3, t0, t1, t2)
219 217
220#define outunpack_blocks(out, x0, x1, x2, x3, t0, t1, t2, rmask) \ 218#define outunpack_blocks(x0, x1, x2, x3, t0, t1, t2, rmask) \
221 transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \ 219 transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \
222 \ 220 \
223 vpshufb rmask, x0, x0; \ 221 vpshufb rmask, x0, x0; \
224 vpshufb rmask, x1, x1; \ 222 vpshufb rmask, x1, x1; \
225 vpshufb rmask, x2, x2; \ 223 vpshufb rmask, x2, x2; \
226 vpshufb rmask, x3, x3; \ 224 vpshufb rmask, x3, x3;
227 vmovdqu x0, (0*4*4)(out); \
228 vmovdqu x1, (1*4*4)(out); \
229 vmovdqu x2, (2*4*4)(out); \
230 vmovdqu x3, (3*4*4)(out);
231
232#define outunpack_xor_blocks(out, x0, x1, x2, x3, t0, t1, t2, rmask) \
233 transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \
234 \
235 vpshufb rmask, x0, x0; \
236 vpshufb rmask, x1, x1; \
237 vpshufb rmask, x2, x2; \
238 vpshufb rmask, x3, x3; \
239 vpxor (0*4*4)(out), x0, x0; \
240 vmovdqu x0, (0*4*4)(out); \
241 vpxor (1*4*4)(out), x1, x1; \
242 vmovdqu x1, (1*4*4)(out); \
243 vpxor (2*4*4)(out), x2, x2; \
244 vmovdqu x2, (2*4*4)(out); \
245 vpxor (3*4*4)(out), x3, x3; \
246 vmovdqu x3, (3*4*4)(out);
247 225
248.data 226.data
249 227
250.align 16 228.align 16
251.Lbswap_mask: 229.Lbswap_mask:
252 .byte 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 230 .byte 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12
231.Lbswap128_mask:
232 .byte 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
253.Lrkr_enc_Q_Q_QBAR_QBAR: 233.Lrkr_enc_Q_Q_QBAR_QBAR:
254 .byte 0, 1, 2, 3, 4, 5, 6, 7, 11, 10, 9, 8, 15, 14, 13, 12 234 .byte 0, 1, 2, 3, 4, 5, 6, 7, 11, 10, 9, 8, 15, 14, 13, 12
255.Lrkr_enc_QBAR_QBAR_QBAR_QBAR: 235.Lrkr_enc_QBAR_QBAR_QBAR_QBAR:
@@ -269,31 +249,26 @@
269 249
270.text 250.text
271 251
272.align 16 252.align 8
273.global __cast6_enc_blk_8way 253.type __cast6_enc_blk8,@function;
274.type __cast6_enc_blk_8way,@function;
275 254
276__cast6_enc_blk_8way: 255__cast6_enc_blk8:
277 /* input: 256 /* input:
278 * %rdi: ctx, CTX 257 * %rdi: ctx, CTX
279 * %rsi: dst 258 * RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2: blocks
280 * %rdx: src 259 * output:
281 * %rcx: bool, if true: xor output 260 * RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2: encrypted blocks
282 */ 261 */
283 262
284 pushq %rbp; 263 pushq %rbp;
285 pushq %rbx; 264 pushq %rbx;
286 pushq %rcx;
287 265
288 vmovdqa .Lbswap_mask, RKM; 266 vmovdqa .Lbswap_mask, RKM;
289 vmovd .Lfirst_mask, R1ST; 267 vmovd .Lfirst_mask, R1ST;
290 vmovd .L32_mask, R32; 268 vmovd .L32_mask, R32;
291 269
292 leaq (4*4*4)(%rdx), %rax; 270 inpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
293 inpack_blocks(%rdx, RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM); 271 inpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
294 inpack_blocks(%rax, RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
295
296 movq %rsi, %r11;
297 272
298 preload_rkr(0, dummy, none); 273 preload_rkr(0, dummy, none);
299 Q(0); 274 Q(0);
@@ -311,36 +286,25 @@ __cast6_enc_blk_8way:
311 QBAR(10); 286 QBAR(10);
312 QBAR(11); 287 QBAR(11);
313 288
314 popq %rcx;
315 popq %rbx; 289 popq %rbx;
316 popq %rbp; 290 popq %rbp;
317 291
318 vmovdqa .Lbswap_mask, RKM; 292 vmovdqa .Lbswap_mask, RKM;
319 leaq (4*4*4)(%r11), %rax;
320
321 testb %cl, %cl;
322 jnz __enc_xor8;
323
324 outunpack_blocks(%r11, RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
325 outunpack_blocks(%rax, RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
326
327 ret;
328 293
329__enc_xor8: 294 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
330 outunpack_xor_blocks(%r11, RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM); 295 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
331 outunpack_xor_blocks(%rax, RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
332 296
333 ret; 297 ret;
334 298
335.align 16 299.align 8
336.global cast6_dec_blk_8way 300.type __cast6_dec_blk8,@function;
337.type cast6_dec_blk_8way,@function;
338 301
339cast6_dec_blk_8way: 302__cast6_dec_blk8:
340 /* input: 303 /* input:
341 * %rdi: ctx, CTX 304 * %rdi: ctx, CTX
342 * %rsi: dst 305 * RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2: encrypted blocks
343 * %rdx: src 306 * output:
307 * RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2: decrypted blocks
344 */ 308 */
345 309
346 pushq %rbp; 310 pushq %rbp;
@@ -350,11 +314,8 @@ cast6_dec_blk_8way:
350 vmovd .Lfirst_mask, R1ST; 314 vmovd .Lfirst_mask, R1ST;
351 vmovd .L32_mask, R32; 315 vmovd .L32_mask, R32;
352 316
353 leaq (4*4*4)(%rdx), %rax; 317 inpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
354 inpack_blocks(%rdx, RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM); 318 inpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
355 inpack_blocks(%rax, RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
356
357 movq %rsi, %r11;
358 319
359 preload_rkr(2, shuffle, .Lrkr_dec_Q_Q_Q_Q); 320 preload_rkr(2, shuffle, .Lrkr_dec_Q_Q_Q_Q);
360 Q(11); 321 Q(11);
@@ -376,8 +337,103 @@ cast6_dec_blk_8way:
376 popq %rbp; 337 popq %rbp;
377 338
378 vmovdqa .Lbswap_mask, RKM; 339 vmovdqa .Lbswap_mask, RKM;
379 leaq (4*4*4)(%r11), %rax; 340 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
380 outunpack_blocks(%r11, RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM); 341 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
381 outunpack_blocks(%rax, RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM); 342
343 ret;
344
345.align 8
346.global cast6_ecb_enc_8way
347.type cast6_ecb_enc_8way,@function;
348
349cast6_ecb_enc_8way:
350 /* input:
351 * %rdi: ctx, CTX
352 * %rsi: dst
353 * %rdx: src
354 */
355
356 movq %rsi, %r11;
357
358 load_8way(%rdx, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
359
360 call __cast6_enc_blk8;
361
362 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
363
364 ret;
365
366.align 8
367.global cast6_ecb_dec_8way
368.type cast6_ecb_dec_8way,@function;
369
370cast6_ecb_dec_8way:
371 /* input:
372 * %rdi: ctx, CTX
373 * %rsi: dst
374 * %rdx: src
375 */
376
377 movq %rsi, %r11;
378
379 load_8way(%rdx, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
380
381 call __cast6_dec_blk8;
382
383 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
384
385 ret;
386
387.align 8
388.global cast6_cbc_dec_8way
389.type cast6_cbc_dec_8way,@function;
390
391cast6_cbc_dec_8way:
392 /* input:
393 * %rdi: ctx, CTX
394 * %rsi: dst
395 * %rdx: src
396 */
397
398 pushq %r12;
399
400 movq %rsi, %r11;
401 movq %rdx, %r12;
402
403 load_8way(%rdx, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
404
405 call __cast6_dec_blk8;
406
407 store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
408
409 popq %r12;
410
411 ret;
412
413.align 8
414.global cast6_ctr_8way
415.type cast6_ctr_8way,@function;
416
417cast6_ctr_8way:
418 /* input:
419 * %rdi: ctx, CTX
420 * %rsi: dst
421 * %rdx: src
422 * %rcx: iv (little endian, 128bit)
423 */
424
425 pushq %r12;
426
427 movq %rsi, %r11;
428 movq %rdx, %r12;
429
430 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
431 RD2, RX, RKR, RKM);
432
433 call __cast6_enc_blk8;
434
435 store_ctr_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
436
437 popq %r12;
382 438
383 ret; 439 ret;
diff --git a/arch/x86/crypto/cast6_avx_glue.c b/arch/x86/crypto/cast6_avx_glue.c
index 15e5f85a5011..92f7ca24790a 100644
--- a/arch/x86/crypto/cast6_avx_glue.c
+++ b/arch/x86/crypto/cast6_avx_glue.c
@@ -40,79 +40,34 @@
40 40
41#define CAST6_PARALLEL_BLOCKS 8 41#define CAST6_PARALLEL_BLOCKS 8
42 42
43asmlinkage void __cast6_enc_blk_8way(struct cast6_ctx *ctx, u8 *dst, 43asmlinkage void cast6_ecb_enc_8way(struct cast6_ctx *ctx, u8 *dst,
44 const u8 *src, bool xor); 44 const u8 *src);
45asmlinkage void cast6_dec_blk_8way(struct cast6_ctx *ctx, u8 *dst, 45asmlinkage void cast6_ecb_dec_8way(struct cast6_ctx *ctx, u8 *dst,
46 const u8 *src); 46 const u8 *src);
47 47
48static inline void cast6_enc_blk_xway(struct cast6_ctx *ctx, u8 *dst, 48asmlinkage void cast6_cbc_dec_8way(struct cast6_ctx *ctx, u8 *dst,
49 const u8 *src) 49 const u8 *src);
50{ 50asmlinkage void cast6_ctr_8way(struct cast6_ctx *ctx, u8 *dst, const u8 *src,
51 __cast6_enc_blk_8way(ctx, dst, src, false); 51 le128 *iv);
52}
53
54static inline void cast6_enc_blk_xway_xor(struct cast6_ctx *ctx, u8 *dst,
55 const u8 *src)
56{
57 __cast6_enc_blk_8way(ctx, dst, src, true);
58}
59
60static inline void cast6_dec_blk_xway(struct cast6_ctx *ctx, u8 *dst,
61 const u8 *src)
62{
63 cast6_dec_blk_8way(ctx, dst, src);
64}
65
66
67static void cast6_decrypt_cbc_xway(void *ctx, u128 *dst, const u128 *src)
68{
69 u128 ivs[CAST6_PARALLEL_BLOCKS - 1];
70 unsigned int j;
71
72 for (j = 0; j < CAST6_PARALLEL_BLOCKS - 1; j++)
73 ivs[j] = src[j];
74
75 cast6_dec_blk_xway(ctx, (u8 *)dst, (u8 *)src);
76
77 for (j = 0; j < CAST6_PARALLEL_BLOCKS - 1; j++)
78 u128_xor(dst + (j + 1), dst + (j + 1), ivs + j);
79}
80 52
81static void cast6_crypt_ctr(void *ctx, u128 *dst, const u128 *src, u128 *iv) 53static void cast6_crypt_ctr(void *ctx, u128 *dst, const u128 *src, le128 *iv)
82{ 54{
83 be128 ctrblk; 55 be128 ctrblk;
84 56
85 u128_to_be128(&ctrblk, iv); 57 le128_to_be128(&ctrblk, iv);
86 u128_inc(iv); 58 le128_inc(iv);
87 59
88 __cast6_encrypt(ctx, (u8 *)&ctrblk, (u8 *)&ctrblk); 60 __cast6_encrypt(ctx, (u8 *)&ctrblk, (u8 *)&ctrblk);
89 u128_xor(dst, src, (u128 *)&ctrblk); 61 u128_xor(dst, src, (u128 *)&ctrblk);
90} 62}
91 63
92static void cast6_crypt_ctr_xway(void *ctx, u128 *dst, const u128 *src,
93 u128 *iv)
94{
95 be128 ctrblks[CAST6_PARALLEL_BLOCKS];
96 unsigned int i;
97
98 for (i = 0; i < CAST6_PARALLEL_BLOCKS; i++) {
99 if (dst != src)
100 dst[i] = src[i];
101
102 u128_to_be128(&ctrblks[i], iv);
103 u128_inc(iv);
104 }
105
106 cast6_enc_blk_xway_xor(ctx, (u8 *)dst, (u8 *)ctrblks);
107}
108
109static const struct common_glue_ctx cast6_enc = { 64static const struct common_glue_ctx cast6_enc = {
110 .num_funcs = 2, 65 .num_funcs = 2,
111 .fpu_blocks_limit = CAST6_PARALLEL_BLOCKS, 66 .fpu_blocks_limit = CAST6_PARALLEL_BLOCKS,
112 67
113 .funcs = { { 68 .funcs = { {
114 .num_blocks = CAST6_PARALLEL_BLOCKS, 69 .num_blocks = CAST6_PARALLEL_BLOCKS,
115 .fn_u = { .ecb = GLUE_FUNC_CAST(cast6_enc_blk_xway) } 70 .fn_u = { .ecb = GLUE_FUNC_CAST(cast6_ecb_enc_8way) }
116 }, { 71 }, {
117 .num_blocks = 1, 72 .num_blocks = 1,
118 .fn_u = { .ecb = GLUE_FUNC_CAST(__cast6_encrypt) } 73 .fn_u = { .ecb = GLUE_FUNC_CAST(__cast6_encrypt) }
@@ -125,7 +80,7 @@ static const struct common_glue_ctx cast6_ctr = {
125 80
126 .funcs = { { 81 .funcs = { {
127 .num_blocks = CAST6_PARALLEL_BLOCKS, 82 .num_blocks = CAST6_PARALLEL_BLOCKS,
128 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(cast6_crypt_ctr_xway) } 83 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(cast6_ctr_8way) }
129 }, { 84 }, {
130 .num_blocks = 1, 85 .num_blocks = 1,
131 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(cast6_crypt_ctr) } 86 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(cast6_crypt_ctr) }
@@ -138,7 +93,7 @@ static const struct common_glue_ctx cast6_dec = {
138 93
139 .funcs = { { 94 .funcs = { {
140 .num_blocks = CAST6_PARALLEL_BLOCKS, 95 .num_blocks = CAST6_PARALLEL_BLOCKS,
141 .fn_u = { .ecb = GLUE_FUNC_CAST(cast6_dec_blk_xway) } 96 .fn_u = { .ecb = GLUE_FUNC_CAST(cast6_ecb_dec_8way) }
142 }, { 97 }, {
143 .num_blocks = 1, 98 .num_blocks = 1,
144 .fn_u = { .ecb = GLUE_FUNC_CAST(__cast6_decrypt) } 99 .fn_u = { .ecb = GLUE_FUNC_CAST(__cast6_decrypt) }
@@ -151,7 +106,7 @@ static const struct common_glue_ctx cast6_dec_cbc = {
151 106
152 .funcs = { { 107 .funcs = { {
153 .num_blocks = CAST6_PARALLEL_BLOCKS, 108 .num_blocks = CAST6_PARALLEL_BLOCKS,
154 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(cast6_decrypt_cbc_xway) } 109 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(cast6_cbc_dec_8way) }
155 }, { 110 }, {
156 .num_blocks = 1, 111 .num_blocks = 1,
157 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(__cast6_decrypt) } 112 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(__cast6_decrypt) }
@@ -215,7 +170,7 @@ static void encrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes)
215 ctx->fpu_enabled = cast6_fpu_begin(ctx->fpu_enabled, nbytes); 170 ctx->fpu_enabled = cast6_fpu_begin(ctx->fpu_enabled, nbytes);
216 171
217 if (nbytes == bsize * CAST6_PARALLEL_BLOCKS) { 172 if (nbytes == bsize * CAST6_PARALLEL_BLOCKS) {
218 cast6_enc_blk_xway(ctx->ctx, srcdst, srcdst); 173 cast6_ecb_enc_8way(ctx->ctx, srcdst, srcdst);
219 return; 174 return;
220 } 175 }
221 176
@@ -232,7 +187,7 @@ static void decrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes)
232 ctx->fpu_enabled = cast6_fpu_begin(ctx->fpu_enabled, nbytes); 187 ctx->fpu_enabled = cast6_fpu_begin(ctx->fpu_enabled, nbytes);
233 188
234 if (nbytes == bsize * CAST6_PARALLEL_BLOCKS) { 189 if (nbytes == bsize * CAST6_PARALLEL_BLOCKS) {
235 cast6_dec_blk_xway(ctx->ctx, srcdst, srcdst); 190 cast6_ecb_dec_8way(ctx->ctx, srcdst, srcdst);
236 return; 191 return;
237 } 192 }
238 193
diff --git a/arch/x86/crypto/crc32c-intel.c b/arch/x86/crypto/crc32c-intel_glue.c
index 493f959261f7..6812ad98355c 100644
--- a/arch/x86/crypto/crc32c-intel.c
+++ b/arch/x86/crypto/crc32c-intel_glue.c
@@ -32,6 +32,8 @@
32 32
33#include <asm/cpufeature.h> 33#include <asm/cpufeature.h>
34#include <asm/cpu_device_id.h> 34#include <asm/cpu_device_id.h>
35#include <asm/i387.h>
36#include <asm/fpu-internal.h>
35 37
36#define CHKSUM_BLOCK_SIZE 1 38#define CHKSUM_BLOCK_SIZE 1
37#define CHKSUM_DIGEST_SIZE 4 39#define CHKSUM_DIGEST_SIZE 4
@@ -44,6 +46,31 @@
44#define REX_PRE 46#define REX_PRE
45#endif 47#endif
46 48
49#ifdef CONFIG_X86_64
50/*
51 * use carryless multiply version of crc32c when buffer
52 * size is >= 512 (when eager fpu is enabled) or
53 * >= 1024 (when eager fpu is disabled) to account
54 * for fpu state save/restore overhead.
55 */
56#define CRC32C_PCL_BREAKEVEN_EAGERFPU 512
57#define CRC32C_PCL_BREAKEVEN_NOEAGERFPU 1024
58
59asmlinkage unsigned int crc_pcl(const u8 *buffer, int len,
60 unsigned int crc_init);
61static int crc32c_pcl_breakeven = CRC32C_PCL_BREAKEVEN_EAGERFPU;
62#if defined(X86_FEATURE_EAGER_FPU)
63#define set_pcl_breakeven_point() \
64do { \
65 if (!use_eager_fpu()) \
66 crc32c_pcl_breakeven = CRC32C_PCL_BREAKEVEN_NOEAGERFPU; \
67} while (0)
68#else
69#define set_pcl_breakeven_point() \
70 (crc32c_pcl_breakeven = CRC32C_PCL_BREAKEVEN_NOEAGERFPU)
71#endif
72#endif /* CONFIG_X86_64 */
73
47static u32 crc32c_intel_le_hw_byte(u32 crc, unsigned char const *data, size_t length) 74static u32 crc32c_intel_le_hw_byte(u32 crc, unsigned char const *data, size_t length)
48{ 75{
49 while (length--) { 76 while (length--) {
@@ -154,6 +181,52 @@ static int crc32c_intel_cra_init(struct crypto_tfm *tfm)
154 return 0; 181 return 0;
155} 182}
156 183
184#ifdef CONFIG_X86_64
185static int crc32c_pcl_intel_update(struct shash_desc *desc, const u8 *data,
186 unsigned int len)
187{
188 u32 *crcp = shash_desc_ctx(desc);
189
190 /*
191 * use faster PCL version if datasize is large enough to
192 * overcome kernel fpu state save/restore overhead
193 */
194 if (len >= crc32c_pcl_breakeven && irq_fpu_usable()) {
195 kernel_fpu_begin();
196 *crcp = crc_pcl(data, len, *crcp);
197 kernel_fpu_end();
198 } else
199 *crcp = crc32c_intel_le_hw(*crcp, data, len);
200 return 0;
201}
202
203static int __crc32c_pcl_intel_finup(u32 *crcp, const u8 *data, unsigned int len,
204 u8 *out)
205{
206 if (len >= crc32c_pcl_breakeven && irq_fpu_usable()) {
207 kernel_fpu_begin();
208 *(__le32 *)out = ~cpu_to_le32(crc_pcl(data, len, *crcp));
209 kernel_fpu_end();
210 } else
211 *(__le32 *)out =
212 ~cpu_to_le32(crc32c_intel_le_hw(*crcp, data, len));
213 return 0;
214}
215
216static int crc32c_pcl_intel_finup(struct shash_desc *desc, const u8 *data,
217 unsigned int len, u8 *out)
218{
219 return __crc32c_pcl_intel_finup(shash_desc_ctx(desc), data, len, out);
220}
221
222static int crc32c_pcl_intel_digest(struct shash_desc *desc, const u8 *data,
223 unsigned int len, u8 *out)
224{
225 return __crc32c_pcl_intel_finup(crypto_shash_ctx(desc->tfm), data, len,
226 out);
227}
228#endif /* CONFIG_X86_64 */
229
157static struct shash_alg alg = { 230static struct shash_alg alg = {
158 .setkey = crc32c_intel_setkey, 231 .setkey = crc32c_intel_setkey,
159 .init = crc32c_intel_init, 232 .init = crc32c_intel_init,
@@ -184,6 +257,14 @@ static int __init crc32c_intel_mod_init(void)
184{ 257{
185 if (!x86_match_cpu(crc32c_cpu_id)) 258 if (!x86_match_cpu(crc32c_cpu_id))
186 return -ENODEV; 259 return -ENODEV;
260#ifdef CONFIG_X86_64
261 if (cpu_has_pclmulqdq) {
262 alg.update = crc32c_pcl_intel_update;
263 alg.finup = crc32c_pcl_intel_finup;
264 alg.digest = crc32c_pcl_intel_digest;
265 set_pcl_breakeven_point();
266 }
267#endif
187 return crypto_register_shash(&alg); 268 return crypto_register_shash(&alg);
188} 269}
189 270
diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
new file mode 100644
index 000000000000..93c6d39237ac
--- /dev/null
+++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
@@ -0,0 +1,460 @@
1/*
2 * Implement fast CRC32C with PCLMULQDQ instructions. (x86_64)
3 *
4 * The white paper on CRC32C calculations with PCLMULQDQ instruction can be
5 * downloaded from:
6 * http://download.intel.com/design/intarch/papers/323405.pdf
7 *
8 * Copyright (C) 2012 Intel Corporation.
9 *
10 * Authors:
11 * Wajdi Feghali <wajdi.k.feghali@intel.com>
12 * James Guilford <james.guilford@intel.com>
13 * David Cote <david.m.cote@intel.com>
14 * Tim Chen <tim.c.chen@linux.intel.com>
15 *
16 * This software is available to you under a choice of one of two
17 * licenses. You may choose to be licensed under the terms of the GNU
18 * General Public License (GPL) Version 2, available from the file
19 * COPYING in the main directory of this source tree, or the
20 * OpenIB.org BSD license below:
21 *
22 * Redistribution and use in source and binary forms, with or
23 * without modification, are permitted provided that the following
24 * conditions are met:
25 *
26 * - Redistributions of source code must retain the above
27 * copyright notice, this list of conditions and the following
28 * disclaimer.
29 *
30 * - Redistributions in binary form must reproduce the above
31 * copyright notice, this list of conditions and the following
32 * disclaimer in the documentation and/or other materials
33 * provided with the distribution.
34 *
35 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
36 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
37 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
38 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
39 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
40 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
42 * SOFTWARE.
43 */
44
45## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
46
47.macro LABEL prefix n
48\prefix\n\():
49.endm
50
51.macro JMPTBL_ENTRY i
52.word crc_\i - crc_array
53.endm
54
55.macro JNC_LESS_THAN j
56 jnc less_than_\j
57.endm
58
59# Define threshold where buffers are considered "small" and routed to more
60# efficient "by-1" code. This "by-1" code only handles up to 255 bytes, so
61# SMALL_SIZE can be no larger than 255.
62
63#define SMALL_SIZE 200
64
65.if (SMALL_SIZE > 255)
66.error "SMALL_ SIZE must be < 256"
67.endif
68
69# unsigned int crc_pcl(u8 *buffer, int len, unsigned int crc_init);
70
71.global crc_pcl
72crc_pcl:
73#define bufp %rdi
74#define bufp_dw %edi
75#define bufp_w %di
76#define bufp_b %dil
77#define bufptmp %rcx
78#define block_0 %rcx
79#define block_1 %rdx
80#define block_2 %r11
81#define len %rsi
82#define len_dw %esi
83#define len_w %si
84#define len_b %sil
85#define crc_init_arg %rdx
86#define tmp %rbx
87#define crc_init %r8
88#define crc_init_dw %r8d
89#define crc1 %r9
90#define crc2 %r10
91
92 pushq %rbx
93 pushq %rdi
94 pushq %rsi
95
96 ## Move crc_init for Linux to a different
97 mov crc_init_arg, crc_init
98
99 ################################################################
100 ## 1) ALIGN:
101 ################################################################
102
103 mov bufp, bufptmp # rdi = *buf
104 neg bufp
105 and $7, bufp # calculate the unalignment amount of
106 # the address
107 je proc_block # Skip if aligned
108
109 ## If len is less than 8 and we're unaligned, we need to jump
110 ## to special code to avoid reading beyond the end of the buffer
111 cmp $8, len
112 jae do_align
113 # less_than_8 expects length in upper 3 bits of len_dw
114 # less_than_8_post_shl1 expects length = carryflag * 8 + len_dw[31:30]
115 shl $32-3+1, len_dw
116 jmp less_than_8_post_shl1
117
118do_align:
119 #### Calculate CRC of unaligned bytes of the buffer (if any)
120 movq (bufptmp), tmp # load a quadward from the buffer
121 add bufp, bufptmp # align buffer pointer for quadword
122 # processing
123 sub bufp, len # update buffer length
124align_loop:
125 crc32b %bl, crc_init_dw # compute crc32 of 1-byte
126 shr $8, tmp # get next byte
127 dec bufp
128 jne align_loop
129
130proc_block:
131
132 ################################################################
133 ## 2) PROCESS BLOCKS:
134 ################################################################
135
136 ## compute num of bytes to be processed
137 movq len, tmp # save num bytes in tmp
138
139 cmpq $128*24, len
140 jae full_block
141
142continue_block:
143 cmpq $SMALL_SIZE, len
144 jb small
145
146 ## len < 128*24
147 movq $2731, %rax # 2731 = ceil(2^16 / 24)
148 mul len_dw
149 shrq $16, %rax
150
151 ## eax contains floor(bytes / 24) = num 24-byte chunks to do
152
153 ## process rax 24-byte chunks (128 >= rax >= 0)
154
155 ## compute end address of each block
156 ## block 0 (base addr + RAX * 8)
157 ## block 1 (base addr + RAX * 16)
158 ## block 2 (base addr + RAX * 24)
159 lea (bufptmp, %rax, 8), block_0
160 lea (block_0, %rax, 8), block_1
161 lea (block_1, %rax, 8), block_2
162
163 xor crc1, crc1
164 xor crc2, crc2
165
166 ## branch into array
167 lea jump_table(%rip), bufp
168 movzxw (bufp, %rax, 2), len
169 offset=crc_array-jump_table
170 lea offset(bufp, len, 1), bufp
171 jmp *bufp
172
173 ################################################################
174 ## 2a) PROCESS FULL BLOCKS:
175 ################################################################
176full_block:
177 movq $128,%rax
178 lea 128*8*2(block_0), block_1
179 lea 128*8*3(block_0), block_2
180 add $128*8*1, block_0
181
182 xor crc1,crc1
183 xor crc2,crc2
184
185 # Fall thruogh into top of crc array (crc_128)
186
187 ################################################################
188 ## 3) CRC Array:
189 ################################################################
190
191crc_array:
192 i=128
193.rept 128-1
194.altmacro
195LABEL crc_ %i
196.noaltmacro
197 crc32q -i*8(block_0), crc_init
198 crc32q -i*8(block_1), crc1
199 crc32q -i*8(block_2), crc2
200 i=(i-1)
201.endr
202
203.altmacro
204LABEL crc_ %i
205.noaltmacro
206 crc32q -i*8(block_0), crc_init
207 crc32q -i*8(block_1), crc1
208# SKIP crc32 -i*8(block_2), crc2 ; Don't do this one yet
209
210 mov block_2, block_0
211
212 ################################################################
213 ## 4) Combine three results:
214 ################################################################
215
216 lea (K_table-16)(%rip), bufp # first entry is for idx 1
217 shlq $3, %rax # rax *= 8
218 subq %rax, tmp # tmp -= rax*8
219 shlq $1, %rax
220 subq %rax, tmp # tmp -= rax*16
221 # (total tmp -= rax*24)
222 addq %rax, bufp
223
224 movdqa (bufp), %xmm0 # 2 consts: K1:K2
225
226 movq crc_init, %xmm1 # CRC for block 1
227 pclmulqdq $0x00,%xmm0,%xmm1 # Multiply by K2
228
229 movq crc1, %xmm2 # CRC for block 2
230 pclmulqdq $0x10, %xmm0, %xmm2 # Multiply by K1
231
232 pxor %xmm2,%xmm1
233 movq %xmm1, %rax
234 xor -i*8(block_2), %rax
235 mov crc2, crc_init
236 crc32 %rax, crc_init
237
238################################################################
239## 5) Check for end:
240################################################################
241
242LABEL crc_ 0
243 mov tmp, len
244 cmp $128*24, tmp
245 jae full_block
246 cmp $24, tmp
247 jae continue_block
248
249less_than_24:
250 shl $32-4, len_dw # less_than_16 expects length
251 # in upper 4 bits of len_dw
252 jnc less_than_16
253 crc32q (bufptmp), crc_init
254 crc32q 8(bufptmp), crc_init
255 jz do_return
256 add $16, bufptmp
257 # len is less than 8 if we got here
258 # less_than_8 expects length in upper 3 bits of len_dw
259 # less_than_8_post_shl1 expects length = carryflag * 8 + len_dw[31:30]
260 shl $2, len_dw
261 jmp less_than_8_post_shl1
262
263 #######################################################################
264 ## 6) LESS THAN 256-bytes REMAIN AT THIS POINT (8-bits of len are full)
265 #######################################################################
266small:
267 shl $32-8, len_dw # Prepare len_dw for less_than_256
268 j=256
269.rept 5 # j = {256, 128, 64, 32, 16}
270.altmacro
271LABEL less_than_ %j # less_than_j: Length should be in
272 # upper lg(j) bits of len_dw
273 j=(j/2)
274 shl $1, len_dw # Get next MSB
275 JNC_LESS_THAN %j
276.noaltmacro
277 i=0
278.rept (j/8)
279 crc32q i(bufptmp), crc_init # Compute crc32 of 8-byte data
280 i=i+8
281.endr
282 jz do_return # Return if remaining length is zero
283 add $j, bufptmp # Advance buf
284.endr
285
286less_than_8: # Length should be stored in
287 # upper 3 bits of len_dw
288 shl $1, len_dw
289less_than_8_post_shl1:
290 jnc less_than_4
291 crc32l (bufptmp), crc_init_dw # CRC of 4 bytes
292 jz do_return # return if remaining data is zero
293 add $4, bufptmp
294less_than_4: # Length should be stored in
295 # upper 2 bits of len_dw
296 shl $1, len_dw
297 jnc less_than_2
298 crc32w (bufptmp), crc_init_dw # CRC of 2 bytes
299 jz do_return # return if remaining data is zero
300 add $2, bufptmp
301less_than_2: # Length should be stored in the MSB
302 # of len_dw
303 shl $1, len_dw
304 jnc less_than_1
305 crc32b (bufptmp), crc_init_dw # CRC of 1 byte
306less_than_1: # Length should be zero
307do_return:
308 movq crc_init, %rax
309 popq %rsi
310 popq %rdi
311 popq %rbx
312 ret
313
314 ################################################################
315 ## jump table Table is 129 entries x 2 bytes each
316 ################################################################
317.align 4
318jump_table:
319 i=0
320.rept 129
321.altmacro
322JMPTBL_ENTRY %i
323.noaltmacro
324 i=i+1
325.endr
326 ################################################################
327 ## PCLMULQDQ tables
328 ## Table is 128 entries x 2 quad words each
329 ################################################################
330.data
331.align 64
332K_table:
333 .quad 0x14cd00bd6,0x105ec76f0
334 .quad 0x0ba4fc28e,0x14cd00bd6
335 .quad 0x1d82c63da,0x0f20c0dfe
336 .quad 0x09e4addf8,0x0ba4fc28e
337 .quad 0x039d3b296,0x1384aa63a
338 .quad 0x102f9b8a2,0x1d82c63da
339 .quad 0x14237f5e6,0x01c291d04
340 .quad 0x00d3b6092,0x09e4addf8
341 .quad 0x0c96cfdc0,0x0740eef02
342 .quad 0x18266e456,0x039d3b296
343 .quad 0x0daece73e,0x0083a6eec
344 .quad 0x0ab7aff2a,0x102f9b8a2
345 .quad 0x1248ea574,0x1c1733996
346 .quad 0x083348832,0x14237f5e6
347 .quad 0x12c743124,0x02ad91c30
348 .quad 0x0b9e02b86,0x00d3b6092
349 .quad 0x018b33a4e,0x06992cea2
350 .quad 0x1b331e26a,0x0c96cfdc0
351 .quad 0x17d35ba46,0x07e908048
352 .quad 0x1bf2e8b8a,0x18266e456
353 .quad 0x1a3e0968a,0x11ed1f9d8
354 .quad 0x0ce7f39f4,0x0daece73e
355 .quad 0x061d82e56,0x0f1d0f55e
356 .quad 0x0d270f1a2,0x0ab7aff2a
357 .quad 0x1c3f5f66c,0x0a87ab8a8
358 .quad 0x12ed0daac,0x1248ea574
359 .quad 0x065863b64,0x08462d800
360 .quad 0x11eef4f8e,0x083348832
361 .quad 0x1ee54f54c,0x071d111a8
362 .quad 0x0b3e32c28,0x12c743124
363 .quad 0x0064f7f26,0x0ffd852c6
364 .quad 0x0dd7e3b0c,0x0b9e02b86
365 .quad 0x0f285651c,0x0dcb17aa4
366 .quad 0x010746f3c,0x018b33a4e
367 .quad 0x1c24afea4,0x0f37c5aee
368 .quad 0x0271d9844,0x1b331e26a
369 .quad 0x08e766a0c,0x06051d5a2
370 .quad 0x093a5f730,0x17d35ba46
371 .quad 0x06cb08e5c,0x11d5ca20e
372 .quad 0x06b749fb2,0x1bf2e8b8a
373 .quad 0x1167f94f2,0x021f3d99c
374 .quad 0x0cec3662e,0x1a3e0968a
375 .quad 0x19329634a,0x08f158014
376 .quad 0x0e6fc4e6a,0x0ce7f39f4
377 .quad 0x08227bb8a,0x1a5e82106
378 .quad 0x0b0cd4768,0x061d82e56
379 .quad 0x13c2b89c4,0x188815ab2
380 .quad 0x0d7a4825c,0x0d270f1a2
381 .quad 0x10f5ff2ba,0x105405f3e
382 .quad 0x00167d312,0x1c3f5f66c
383 .quad 0x0f6076544,0x0e9adf796
384 .quad 0x026f6a60a,0x12ed0daac
385 .quad 0x1a2adb74e,0x096638b34
386 .quad 0x19d34af3a,0x065863b64
387 .quad 0x049c3cc9c,0x1e50585a0
388 .quad 0x068bce87a,0x11eef4f8e
389 .quad 0x1524fa6c6,0x19f1c69dc
390 .quad 0x16cba8aca,0x1ee54f54c
391 .quad 0x042d98888,0x12913343e
392 .quad 0x1329d9f7e,0x0b3e32c28
393 .quad 0x1b1c69528,0x088f25a3a
394 .quad 0x02178513a,0x0064f7f26
395 .quad 0x0e0ac139e,0x04e36f0b0
396 .quad 0x0170076fa,0x0dd7e3b0c
397 .quad 0x141a1a2e2,0x0bd6f81f8
398 .quad 0x16ad828b4,0x0f285651c
399 .quad 0x041d17b64,0x19425cbba
400 .quad 0x1fae1cc66,0x010746f3c
401 .quad 0x1a75b4b00,0x18db37e8a
402 .quad 0x0f872e54c,0x1c24afea4
403 .quad 0x01e41e9fc,0x04c144932
404 .quad 0x086d8e4d2,0x0271d9844
405 .quad 0x160f7af7a,0x052148f02
406 .quad 0x05bb8f1bc,0x08e766a0c
407 .quad 0x0a90fd27a,0x0a3c6f37a
408 .quad 0x0b3af077a,0x093a5f730
409 .quad 0x04984d782,0x1d22c238e
410 .quad 0x0ca6ef3ac,0x06cb08e5c
411 .quad 0x0234e0b26,0x063ded06a
412 .quad 0x1d88abd4a,0x06b749fb2
413 .quad 0x04597456a,0x04d56973c
414 .quad 0x0e9e28eb4,0x1167f94f2
415 .quad 0x07b3ff57a,0x19385bf2e
416 .quad 0x0c9c8b782,0x0cec3662e
417 .quad 0x13a9cba9e,0x0e417f38a
418 .quad 0x093e106a4,0x19329634a
419 .quad 0x167001a9c,0x14e727980
420 .quad 0x1ddffc5d4,0x0e6fc4e6a
421 .quad 0x00df04680,0x0d104b8fc
422 .quad 0x02342001e,0x08227bb8a
423 .quad 0x00a2a8d7e,0x05b397730
424 .quad 0x168763fa6,0x0b0cd4768
425 .quad 0x1ed5a407a,0x0e78eb416
426 .quad 0x0d2c3ed1a,0x13c2b89c4
427 .quad 0x0995a5724,0x1641378f0
428 .quad 0x19b1afbc4,0x0d7a4825c
429 .quad 0x109ffedc0,0x08d96551c
430 .quad 0x0f2271e60,0x10f5ff2ba
431 .quad 0x00b0bf8ca,0x00bf80dd2
432 .quad 0x123888b7a,0x00167d312
433 .quad 0x1e888f7dc,0x18dcddd1c
434 .quad 0x002ee03b2,0x0f6076544
435 .quad 0x183e8d8fe,0x06a45d2b2
436 .quad 0x133d7a042,0x026f6a60a
437 .quad 0x116b0f50c,0x1dd3e10e8
438 .quad 0x05fabe670,0x1a2adb74e
439 .quad 0x130004488,0x0de87806c
440 .quad 0x000bcf5f6,0x19d34af3a
441 .quad 0x18f0c7078,0x014338754
442 .quad 0x017f27698,0x049c3cc9c
443 .quad 0x058ca5f00,0x15e3e77ee
444 .quad 0x1af900c24,0x068bce87a
445 .quad 0x0b5cfca28,0x0dd07448e
446 .quad 0x0ded288f8,0x1524fa6c6
447 .quad 0x059f229bc,0x1d8048348
448 .quad 0x06d390dec,0x16cba8aca
449 .quad 0x037170390,0x0a3e3e02c
450 .quad 0x06353c1cc,0x042d98888
451 .quad 0x0c4584f5c,0x0d73c7bea
452 .quad 0x1f16a3418,0x1329d9f7e
453 .quad 0x0531377e2,0x185137662
454 .quad 0x1d8d9ca7c,0x1b1c69528
455 .quad 0x0b25b29f2,0x18a08b5bc
456 .quad 0x19fb2a8b0,0x02178513a
457 .quad 0x1a08fe6ac,0x1da758ae0
458 .quad 0x045cddf4e,0x0e0ac139e
459 .quad 0x1a91647f2,0x169cf9eb0
460 .quad 0x1a0f717c4,0x0170076fa
diff --git a/arch/x86/crypto/glue_helper-asm-avx.S b/arch/x86/crypto/glue_helper-asm-avx.S
new file mode 100644
index 000000000000..f7b6ea2ddfdb
--- /dev/null
+++ b/arch/x86/crypto/glue_helper-asm-avx.S
@@ -0,0 +1,91 @@
1/*
2 * Shared glue code for 128bit block ciphers, AVX assembler macros
3 *
4 * Copyright (c) 2012 Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 */
17
18#define load_8way(src, x0, x1, x2, x3, x4, x5, x6, x7) \
19 vmovdqu (0*16)(src), x0; \
20 vmovdqu (1*16)(src), x1; \
21 vmovdqu (2*16)(src), x2; \
22 vmovdqu (3*16)(src), x3; \
23 vmovdqu (4*16)(src), x4; \
24 vmovdqu (5*16)(src), x5; \
25 vmovdqu (6*16)(src), x6; \
26 vmovdqu (7*16)(src), x7;
27
28#define store_8way(dst, x0, x1, x2, x3, x4, x5, x6, x7) \
29 vmovdqu x0, (0*16)(dst); \
30 vmovdqu x1, (1*16)(dst); \
31 vmovdqu x2, (2*16)(dst); \
32 vmovdqu x3, (3*16)(dst); \
33 vmovdqu x4, (4*16)(dst); \
34 vmovdqu x5, (5*16)(dst); \
35 vmovdqu x6, (6*16)(dst); \
36 vmovdqu x7, (7*16)(dst);
37
38#define store_cbc_8way(src, dst, x0, x1, x2, x3, x4, x5, x6, x7) \
39 vpxor (0*16)(src), x1, x1; \
40 vpxor (1*16)(src), x2, x2; \
41 vpxor (2*16)(src), x3, x3; \
42 vpxor (3*16)(src), x4, x4; \
43 vpxor (4*16)(src), x5, x5; \
44 vpxor (5*16)(src), x6, x6; \
45 vpxor (6*16)(src), x7, x7; \
46 store_8way(dst, x0, x1, x2, x3, x4, x5, x6, x7);
47
48#define inc_le128(x, minus_one, tmp) \
49 vpcmpeqq minus_one, x, tmp; \
50 vpsubq minus_one, x, x; \
51 vpslldq $8, tmp, tmp; \
52 vpsubq tmp, x, x;
53
54#define load_ctr_8way(iv, bswap, x0, x1, x2, x3, x4, x5, x6, x7, t0, t1, t2) \
55 vpcmpeqd t0, t0, t0; \
56 vpsrldq $8, t0, t0; /* low: -1, high: 0 */ \
57 vmovdqa bswap, t1; \
58 \
59 /* load IV and byteswap */ \
60 vmovdqu (iv), x7; \
61 vpshufb t1, x7, x0; \
62 \
63 /* construct IVs */ \
64 inc_le128(x7, t0, t2); \
65 vpshufb t1, x7, x1; \
66 inc_le128(x7, t0, t2); \
67 vpshufb t1, x7, x2; \
68 inc_le128(x7, t0, t2); \
69 vpshufb t1, x7, x3; \
70 inc_le128(x7, t0, t2); \
71 vpshufb t1, x7, x4; \
72 inc_le128(x7, t0, t2); \
73 vpshufb t1, x7, x5; \
74 inc_le128(x7, t0, t2); \
75 vpshufb t1, x7, x6; \
76 inc_le128(x7, t0, t2); \
77 vmovdqa x7, t2; \
78 vpshufb t1, x7, x7; \
79 inc_le128(t2, t0, t1); \
80 vmovdqu t2, (iv);
81
82#define store_ctr_8way(src, dst, x0, x1, x2, x3, x4, x5, x6, x7) \
83 vpxor (0*16)(src), x0, x0; \
84 vpxor (1*16)(src), x1, x1; \
85 vpxor (2*16)(src), x2, x2; \
86 vpxor (3*16)(src), x3, x3; \
87 vpxor (4*16)(src), x4, x4; \
88 vpxor (5*16)(src), x5, x5; \
89 vpxor (6*16)(src), x6, x6; \
90 vpxor (7*16)(src), x7, x7; \
91 store_8way(dst, x0, x1, x2, x3, x4, x5, x6, x7);
diff --git a/arch/x86/crypto/glue_helper.c b/arch/x86/crypto/glue_helper.c
index 30b3927bd733..22ce4f683e55 100644
--- a/arch/x86/crypto/glue_helper.c
+++ b/arch/x86/crypto/glue_helper.c
@@ -221,16 +221,16 @@ static void glue_ctr_crypt_final_128bit(const common_glue_ctr_func_t fn_ctr,
221 u8 *src = (u8 *)walk->src.virt.addr; 221 u8 *src = (u8 *)walk->src.virt.addr;
222 u8 *dst = (u8 *)walk->dst.virt.addr; 222 u8 *dst = (u8 *)walk->dst.virt.addr;
223 unsigned int nbytes = walk->nbytes; 223 unsigned int nbytes = walk->nbytes;
224 u128 ctrblk; 224 le128 ctrblk;
225 u128 tmp; 225 u128 tmp;
226 226
227 be128_to_u128(&ctrblk, (be128 *)walk->iv); 227 be128_to_le128(&ctrblk, (be128 *)walk->iv);
228 228
229 memcpy(&tmp, src, nbytes); 229 memcpy(&tmp, src, nbytes);
230 fn_ctr(ctx, &tmp, &tmp, &ctrblk); 230 fn_ctr(ctx, &tmp, &tmp, &ctrblk);
231 memcpy(dst, &tmp, nbytes); 231 memcpy(dst, &tmp, nbytes);
232 232
233 u128_to_be128((be128 *)walk->iv, &ctrblk); 233 le128_to_be128((be128 *)walk->iv, &ctrblk);
234} 234}
235EXPORT_SYMBOL_GPL(glue_ctr_crypt_final_128bit); 235EXPORT_SYMBOL_GPL(glue_ctr_crypt_final_128bit);
236 236
@@ -243,11 +243,11 @@ static unsigned int __glue_ctr_crypt_128bit(const struct common_glue_ctx *gctx,
243 unsigned int nbytes = walk->nbytes; 243 unsigned int nbytes = walk->nbytes;
244 u128 *src = (u128 *)walk->src.virt.addr; 244 u128 *src = (u128 *)walk->src.virt.addr;
245 u128 *dst = (u128 *)walk->dst.virt.addr; 245 u128 *dst = (u128 *)walk->dst.virt.addr;
246 u128 ctrblk; 246 le128 ctrblk;
247 unsigned int num_blocks, func_bytes; 247 unsigned int num_blocks, func_bytes;
248 unsigned int i; 248 unsigned int i;
249 249
250 be128_to_u128(&ctrblk, (be128 *)walk->iv); 250 be128_to_le128(&ctrblk, (be128 *)walk->iv);
251 251
252 /* Process multi-block batch */ 252 /* Process multi-block batch */
253 for (i = 0; i < gctx->num_funcs; i++) { 253 for (i = 0; i < gctx->num_funcs; i++) {
@@ -269,7 +269,7 @@ static unsigned int __glue_ctr_crypt_128bit(const struct common_glue_ctx *gctx,
269 } 269 }
270 270
271done: 271done:
272 u128_to_be128((be128 *)walk->iv, &ctrblk); 272 le128_to_be128((be128 *)walk->iv, &ctrblk);
273 return nbytes; 273 return nbytes;
274} 274}
275 275
diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
index 504106bf04a2..02b0e9fe997c 100644
--- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
+++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
@@ -24,7 +24,16 @@
24 * 24 *
25 */ 25 */
26 26
27#include "glue_helper-asm-avx.S"
28
27.file "serpent-avx-x86_64-asm_64.S" 29.file "serpent-avx-x86_64-asm_64.S"
30
31.data
32.align 16
33
34.Lbswap128_mask:
35 .byte 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
36
28.text 37.text
29 38
30#define CTX %rdi 39#define CTX %rdi
@@ -550,51 +559,27 @@
550 vpunpcklqdq x3, t2, x2; \ 559 vpunpcklqdq x3, t2, x2; \
551 vpunpckhqdq x3, t2, x3; 560 vpunpckhqdq x3, t2, x3;
552 561
553#define read_blocks(in, x0, x1, x2, x3, t0, t1, t2) \ 562#define read_blocks(x0, x1, x2, x3, t0, t1, t2) \
554 vmovdqu (0*4*4)(in), x0; \
555 vmovdqu (1*4*4)(in), x1; \
556 vmovdqu (2*4*4)(in), x2; \
557 vmovdqu (3*4*4)(in), x3; \
558 \
559 transpose_4x4(x0, x1, x2, x3, t0, t1, t2) 563 transpose_4x4(x0, x1, x2, x3, t0, t1, t2)
560 564
561#define write_blocks(out, x0, x1, x2, x3, t0, t1, t2) \ 565#define write_blocks(x0, x1, x2, x3, t0, t1, t2) \
562 transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \ 566 transpose_4x4(x0, x1, x2, x3, t0, t1, t2)
563 \
564 vmovdqu x0, (0*4*4)(out); \
565 vmovdqu x1, (1*4*4)(out); \
566 vmovdqu x2, (2*4*4)(out); \
567 vmovdqu x3, (3*4*4)(out);
568
569#define xor_blocks(out, x0, x1, x2, x3, t0, t1, t2) \
570 transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \
571 \
572 vpxor (0*4*4)(out), x0, x0; \
573 vmovdqu x0, (0*4*4)(out); \
574 vpxor (1*4*4)(out), x1, x1; \
575 vmovdqu x1, (1*4*4)(out); \
576 vpxor (2*4*4)(out), x2, x2; \
577 vmovdqu x2, (2*4*4)(out); \
578 vpxor (3*4*4)(out), x3, x3; \
579 vmovdqu x3, (3*4*4)(out);
580 567
581.align 8 568.align 8
582.global __serpent_enc_blk_8way_avx 569.type __serpent_enc_blk8_avx,@function;
583.type __serpent_enc_blk_8way_avx,@function;
584 570
585__serpent_enc_blk_8way_avx: 571__serpent_enc_blk8_avx:
586 /* input: 572 /* input:
587 * %rdi: ctx, CTX 573 * %rdi: ctx, CTX
588 * %rsi: dst 574 * RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2: blocks
589 * %rdx: src 575 * output:
590 * %rcx: bool, if true: xor output 576 * RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2: encrypted blocks
591 */ 577 */
592 578
593 vpcmpeqd RNOT, RNOT, RNOT; 579 vpcmpeqd RNOT, RNOT, RNOT;
594 580
595 leaq (4*4*4)(%rdx), %rax; 581 read_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
596 read_blocks(%rdx, RA1, RB1, RC1, RD1, RK0, RK1, RK2); 582 read_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
597 read_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
598 583
599 K2(RA, RB, RC, RD, RE, 0); 584 K2(RA, RB, RC, RD, RE, 0);
600 S(S0, RA, RB, RC, RD, RE); LK2(RC, RB, RD, RA, RE, 1); 585 S(S0, RA, RB, RC, RD, RE); LK2(RC, RB, RD, RA, RE, 1);
@@ -630,38 +615,26 @@ __serpent_enc_blk_8way_avx:
630 S(S6, RA, RB, RD, RC, RE); LK2(RD, RE, RB, RC, RA, 31); 615 S(S6, RA, RB, RD, RC, RE); LK2(RD, RE, RB, RC, RA, 31);
631 S(S7, RD, RE, RB, RC, RA); K2(RA, RB, RC, RD, RE, 32); 616 S(S7, RD, RE, RB, RC, RA); K2(RA, RB, RC, RD, RE, 32);
632 617
633 leaq (4*4*4)(%rsi), %rax; 618 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
634 619 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
635 testb %cl, %cl;
636 jnz __enc_xor8;
637
638 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
639 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
640
641 ret;
642
643__enc_xor8:
644 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
645 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
646 620
647 ret; 621 ret;
648 622
649.align 8 623.align 8
650.global serpent_dec_blk_8way_avx 624.type __serpent_dec_blk8_avx,@function;
651.type serpent_dec_blk_8way_avx,@function;
652 625
653serpent_dec_blk_8way_avx: 626__serpent_dec_blk8_avx:
654 /* input: 627 /* input:
655 * %rdi: ctx, CTX 628 * %rdi: ctx, CTX
656 * %rsi: dst 629 * RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2: encrypted blocks
657 * %rdx: src 630 * output:
631 * RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2: decrypted blocks
658 */ 632 */
659 633
660 vpcmpeqd RNOT, RNOT, RNOT; 634 vpcmpeqd RNOT, RNOT, RNOT;
661 635
662 leaq (4*4*4)(%rdx), %rax; 636 read_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
663 read_blocks(%rdx, RA1, RB1, RC1, RD1, RK0, RK1, RK2); 637 read_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
664 read_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
665 638
666 K2(RA, RB, RC, RD, RE, 32); 639 K2(RA, RB, RC, RD, RE, 32);
667 SP(SI7, RA, RB, RC, RD, RE, 31); KL2(RB, RD, RA, RE, RC, 31); 640 SP(SI7, RA, RB, RC, RD, RE, 31); KL2(RB, RD, RA, RE, RC, 31);
@@ -697,8 +670,85 @@ serpent_dec_blk_8way_avx:
697 SP(SI1, RD, RB, RC, RA, RE, 1); KL2(RE, RB, RC, RA, RD, 1); 670 SP(SI1, RD, RB, RC, RA, RE, 1); KL2(RE, RB, RC, RA, RD, 1);
698 S(SI0, RE, RB, RC, RA, RD); K2(RC, RD, RB, RE, RA, 0); 671 S(SI0, RE, RB, RC, RA, RD); K2(RC, RD, RB, RE, RA, 0);
699 672
700 leaq (4*4*4)(%rsi), %rax; 673 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
701 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2); 674 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
702 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2); 675
676 ret;
677
678.align 8
679.global serpent_ecb_enc_8way_avx
680.type serpent_ecb_enc_8way_avx,@function;
681
682serpent_ecb_enc_8way_avx:
683 /* input:
684 * %rdi: ctx, CTX
685 * %rsi: dst
686 * %rdx: src
687 */
688
689 load_8way(%rdx, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
690
691 call __serpent_enc_blk8_avx;
692
693 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
694
695 ret;
696
697.align 8
698.global serpent_ecb_dec_8way_avx
699.type serpent_ecb_dec_8way_avx,@function;
700
701serpent_ecb_dec_8way_avx:
702 /* input:
703 * %rdi: ctx, CTX
704 * %rsi: dst
705 * %rdx: src
706 */
707
708 load_8way(%rdx, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
709
710 call __serpent_dec_blk8_avx;
711
712 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
713
714 ret;
715
716.align 8
717.global serpent_cbc_dec_8way_avx
718.type serpent_cbc_dec_8way_avx,@function;
719
720serpent_cbc_dec_8way_avx:
721 /* input:
722 * %rdi: ctx, CTX
723 * %rsi: dst
724 * %rdx: src
725 */
726
727 load_8way(%rdx, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
728
729 call __serpent_dec_blk8_avx;
730
731 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
732
733 ret;
734
735.align 8
736.global serpent_ctr_8way_avx
737.type serpent_ctr_8way_avx,@function;
738
739serpent_ctr_8way_avx:
740 /* input:
741 * %rdi: ctx, CTX
742 * %rsi: dst
743 * %rdx: src
744 * %rcx: iv (little endian, 128bit)
745 */
746
747 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
748 RD2, RK0, RK1, RK2);
749
750 call __serpent_enc_blk8_avx;
751
752 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
703 753
704 ret; 754 ret;
diff --git a/arch/x86/crypto/serpent_avx_glue.c b/arch/x86/crypto/serpent_avx_glue.c
index 3f543a04cf1e..52abaaf28e7f 100644
--- a/arch/x86/crypto/serpent_avx_glue.c
+++ b/arch/x86/crypto/serpent_avx_glue.c
@@ -42,55 +42,24 @@
42#include <asm/crypto/ablk_helper.h> 42#include <asm/crypto/ablk_helper.h>
43#include <asm/crypto/glue_helper.h> 43#include <asm/crypto/glue_helper.h>
44 44
45static void serpent_decrypt_cbc_xway(void *ctx, u128 *dst, const u128 *src) 45static void serpent_crypt_ctr(void *ctx, u128 *dst, const u128 *src, le128 *iv)
46{
47 u128 ivs[SERPENT_PARALLEL_BLOCKS - 1];
48 unsigned int j;
49
50 for (j = 0; j < SERPENT_PARALLEL_BLOCKS - 1; j++)
51 ivs[j] = src[j];
52
53 serpent_dec_blk_xway(ctx, (u8 *)dst, (u8 *)src);
54
55 for (j = 0; j < SERPENT_PARALLEL_BLOCKS - 1; j++)
56 u128_xor(dst + (j + 1), dst + (j + 1), ivs + j);
57}
58
59static void serpent_crypt_ctr(void *ctx, u128 *dst, const u128 *src, u128 *iv)
60{ 46{
61 be128 ctrblk; 47 be128 ctrblk;
62 48
63 u128_to_be128(&ctrblk, iv); 49 le128_to_be128(&ctrblk, iv);
64 u128_inc(iv); 50 le128_inc(iv);
65 51
66 __serpent_encrypt(ctx, (u8 *)&ctrblk, (u8 *)&ctrblk); 52 __serpent_encrypt(ctx, (u8 *)&ctrblk, (u8 *)&ctrblk);
67 u128_xor(dst, src, (u128 *)&ctrblk); 53 u128_xor(dst, src, (u128 *)&ctrblk);
68} 54}
69 55
70static void serpent_crypt_ctr_xway(void *ctx, u128 *dst, const u128 *src,
71 u128 *iv)
72{
73 be128 ctrblks[SERPENT_PARALLEL_BLOCKS];
74 unsigned int i;
75
76 for (i = 0; i < SERPENT_PARALLEL_BLOCKS; i++) {
77 if (dst != src)
78 dst[i] = src[i];
79
80 u128_to_be128(&ctrblks[i], iv);
81 u128_inc(iv);
82 }
83
84 serpent_enc_blk_xway_xor(ctx, (u8 *)dst, (u8 *)ctrblks);
85}
86
87static const struct common_glue_ctx serpent_enc = { 56static const struct common_glue_ctx serpent_enc = {
88 .num_funcs = 2, 57 .num_funcs = 2,
89 .fpu_blocks_limit = SERPENT_PARALLEL_BLOCKS, 58 .fpu_blocks_limit = SERPENT_PARALLEL_BLOCKS,
90 59
91 .funcs = { { 60 .funcs = { {
92 .num_blocks = SERPENT_PARALLEL_BLOCKS, 61 .num_blocks = SERPENT_PARALLEL_BLOCKS,
93 .fn_u = { .ecb = GLUE_FUNC_CAST(serpent_enc_blk_xway) } 62 .fn_u = { .ecb = GLUE_FUNC_CAST(serpent_ecb_enc_8way_avx) }
94 }, { 63 }, {
95 .num_blocks = 1, 64 .num_blocks = 1,
96 .fn_u = { .ecb = GLUE_FUNC_CAST(__serpent_encrypt) } 65 .fn_u = { .ecb = GLUE_FUNC_CAST(__serpent_encrypt) }
@@ -103,7 +72,7 @@ static const struct common_glue_ctx serpent_ctr = {
103 72
104 .funcs = { { 73 .funcs = { {
105 .num_blocks = SERPENT_PARALLEL_BLOCKS, 74 .num_blocks = SERPENT_PARALLEL_BLOCKS,
106 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(serpent_crypt_ctr_xway) } 75 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(serpent_ctr_8way_avx) }
107 }, { 76 }, {
108 .num_blocks = 1, 77 .num_blocks = 1,
109 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(serpent_crypt_ctr) } 78 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(serpent_crypt_ctr) }
@@ -116,7 +85,7 @@ static const struct common_glue_ctx serpent_dec = {
116 85
117 .funcs = { { 86 .funcs = { {
118 .num_blocks = SERPENT_PARALLEL_BLOCKS, 87 .num_blocks = SERPENT_PARALLEL_BLOCKS,
119 .fn_u = { .ecb = GLUE_FUNC_CAST(serpent_dec_blk_xway) } 88 .fn_u = { .ecb = GLUE_FUNC_CAST(serpent_ecb_dec_8way_avx) }
120 }, { 89 }, {
121 .num_blocks = 1, 90 .num_blocks = 1,
122 .fn_u = { .ecb = GLUE_FUNC_CAST(__serpent_decrypt) } 91 .fn_u = { .ecb = GLUE_FUNC_CAST(__serpent_decrypt) }
@@ -129,7 +98,7 @@ static const struct common_glue_ctx serpent_dec_cbc = {
129 98
130 .funcs = { { 99 .funcs = { {
131 .num_blocks = SERPENT_PARALLEL_BLOCKS, 100 .num_blocks = SERPENT_PARALLEL_BLOCKS,
132 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(serpent_decrypt_cbc_xway) } 101 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(serpent_cbc_dec_8way_avx) }
133 }, { 102 }, {
134 .num_blocks = 1, 103 .num_blocks = 1,
135 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(__serpent_decrypt) } 104 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(__serpent_decrypt) }
@@ -193,7 +162,7 @@ static void encrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes)
193 ctx->fpu_enabled = serpent_fpu_begin(ctx->fpu_enabled, nbytes); 162 ctx->fpu_enabled = serpent_fpu_begin(ctx->fpu_enabled, nbytes);
194 163
195 if (nbytes == bsize * SERPENT_PARALLEL_BLOCKS) { 164 if (nbytes == bsize * SERPENT_PARALLEL_BLOCKS) {
196 serpent_enc_blk_xway(ctx->ctx, srcdst, srcdst); 165 serpent_ecb_enc_8way_avx(ctx->ctx, srcdst, srcdst);
197 return; 166 return;
198 } 167 }
199 168
@@ -210,7 +179,7 @@ static void decrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes)
210 ctx->fpu_enabled = serpent_fpu_begin(ctx->fpu_enabled, nbytes); 179 ctx->fpu_enabled = serpent_fpu_begin(ctx->fpu_enabled, nbytes);
211 180
212 if (nbytes == bsize * SERPENT_PARALLEL_BLOCKS) { 181 if (nbytes == bsize * SERPENT_PARALLEL_BLOCKS) {
213 serpent_dec_blk_xway(ctx->ctx, srcdst, srcdst); 182 serpent_ecb_dec_8way_avx(ctx->ctx, srcdst, srcdst);
214 return; 183 return;
215 } 184 }
216 185
diff --git a/arch/x86/crypto/serpent_sse2_glue.c b/arch/x86/crypto/serpent_sse2_glue.c
index 9107a9908c41..97a356ece24d 100644
--- a/arch/x86/crypto/serpent_sse2_glue.c
+++ b/arch/x86/crypto/serpent_sse2_glue.c
@@ -59,19 +59,19 @@ static void serpent_decrypt_cbc_xway(void *ctx, u128 *dst, const u128 *src)
59 u128_xor(dst + (j + 1), dst + (j + 1), ivs + j); 59 u128_xor(dst + (j + 1), dst + (j + 1), ivs + j);
60} 60}
61 61
62static void serpent_crypt_ctr(void *ctx, u128 *dst, const u128 *src, u128 *iv) 62static void serpent_crypt_ctr(void *ctx, u128 *dst, const u128 *src, le128 *iv)
63{ 63{
64 be128 ctrblk; 64 be128 ctrblk;
65 65
66 u128_to_be128(&ctrblk, iv); 66 le128_to_be128(&ctrblk, iv);
67 u128_inc(iv); 67 le128_inc(iv);
68 68
69 __serpent_encrypt(ctx, (u8 *)&ctrblk, (u8 *)&ctrblk); 69 __serpent_encrypt(ctx, (u8 *)&ctrblk, (u8 *)&ctrblk);
70 u128_xor(dst, src, (u128 *)&ctrblk); 70 u128_xor(dst, src, (u128 *)&ctrblk);
71} 71}
72 72
73static void serpent_crypt_ctr_xway(void *ctx, u128 *dst, const u128 *src, 73static void serpent_crypt_ctr_xway(void *ctx, u128 *dst, const u128 *src,
74 u128 *iv) 74 le128 *iv)
75{ 75{
76 be128 ctrblks[SERPENT_PARALLEL_BLOCKS]; 76 be128 ctrblks[SERPENT_PARALLEL_BLOCKS];
77 unsigned int i; 77 unsigned int i;
@@ -80,8 +80,8 @@ static void serpent_crypt_ctr_xway(void *ctx, u128 *dst, const u128 *src,
80 if (dst != src) 80 if (dst != src)
81 dst[i] = src[i]; 81 dst[i] = src[i];
82 82
83 u128_to_be128(&ctrblks[i], iv); 83 le128_to_be128(&ctrblks[i], iv);
84 u128_inc(iv); 84 le128_inc(iv);
85 } 85 }
86 86
87 serpent_enc_blk_xway_xor(ctx, (u8 *)dst, (u8 *)ctrblks); 87 serpent_enc_blk_xway_xor(ctx, (u8 *)dst, (u8 *)ctrblks);
diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
index 1585abb13dde..ebac16bfa830 100644
--- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
+++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
@@ -23,7 +23,16 @@
23 * 23 *
24 */ 24 */
25 25
26#include "glue_helper-asm-avx.S"
27
26.file "twofish-avx-x86_64-asm_64.S" 28.file "twofish-avx-x86_64-asm_64.S"
29
30.data
31.align 16
32
33.Lbswap128_mask:
34 .byte 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
35
27.text 36.text
28 37
29/* structure of crypto context */ 38/* structure of crypto context */
@@ -217,69 +226,45 @@
217 vpunpcklqdq x3, t2, x2; \ 226 vpunpcklqdq x3, t2, x2; \
218 vpunpckhqdq x3, t2, x3; 227 vpunpckhqdq x3, t2, x3;
219 228
220#define inpack_blocks(in, x0, x1, x2, x3, wkey, t0, t1, t2) \ 229#define inpack_blocks(x0, x1, x2, x3, wkey, t0, t1, t2) \
221 vpxor (0*4*4)(in), wkey, x0; \ 230 vpxor x0, wkey, x0; \
222 vpxor (1*4*4)(in), wkey, x1; \ 231 vpxor x1, wkey, x1; \
223 vpxor (2*4*4)(in), wkey, x2; \ 232 vpxor x2, wkey, x2; \
224 vpxor (3*4*4)(in), wkey, x3; \ 233 vpxor x3, wkey, x3; \
225 \ 234 \
226 transpose_4x4(x0, x1, x2, x3, t0, t1, t2) 235 transpose_4x4(x0, x1, x2, x3, t0, t1, t2)
227 236
228#define outunpack_blocks(out, x0, x1, x2, x3, wkey, t0, t1, t2) \ 237#define outunpack_blocks(x0, x1, x2, x3, wkey, t0, t1, t2) \
229 transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \
230 \
231 vpxor x0, wkey, x0; \
232 vmovdqu x0, (0*4*4)(out); \
233 vpxor x1, wkey, x1; \
234 vmovdqu x1, (1*4*4)(out); \
235 vpxor x2, wkey, x2; \
236 vmovdqu x2, (2*4*4)(out); \
237 vpxor x3, wkey, x3; \
238 vmovdqu x3, (3*4*4)(out);
239
240#define outunpack_xor_blocks(out, x0, x1, x2, x3, wkey, t0, t1, t2) \
241 transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \ 238 transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \
242 \ 239 \
243 vpxor x0, wkey, x0; \ 240 vpxor x0, wkey, x0; \
244 vpxor (0*4*4)(out), x0, x0; \ 241 vpxor x1, wkey, x1; \
245 vmovdqu x0, (0*4*4)(out); \ 242 vpxor x2, wkey, x2; \
246 vpxor x1, wkey, x1; \ 243 vpxor x3, wkey, x3;
247 vpxor (1*4*4)(out), x1, x1; \
248 vmovdqu x1, (1*4*4)(out); \
249 vpxor x2, wkey, x2; \
250 vpxor (2*4*4)(out), x2, x2; \
251 vmovdqu x2, (2*4*4)(out); \
252 vpxor x3, wkey, x3; \
253 vpxor (3*4*4)(out), x3, x3; \
254 vmovdqu x3, (3*4*4)(out);
255 244
256.align 8 245.align 8
257.global __twofish_enc_blk_8way 246.type __twofish_enc_blk8,@function;
258.type __twofish_enc_blk_8way,@function;
259 247
260__twofish_enc_blk_8way: 248__twofish_enc_blk8:
261 /* input: 249 /* input:
262 * %rdi: ctx, CTX 250 * %rdi: ctx, CTX
263 * %rsi: dst 251 * RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2: blocks
264 * %rdx: src 252 * output:
265 * %rcx: bool, if true: xor output 253 * RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2: encrypted blocks
266 */ 254 */
267 255
256 vmovdqu w(CTX), RK1;
257
268 pushq %rbp; 258 pushq %rbp;
269 pushq %rbx; 259 pushq %rbx;
270 pushq %rcx; 260 pushq %rcx;
271 261
272 vmovdqu w(CTX), RK1; 262 inpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
273
274 leaq (4*4*4)(%rdx), %rax;
275 inpack_blocks(%rdx, RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
276 preload_rgi(RA1); 263 preload_rgi(RA1);
277 rotate_1l(RD1); 264 rotate_1l(RD1);
278 inpack_blocks(%rax, RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2); 265 inpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
279 rotate_1l(RD2); 266 rotate_1l(RD2);
280 267
281 movq %rsi, %r11;
282
283 encrypt_cycle(0); 268 encrypt_cycle(0);
284 encrypt_cycle(1); 269 encrypt_cycle(1);
285 encrypt_cycle(2); 270 encrypt_cycle(2);
@@ -295,47 +280,33 @@ __twofish_enc_blk_8way:
295 popq %rbx; 280 popq %rbx;
296 popq %rbp; 281 popq %rbp;
297 282
298 leaq (4*4*4)(%r11), %rax; 283 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
299 284 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
300 testb %cl, %cl;
301 jnz __enc_xor8;
302
303 outunpack_blocks(%r11, RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
304 outunpack_blocks(%rax, RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
305
306 ret;
307
308__enc_xor8:
309 outunpack_xor_blocks(%r11, RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
310 outunpack_xor_blocks(%rax, RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
311 285
312 ret; 286 ret;
313 287
314.align 8 288.align 8
315.global twofish_dec_blk_8way 289.type __twofish_dec_blk8,@function;
316.type twofish_dec_blk_8way,@function;
317 290
318twofish_dec_blk_8way: 291__twofish_dec_blk8:
319 /* input: 292 /* input:
320 * %rdi: ctx, CTX 293 * %rdi: ctx, CTX
321 * %rsi: dst 294 * RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2: encrypted blocks
322 * %rdx: src 295 * output:
296 * RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2: decrypted blocks
323 */ 297 */
324 298
299 vmovdqu (w+4*4)(CTX), RK1;
300
325 pushq %rbp; 301 pushq %rbp;
326 pushq %rbx; 302 pushq %rbx;
327 303
328 vmovdqu (w+4*4)(CTX), RK1; 304 inpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
329
330 leaq (4*4*4)(%rdx), %rax;
331 inpack_blocks(%rdx, RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
332 preload_rgi(RC1); 305 preload_rgi(RC1);
333 rotate_1l(RA1); 306 rotate_1l(RA1);
334 inpack_blocks(%rax, RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2); 307 inpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
335 rotate_1l(RA2); 308 rotate_1l(RA2);
336 309
337 movq %rsi, %r11;
338
339 decrypt_cycle(7); 310 decrypt_cycle(7);
340 decrypt_cycle(6); 311 decrypt_cycle(6);
341 decrypt_cycle(5); 312 decrypt_cycle(5);
@@ -350,8 +321,103 @@ twofish_dec_blk_8way:
350 popq %rbx; 321 popq %rbx;
351 popq %rbp; 322 popq %rbp;
352 323
353 leaq (4*4*4)(%r11), %rax; 324 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
354 outunpack_blocks(%r11, RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2); 325 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
355 outunpack_blocks(%rax, RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2); 326
327 ret;
328
329.align 8
330.global twofish_ecb_enc_8way
331.type twofish_ecb_enc_8way,@function;
332
333twofish_ecb_enc_8way:
334 /* input:
335 * %rdi: ctx, CTX
336 * %rsi: dst
337 * %rdx: src
338 */
339
340 movq %rsi, %r11;
341
342 load_8way(%rdx, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
343
344 call __twofish_enc_blk8;
345
346 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
347
348 ret;
349
350.align 8
351.global twofish_ecb_dec_8way
352.type twofish_ecb_dec_8way,@function;
353
354twofish_ecb_dec_8way:
355 /* input:
356 * %rdi: ctx, CTX
357 * %rsi: dst
358 * %rdx: src
359 */
360
361 movq %rsi, %r11;
362
363 load_8way(%rdx, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
364
365 call __twofish_dec_blk8;
366
367 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
368
369 ret;
370
371.align 8
372.global twofish_cbc_dec_8way
373.type twofish_cbc_dec_8way,@function;
374
375twofish_cbc_dec_8way:
376 /* input:
377 * %rdi: ctx, CTX
378 * %rsi: dst
379 * %rdx: src
380 */
381
382 pushq %r12;
383
384 movq %rsi, %r11;
385 movq %rdx, %r12;
386
387 load_8way(%rdx, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
388
389 call __twofish_dec_blk8;
390
391 store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
392
393 popq %r12;
394
395 ret;
396
397.align 8
398.global twofish_ctr_8way
399.type twofish_ctr_8way,@function;
400
401twofish_ctr_8way:
402 /* input:
403 * %rdi: ctx, CTX
404 * %rsi: dst
405 * %rdx: src
406 * %rcx: iv (little endian, 128bit)
407 */
408
409 pushq %r12;
410
411 movq %rsi, %r11;
412 movq %rdx, %r12;
413
414 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
415 RD2, RX0, RX1, RY0);
416
417 call __twofish_enc_blk8;
418
419 store_ctr_8way(%r12, %r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
420
421 popq %r12;
356 422
357 ret; 423 ret;
diff --git a/arch/x86/crypto/twofish_avx_glue.c b/arch/x86/crypto/twofish_avx_glue.c
index e7708b5442e0..94ac91d26e47 100644
--- a/arch/x86/crypto/twofish_avx_glue.c
+++ b/arch/x86/crypto/twofish_avx_glue.c
@@ -45,66 +45,23 @@
45 45
46#define TWOFISH_PARALLEL_BLOCKS 8 46#define TWOFISH_PARALLEL_BLOCKS 8
47 47
48static inline void twofish_enc_blk_3way(struct twofish_ctx *ctx, u8 *dst,
49 const u8 *src)
50{
51 __twofish_enc_blk_3way(ctx, dst, src, false);
52}
53
54/* 8-way parallel cipher functions */ 48/* 8-way parallel cipher functions */
55asmlinkage void __twofish_enc_blk_8way(struct twofish_ctx *ctx, u8 *dst, 49asmlinkage void twofish_ecb_enc_8way(struct twofish_ctx *ctx, u8 *dst,
56 const u8 *src, bool xor); 50 const u8 *src);
57asmlinkage void twofish_dec_blk_8way(struct twofish_ctx *ctx, u8 *dst, 51asmlinkage void twofish_ecb_dec_8way(struct twofish_ctx *ctx, u8 *dst,
58 const u8 *src); 52 const u8 *src);
59 53
60static inline void twofish_enc_blk_xway(struct twofish_ctx *ctx, u8 *dst, 54asmlinkage void twofish_cbc_dec_8way(struct twofish_ctx *ctx, u8 *dst,
61 const u8 *src) 55 const u8 *src);
62{ 56asmlinkage void twofish_ctr_8way(struct twofish_ctx *ctx, u8 *dst,
63 __twofish_enc_blk_8way(ctx, dst, src, false); 57 const u8 *src, le128 *iv);
64}
65
66static inline void twofish_enc_blk_xway_xor(struct twofish_ctx *ctx, u8 *dst,
67 const u8 *src)
68{
69 __twofish_enc_blk_8way(ctx, dst, src, true);
70}
71 58
72static inline void twofish_dec_blk_xway(struct twofish_ctx *ctx, u8 *dst, 59static inline void twofish_enc_blk_3way(struct twofish_ctx *ctx, u8 *dst,
73 const u8 *src) 60 const u8 *src)
74{ 61{
75 twofish_dec_blk_8way(ctx, dst, src); 62 __twofish_enc_blk_3way(ctx, dst, src, false);
76}
77
78static void twofish_dec_blk_cbc_xway(void *ctx, u128 *dst, const u128 *src)
79{
80 u128 ivs[TWOFISH_PARALLEL_BLOCKS - 1];
81 unsigned int j;
82
83 for (j = 0; j < TWOFISH_PARALLEL_BLOCKS - 1; j++)
84 ivs[j] = src[j];
85
86 twofish_dec_blk_xway(ctx, (u8 *)dst, (u8 *)src);
87
88 for (j = 0; j < TWOFISH_PARALLEL_BLOCKS - 1; j++)
89 u128_xor(dst + (j + 1), dst + (j + 1), ivs + j);
90} 63}
91 64
92static void twofish_enc_blk_ctr_xway(void *ctx, u128 *dst, const u128 *src,
93 u128 *iv)
94{
95 be128 ctrblks[TWOFISH_PARALLEL_BLOCKS];
96 unsigned int i;
97
98 for (i = 0; i < TWOFISH_PARALLEL_BLOCKS; i++) {
99 if (dst != src)
100 dst[i] = src[i];
101
102 u128_to_be128(&ctrblks[i], iv);
103 u128_inc(iv);
104 }
105
106 twofish_enc_blk_xway_xor(ctx, (u8 *)dst, (u8 *)ctrblks);
107}
108 65
109static const struct common_glue_ctx twofish_enc = { 66static const struct common_glue_ctx twofish_enc = {
110 .num_funcs = 3, 67 .num_funcs = 3,
@@ -112,7 +69,7 @@ static const struct common_glue_ctx twofish_enc = {
112 69
113 .funcs = { { 70 .funcs = { {
114 .num_blocks = TWOFISH_PARALLEL_BLOCKS, 71 .num_blocks = TWOFISH_PARALLEL_BLOCKS,
115 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk_xway) } 72 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_ecb_enc_8way) }
116 }, { 73 }, {
117 .num_blocks = 3, 74 .num_blocks = 3,
118 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk_3way) } 75 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk_3way) }
@@ -128,7 +85,7 @@ static const struct common_glue_ctx twofish_ctr = {
128 85
129 .funcs = { { 86 .funcs = { {
130 .num_blocks = TWOFISH_PARALLEL_BLOCKS, 87 .num_blocks = TWOFISH_PARALLEL_BLOCKS,
131 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(twofish_enc_blk_ctr_xway) } 88 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(twofish_ctr_8way) }
132 }, { 89 }, {
133 .num_blocks = 3, 90 .num_blocks = 3,
134 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(twofish_enc_blk_ctr_3way) } 91 .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(twofish_enc_blk_ctr_3way) }
@@ -144,7 +101,7 @@ static const struct common_glue_ctx twofish_dec = {
144 101
145 .funcs = { { 102 .funcs = { {
146 .num_blocks = TWOFISH_PARALLEL_BLOCKS, 103 .num_blocks = TWOFISH_PARALLEL_BLOCKS,
147 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_dec_blk_xway) } 104 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_ecb_dec_8way) }
148 }, { 105 }, {
149 .num_blocks = 3, 106 .num_blocks = 3,
150 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_dec_blk_3way) } 107 .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_dec_blk_3way) }
@@ -160,7 +117,7 @@ static const struct common_glue_ctx twofish_dec_cbc = {
160 117
161 .funcs = { { 118 .funcs = { {
162 .num_blocks = TWOFISH_PARALLEL_BLOCKS, 119 .num_blocks = TWOFISH_PARALLEL_BLOCKS,
163 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(twofish_dec_blk_cbc_xway) } 120 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(twofish_cbc_dec_8way) }
164 }, { 121 }, {
165 .num_blocks = 3, 122 .num_blocks = 3,
166 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(twofish_dec_blk_cbc_3way) } 123 .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(twofish_dec_blk_cbc_3way) }
@@ -227,7 +184,7 @@ static void encrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes)
227 ctx->fpu_enabled = twofish_fpu_begin(ctx->fpu_enabled, nbytes); 184 ctx->fpu_enabled = twofish_fpu_begin(ctx->fpu_enabled, nbytes);
228 185
229 if (nbytes == bsize * TWOFISH_PARALLEL_BLOCKS) { 186 if (nbytes == bsize * TWOFISH_PARALLEL_BLOCKS) {
230 twofish_enc_blk_xway(ctx->ctx, srcdst, srcdst); 187 twofish_ecb_enc_8way(ctx->ctx, srcdst, srcdst);
231 return; 188 return;
232 } 189 }
233 190
@@ -249,7 +206,7 @@ static void decrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes)
249 ctx->fpu_enabled = twofish_fpu_begin(ctx->fpu_enabled, nbytes); 206 ctx->fpu_enabled = twofish_fpu_begin(ctx->fpu_enabled, nbytes);
250 207
251 if (nbytes == bsize * TWOFISH_PARALLEL_BLOCKS) { 208 if (nbytes == bsize * TWOFISH_PARALLEL_BLOCKS) {
252 twofish_dec_blk_xway(ctx->ctx, srcdst, srcdst); 209 twofish_ecb_dec_8way(ctx->ctx, srcdst, srcdst);
253 return; 210 return;
254 } 211 }
255 212
diff --git a/arch/x86/crypto/twofish_glue_3way.c b/arch/x86/crypto/twofish_glue_3way.c
index aa3eb358b7e8..13e63b3e1dfb 100644
--- a/arch/x86/crypto/twofish_glue_3way.c
+++ b/arch/x86/crypto/twofish_glue_3way.c
@@ -62,15 +62,15 @@ void twofish_dec_blk_cbc_3way(void *ctx, u128 *dst, const u128 *src)
62} 62}
63EXPORT_SYMBOL_GPL(twofish_dec_blk_cbc_3way); 63EXPORT_SYMBOL_GPL(twofish_dec_blk_cbc_3way);
64 64
65void twofish_enc_blk_ctr(void *ctx, u128 *dst, const u128 *src, u128 *iv) 65void twofish_enc_blk_ctr(void *ctx, u128 *dst, const u128 *src, le128 *iv)
66{ 66{
67 be128 ctrblk; 67 be128 ctrblk;
68 68
69 if (dst != src) 69 if (dst != src)
70 *dst = *src; 70 *dst = *src;
71 71
72 u128_to_be128(&ctrblk, iv); 72 le128_to_be128(&ctrblk, iv);
73 u128_inc(iv); 73 le128_inc(iv);
74 74
75 twofish_enc_blk(ctx, (u8 *)&ctrblk, (u8 *)&ctrblk); 75 twofish_enc_blk(ctx, (u8 *)&ctrblk, (u8 *)&ctrblk);
76 u128_xor(dst, dst, (u128 *)&ctrblk); 76 u128_xor(dst, dst, (u128 *)&ctrblk);
@@ -78,7 +78,7 @@ void twofish_enc_blk_ctr(void *ctx, u128 *dst, const u128 *src, u128 *iv)
78EXPORT_SYMBOL_GPL(twofish_enc_blk_ctr); 78EXPORT_SYMBOL_GPL(twofish_enc_blk_ctr);
79 79
80void twofish_enc_blk_ctr_3way(void *ctx, u128 *dst, const u128 *src, 80void twofish_enc_blk_ctr_3way(void *ctx, u128 *dst, const u128 *src,
81 u128 *iv) 81 le128 *iv)
82{ 82{
83 be128 ctrblks[3]; 83 be128 ctrblks[3];
84 84
@@ -88,12 +88,12 @@ void twofish_enc_blk_ctr_3way(void *ctx, u128 *dst, const u128 *src,
88 dst[2] = src[2]; 88 dst[2] = src[2];
89 } 89 }
90 90
91 u128_to_be128(&ctrblks[0], iv); 91 le128_to_be128(&ctrblks[0], iv);
92 u128_inc(iv); 92 le128_inc(iv);
93 u128_to_be128(&ctrblks[1], iv); 93 le128_to_be128(&ctrblks[1], iv);
94 u128_inc(iv); 94 le128_inc(iv);
95 u128_to_be128(&ctrblks[2], iv); 95 le128_to_be128(&ctrblks[2], iv);
96 u128_inc(iv); 96 le128_inc(iv);
97 97
98 twofish_enc_blk_xor_3way(ctx, (u8 *)dst, (u8 *)ctrblks); 98 twofish_enc_blk_xor_3way(ctx, (u8 *)dst, (u8 *)ctrblks);
99} 99}
diff --git a/arch/x86/include/asm/crypto/camellia.h b/arch/x86/include/asm/crypto/camellia.h
new file mode 100644
index 000000000000..98038add801e
--- /dev/null
+++ b/arch/x86/include/asm/crypto/camellia.h
@@ -0,0 +1,82 @@
1#ifndef ASM_X86_CAMELLIA_H
2#define ASM_X86_CAMELLIA_H
3
4#include <linux/kernel.h>
5#include <linux/crypto.h>
6
7#define CAMELLIA_MIN_KEY_SIZE 16
8#define CAMELLIA_MAX_KEY_SIZE 32
9#define CAMELLIA_BLOCK_SIZE 16
10#define CAMELLIA_TABLE_BYTE_LEN 272
11#define CAMELLIA_PARALLEL_BLOCKS 2
12
13struct camellia_ctx {
14 u64 key_table[CAMELLIA_TABLE_BYTE_LEN / sizeof(u64)];
15 u32 key_length;
16};
17
18struct camellia_lrw_ctx {
19 struct lrw_table_ctx lrw_table;
20 struct camellia_ctx camellia_ctx;
21};
22
23struct camellia_xts_ctx {
24 struct camellia_ctx tweak_ctx;
25 struct camellia_ctx crypt_ctx;
26};
27
28extern int __camellia_setkey(struct camellia_ctx *cctx,
29 const unsigned char *key,
30 unsigned int key_len, u32 *flags);
31
32extern int lrw_camellia_setkey(struct crypto_tfm *tfm, const u8 *key,
33 unsigned int keylen);
34extern void lrw_camellia_exit_tfm(struct crypto_tfm *tfm);
35
36extern int xts_camellia_setkey(struct crypto_tfm *tfm, const u8 *key,
37 unsigned int keylen);
38
39/* regular block cipher functions */
40asmlinkage void __camellia_enc_blk(struct camellia_ctx *ctx, u8 *dst,
41 const u8 *src, bool xor);
42asmlinkage void camellia_dec_blk(struct camellia_ctx *ctx, u8 *dst,
43 const u8 *src);
44
45/* 2-way parallel cipher functions */
46asmlinkage void __camellia_enc_blk_2way(struct camellia_ctx *ctx, u8 *dst,
47 const u8 *src, bool xor);
48asmlinkage void camellia_dec_blk_2way(struct camellia_ctx *ctx, u8 *dst,
49 const u8 *src);
50
51static inline void camellia_enc_blk(struct camellia_ctx *ctx, u8 *dst,
52 const u8 *src)
53{
54 __camellia_enc_blk(ctx, dst, src, false);
55}
56
57static inline void camellia_enc_blk_xor(struct camellia_ctx *ctx, u8 *dst,
58 const u8 *src)
59{
60 __camellia_enc_blk(ctx, dst, src, true);
61}
62
63static inline void camellia_enc_blk_2way(struct camellia_ctx *ctx, u8 *dst,
64 const u8 *src)
65{
66 __camellia_enc_blk_2way(ctx, dst, src, false);
67}
68
69static inline void camellia_enc_blk_xor_2way(struct camellia_ctx *ctx, u8 *dst,
70 const u8 *src)
71{
72 __camellia_enc_blk_2way(ctx, dst, src, true);
73}
74
75/* glue helpers */
76extern void camellia_decrypt_cbc_2way(void *ctx, u128 *dst, const u128 *src);
77extern void camellia_crypt_ctr(void *ctx, u128 *dst, const u128 *src,
78 le128 *iv);
79extern void camellia_crypt_ctr_2way(void *ctx, u128 *dst, const u128 *src,
80 le128 *iv);
81
82#endif /* ASM_X86_CAMELLIA_H */
diff --git a/arch/x86/include/asm/crypto/glue_helper.h b/arch/x86/include/asm/crypto/glue_helper.h
index 3e408bddc96f..e2d65b061d27 100644
--- a/arch/x86/include/asm/crypto/glue_helper.h
+++ b/arch/x86/include/asm/crypto/glue_helper.h
@@ -13,7 +13,7 @@
13typedef void (*common_glue_func_t)(void *ctx, u8 *dst, const u8 *src); 13typedef void (*common_glue_func_t)(void *ctx, u8 *dst, const u8 *src);
14typedef void (*common_glue_cbc_func_t)(void *ctx, u128 *dst, const u128 *src); 14typedef void (*common_glue_cbc_func_t)(void *ctx, u128 *dst, const u128 *src);
15typedef void (*common_glue_ctr_func_t)(void *ctx, u128 *dst, const u128 *src, 15typedef void (*common_glue_ctr_func_t)(void *ctx, u128 *dst, const u128 *src,
16 u128 *iv); 16 le128 *iv);
17 17
18#define GLUE_FUNC_CAST(fn) ((common_glue_func_t)(fn)) 18#define GLUE_FUNC_CAST(fn) ((common_glue_func_t)(fn))
19#define GLUE_CBC_FUNC_CAST(fn) ((common_glue_cbc_func_t)(fn)) 19#define GLUE_CBC_FUNC_CAST(fn) ((common_glue_cbc_func_t)(fn))
@@ -71,23 +71,29 @@ static inline void glue_fpu_end(bool fpu_enabled)
71 kernel_fpu_end(); 71 kernel_fpu_end();
72} 72}
73 73
74static inline void u128_to_be128(be128 *dst, const u128 *src) 74static inline void le128_to_be128(be128 *dst, const le128 *src)
75{ 75{
76 dst->a = cpu_to_be64(src->a); 76 dst->a = cpu_to_be64(le64_to_cpu(src->a));
77 dst->b = cpu_to_be64(src->b); 77 dst->b = cpu_to_be64(le64_to_cpu(src->b));
78} 78}
79 79
80static inline void be128_to_u128(u128 *dst, const be128 *src) 80static inline void be128_to_le128(le128 *dst, const be128 *src)
81{ 81{
82 dst->a = be64_to_cpu(src->a); 82 dst->a = cpu_to_le64(be64_to_cpu(src->a));
83 dst->b = be64_to_cpu(src->b); 83 dst->b = cpu_to_le64(be64_to_cpu(src->b));
84} 84}
85 85
86static inline void u128_inc(u128 *i) 86static inline void le128_inc(le128 *i)
87{ 87{
88 i->b++; 88 u64 a = le64_to_cpu(i->a);
89 if (!i->b) 89 u64 b = le64_to_cpu(i->b);
90 i->a++; 90
91 b++;
92 if (!b)
93 a++;
94
95 i->a = cpu_to_le64(a);
96 i->b = cpu_to_le64(b);
91} 97}
92 98
93extern int glue_ecb_crypt_128bit(const struct common_glue_ctx *gctx, 99extern int glue_ecb_crypt_128bit(const struct common_glue_ctx *gctx,
diff --git a/arch/x86/include/asm/crypto/serpent-avx.h b/arch/x86/include/asm/crypto/serpent-avx.h
index 432deedd2945..0da1d3e2a55c 100644
--- a/arch/x86/include/asm/crypto/serpent-avx.h
+++ b/arch/x86/include/asm/crypto/serpent-avx.h
@@ -6,27 +6,14 @@
6 6
7#define SERPENT_PARALLEL_BLOCKS 8 7#define SERPENT_PARALLEL_BLOCKS 8
8 8
9asmlinkage void __serpent_enc_blk_8way_avx(struct serpent_ctx *ctx, u8 *dst, 9asmlinkage void serpent_ecb_enc_8way_avx(struct serpent_ctx *ctx, u8 *dst,
10 const u8 *src, bool xor); 10 const u8 *src);
11asmlinkage void serpent_dec_blk_8way_avx(struct serpent_ctx *ctx, u8 *dst, 11asmlinkage void serpent_ecb_dec_8way_avx(struct serpent_ctx *ctx, u8 *dst,
12 const u8 *src); 12 const u8 *src);
13 13
14static inline void serpent_enc_blk_xway(struct serpent_ctx *ctx, u8 *dst, 14asmlinkage void serpent_cbc_dec_8way_avx(struct serpent_ctx *ctx, u8 *dst,
15 const u8 *src) 15 const u8 *src);
16{ 16asmlinkage void serpent_ctr_8way_avx(struct serpent_ctx *ctx, u8 *dst,
17 __serpent_enc_blk_8way_avx(ctx, dst, src, false); 17 const u8 *src, le128 *iv);
18}
19
20static inline void serpent_enc_blk_xway_xor(struct serpent_ctx *ctx, u8 *dst,
21 const u8 *src)
22{
23 __serpent_enc_blk_8way_avx(ctx, dst, src, true);
24}
25
26static inline void serpent_dec_blk_xway(struct serpent_ctx *ctx, u8 *dst,
27 const u8 *src)
28{
29 serpent_dec_blk_8way_avx(ctx, dst, src);
30}
31 18
32#endif 19#endif
diff --git a/arch/x86/include/asm/crypto/twofish.h b/arch/x86/include/asm/crypto/twofish.h
index 9d2c514bd5f9..878c51ceebb5 100644
--- a/arch/x86/include/asm/crypto/twofish.h
+++ b/arch/x86/include/asm/crypto/twofish.h
@@ -31,9 +31,9 @@ asmlinkage void twofish_dec_blk_3way(struct twofish_ctx *ctx, u8 *dst,
31/* helpers from twofish_x86_64-3way module */ 31/* helpers from twofish_x86_64-3way module */
32extern void twofish_dec_blk_cbc_3way(void *ctx, u128 *dst, const u128 *src); 32extern void twofish_dec_blk_cbc_3way(void *ctx, u128 *dst, const u128 *src);
33extern void twofish_enc_blk_ctr(void *ctx, u128 *dst, const u128 *src, 33extern void twofish_enc_blk_ctr(void *ctx, u128 *dst, const u128 *src,
34 u128 *iv); 34 le128 *iv);
35extern void twofish_enc_blk_ctr_3way(void *ctx, u128 *dst, const u128 *src, 35extern void twofish_enc_blk_ctr_3way(void *ctx, u128 *dst, const u128 *src,
36 u128 *iv); 36 le128 *iv);
37 37
38extern int lrw_twofish_setkey(struct crypto_tfm *tfm, const u8 *key, 38extern int lrw_twofish_setkey(struct crypto_tfm *tfm, const u8 *key,
39 unsigned int keylen); 39 unsigned int keylen);
diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
index fd13815fe85c..6e8fdf5ad113 100644
--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -69,37 +69,23 @@ extern u64 efi_call6(void *fp, u64 arg1, u64 arg2, u64 arg3,
69 efi_call6((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3), \ 69 efi_call6((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3), \
70 (u64)(a4), (u64)(a5), (u64)(a6)) 70 (u64)(a4), (u64)(a5), (u64)(a6))
71 71
72extern unsigned long efi_call_virt_prelog(void);
73extern void efi_call_virt_epilog(unsigned long);
74
75#define efi_callx(x, func, ...) \
76 ({ \
77 efi_status_t __status; \
78 unsigned long __pgd; \
79 \
80 __pgd = efi_call_virt_prelog(); \
81 __status = efi_call##x(func, __VA_ARGS__); \
82 efi_call_virt_epilog(__pgd); \
83 __status; \
84 })
85
86#define efi_call_virt0(f) \ 72#define efi_call_virt0(f) \
87 efi_callx(0, (void *)(efi.systab->runtime->f)) 73 efi_call0((void *)(efi.systab->runtime->f))
88#define efi_call_virt1(f, a1) \ 74#define efi_call_virt1(f, a1) \
89 efi_callx(1, (void *)(efi.systab->runtime->f), (u64)(a1)) 75 efi_call1((void *)(efi.systab->runtime->f), (u64)(a1))
90#define efi_call_virt2(f, a1, a2) \ 76#define efi_call_virt2(f, a1, a2) \
91 efi_callx(2, (void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2)) 77 efi_call2((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2))
92#define efi_call_virt3(f, a1, a2, a3) \ 78#define efi_call_virt3(f, a1, a2, a3) \
93 efi_callx(3, (void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \ 79 efi_call3((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
94 (u64)(a3)) 80 (u64)(a3))
95#define efi_call_virt4(f, a1, a2, a3, a4) \ 81#define efi_call_virt4(f, a1, a2, a3, a4) \
96 efi_callx(4, (void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \ 82 efi_call4((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
97 (u64)(a3), (u64)(a4)) 83 (u64)(a3), (u64)(a4))
98#define efi_call_virt5(f, a1, a2, a3, a4, a5) \ 84#define efi_call_virt5(f, a1, a2, a3, a4, a5) \
99 efi_callx(5, (void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \ 85 efi_call5((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
100 (u64)(a3), (u64)(a4), (u64)(a5)) 86 (u64)(a3), (u64)(a4), (u64)(a5))
101#define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \ 87#define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \
102 efi_callx(6, (void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \ 88 efi_call6((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
103 (u64)(a3), (u64)(a4), (u64)(a5), (u64)(a6)) 89 (u64)(a3), (u64)(a4), (u64)(a5), (u64)(a6))
104 90
105extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size, 91extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size,
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index a1f780d45f76..5199db2923d3 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -404,7 +404,14 @@ static inline int pte_same(pte_t a, pte_t b)
404 404
405static inline int pte_present(pte_t a) 405static inline int pte_present(pte_t a)
406{ 406{
407 return pte_flags(a) & (_PAGE_PRESENT | _PAGE_PROTNONE); 407 return pte_flags(a) & (_PAGE_PRESENT | _PAGE_PROTNONE |
408 _PAGE_NUMA);
409}
410
411#define pte_accessible pte_accessible
412static inline int pte_accessible(pte_t a)
413{
414 return pte_flags(a) & _PAGE_PRESENT;
408} 415}
409 416
410static inline int pte_hidden(pte_t pte) 417static inline int pte_hidden(pte_t pte)
@@ -420,7 +427,8 @@ static inline int pmd_present(pmd_t pmd)
420 * the _PAGE_PSE flag will remain set at all times while the 427 * the _PAGE_PSE flag will remain set at all times while the
421 * _PAGE_PRESENT bit is clear). 428 * _PAGE_PRESENT bit is clear).
422 */ 429 */
423 return pmd_flags(pmd) & (_PAGE_PRESENT | _PAGE_PROTNONE | _PAGE_PSE); 430 return pmd_flags(pmd) & (_PAGE_PRESENT | _PAGE_PROTNONE | _PAGE_PSE |
431 _PAGE_NUMA);
424} 432}
425 433
426static inline int pmd_none(pmd_t pmd) 434static inline int pmd_none(pmd_t pmd)
@@ -479,6 +487,11 @@ static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long address)
479 487
480static inline int pmd_bad(pmd_t pmd) 488static inline int pmd_bad(pmd_t pmd)
481{ 489{
490#ifdef CONFIG_NUMA_BALANCING
491 /* pmd_numa check */
492 if ((pmd_flags(pmd) & (_PAGE_NUMA|_PAGE_PRESENT)) == _PAGE_NUMA)
493 return 0;
494#endif
482 return (pmd_flags(pmd) & ~_PAGE_USER) != _KERNPG_TABLE; 495 return (pmd_flags(pmd) & ~_PAGE_USER) != _KERNPG_TABLE;
483} 496}
484 497
diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
index ec8a1fc9505d..3c32db8c539d 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -64,6 +64,26 @@
64#define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE) 64#define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
65#define _PAGE_PROTNONE (_AT(pteval_t, 1) << _PAGE_BIT_PROTNONE) 65#define _PAGE_PROTNONE (_AT(pteval_t, 1) << _PAGE_BIT_PROTNONE)
66 66
67/*
68 * _PAGE_NUMA indicates that this page will trigger a numa hinting
69 * minor page fault to gather numa placement statistics (see
70 * pte_numa()). The bit picked (8) is within the range between
71 * _PAGE_FILE (6) and _PAGE_PROTNONE (8) bits. Therefore, it doesn't
72 * require changes to the swp entry format because that bit is always
73 * zero when the pte is not present.
74 *
75 * The bit picked must be always zero when the pmd is present and not
76 * present, so that we don't lose information when we set it while
77 * atomically clearing the present bit.
78 *
79 * Because we shared the same bit (8) with _PAGE_PROTNONE this can be
80 * interpreted as _PAGE_NUMA only in places that _PAGE_PROTNONE
81 * couldn't reach, like handle_mm_fault() (see access_error in
82 * arch/x86/mm/fault.c, the vma protection must not be PROT_NONE for
83 * handle_mm_fault() to be invoked).
84 */
85#define _PAGE_NUMA _PAGE_PROTNONE
86
67#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \ 87#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \
68 _PAGE_ACCESSED | _PAGE_DIRTY) 88 _PAGE_ACCESSED | _PAGE_DIRTY)
69#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | \ 89#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | \
diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
index d4f460f962ee..f84fe00fad48 100644
--- a/arch/x86/kernel/tboot.c
+++ b/arch/x86/kernel/tboot.c
@@ -103,13 +103,71 @@ void __init tboot_probe(void)
103 pr_debug("tboot_size: 0x%x\n", tboot->tboot_size); 103 pr_debug("tboot_size: 0x%x\n", tboot->tboot_size);
104} 104}
105 105
106static pgd_t *tboot_pg_dir;
107static struct mm_struct tboot_mm = {
108 .mm_rb = RB_ROOT,
109 .pgd = swapper_pg_dir,
110 .mm_users = ATOMIC_INIT(2),
111 .mm_count = ATOMIC_INIT(1),
112 .mmap_sem = __RWSEM_INITIALIZER(init_mm.mmap_sem),
113 .page_table_lock = __SPIN_LOCK_UNLOCKED(init_mm.page_table_lock),
114 .mmlist = LIST_HEAD_INIT(init_mm.mmlist),
115};
116
106static inline void switch_to_tboot_pt(void) 117static inline void switch_to_tboot_pt(void)
107{ 118{
108#ifdef CONFIG_X86_32 119 write_cr3(virt_to_phys(tboot_pg_dir));
109 load_cr3(initial_page_table); 120}
110#else 121
111 write_cr3(real_mode_header->trampoline_pgd); 122static int map_tboot_page(unsigned long vaddr, unsigned long pfn,
112#endif 123 pgprot_t prot)
124{
125 pgd_t *pgd;
126 pud_t *pud;
127 pmd_t *pmd;
128 pte_t *pte;
129
130 pgd = pgd_offset(&tboot_mm, vaddr);
131 pud = pud_alloc(&tboot_mm, pgd, vaddr);
132 if (!pud)
133 return -1;
134 pmd = pmd_alloc(&tboot_mm, pud, vaddr);
135 if (!pmd)
136 return -1;
137 pte = pte_alloc_map(&tboot_mm, NULL, pmd, vaddr);
138 if (!pte)
139 return -1;
140 set_pte_at(&tboot_mm, vaddr, pte, pfn_pte(pfn, prot));
141 pte_unmap(pte);
142 return 0;
143}
144
145static int map_tboot_pages(unsigned long vaddr, unsigned long start_pfn,
146 unsigned long nr)
147{
148 /* Reuse the original kernel mapping */
149 tboot_pg_dir = pgd_alloc(&tboot_mm);
150 if (!tboot_pg_dir)
151 return -1;
152
153 for (; nr > 0; nr--, vaddr += PAGE_SIZE, start_pfn++) {
154 if (map_tboot_page(vaddr, start_pfn, PAGE_KERNEL_EXEC))
155 return -1;
156 }
157
158 return 0;
159}
160
161static void tboot_create_trampoline(void)
162{
163 u32 map_base, map_size;
164
165 /* Create identity map for tboot shutdown code. */
166 map_base = PFN_DOWN(tboot->tboot_base);
167 map_size = PFN_UP(tboot->tboot_size);
168 if (map_tboot_pages(map_base << PAGE_SHIFT, map_base, map_size))
169 panic("tboot: Error mapping tboot pages (mfns) @ 0x%x, 0x%x\n",
170 map_base, map_size);
113} 171}
114 172
115#ifdef CONFIG_ACPI_SLEEP 173#ifdef CONFIG_ACPI_SLEEP
@@ -167,6 +225,14 @@ void tboot_shutdown(u32 shutdown_type)
167 if (!tboot_enabled()) 225 if (!tboot_enabled())
168 return; 226 return;
169 227
228 /*
229 * if we're being called before the 1:1 mapping is set up then just
230 * return and let the normal shutdown happen; this should only be
231 * due to very early panic()
232 */
233 if (!tboot_pg_dir)
234 return;
235
170 /* if this is S3 then set regions to MAC */ 236 /* if this is S3 then set regions to MAC */
171 if (shutdown_type == TB_SHUTDOWN_S3) 237 if (shutdown_type == TB_SHUTDOWN_S3)
172 if (tboot_setup_sleep()) 238 if (tboot_setup_sleep())
@@ -277,6 +343,8 @@ static __init int tboot_late_init(void)
277 if (!tboot_enabled()) 343 if (!tboot_enabled())
278 return 0; 344 return 0;
279 345
346 tboot_create_trampoline();
347
280 atomic_set(&ap_wfs_count, 0); 348 atomic_set(&ap_wfs_count, 0);
281 register_hotcpu_notifier(&tboot_cpu_notifier); 349 register_hotcpu_notifier(&tboot_cpu_notifier);
282 350
diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
index 3a3e8c9e280d..9a907a67be8f 100644
--- a/arch/x86/kernel/vsyscall_64.c
+++ b/arch/x86/kernel/vsyscall_64.c
@@ -145,19 +145,6 @@ static int addr_to_vsyscall_nr(unsigned long addr)
145 return nr; 145 return nr;
146} 146}
147 147
148#ifdef CONFIG_SECCOMP
149static int vsyscall_seccomp(struct task_struct *tsk, int syscall_nr)
150{
151 if (!seccomp_mode(&tsk->seccomp))
152 return 0;
153 task_pt_regs(tsk)->orig_ax = syscall_nr;
154 task_pt_regs(tsk)->ax = syscall_nr;
155 return __secure_computing(syscall_nr);
156}
157#else
158#define vsyscall_seccomp(_tsk, _nr) 0
159#endif
160
161static bool write_ok_or_segv(unsigned long ptr, size_t size) 148static bool write_ok_or_segv(unsigned long ptr, size_t size)
162{ 149{
163 /* 150 /*
@@ -190,10 +177,9 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
190{ 177{
191 struct task_struct *tsk; 178 struct task_struct *tsk;
192 unsigned long caller; 179 unsigned long caller;
193 int vsyscall_nr; 180 int vsyscall_nr, syscall_nr, tmp;
194 int prev_sig_on_uaccess_error; 181 int prev_sig_on_uaccess_error;
195 long ret; 182 long ret;
196 int skip;
197 183
198 /* 184 /*
199 * No point in checking CS -- the only way to get here is a user mode 185 * No point in checking CS -- the only way to get here is a user mode
@@ -225,56 +211,84 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
225 } 211 }
226 212
227 tsk = current; 213 tsk = current;
228 /*
229 * With a real vsyscall, page faults cause SIGSEGV. We want to
230 * preserve that behavior to make writing exploits harder.
231 */
232 prev_sig_on_uaccess_error = current_thread_info()->sig_on_uaccess_error;
233 current_thread_info()->sig_on_uaccess_error = 1;
234 214
235 /* 215 /*
216 * Check for access_ok violations and find the syscall nr.
217 *
236 * NULL is a valid user pointer (in the access_ok sense) on 32-bit and 218 * NULL is a valid user pointer (in the access_ok sense) on 32-bit and
237 * 64-bit, so we don't need to special-case it here. For all the 219 * 64-bit, so we don't need to special-case it here. For all the
238 * vsyscalls, NULL means "don't write anything" not "write it at 220 * vsyscalls, NULL means "don't write anything" not "write it at
239 * address 0". 221 * address 0".
240 */ 222 */
241 ret = -EFAULT;
242 skip = 0;
243 switch (vsyscall_nr) { 223 switch (vsyscall_nr) {
244 case 0: 224 case 0:
245 skip = vsyscall_seccomp(tsk, __NR_gettimeofday);
246 if (skip)
247 break;
248
249 if (!write_ok_or_segv(regs->di, sizeof(struct timeval)) || 225 if (!write_ok_or_segv(regs->di, sizeof(struct timeval)) ||
250 !write_ok_or_segv(regs->si, sizeof(struct timezone))) 226 !write_ok_or_segv(regs->si, sizeof(struct timezone))) {
251 break; 227 ret = -EFAULT;
228 goto check_fault;
229 }
230
231 syscall_nr = __NR_gettimeofday;
232 break;
233
234 case 1:
235 if (!write_ok_or_segv(regs->di, sizeof(time_t))) {
236 ret = -EFAULT;
237 goto check_fault;
238 }
239
240 syscall_nr = __NR_time;
241 break;
242
243 case 2:
244 if (!write_ok_or_segv(regs->di, sizeof(unsigned)) ||
245 !write_ok_or_segv(regs->si, sizeof(unsigned))) {
246 ret = -EFAULT;
247 goto check_fault;
248 }
249
250 syscall_nr = __NR_getcpu;
251 break;
252 }
253
254 /*
255 * Handle seccomp. regs->ip must be the original value.
256 * See seccomp_send_sigsys and Documentation/prctl/seccomp_filter.txt.
257 *
258 * We could optimize the seccomp disabled case, but performance
259 * here doesn't matter.
260 */
261 regs->orig_ax = syscall_nr;
262 regs->ax = -ENOSYS;
263 tmp = secure_computing(syscall_nr);
264 if ((!tmp && regs->orig_ax != syscall_nr) || regs->ip != address) {
265 warn_bad_vsyscall(KERN_DEBUG, regs,
266 "seccomp tried to change syscall nr or ip");
267 do_exit(SIGSYS);
268 }
269 if (tmp)
270 goto do_ret; /* skip requested */
252 271
272 /*
273 * With a real vsyscall, page faults cause SIGSEGV. We want to
274 * preserve that behavior to make writing exploits harder.
275 */
276 prev_sig_on_uaccess_error = current_thread_info()->sig_on_uaccess_error;
277 current_thread_info()->sig_on_uaccess_error = 1;
278
279 ret = -EFAULT;
280 switch (vsyscall_nr) {
281 case 0:
253 ret = sys_gettimeofday( 282 ret = sys_gettimeofday(
254 (struct timeval __user *)regs->di, 283 (struct timeval __user *)regs->di,
255 (struct timezone __user *)regs->si); 284 (struct timezone __user *)regs->si);
256 break; 285 break;
257 286
258 case 1: 287 case 1:
259 skip = vsyscall_seccomp(tsk, __NR_time);
260 if (skip)
261 break;
262
263 if (!write_ok_or_segv(regs->di, sizeof(time_t)))
264 break;
265
266 ret = sys_time((time_t __user *)regs->di); 288 ret = sys_time((time_t __user *)regs->di);
267 break; 289 break;
268 290
269 case 2: 291 case 2:
270 skip = vsyscall_seccomp(tsk, __NR_getcpu);
271 if (skip)
272 break;
273
274 if (!write_ok_or_segv(regs->di, sizeof(unsigned)) ||
275 !write_ok_or_segv(regs->si, sizeof(unsigned)))
276 break;
277
278 ret = sys_getcpu((unsigned __user *)regs->di, 292 ret = sys_getcpu((unsigned __user *)regs->di,
279 (unsigned __user *)regs->si, 293 (unsigned __user *)regs->si,
280 NULL); 294 NULL);
@@ -283,12 +297,7 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
283 297
284 current_thread_info()->sig_on_uaccess_error = prev_sig_on_uaccess_error; 298 current_thread_info()->sig_on_uaccess_error = prev_sig_on_uaccess_error;
285 299
286 if (skip) { 300check_fault:
287 if ((long)regs->ax <= 0L) /* seccomp errno emulation */
288 goto do_ret;
289 goto done; /* seccomp trace/trap */
290 }
291
292 if (ret == -EFAULT) { 301 if (ret == -EFAULT) {
293 /* Bad news -- userspace fed a bad pointer to a vsyscall. */ 302 /* Bad news -- userspace fed a bad pointer to a vsyscall. */
294 warn_bad_vsyscall(KERN_INFO, regs, 303 warn_bad_vsyscall(KERN_INFO, regs,
@@ -311,7 +320,6 @@ do_ret:
311 /* Emulate a ret instruction. */ 320 /* Emulate a ret instruction. */
312 regs->ip = caller; 321 regs->ip = caller;
313 regs->sp += 8; 322 regs->sp += 8;
314done:
315 return true; 323 return true;
316 324
317sigsegv: 325sigsegv:
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 07519a120449..2ead3c8a4c84 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -108,13 +108,13 @@ void sync_global_pgds(unsigned long start, unsigned long end)
108 for (address = start; address <= end; address += PGDIR_SIZE) { 108 for (address = start; address <= end; address += PGDIR_SIZE) {
109 const pgd_t *pgd_ref = pgd_offset_k(address); 109 const pgd_t *pgd_ref = pgd_offset_k(address);
110 struct page *page; 110 struct page *page;
111 pgd_t *pgd;
112 111
113 if (pgd_none(*pgd_ref)) 112 if (pgd_none(*pgd_ref))
114 continue; 113 continue;
115 114
116 spin_lock(&pgd_lock); 115 spin_lock(&pgd_lock);
117 list_for_each_entry(page, &pgd_list, lru) { 116 list_for_each_entry(page, &pgd_list, lru) {
117 pgd_t *pgd;
118 spinlock_t *pgt_lock; 118 spinlock_t *pgt_lock;
119 119
120 pgd = (pgd_t *)page_address(page) + pgd_index(address); 120 pgd = (pgd_t *)page_address(page) + pgd_index(address);
@@ -130,13 +130,6 @@ void sync_global_pgds(unsigned long start, unsigned long end)
130 130
131 spin_unlock(pgt_lock); 131 spin_unlock(pgt_lock);
132 } 132 }
133
134 pgd = __va(real_mode_header->trampoline_pgd);
135 pgd += pgd_index(address);
136
137 if (pgd_none(*pgd))
138 set_pgd(pgd, *pgd_ref);
139
140 spin_unlock(&pgd_lock); 133 spin_unlock(&pgd_lock);
141 } 134 }
142} 135}
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index e190f7b56653..78fe3f1ac49f 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -50,107 +50,6 @@ int ioremap_change_attr(unsigned long vaddr, unsigned long size,
50 return err; 50 return err;
51} 51}
52 52
53#ifdef CONFIG_X86_64
54static void ident_pte_range(unsigned long paddr, unsigned long vaddr,
55 pmd_t *ppmd, pmd_t *vpmd, unsigned long end)
56{
57 pte_t *ppte = pte_offset_kernel(ppmd, paddr);
58 pte_t *vpte = pte_offset_kernel(vpmd, vaddr);
59
60 do {
61 set_pte(ppte, *vpte);
62 } while (ppte++, vpte++, vaddr += PAGE_SIZE, vaddr != end);
63}
64
65static int ident_pmd_range(unsigned long paddr, unsigned long vaddr,
66 pud_t *ppud, pud_t *vpud, unsigned long end)
67{
68 pmd_t *ppmd = pmd_offset(ppud, paddr);
69 pmd_t *vpmd = pmd_offset(vpud, vaddr);
70 unsigned long next;
71
72 do {
73 next = pmd_addr_end(vaddr, end);
74
75 if (!pmd_present(*ppmd)) {
76 pte_t *ppte = (pte_t *)get_zeroed_page(GFP_KERNEL);
77 if (!ppte)
78 return 1;
79
80 set_pmd(ppmd, __pmd(_KERNPG_TABLE | __pa(ppte)));
81 }
82
83 ident_pte_range(paddr, vaddr, ppmd, vpmd, next);
84 } while (ppmd++, vpmd++, vaddr = next, vaddr != end);
85
86 return 0;
87}
88
89static int ident_pud_range(unsigned long paddr, unsigned long vaddr,
90 pgd_t *ppgd, pgd_t *vpgd, unsigned long end)
91{
92 pud_t *ppud = pud_offset(ppgd, paddr);
93 pud_t *vpud = pud_offset(vpgd, vaddr);
94 unsigned long next;
95
96 do {
97 next = pud_addr_end(vaddr, end);
98
99 if (!pud_present(*ppud)) {
100 pmd_t *ppmd = (pmd_t *)get_zeroed_page(GFP_KERNEL);
101 if (!ppmd)
102 return 1;
103
104 set_pud(ppud, __pud(_KERNPG_TABLE | __pa(ppmd)));
105 }
106
107 if (ident_pmd_range(paddr, vaddr, ppud, vpud, next))
108 return 1;
109 } while (ppud++, vpud++, vaddr = next, vaddr != end);
110
111 return 0;
112}
113
114static int insert_identity_mapping(resource_size_t paddr, unsigned long vaddr,
115 unsigned long size)
116{
117 unsigned long end = vaddr + size;
118 unsigned long next;
119 pgd_t *vpgd, *ppgd;
120
121 /* Don't map over the guard hole. */
122 if (paddr >= 0x800000000000 || paddr + size > 0x800000000000)
123 return 1;
124
125 ppgd = __va(real_mode_header->trampoline_pgd) + pgd_index(paddr);
126
127 vpgd = pgd_offset_k(vaddr);
128 do {
129 next = pgd_addr_end(vaddr, end);
130
131 if (!pgd_present(*ppgd)) {
132 pud_t *ppud = (pud_t *)get_zeroed_page(GFP_KERNEL);
133 if (!ppud)
134 return 1;
135
136 set_pgd(ppgd, __pgd(_KERNPG_TABLE | __pa(ppud)));
137 }
138
139 if (ident_pud_range(paddr, vaddr, ppgd, vpgd, next))
140 return 1;
141 } while (ppgd++, vpgd++, vaddr = next, vaddr != end);
142
143 return 0;
144}
145#else
146static inline int insert_identity_mapping(resource_size_t paddr,
147 unsigned long vaddr,
148 unsigned long size)
149{
150 return 0;
151}
152#endif /* CONFIG_X86_64 */
153
154/* 53/*
155 * Remap an arbitrary physical address space into the kernel virtual 54 * Remap an arbitrary physical address space into the kernel virtual
156 * address space. Needed when the kernel wants to access high addresses 55 * address space. Needed when the kernel wants to access high addresses
@@ -264,10 +163,6 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
264 ret_addr = (void __iomem *) (vaddr + offset); 163 ret_addr = (void __iomem *) (vaddr + offset);
265 mmiotrace_ioremap(unaligned_phys_addr, unaligned_size, ret_addr); 164 mmiotrace_ioremap(unaligned_phys_addr, unaligned_size, ret_addr);
266 165
267 if (insert_identity_mapping(phys_addr, vaddr, size))
268 printk(KERN_WARNING "ioremap: unable to map 0x%llx in identity pagetable\n",
269 (unsigned long long)phys_addr);
270
271 /* 166 /*
272 * Check if the request spans more than any BAR in the iomem resource 167 * Check if the request spans more than any BAR in the iomem resource
273 * tree. 168 * tree.
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 931930a96160..a718e0d23503 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -919,13 +919,11 @@ static int change_page_attr_set_clr(unsigned long *addr, int numpages,
919 919
920 /* 920 /*
921 * On success we use clflush, when the CPU supports it to 921 * On success we use clflush, when the CPU supports it to
922 * avoid the wbindv. If the CPU does not support it, in the 922 * avoid the wbindv. If the CPU does not support it and in the
923 * error case, and during early boot (for EFI) we fall back 923 * error case we fall back to cpa_flush_all (which uses
924 * to cpa_flush_all (which uses wbinvd): 924 * wbindv):
925 */ 925 */
926 if (early_boot_irqs_disabled) 926 if (!ret && cpu_has_clflush) {
927 __cpa_flush_all((void *)(long)cache);
928 else if (!ret && cpu_has_clflush) {
929 if (cpa.flags & (CPA_PAGES_ARRAY | CPA_ARRAY)) { 927 if (cpa.flags & (CPA_PAGES_ARRAY | CPA_ARRAY)) {
930 cpa_flush_array(addr, numpages, cache, 928 cpa_flush_array(addr, numpages, cache,
931 cpa.flags, pages); 929 cpa.flags, pages);
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index 217eb705fac0..e27fbf887f3b 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -301,6 +301,13 @@ void pgd_free(struct mm_struct *mm, pgd_t *pgd)
301 free_page((unsigned long)pgd); 301 free_page((unsigned long)pgd);
302} 302}
303 303
304/*
305 * Used to set accessed or dirty bits in the page table entries
306 * on other architectures. On x86, the accessed and dirty bits
307 * are tracked by hardware. However, do_wp_page calls this function
308 * to also make the pte writeable at the same time the dirty bit is
309 * set. In that case we do actually need to write the PTE.
310 */
304int ptep_set_access_flags(struct vm_area_struct *vma, 311int ptep_set_access_flags(struct vm_area_struct *vma,
305 unsigned long address, pte_t *ptep, 312 unsigned long address, pte_t *ptep,
306 pte_t entry, int dirty) 313 pte_t entry, int dirty)
@@ -310,7 +317,6 @@ int ptep_set_access_flags(struct vm_area_struct *vma,
310 if (changed && dirty) { 317 if (changed && dirty) {
311 *ptep = entry; 318 *ptep = entry;
312 pte_update_defer(vma->vm_mm, address, ptep); 319 pte_update_defer(vma->vm_mm, address, ptep);
313 flush_tlb_page(vma, address);
314 } 320 }
315 321
316 return changed; 322 return changed;
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 0a34d9e9c263..ad4439145f85 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -239,7 +239,22 @@ static efi_status_t __init phys_efi_set_virtual_address_map(
239 return status; 239 return status;
240} 240}
241 241
242static int efi_set_rtc_mmss(unsigned long nowtime) 242static efi_status_t __init phys_efi_get_time(efi_time_t *tm,
243 efi_time_cap_t *tc)
244{
245 unsigned long flags;
246 efi_status_t status;
247
248 spin_lock_irqsave(&rtc_lock, flags);
249 efi_call_phys_prelog();
250 status = efi_call_phys2(efi_phys.get_time, virt_to_phys(tm),
251 virt_to_phys(tc));
252 efi_call_phys_epilog();
253 spin_unlock_irqrestore(&rtc_lock, flags);
254 return status;
255}
256
257int efi_set_rtc_mmss(unsigned long nowtime)
243{ 258{
244 int real_seconds, real_minutes; 259 int real_seconds, real_minutes;
245 efi_status_t status; 260 efi_status_t status;
@@ -268,7 +283,7 @@ static int efi_set_rtc_mmss(unsigned long nowtime)
268 return 0; 283 return 0;
269} 284}
270 285
271static unsigned long efi_get_time(void) 286unsigned long efi_get_time(void)
272{ 287{
273 efi_status_t status; 288 efi_status_t status;
274 efi_time_t eft; 289 efi_time_t eft;
@@ -624,13 +639,18 @@ static int __init efi_runtime_init(void)
624 } 639 }
625 /* 640 /*
626 * We will only need *early* access to the following 641 * We will only need *early* access to the following
627 * EFI runtime service before set_virtual_address_map 642 * two EFI runtime services before set_virtual_address_map
628 * is invoked. 643 * is invoked.
629 */ 644 */
645 efi_phys.get_time = (efi_get_time_t *)runtime->get_time;
630 efi_phys.set_virtual_address_map = 646 efi_phys.set_virtual_address_map =
631 (efi_set_virtual_address_map_t *) 647 (efi_set_virtual_address_map_t *)
632 runtime->set_virtual_address_map; 648 runtime->set_virtual_address_map;
633 649 /*
650 * Make efi_get_time can be called before entering
651 * virtual mode.
652 */
653 efi.get_time = phys_efi_get_time;
634 early_iounmap(runtime, sizeof(efi_runtime_services_t)); 654 early_iounmap(runtime, sizeof(efi_runtime_services_t));
635 655
636 return 0; 656 return 0;
@@ -716,10 +736,12 @@ void __init efi_init(void)
716 efi_enabled = 0; 736 efi_enabled = 0;
717 return; 737 return;
718 } 738 }
739#ifdef CONFIG_X86_32
719 if (efi_is_native()) { 740 if (efi_is_native()) {
720 x86_platform.get_wallclock = efi_get_time; 741 x86_platform.get_wallclock = efi_get_time;
721 x86_platform.set_wallclock = efi_set_rtc_mmss; 742 x86_platform.set_wallclock = efi_set_rtc_mmss;
722 } 743 }
744#endif
723 745
724#if EFI_DEBUG 746#if EFI_DEBUG
725 print_efi_memmap(); 747 print_efi_memmap();
diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index 06c8b2e662ab..95fd505dfeb6 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -58,21 +58,6 @@ static void __init early_code_mapping_set_exec(int executable)
58 } 58 }
59} 59}
60 60
61unsigned long efi_call_virt_prelog(void)
62{
63 unsigned long saved;
64
65 saved = read_cr3();
66 write_cr3(real_mode_header->trampoline_pgd);
67
68 return saved;
69}
70
71void efi_call_virt_epilog(unsigned long saved)
72{
73 write_cr3(saved);
74}
75
76void __init efi_call_phys_prelog(void) 61void __init efi_call_phys_prelog(void)
77{ 62{
78 unsigned long vaddress; 63 unsigned long vaddress;
diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
index 8e6ab6137852..cbca565af5bd 100644
--- a/arch/x86/realmode/init.c
+++ b/arch/x86/realmode/init.c
@@ -78,21 +78,8 @@ void __init setup_real_mode(void)
78 *trampoline_cr4_features = read_cr4(); 78 *trampoline_cr4_features = read_cr4();
79 79
80 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd); 80 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
81 81 trampoline_pgd[0] = __pa(level3_ident_pgt) + _KERNPG_TABLE;
82 /* 82 trampoline_pgd[511] = __pa(level3_kernel_pgt) + _KERNPG_TABLE;
83 * Create an identity mapping for all of physical memory.
84 */
85 for (i = 0; i <= pgd_index(max_pfn << PAGE_SHIFT); i++) {
86 int index = pgd_index(PAGE_OFFSET) + i;
87
88 trampoline_pgd[i] = (u64)pgd_val(swapper_pg_dir[index]);
89 }
90
91 /*
92 * Copy the upper-half of the kernel pages tables.
93 */
94 for (i = pgd_index(PAGE_OFFSET); i < PTRS_PER_PGD; i++)
95 trampoline_pgd[i] = (u64)pgd_val(swapper_pg_dir[i]);
96#endif 83#endif
97} 84}
98 85