aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64
diff options
context:
space:
mode:
authorMichal Marek <mmarek@suse.cz>2010-08-04 07:59:13 -0400
committerMichal Marek <mmarek@suse.cz>2010-08-04 07:59:13 -0400
commit772320e84588dcbe1600ffb83e5f328f2209ac2a (patch)
treea7de21b79340aeaa17c58126f6b801b82c77b53a /arch/ia64
parent1ce53adf13a54375d2a5c7cdbe341b2558389615 (diff)
parent9fe6206f400646a2322096b56c59891d530e8d51 (diff)
Merge commit 'v2.6.35' into kbuild/kbuild
Conflicts: arch/powerpc/Makefile
Diffstat (limited to 'arch/ia64')
-rw-r--r--arch/ia64/Kconfig34
-rw-r--r--arch/ia64/Makefile1
-rw-r--r--arch/ia64/configs/bigsur_defconfig2
-rw-r--r--arch/ia64/configs/generic_defconfig2
-rw-r--r--arch/ia64/configs/gensparse_defconfig2
-rw-r--r--arch/ia64/configs/sim_defconfig2
-rw-r--r--arch/ia64/configs/tiger_defconfig1
-rw-r--r--arch/ia64/configs/xen_domu_defconfig2
-rw-r--r--arch/ia64/configs/zx1_defconfig2
-rw-r--r--arch/ia64/hp/common/aml_nfw.c6
-rw-r--r--arch/ia64/hp/common/sba_iommu.c8
-rw-r--r--arch/ia64/ia32/Makefile11
-rw-r--r--arch/ia64/ia32/audit.c42
-rw-r--r--arch/ia64/ia32/binfmt_elf32.c245
-rw-r--r--arch/ia64/ia32/elfcore32.h148
-rw-r--r--arch/ia64/ia32/ia32_entry.S468
-rw-r--r--arch/ia64/ia32/ia32_ldt.c146
-rw-r--r--arch/ia64/ia32/ia32_signal.c1010
-rw-r--r--arch/ia64/ia32/ia32_support.c253
-rw-r--r--arch/ia64/ia32/ia32_traps.c156
-rw-r--r--arch/ia64/ia32/ia32priv.h532
-rw-r--r--arch/ia64/ia32/sys_ia32.c2765
-rw-r--r--arch/ia64/include/asm/acpi.h26
-rw-r--r--arch/ia64/include/asm/atomic.h4
-rw-r--r--arch/ia64/include/asm/bitops.h11
-rw-r--r--arch/ia64/include/asm/compat.h3
-rw-r--r--arch/ia64/include/asm/dmi.h1
-rw-r--r--arch/ia64/include/asm/elf.h52
-rw-r--r--arch/ia64/include/asm/ia32.h40
-rw-r--r--arch/ia64/include/asm/mmzone.h4
-rw-r--r--arch/ia64/include/asm/pci.h14
-rw-r--r--arch/ia64/include/asm/percpu.h7
-rw-r--r--arch/ia64/include/asm/pgtable.h2
-rw-r--r--arch/ia64/include/asm/processor.h46
-rw-r--r--arch/ia64/include/asm/ptrace.h4
-rw-r--r--arch/ia64/include/asm/scatterlist.h26
-rw-r--r--arch/ia64/include/asm/syscall.h81
-rw-r--r--arch/ia64/include/asm/system.h11
-rw-r--r--arch/ia64/include/asm/thread_info.h2
-rw-r--r--arch/ia64/include/asm/topology.h5
-rw-r--r--arch/ia64/include/asm/unistd.h14
-rw-r--r--arch/ia64/include/asm/xen/events.h4
-rw-r--r--arch/ia64/kernel/Makefile8
-rw-r--r--arch/ia64/kernel/acpi-ext.c1
-rw-r--r--arch/ia64/kernel/acpi.c49
-rw-r--r--arch/ia64/kernel/audit.c21
-rw-r--r--arch/ia64/kernel/cpufreq/acpi-cpufreq.c11
-rw-r--r--arch/ia64/kernel/efi.c1
-rw-r--r--arch/ia64/kernel/elfcore.c80
-rw-r--r--arch/ia64/kernel/entry.S39
-rw-r--r--arch/ia64/kernel/ia64_ksyms.c4
-rw-r--r--arch/ia64/kernel/iosapic.c1
-rw-r--r--arch/ia64/kernel/irq_ia64.c10
-rw-r--r--arch/ia64/kernel/ivt.S114
-rw-r--r--arch/ia64/kernel/kprobes.c2
-rw-r--r--arch/ia64/kernel/mca.c1
-rw-r--r--arch/ia64/kernel/mca_drv.c1
-rw-r--r--arch/ia64/kernel/pci-swiotlb.c3
-rw-r--r--arch/ia64/kernel/perfmon.c6
-rw-r--r--arch/ia64/kernel/process.c61
-rw-r--r--arch/ia64/kernel/ptrace.c19
-rw-r--r--arch/ia64/kernel/salinfo.c5
-rw-r--r--arch/ia64/kernel/setup.c5
-rw-r--r--arch/ia64/kernel/signal.c54
-rw-r--r--arch/ia64/kernel/smpboot.c16
-rw-r--r--arch/ia64/kernel/time.c14
-rw-r--r--arch/ia64/kernel/topology.c7
-rw-r--r--arch/ia64/kernel/traps.c9
-rw-r--r--arch/ia64/kernel/unaligned.c24
-rw-r--r--arch/ia64/kernel/uncached.c2
-rw-r--r--arch/ia64/kvm/Kconfig2
-rw-r--r--arch/ia64/kvm/kvm-ia64.c68
-rw-r--r--arch/ia64/kvm/kvm_fw.c28
-rw-r--r--arch/ia64/kvm/mmio.c4
-rw-r--r--arch/ia64/kvm/vcpu.c4
-rw-r--r--arch/ia64/kvm/vmm.c2
-rw-r--r--arch/ia64/mm/discontig.c3
-rw-r--r--arch/ia64/mm/fault.c13
-rw-r--r--arch/ia64/mm/hugetlbpage.c1
-rw-r--r--arch/ia64/mm/init.c7
-rw-r--r--arch/ia64/mm/tlb.c3
-rw-r--r--arch/ia64/pci/pci.c27
-rw-r--r--arch/ia64/sn/kernel/bte.c1
-rw-r--r--arch/ia64/sn/kernel/io_acpi_init.c1
-rw-r--r--arch/ia64/sn/kernel/io_common.c1
-rw-r--r--arch/ia64/sn/kernel/io_init.c1
-rw-r--r--arch/ia64/sn/kernel/irq.c1
-rw-r--r--arch/ia64/sn/kernel/msi_sn.c1
-rw-r--r--arch/ia64/sn/kernel/setup.c4
-rw-r--r--arch/ia64/sn/kernel/sn2/sn_hwperf.c13
-rw-r--r--arch/ia64/sn/pci/pci_dma.c1
-rw-r--r--arch/ia64/sn/pci/pcibr/pcibr_provider.c1
-rw-r--r--arch/ia64/sn/pci/tioca_provider.c1
-rw-r--r--arch/ia64/sn/pci/tioce_provider.c1
-rw-r--r--arch/ia64/uv/kernel/setup.c2
-rw-r--r--arch/ia64/xen/grant-table.c1
-rw-r--r--arch/ia64/xen/hypercall.S5
-rw-r--r--arch/ia64/xen/xen_pv_ops.c16
98 files changed, 348 insertions, 6628 deletions
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 2d7f56a98e0f..95610820041e 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -53,10 +53,13 @@ config MMU
53 bool 53 bool
54 default y 54 default y
55 55
56config SWIOTLB 56config NEED_DMA_MAP_STATE
57 bool 57 def_bool y
58 58
59config IOMMU_HELPER 59config NEED_SG_DMA_LENGTH
60 def_bool y
61
62config SWIOTLB
60 bool 63 bool
61 64
62config GENERIC_LOCKBREAK 65config GENERIC_LOCKBREAK
@@ -495,26 +498,17 @@ config HAVE_ARCH_NODEDATA_EXTENSION
495 def_bool y 498 def_bool y
496 depends on NUMA 499 depends on NUMA
497 500
498config ARCH_PROC_KCORE_TEXT 501config USE_PERCPU_NUMA_NODE_ID
499 def_bool y 502 def_bool y
500 depends on PROC_KCORE 503 depends on NUMA
501
502config IA32_SUPPORT
503 bool "Support for Linux/x86 binaries"
504 help
505 IA-64 processors can execute IA-32 (X86) instructions. By
506 saying Y here, the kernel will include IA-32 system call
507 emulation support which makes it possible to transparently
508 run IA-32 Linux binaries on an IA-64 Linux system.
509 If in doubt, say Y.
510 504
511config COMPAT 505config HAVE_MEMORYLESS_NODES
512 bool 506 def_bool y
513 depends on IA32_SUPPORT 507 depends on NUMA
514 default y
515 508
516config COMPAT_FOR_U64_ALIGNMENT 509config ARCH_PROC_KCORE_TEXT
517 def_bool COMPAT 510 def_bool y
511 depends on PROC_KCORE
518 512
519config IA64_MCA_RECOVERY 513config IA64_MCA_RECOVERY
520 tristate "MCA recovery from errors other than TLB." 514 tristate "MCA recovery from errors other than TLB."
diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
index 62b10f5f2540..be7bfa12b705 100644
--- a/arch/ia64/Makefile
+++ b/arch/ia64/Makefile
@@ -46,7 +46,6 @@ head-y := arch/ia64/kernel/head.o arch/ia64/kernel/init_task.o
46 46
47libs-y += arch/ia64/lib/ 47libs-y += arch/ia64/lib/
48core-y += arch/ia64/kernel/ arch/ia64/mm/ 48core-y += arch/ia64/kernel/ arch/ia64/mm/
49core-$(CONFIG_IA32_SUPPORT) += arch/ia64/ia32/
50core-$(CONFIG_IA64_DIG) += arch/ia64/dig/ 49core-$(CONFIG_IA64_DIG) += arch/ia64/dig/
51core-$(CONFIG_IA64_DIG_VTD) += arch/ia64/dig/ 50core-$(CONFIG_IA64_DIG_VTD) += arch/ia64/dig/
52core-$(CONFIG_IA64_GENERIC) += arch/ia64/dig/ 51core-$(CONFIG_IA64_GENERIC) += arch/ia64/dig/
diff --git a/arch/ia64/configs/bigsur_defconfig b/arch/ia64/configs/bigsur_defconfig
index ace41096b47b..312b12094a1d 100644
--- a/arch/ia64/configs/bigsur_defconfig
+++ b/arch/ia64/configs/bigsur_defconfig
@@ -131,8 +131,6 @@ CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
131CONFIG_ARCH_FLATMEM_ENABLE=y 131CONFIG_ARCH_FLATMEM_ENABLE=y
132CONFIG_ARCH_SPARSEMEM_ENABLE=y 132CONFIG_ARCH_SPARSEMEM_ENABLE=y
133# CONFIG_VIRTUAL_MEM_MAP is not set 133# CONFIG_VIRTUAL_MEM_MAP is not set
134CONFIG_IA32_SUPPORT=y
135CONFIG_COMPAT=y
136# CONFIG_IA64_MCA_RECOVERY is not set 134# CONFIG_IA64_MCA_RECOVERY is not set
137CONFIG_PERFMON=y 135CONFIG_PERFMON=y
138CONFIG_IA64_PALINFO=y 136CONFIG_IA64_PALINFO=y
diff --git a/arch/ia64/configs/generic_defconfig b/arch/ia64/configs/generic_defconfig
index 75645495c2dd..6a4cc506fb5f 100644
--- a/arch/ia64/configs/generic_defconfig
+++ b/arch/ia64/configs/generic_defconfig
@@ -205,8 +205,6 @@ CONFIG_VIRTUAL_MEM_MAP=y
205CONFIG_HOLES_IN_ZONE=y 205CONFIG_HOLES_IN_ZONE=y
206CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y 206CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
207CONFIG_HAVE_ARCH_NODEDATA_EXTENSION=y 207CONFIG_HAVE_ARCH_NODEDATA_EXTENSION=y
208CONFIG_IA32_SUPPORT=y
209CONFIG_COMPAT=y
210CONFIG_COMPAT_FOR_U64_ALIGNMENT=y 208CONFIG_COMPAT_FOR_U64_ALIGNMENT=y
211CONFIG_IA64_MCA_RECOVERY=y 209CONFIG_IA64_MCA_RECOVERY=y
212CONFIG_PERFMON=y 210CONFIG_PERFMON=y
diff --git a/arch/ia64/configs/gensparse_defconfig b/arch/ia64/configs/gensparse_defconfig
index e86fbd39c795..2dc185b0f9a3 100644
--- a/arch/ia64/configs/gensparse_defconfig
+++ b/arch/ia64/configs/gensparse_defconfig
@@ -139,8 +139,6 @@ CONFIG_ARCH_SPARSEMEM_ENABLE=y
139CONFIG_ARCH_DISCONTIGMEM_DEFAULT=y 139CONFIG_ARCH_DISCONTIGMEM_DEFAULT=y
140CONFIG_NUMA=y 140CONFIG_NUMA=y
141CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y 141CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
142CONFIG_IA32_SUPPORT=y
143CONFIG_COMPAT=y
144CONFIG_IA64_MCA_RECOVERY=y 142CONFIG_IA64_MCA_RECOVERY=y
145CONFIG_PERFMON=y 143CONFIG_PERFMON=y
146CONFIG_IA64_PALINFO=y 144CONFIG_IA64_PALINFO=y
diff --git a/arch/ia64/configs/sim_defconfig b/arch/ia64/configs/sim_defconfig
index 546a772f438e..21a23cdfd41c 100644
--- a/arch/ia64/configs/sim_defconfig
+++ b/arch/ia64/configs/sim_defconfig
@@ -130,8 +130,6 @@ CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
130CONFIG_ARCH_FLATMEM_ENABLE=y 130CONFIG_ARCH_FLATMEM_ENABLE=y
131CONFIG_ARCH_SPARSEMEM_ENABLE=y 131CONFIG_ARCH_SPARSEMEM_ENABLE=y
132# CONFIG_VIRTUAL_MEM_MAP is not set 132# CONFIG_VIRTUAL_MEM_MAP is not set
133CONFIG_IA32_SUPPORT=y
134CONFIG_COMPAT=y
135# CONFIG_IA64_MCA_RECOVERY is not set 133# CONFIG_IA64_MCA_RECOVERY is not set
136# CONFIG_PERFMON is not set 134# CONFIG_PERFMON is not set
137CONFIG_IA64_PALINFO=m 135CONFIG_IA64_PALINFO=m
diff --git a/arch/ia64/configs/tiger_defconfig b/arch/ia64/configs/tiger_defconfig
index c522edf23c62..c5a5ea9d54ae 100644
--- a/arch/ia64/configs/tiger_defconfig
+++ b/arch/ia64/configs/tiger_defconfig
@@ -154,7 +154,6 @@ CONFIG_ARCH_SPARSEMEM_ENABLE=y
154CONFIG_ARCH_POPULATES_NODE_MAP=y 154CONFIG_ARCH_POPULATES_NODE_MAP=y
155CONFIG_VIRTUAL_MEM_MAP=y 155CONFIG_VIRTUAL_MEM_MAP=y
156CONFIG_HOLES_IN_ZONE=y 156CONFIG_HOLES_IN_ZONE=y
157# CONFIG_IA32_SUPPORT is not set
158CONFIG_IA64_MCA_RECOVERY=y 157CONFIG_IA64_MCA_RECOVERY=y
159CONFIG_PERFMON=y 158CONFIG_PERFMON=y
160CONFIG_IA64_PALINFO=y 159CONFIG_IA64_PALINFO=y
diff --git a/arch/ia64/configs/xen_domu_defconfig b/arch/ia64/configs/xen_domu_defconfig
index 0bb0714dc19d..c67eafc4bb38 100644
--- a/arch/ia64/configs/xen_domu_defconfig
+++ b/arch/ia64/configs/xen_domu_defconfig
@@ -200,8 +200,6 @@ CONFIG_ARCH_SPARSEMEM_ENABLE=y
200CONFIG_ARCH_POPULATES_NODE_MAP=y 200CONFIG_ARCH_POPULATES_NODE_MAP=y
201CONFIG_VIRTUAL_MEM_MAP=y 201CONFIG_VIRTUAL_MEM_MAP=y
202CONFIG_HOLES_IN_ZONE=y 202CONFIG_HOLES_IN_ZONE=y
203# CONFIG_IA32_SUPPORT is not set
204# CONFIG_COMPAT_FOR_U64_ALIGNMENT is not set
205CONFIG_IA64_MCA_RECOVERY=y 203CONFIG_IA64_MCA_RECOVERY=y
206CONFIG_PERFMON=y 204CONFIG_PERFMON=y
207CONFIG_IA64_PALINFO=y 205CONFIG_IA64_PALINFO=y
diff --git a/arch/ia64/configs/zx1_defconfig b/arch/ia64/configs/zx1_defconfig
index 514f0635dafe..3cec65b534c2 100644
--- a/arch/ia64/configs/zx1_defconfig
+++ b/arch/ia64/configs/zx1_defconfig
@@ -150,8 +150,6 @@ CONFIG_ARCH_DISCONTIGMEM_DEFAULT=y
150CONFIG_ARCH_POPULATES_NODE_MAP=y 150CONFIG_ARCH_POPULATES_NODE_MAP=y
151CONFIG_VIRTUAL_MEM_MAP=y 151CONFIG_VIRTUAL_MEM_MAP=y
152CONFIG_HOLES_IN_ZONE=y 152CONFIG_HOLES_IN_ZONE=y
153CONFIG_IA32_SUPPORT=y
154CONFIG_COMPAT=y
155CONFIG_IA64_MCA_RECOVERY=y 153CONFIG_IA64_MCA_RECOVERY=y
156CONFIG_PERFMON=y 154CONFIG_PERFMON=y
157CONFIG_IA64_PALINFO=y 155CONFIG_IA64_PALINFO=y
diff --git a/arch/ia64/hp/common/aml_nfw.c b/arch/ia64/hp/common/aml_nfw.c
index 4abd2c79bb1d..22078486d35d 100644
--- a/arch/ia64/hp/common/aml_nfw.c
+++ b/arch/ia64/hp/common/aml_nfw.c
@@ -77,7 +77,7 @@ static void aml_nfw_execute(struct ia64_nfw_context *c)
77 c->arg[4], c->arg[5], c->arg[6], c->arg[7]); 77 c->arg[4], c->arg[5], c->arg[6], c->arg[7]);
78} 78}
79 79
80static void aml_nfw_read_arg(u8 *offset, u32 bit_width, acpi_integer *value) 80static void aml_nfw_read_arg(u8 *offset, u32 bit_width, u64 *value)
81{ 81{
82 switch (bit_width) { 82 switch (bit_width) {
83 case 8: 83 case 8:
@@ -95,7 +95,7 @@ static void aml_nfw_read_arg(u8 *offset, u32 bit_width, acpi_integer *value)
95 } 95 }
96} 96}
97 97
98static void aml_nfw_write_arg(u8 *offset, u32 bit_width, acpi_integer *value) 98static void aml_nfw_write_arg(u8 *offset, u32 bit_width, u64 *value)
99{ 99{
100 switch (bit_width) { 100 switch (bit_width) {
101 case 8: 101 case 8:
@@ -114,7 +114,7 @@ static void aml_nfw_write_arg(u8 *offset, u32 bit_width, acpi_integer *value)
114} 114}
115 115
116static acpi_status aml_nfw_handler(u32 function, acpi_physical_address address, 116static acpi_status aml_nfw_handler(u32 function, acpi_physical_address address,
117 u32 bit_width, acpi_integer *value, void *handler_context, 117 u32 bit_width, u64 *value, void *handler_context,
118 void *region_context) 118 void *region_context)
119{ 119{
120 struct ia64_nfw_context *context = handler_context; 120 struct ia64_nfw_context *context = handler_context;
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index e14c492a8a93..4ce8d1358fee 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -2046,13 +2046,13 @@ acpi_sba_ioc_add(struct acpi_device *device)
2046 struct ioc *ioc; 2046 struct ioc *ioc;
2047 acpi_status status; 2047 acpi_status status;
2048 u64 hpa, length; 2048 u64 hpa, length;
2049 struct acpi_device_info *dev_info; 2049 struct acpi_device_info *adi;
2050 2050
2051 status = hp_acpi_csr_space(device->handle, &hpa, &length); 2051 status = hp_acpi_csr_space(device->handle, &hpa, &length);
2052 if (ACPI_FAILURE(status)) 2052 if (ACPI_FAILURE(status))
2053 return 1; 2053 return 1;
2054 2054
2055 status = acpi_get_object_info(device->handle, &dev_info); 2055 status = acpi_get_object_info(device->handle, &adi);
2056 if (ACPI_FAILURE(status)) 2056 if (ACPI_FAILURE(status))
2057 return 1; 2057 return 1;
2058 2058
@@ -2060,13 +2060,13 @@ acpi_sba_ioc_add(struct acpi_device *device)
2060 * For HWP0001, only SBA appears in ACPI namespace. It encloses the PCI 2060 * For HWP0001, only SBA appears in ACPI namespace. It encloses the PCI
2061 * root bridges, and its CSR space includes the IOC function. 2061 * root bridges, and its CSR space includes the IOC function.
2062 */ 2062 */
2063 if (strncmp("HWP0001", dev_info->hardware_id.string, 7) == 0) { 2063 if (strncmp("HWP0001", adi->hardware_id.string, 7) == 0) {
2064 hpa += ZX1_IOC_OFFSET; 2064 hpa += ZX1_IOC_OFFSET;
2065 /* zx1 based systems default to kernel page size iommu pages */ 2065 /* zx1 based systems default to kernel page size iommu pages */
2066 if (!iovp_shift) 2066 if (!iovp_shift)
2067 iovp_shift = min(PAGE_SHIFT, 16); 2067 iovp_shift = min(PAGE_SHIFT, 16);
2068 } 2068 }
2069 kfree(dev_info); 2069 kfree(adi);
2070 2070
2071 /* 2071 /*
2072 * default anything not caught above or specified on cmdline to 4k 2072 * default anything not caught above or specified on cmdline to 4k
diff --git a/arch/ia64/ia32/Makefile b/arch/ia64/ia32/Makefile
deleted file mode 100644
index baad8c7699c0..000000000000
--- a/arch/ia64/ia32/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
1#
2# Makefile for the ia32 kernel emulation subsystem.
3#
4
5obj-y := ia32_entry.o sys_ia32.o ia32_signal.o \
6 ia32_support.o ia32_traps.o binfmt_elf32.o ia32_ldt.o
7obj-$(CONFIG_AUDIT) += audit.o
8
9# Don't let GCC uses f16-f31 so that save_ia32_fpstate_live() and
10# restore_ia32_fpstate_live() can be sure the live register contain user-level state.
11CFLAGS_ia32_signal.o += -mfixed-range=f16-f31
diff --git a/arch/ia64/ia32/audit.c b/arch/ia64/ia32/audit.c
deleted file mode 100644
index 5c93ddd1e42d..000000000000
--- a/arch/ia64/ia32/audit.c
+++ /dev/null
@@ -1,42 +0,0 @@
1#include "../../x86/include/asm/unistd_32.h"
2
3unsigned ia32_dir_class[] = {
4#include <asm-generic/audit_dir_write.h>
5~0U
6};
7
8unsigned ia32_chattr_class[] = {
9#include <asm-generic/audit_change_attr.h>
10~0U
11};
12
13unsigned ia32_write_class[] = {
14#include <asm-generic/audit_write.h>
15~0U
16};
17
18unsigned ia32_read_class[] = {
19#include <asm-generic/audit_read.h>
20~0U
21};
22
23unsigned ia32_signal_class[] = {
24#include <asm-generic/audit_signal.h>
25~0U
26};
27
28int ia32_classify_syscall(unsigned syscall)
29{
30 switch(syscall) {
31 case __NR_open:
32 return 2;
33 case __NR_openat:
34 return 3;
35 case __NR_socketcall:
36 return 4;
37 case __NR_execve:
38 return 5;
39 default:
40 return 1;
41 }
42}
diff --git a/arch/ia64/ia32/binfmt_elf32.c b/arch/ia64/ia32/binfmt_elf32.c
deleted file mode 100644
index c69552bf893e..000000000000
--- a/arch/ia64/ia32/binfmt_elf32.c
+++ /dev/null
@@ -1,245 +0,0 @@
1/*
2 * IA-32 ELF support.
3 *
4 * Copyright (C) 1999 Arun Sharma <arun.sharma@intel.com>
5 * Copyright (C) 2001 Hewlett-Packard Co
6 * David Mosberger-Tang <davidm@hpl.hp.com>
7 *
8 * 06/16/00 A. Mallick initialize csd/ssd/tssd/cflg for ia32_load_state
9 * 04/13/01 D. Mosberger dropped saving tssd in ar.k1---it's not needed
10 * 09/14/01 D. Mosberger fixed memory management for gdt/tss page
11 */
12
13#include <linux/types.h>
14#include <linux/mm.h>
15#include <linux/security.h>
16
17#include <asm/param.h>
18#include <asm/signal.h>
19
20#include "ia32priv.h"
21#include "elfcore32.h"
22
23/* Override some function names */
24#undef start_thread
25#define start_thread ia32_start_thread
26#define elf_format elf32_format
27#define init_elf_binfmt init_elf32_binfmt
28#define exit_elf_binfmt exit_elf32_binfmt
29
30#undef CLOCKS_PER_SEC
31#define CLOCKS_PER_SEC IA32_CLOCKS_PER_SEC
32
33extern void ia64_elf32_init (struct pt_regs *regs);
34
35static void elf32_set_personality (void);
36
37static unsigned long __attribute ((unused))
38randomize_stack_top(unsigned long stack_top);
39
40#define setup_arg_pages(bprm,tos,exec) ia32_setup_arg_pages(bprm,exec)
41#define elf_map elf32_map
42
43#undef SET_PERSONALITY
44#define SET_PERSONALITY(ex) elf32_set_personality()
45
46#define elf_read_implies_exec(ex, have_pt_gnu_stack) (!(have_pt_gnu_stack))
47
48/* Ugly but avoids duplication */
49#include "../../../fs/binfmt_elf.c"
50
51extern struct page *ia32_shared_page[];
52extern unsigned long *ia32_gdt;
53extern struct page *ia32_gate_page;
54
55int
56ia32_install_shared_page (struct vm_area_struct *vma, struct vm_fault *vmf)
57{
58 vmf->page = ia32_shared_page[smp_processor_id()];
59 get_page(vmf->page);
60 return 0;
61}
62
63int
64ia32_install_gate_page (struct vm_area_struct *vma, struct vm_fault *vmf)
65{
66 vmf->page = ia32_gate_page;
67 get_page(vmf->page);
68 return 0;
69}
70
71
72static const struct vm_operations_struct ia32_shared_page_vm_ops = {
73 .fault = ia32_install_shared_page
74};
75
76static const struct vm_operations_struct ia32_gate_page_vm_ops = {
77 .fault = ia32_install_gate_page
78};
79
80void
81ia64_elf32_init (struct pt_regs *regs)
82{
83 struct vm_area_struct *vma;
84
85 /*
86 * Map GDT below 4GB, where the processor can find it. We need to map
87 * it with privilege level 3 because the IVE uses non-privileged accesses to these
88 * tables. IA-32 segmentation is used to protect against IA-32 accesses to them.
89 */
90 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
91 if (vma) {
92 vma->vm_mm = current->mm;
93 vma->vm_start = IA32_GDT_OFFSET;
94 vma->vm_end = vma->vm_start + PAGE_SIZE;
95 vma->vm_page_prot = PAGE_SHARED;
96 vma->vm_flags = VM_READ|VM_MAYREAD|VM_RESERVED;
97 vma->vm_ops = &ia32_shared_page_vm_ops;
98 down_write(&current->mm->mmap_sem);
99 {
100 if (insert_vm_struct(current->mm, vma)) {
101 kmem_cache_free(vm_area_cachep, vma);
102 up_write(&current->mm->mmap_sem);
103 BUG();
104 }
105 }
106 up_write(&current->mm->mmap_sem);
107 }
108
109 /*
110 * When user stack is not executable, push sigreturn code to stack makes
111 * segmentation fault raised when returning to kernel. So now sigreturn
112 * code is locked in specific gate page, which is pointed by pretcode
113 * when setup_frame_ia32
114 */
115 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
116 if (vma) {
117 vma->vm_mm = current->mm;
118 vma->vm_start = IA32_GATE_OFFSET;
119 vma->vm_end = vma->vm_start + PAGE_SIZE;
120 vma->vm_page_prot = PAGE_COPY_EXEC;
121 vma->vm_flags = VM_READ | VM_MAYREAD | VM_EXEC
122 | VM_MAYEXEC | VM_RESERVED;
123 vma->vm_ops = &ia32_gate_page_vm_ops;
124 down_write(&current->mm->mmap_sem);
125 {
126 if (insert_vm_struct(current->mm, vma)) {
127 kmem_cache_free(vm_area_cachep, vma);
128 up_write(&current->mm->mmap_sem);
129 BUG();
130 }
131 }
132 up_write(&current->mm->mmap_sem);
133 }
134
135 /*
136 * Install LDT as anonymous memory. This gives us all-zero segment descriptors
137 * until a task modifies them via modify_ldt().
138 */
139 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
140 if (vma) {
141 vma->vm_mm = current->mm;
142 vma->vm_start = IA32_LDT_OFFSET;
143 vma->vm_end = vma->vm_start + PAGE_ALIGN(IA32_LDT_ENTRIES*IA32_LDT_ENTRY_SIZE);
144 vma->vm_page_prot = PAGE_SHARED;
145 vma->vm_flags = VM_READ|VM_WRITE|VM_MAYREAD|VM_MAYWRITE;
146 down_write(&current->mm->mmap_sem);
147 {
148 if (insert_vm_struct(current->mm, vma)) {
149 kmem_cache_free(vm_area_cachep, vma);
150 up_write(&current->mm->mmap_sem);
151 BUG();
152 }
153 }
154 up_write(&current->mm->mmap_sem);
155 }
156
157 ia64_psr(regs)->ac = 0; /* turn off alignment checking */
158 regs->loadrs = 0;
159 /*
160 * According to the ABI %edx points to an `atexit' handler. Since we don't have
161 * one we'll set it to 0 and initialize all the other registers just to make
162 * things more deterministic, ala the i386 implementation.
163 */
164 regs->r8 = 0; /* %eax */
165 regs->r11 = 0; /* %ebx */
166 regs->r9 = 0; /* %ecx */
167 regs->r10 = 0; /* %edx */
168 regs->r13 = 0; /* %ebp */
169 regs->r14 = 0; /* %esi */
170 regs->r15 = 0; /* %edi */
171
172 current->thread.eflag = IA32_EFLAG;
173 current->thread.fsr = IA32_FSR_DEFAULT;
174 current->thread.fcr = IA32_FCR_DEFAULT;
175 current->thread.fir = 0;
176 current->thread.fdr = 0;
177
178 /*
179 * Setup GDTD. Note: GDTD is the descrambled version of the pseudo-descriptor
180 * format defined by Figure 3-11 "Pseudo-Descriptor Format" in the IA-32
181 * architecture manual. Also note that the only fields that are not ignored are
182 * `base', `limit', 'G', `P' (must be 1) and `S' (must be 0).
183 */
184 regs->r31 = IA32_SEG_UNSCRAMBLE(IA32_SEG_DESCRIPTOR(IA32_GDT_OFFSET, IA32_PAGE_SIZE - 1,
185 0, 0, 0, 1, 0, 0, 0));
186 /* Setup the segment selectors */
187 regs->r16 = (__USER_DS << 16) | __USER_DS; /* ES == DS, GS, FS are zero */
188 regs->r17 = (__USER_DS << 16) | __USER_CS; /* SS, CS; ia32_load_state() sets TSS and LDT */
189
190 ia32_load_segment_descriptors(current);
191 ia32_load_state(current);
192}
193
194/*
195 * Undo the override of setup_arg_pages() without this ia32_setup_arg_pages()
196 * will suffer infinite self recursion.
197 */
198#undef setup_arg_pages
199
200int
201ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack)
202{
203 int ret;
204
205 ret = setup_arg_pages(bprm, IA32_STACK_TOP, executable_stack);
206 if (!ret) {
207 /*
208 * Can't do it in ia64_elf32_init(). Needs to be done before
209 * calls to elf32_map()
210 */
211 current->thread.ppl = ia32_init_pp_list();
212 }
213
214 return ret;
215}
216
217static void
218elf32_set_personality (void)
219{
220 set_personality(PER_LINUX32);
221 current->thread.map_base = IA32_PAGE_OFFSET/3;
222}
223
224static unsigned long
225elf32_map(struct file *filep, unsigned long addr, struct elf_phdr *eppnt,
226 int prot, int type, unsigned long unused)
227{
228 unsigned long pgoff = (eppnt->p_vaddr) & ~IA32_PAGE_MASK;
229
230 return ia32_do_mmap(filep, (addr & IA32_PAGE_MASK), eppnt->p_filesz + pgoff, prot, type,
231 eppnt->p_offset - pgoff);
232}
233
234#define cpu_uses_ia32el() (local_cpu_data->family > 0x1f)
235
236static int __init check_elf32_binfmt(void)
237{
238 if (cpu_uses_ia32el()) {
239 printk("Please use IA-32 EL for executing IA-32 binaries\n");
240 unregister_binfmt(&elf_format);
241 }
242 return 0;
243}
244
245module_init(check_elf32_binfmt)
diff --git a/arch/ia64/ia32/elfcore32.h b/arch/ia64/ia32/elfcore32.h
deleted file mode 100644
index 657725742617..000000000000
--- a/arch/ia64/ia32/elfcore32.h
+++ /dev/null
@@ -1,148 +0,0 @@
1/*
2 * IA-32 ELF core dump support.
3 *
4 * Copyright (C) 2003 Arun Sharma <arun.sharma@intel.com>
5 *
6 * Derived from the x86_64 version
7 */
8#ifndef _ELFCORE32_H_
9#define _ELFCORE32_H_
10
11#include <asm/intrinsics.h>
12#include <asm/uaccess.h>
13
14/* Override elfcore.h */
15#define _LINUX_ELFCORE_H 1
16typedef unsigned int elf_greg_t;
17
18#define ELF_NGREG (sizeof (struct user_regs_struct32) / sizeof(elf_greg_t))
19typedef elf_greg_t elf_gregset_t[ELF_NGREG];
20
21typedef struct ia32_user_i387_struct elf_fpregset_t;
22typedef struct ia32_user_fxsr_struct elf_fpxregset_t;
23
24struct elf_siginfo
25{
26 int si_signo; /* signal number */
27 int si_code; /* extra code */
28 int si_errno; /* errno */
29};
30
31#ifdef CONFIG_VIRT_CPU_ACCOUNTING
32/*
33 * Hacks are here since types between compat_timeval (= pair of s32) and
34 * ia64-native timeval (= pair of s64) are not compatible, at least a file
35 * arch/ia64/ia32/../../../fs/binfmt_elf.c will get warnings from compiler on
36 * use of cputime_to_timeval(), which usually an alias of jiffies_to_timeval().
37 */
38#define cputime_to_timeval(a,b) \
39 do { (b)->tv_usec = 0; (b)->tv_sec = (a)/NSEC_PER_SEC; } while(0)
40#else
41#define jiffies_to_timeval(a,b) \
42 do { (b)->tv_usec = 0; (b)->tv_sec = (a)/HZ; } while(0)
43#endif
44
45struct elf_prstatus
46{
47 struct elf_siginfo pr_info; /* Info associated with signal */
48 short pr_cursig; /* Current signal */
49 unsigned int pr_sigpend; /* Set of pending signals */
50 unsigned int pr_sighold; /* Set of held signals */
51 pid_t pr_pid;
52 pid_t pr_ppid;
53 pid_t pr_pgrp;
54 pid_t pr_sid;
55 struct compat_timeval pr_utime; /* User time */
56 struct compat_timeval pr_stime; /* System time */
57 struct compat_timeval pr_cutime; /* Cumulative user time */
58 struct compat_timeval pr_cstime; /* Cumulative system time */
59 elf_gregset_t pr_reg; /* GP registers */
60 int pr_fpvalid; /* True if math co-processor being used. */
61};
62
63#define ELF_PRARGSZ (80) /* Number of chars for args */
64
65struct elf_prpsinfo
66{
67 char pr_state; /* numeric process state */
68 char pr_sname; /* char for pr_state */
69 char pr_zomb; /* zombie */
70 char pr_nice; /* nice val */
71 unsigned int pr_flag; /* flags */
72 __u16 pr_uid;
73 __u16 pr_gid;
74 pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid;
75 /* Lots missing */
76 char pr_fname[16]; /* filename of executable */
77 char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
78};
79
80#define ELF_CORE_COPY_REGS(pr_reg, regs) \
81 pr_reg[0] = regs->r11; \
82 pr_reg[1] = regs->r9; \
83 pr_reg[2] = regs->r10; \
84 pr_reg[3] = regs->r14; \
85 pr_reg[4] = regs->r15; \
86 pr_reg[5] = regs->r13; \
87 pr_reg[6] = regs->r8; \
88 pr_reg[7] = regs->r16 & 0xffff; \
89 pr_reg[8] = (regs->r16 >> 16) & 0xffff; \
90 pr_reg[9] = (regs->r16 >> 32) & 0xffff; \
91 pr_reg[10] = (regs->r16 >> 48) & 0xffff; \
92 pr_reg[11] = regs->r1; \
93 pr_reg[12] = regs->cr_iip; \
94 pr_reg[13] = regs->r17 & 0xffff; \
95 pr_reg[14] = ia64_getreg(_IA64_REG_AR_EFLAG); \
96 pr_reg[15] = regs->r12; \
97 pr_reg[16] = (regs->r17 >> 16) & 0xffff;
98
99static inline void elf_core_copy_regs(elf_gregset_t *elfregs,
100 struct pt_regs *regs)
101{
102 ELF_CORE_COPY_REGS((*elfregs), regs)
103}
104
105static inline int elf_core_copy_task_regs(struct task_struct *t,
106 elf_gregset_t* elfregs)
107{
108 ELF_CORE_COPY_REGS((*elfregs), task_pt_regs(t));
109 return 1;
110}
111
112static inline int
113elf_core_copy_task_fpregs(struct task_struct *tsk, struct pt_regs *regs, elf_fpregset_t *fpu)
114{
115 struct ia32_user_i387_struct *fpstate = (void*)fpu;
116 mm_segment_t old_fs;
117
118 if (!tsk_used_math(tsk))
119 return 0;
120
121 old_fs = get_fs();
122 set_fs(KERNEL_DS);
123 save_ia32_fpstate(tsk, (struct ia32_user_i387_struct __user *) fpstate);
124 set_fs(old_fs);
125
126 return 1;
127}
128
129#define ELF_CORE_COPY_XFPREGS 1
130#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
131static inline int
132elf_core_copy_task_xfpregs(struct task_struct *tsk, elf_fpxregset_t *xfpu)
133{
134 struct ia32_user_fxsr_struct *fpxstate = (void*) xfpu;
135 mm_segment_t old_fs;
136
137 if (!tsk_used_math(tsk))
138 return 0;
139
140 old_fs = get_fs();
141 set_fs(KERNEL_DS);
142 save_ia32_fpxstate(tsk, (struct ia32_user_fxsr_struct __user *) fpxstate);
143 set_fs(old_fs);
144
145 return 1;
146}
147
148#endif /* _ELFCORE32_H_ */
diff --git a/arch/ia64/ia32/ia32_entry.S b/arch/ia64/ia32/ia32_entry.S
deleted file mode 100644
index 2fd7479aa216..000000000000
--- a/arch/ia64/ia32/ia32_entry.S
+++ /dev/null
@@ -1,468 +0,0 @@
1#include <asm/asmmacro.h>
2#include <asm/ia32.h>
3#include <asm/asm-offsets.h>
4#include <asm/signal.h>
5#include <asm/thread_info.h>
6
7#include "../kernel/minstate.h"
8
9 /*
10 * execve() is special because in case of success, we need to
11 * setup a null register window frame (in case an IA-32 process
12 * is exec'ing an IA-64 program).
13 */
14ENTRY(ia32_execve)
15 .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(3)
16 alloc loc1=ar.pfs,3,2,4,0
17 mov loc0=rp
18 .body
19 zxt4 out0=in0 // filename
20 ;; // stop bit between alloc and call
21 zxt4 out1=in1 // argv
22 zxt4 out2=in2 // envp
23 add out3=16,sp // regs
24 br.call.sptk.few rp=sys32_execve
251: cmp.ge p6,p0=r8,r0
26 mov ar.pfs=loc1 // restore ar.pfs
27 ;;
28(p6) mov ar.pfs=r0 // clear ar.pfs in case of success
29 sxt4 r8=r8 // return 64-bit result
30 mov rp=loc0
31 br.ret.sptk.few rp
32END(ia32_execve)
33
34ENTRY(ia32_clone)
35 .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(5)
36 alloc r16=ar.pfs,5,2,6,0
37 DO_SAVE_SWITCH_STACK
38 mov loc0=rp
39 mov loc1=r16 // save ar.pfs across do_fork
40 .body
41 zxt4 out1=in1 // newsp
42 mov out3=16 // stacksize (compensates for 16-byte scratch area)
43 adds out2=IA64_SWITCH_STACK_SIZE+16,sp // out2 = &regs
44 mov out0=in0 // out0 = clone_flags
45 zxt4 out4=in2 // out4 = parent_tidptr
46 zxt4 out5=in4 // out5 = child_tidptr
47 br.call.sptk.many rp=do_fork
48.ret0: .restore sp
49 adds sp=IA64_SWITCH_STACK_SIZE,sp // pop the switch stack
50 mov ar.pfs=loc1
51 mov rp=loc0
52 br.ret.sptk.many rp
53END(ia32_clone)
54
55GLOBAL_ENTRY(ia32_ret_from_clone)
56 PT_REGS_UNWIND_INFO(0)
57{ /*
58 * Some versions of gas generate bad unwind info if the first instruction of a
59 * procedure doesn't go into the first slot of a bundle. This is a workaround.
60 */
61 nop.m 0
62 nop.i 0
63 /*
64 * We need to call schedule_tail() to complete the scheduling process.
65 * Called by ia64_switch_to after do_fork()->copy_thread(). r8 contains the
66 * address of the previously executing task.
67 */
68 br.call.sptk.many rp=ia64_invoke_schedule_tail
69}
70.ret1:
71 adds r2=TI_FLAGS+IA64_TASK_SIZE,r13
72 ;;
73 ld4 r2=[r2]
74 ;;
75 mov r8=0
76 and r2=_TIF_SYSCALL_TRACEAUDIT,r2
77 ;;
78 cmp.ne p6,p0=r2,r0
79(p6) br.cond.spnt .ia32_strace_check_retval
80 ;; // prevent RAW on r8
81END(ia32_ret_from_clone)
82 // fall through
83GLOBAL_ENTRY(ia32_ret_from_syscall)
84 PT_REGS_UNWIND_INFO(0)
85
86 cmp.ge p6,p7=r8,r0 // syscall executed successfully?
87 adds r2=IA64_PT_REGS_R8_OFFSET+16,sp // r2 = &pt_regs.r8
88 ;;
89 alloc r3=ar.pfs,0,0,0,0 // drop the syscall argument frame
90 st8 [r2]=r8 // store return value in slot for r8
91 br.cond.sptk.many ia64_leave_kernel
92END(ia32_ret_from_syscall)
93
94 //
95 // Invoke a system call, but do some tracing before and after the call.
96 // We MUST preserve the current register frame throughout this routine
97 // because some system calls (such as ia64_execve) directly
98 // manipulate ar.pfs.
99 //
100 // Input:
101 // r8 = syscall number
102 // b6 = syscall entry point
103 //
104GLOBAL_ENTRY(ia32_trace_syscall)
105 PT_REGS_UNWIND_INFO(0)
106 mov r3=-38
107 adds r2=IA64_PT_REGS_R8_OFFSET+16,sp
108 ;;
109 st8 [r2]=r3 // initialize return code to -ENOSYS
110 br.call.sptk.few rp=syscall_trace_enter // give parent a chance to catch syscall args
111 cmp.lt p6,p0=r8,r0 // check tracehook
112 adds r2=IA64_PT_REGS_R8_OFFSET+16,sp // r2 = &pt_regs.r8
113 ;;
114(p6) st8.spill [r2]=r8 // store return value in slot for r8
115(p6) br.spnt.few .ret4
116.ret2: // Need to reload arguments (they may be changed by the tracing process)
117 adds r2=IA64_PT_REGS_R1_OFFSET+16,sp // r2 = &pt_regs.r1
118 adds r3=IA64_PT_REGS_R13_OFFSET+16,sp // r3 = &pt_regs.r13
119 mov r15=IA32_NR_syscalls
120 ;;
121 ld4 r8=[r2],IA64_PT_REGS_R9_OFFSET-IA64_PT_REGS_R1_OFFSET
122 movl r16=ia32_syscall_table
123 ;;
124 ld4 r33=[r2],8 // r9 == ecx
125 ld4 r37=[r3],16 // r13 == ebp
126 cmp.ltu.unc p6,p7=r8,r15
127 ;;
128 ld4 r34=[r2],8 // r10 == edx
129 ld4 r36=[r3],8 // r15 == edi
130(p6) shladd r16=r8,3,r16 // force ni_syscall if not valid syscall number
131 ;;
132 ld8 r16=[r16]
133 ;;
134 ld4 r32=[r2],8 // r11 == ebx
135 mov b6=r16
136 ld4 r35=[r3],8 // r14 == esi
137 br.call.sptk.few rp=b6 // do the syscall
138.ia32_strace_check_retval:
139 cmp.lt p6,p0=r8,r0 // syscall failed?
140 adds r2=IA64_PT_REGS_R8_OFFSET+16,sp // r2 = &pt_regs.r8
141 ;;
142 st8.spill [r2]=r8 // store return value in slot for r8
143 br.call.sptk.few rp=syscall_trace_leave // give parent a chance to catch return value
144.ret4: alloc r2=ar.pfs,0,0,0,0 // drop the syscall argument frame
145 br.cond.sptk.many ia64_leave_kernel
146END(ia32_trace_syscall)
147
148GLOBAL_ENTRY(sys32_vfork)
149 alloc r16=ar.pfs,2,2,4,0;;
150 mov out0=IA64_CLONE_VFORK|IA64_CLONE_VM|SIGCHLD // out0 = clone_flags
151 br.cond.sptk.few .fork1 // do the work
152END(sys32_vfork)
153
154GLOBAL_ENTRY(sys32_fork)
155 .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(2)
156 alloc r16=ar.pfs,2,2,4,0
157 mov out0=SIGCHLD // out0 = clone_flags
158 ;;
159.fork1:
160 mov loc0=rp
161 mov loc1=r16 // save ar.pfs across do_fork
162 DO_SAVE_SWITCH_STACK
163
164 .body
165
166 mov out1=0
167 mov out3=0
168 adds out2=IA64_SWITCH_STACK_SIZE+16,sp // out2 = &regs
169 br.call.sptk.few rp=do_fork
170.ret5: .restore sp
171 adds sp=IA64_SWITCH_STACK_SIZE,sp // pop the switch stack
172 mov ar.pfs=loc1
173 mov rp=loc0
174 br.ret.sptk.many rp
175END(sys32_fork)
176
177 .rodata
178 .align 8
179 .globl ia32_syscall_table
180ia32_syscall_table:
181 data8 sys_ni_syscall /* 0 - old "setup(" system call*/
182 data8 sys_exit
183 data8 sys32_fork
184 data8 sys_read
185 data8 sys_write
186 data8 compat_sys_open /* 5 */
187 data8 sys_close
188 data8 sys32_waitpid
189 data8 sys_creat
190 data8 sys_link
191 data8 sys_unlink /* 10 */
192 data8 ia32_execve
193 data8 sys_chdir
194 data8 compat_sys_time
195 data8 sys_mknod
196 data8 sys_chmod /* 15 */
197 data8 sys_lchown /* 16-bit version */
198 data8 sys_ni_syscall /* old break syscall holder */
199 data8 sys_ni_syscall
200 data8 sys32_lseek
201 data8 sys_getpid /* 20 */
202 data8 compat_sys_mount
203 data8 sys_oldumount
204 data8 sys_setuid /* 16-bit version */
205 data8 sys_getuid /* 16-bit version */
206 data8 compat_sys_stime /* 25 */
207 data8 compat_sys_ptrace
208 data8 sys32_alarm
209 data8 sys_ni_syscall
210 data8 sys_pause
211 data8 compat_sys_utime /* 30 */
212 data8 sys_ni_syscall /* old stty syscall holder */
213 data8 sys_ni_syscall /* old gtty syscall holder */
214 data8 sys_access
215 data8 sys_nice
216 data8 sys_ni_syscall /* 35 */ /* old ftime syscall holder */
217 data8 sys_sync
218 data8 sys_kill
219 data8 sys_rename
220 data8 sys_mkdir
221 data8 sys_rmdir /* 40 */
222 data8 sys_dup
223 data8 sys_ia64_pipe
224 data8 compat_sys_times
225 data8 sys_ni_syscall /* old prof syscall holder */
226 data8 sys32_brk /* 45 */
227 data8 sys_setgid /* 16-bit version */
228 data8 sys_getgid /* 16-bit version */
229 data8 sys32_signal
230 data8 sys_geteuid /* 16-bit version */
231 data8 sys_getegid /* 16-bit version */ /* 50 */
232 data8 sys_acct
233 data8 sys_umount /* recycled never used phys( */
234 data8 sys_ni_syscall /* old lock syscall holder */
235 data8 compat_sys_ioctl
236 data8 compat_sys_fcntl /* 55 */
237 data8 sys_ni_syscall /* old mpx syscall holder */
238 data8 sys_setpgid
239 data8 sys_ni_syscall /* old ulimit syscall holder */
240 data8 sys_ni_syscall
241 data8 sys_umask /* 60 */
242 data8 sys_chroot
243 data8 compat_sys_ustat
244 data8 sys_dup2
245 data8 sys_getppid
246 data8 sys_getpgrp /* 65 */
247 data8 sys_setsid
248 data8 sys32_sigaction
249 data8 sys_ni_syscall
250 data8 sys_ni_syscall
251 data8 sys_setreuid /* 16-bit version */ /* 70 */
252 data8 sys_setregid /* 16-bit version */
253 data8 sys32_sigsuspend
254 data8 compat_sys_sigpending
255 data8 sys_sethostname
256 data8 compat_sys_setrlimit /* 75 */
257 data8 compat_sys_old_getrlimit
258 data8 compat_sys_getrusage
259 data8 compat_sys_gettimeofday
260 data8 compat_sys_settimeofday
261 data8 sys32_getgroups16 /* 80 */
262 data8 sys32_setgroups16
263 data8 sys32_old_select
264 data8 sys_symlink
265 data8 sys_ni_syscall
266 data8 sys_readlink /* 85 */
267 data8 sys_uselib
268 data8 sys_swapon
269 data8 sys_reboot
270 data8 compat_sys_old_readdir
271 data8 sys32_mmap /* 90 */
272 data8 sys32_munmap
273 data8 sys_truncate
274 data8 sys_ftruncate
275 data8 sys_fchmod
276 data8 sys_fchown /* 16-bit version */ /* 95 */
277 data8 sys_getpriority
278 data8 sys_setpriority
279 data8 sys_ni_syscall /* old profil syscall holder */
280 data8 compat_sys_statfs
281 data8 compat_sys_fstatfs /* 100 */
282 data8 sys_ni_syscall /* ioperm */
283 data8 compat_sys_socketcall
284 data8 sys_syslog
285 data8 compat_sys_setitimer
286 data8 compat_sys_getitimer /* 105 */
287 data8 compat_sys_newstat
288 data8 compat_sys_newlstat
289 data8 compat_sys_newfstat
290 data8 sys_ni_syscall
291 data8 sys_ni_syscall /* iopl */ /* 110 */
292 data8 sys_vhangup
293 data8 sys_ni_syscall /* used to be sys_idle */
294 data8 sys_ni_syscall
295 data8 compat_sys_wait4
296 data8 sys_swapoff /* 115 */
297 data8 compat_sys_sysinfo
298 data8 sys32_ipc
299 data8 sys_fsync
300 data8 sys32_sigreturn
301 data8 ia32_clone /* 120 */
302 data8 sys_setdomainname
303 data8 sys32_newuname
304 data8 sys32_modify_ldt
305 data8 compat_sys_adjtimex
306 data8 sys32_mprotect /* 125 */
307 data8 compat_sys_sigprocmask
308 data8 sys_ni_syscall /* create_module */
309 data8 sys_ni_syscall /* init_module */
310 data8 sys_ni_syscall /* delete_module */
311 data8 sys_ni_syscall /* get_kernel_syms */ /* 130 */
312 data8 sys32_quotactl
313 data8 sys_getpgid
314 data8 sys_fchdir
315 data8 sys_ni_syscall /* sys_bdflush */
316 data8 sys_sysfs /* 135 */
317 data8 sys32_personality
318 data8 sys_ni_syscall /* for afs_syscall */
319 data8 sys_setfsuid /* 16-bit version */
320 data8 sys_setfsgid /* 16-bit version */
321 data8 sys_llseek /* 140 */
322 data8 compat_sys_getdents
323 data8 compat_sys_select
324 data8 sys_flock
325 data8 sys32_msync
326 data8 compat_sys_readv /* 145 */
327 data8 compat_sys_writev
328 data8 sys_getsid
329 data8 sys_fdatasync
330 data8 compat_sys_sysctl
331 data8 sys_mlock /* 150 */
332 data8 sys_munlock
333 data8 sys_mlockall
334 data8 sys_munlockall
335 data8 sys_sched_setparam
336 data8 sys_sched_getparam /* 155 */
337 data8 sys_sched_setscheduler
338 data8 sys_sched_getscheduler
339 data8 sys_sched_yield
340 data8 sys_sched_get_priority_max
341 data8 sys_sched_get_priority_min /* 160 */
342 data8 sys32_sched_rr_get_interval
343 data8 compat_sys_nanosleep
344 data8 sys32_mremap
345 data8 sys_setresuid /* 16-bit version */
346 data8 sys32_getresuid16 /* 16-bit version */ /* 165 */
347 data8 sys_ni_syscall /* vm86 */
348 data8 sys_ni_syscall /* sys_query_module */
349 data8 sys_poll
350 data8 sys_ni_syscall /* nfsservctl */
351 data8 sys_setresgid /* 170 */
352 data8 sys32_getresgid16
353 data8 sys_prctl
354 data8 sys32_rt_sigreturn
355 data8 sys32_rt_sigaction
356 data8 sys32_rt_sigprocmask /* 175 */
357 data8 sys_rt_sigpending
358 data8 compat_sys_rt_sigtimedwait
359 data8 sys32_rt_sigqueueinfo
360 data8 compat_sys_rt_sigsuspend
361 data8 sys32_pread /* 180 */
362 data8 sys32_pwrite
363 data8 sys_chown /* 16-bit version */
364 data8 sys_getcwd
365 data8 sys_capget
366 data8 sys_capset /* 185 */
367 data8 sys32_sigaltstack
368 data8 sys32_sendfile
369 data8 sys_ni_syscall /* streams1 */
370 data8 sys_ni_syscall /* streams2 */
371 data8 sys32_vfork /* 190 */
372 data8 compat_sys_getrlimit
373 data8 sys32_mmap2
374 data8 sys32_truncate64
375 data8 sys32_ftruncate64
376 data8 sys32_stat64 /* 195 */
377 data8 sys32_lstat64
378 data8 sys32_fstat64
379 data8 sys_lchown
380 data8 sys_getuid
381 data8 sys_getgid /* 200 */
382 data8 sys_geteuid
383 data8 sys_getegid
384 data8 sys_setreuid
385 data8 sys_setregid
386 data8 sys_getgroups /* 205 */
387 data8 sys_setgroups
388 data8 sys_fchown
389 data8 sys_setresuid
390 data8 sys_getresuid
391 data8 sys_setresgid /* 210 */
392 data8 sys_getresgid
393 data8 sys_chown
394 data8 sys_setuid
395 data8 sys_setgid
396 data8 sys_setfsuid /* 215 */
397 data8 sys_setfsgid
398 data8 sys_pivot_root
399 data8 sys_mincore
400 data8 sys_madvise
401 data8 compat_sys_getdents64 /* 220 */
402 data8 compat_sys_fcntl64
403 data8 sys_ni_syscall /* reserved for TUX */
404 data8 sys_ni_syscall /* reserved for Security */
405 data8 sys_gettid
406 data8 sys_readahead /* 225 */
407 data8 sys_setxattr
408 data8 sys_lsetxattr
409 data8 sys_fsetxattr
410 data8 sys_getxattr
411 data8 sys_lgetxattr /* 230 */
412 data8 sys_fgetxattr
413 data8 sys_listxattr
414 data8 sys_llistxattr
415 data8 sys_flistxattr
416 data8 sys_removexattr /* 235 */
417 data8 sys_lremovexattr
418 data8 sys_fremovexattr
419 data8 sys_tkill
420 data8 sys_sendfile64
421 data8 compat_sys_futex /* 240 */
422 data8 compat_sys_sched_setaffinity
423 data8 compat_sys_sched_getaffinity
424 data8 sys32_set_thread_area
425 data8 sys32_get_thread_area
426 data8 compat_sys_io_setup /* 245 */
427 data8 sys_io_destroy
428 data8 compat_sys_io_getevents
429 data8 compat_sys_io_submit
430 data8 sys_io_cancel
431 data8 sys_fadvise64 /* 250 */
432 data8 sys_ni_syscall
433 data8 sys_exit_group
434 data8 sys_lookup_dcookie
435 data8 sys_epoll_create
436 data8 sys32_epoll_ctl /* 255 */
437 data8 sys32_epoll_wait
438 data8 sys_remap_file_pages
439 data8 sys_set_tid_address
440 data8 compat_sys_timer_create
441 data8 compat_sys_timer_settime /* 260 */
442 data8 compat_sys_timer_gettime
443 data8 sys_timer_getoverrun
444 data8 sys_timer_delete
445 data8 compat_sys_clock_settime
446 data8 compat_sys_clock_gettime /* 265 */
447 data8 compat_sys_clock_getres
448 data8 compat_sys_clock_nanosleep
449 data8 compat_sys_statfs64
450 data8 compat_sys_fstatfs64
451 data8 sys_tgkill /* 270 */
452 data8 compat_sys_utimes
453 data8 sys32_fadvise64_64
454 data8 sys_ni_syscall
455 data8 sys_ni_syscall
456 data8 sys_ni_syscall /* 275 */
457 data8 sys_ni_syscall
458 data8 compat_sys_mq_open
459 data8 sys_mq_unlink
460 data8 compat_sys_mq_timedsend
461 data8 compat_sys_mq_timedreceive /* 280 */
462 data8 compat_sys_mq_notify
463 data8 compat_sys_mq_getsetattr
464 data8 sys_ni_syscall /* reserved for kexec */
465 data8 compat_sys_waitid
466
467 // guard against failures to increase IA32_NR_syscalls
468 .org ia32_syscall_table + 8*IA32_NR_syscalls
diff --git a/arch/ia64/ia32/ia32_ldt.c b/arch/ia64/ia32/ia32_ldt.c
deleted file mode 100644
index 16d51c146849..000000000000
--- a/arch/ia64/ia32/ia32_ldt.c
+++ /dev/null
@@ -1,146 +0,0 @@
1/*
2 * Copyright (C) 2001, 2004 Hewlett-Packard Co
3 * David Mosberger-Tang <davidm@hpl.hp.com>
4 *
5 * Adapted from arch/i386/kernel/ldt.c
6 */
7
8#include <linux/errno.h>
9#include <linux/sched.h>
10#include <linux/string.h>
11#include <linux/mm.h>
12#include <linux/smp.h>
13#include <linux/vmalloc.h>
14
15#include <asm/uaccess.h>
16
17#include "ia32priv.h"
18
19/*
20 * read_ldt() is not really atomic - this is not a problem since synchronization of reads
21 * and writes done to the LDT has to be assured by user-space anyway. Writes are atomic,
22 * to protect the security checks done on new descriptors.
23 */
24static int
25read_ldt (void __user *ptr, unsigned long bytecount)
26{
27 unsigned long bytes_left, n;
28 char __user *src, *dst;
29 char buf[256]; /* temporary buffer (don't overflow kernel stack!) */
30
31 if (bytecount > IA32_LDT_ENTRIES*IA32_LDT_ENTRY_SIZE)
32 bytecount = IA32_LDT_ENTRIES*IA32_LDT_ENTRY_SIZE;
33
34 bytes_left = bytecount;
35
36 src = (void __user *) IA32_LDT_OFFSET;
37 dst = ptr;
38
39 while (bytes_left) {
40 n = sizeof(buf);
41 if (n > bytes_left)
42 n = bytes_left;
43
44 /*
45 * We know we're reading valid memory, but we still must guard against
46 * running out of memory.
47 */
48 if (__copy_from_user(buf, src, n))
49 return -EFAULT;
50
51 if (copy_to_user(dst, buf, n))
52 return -EFAULT;
53
54 src += n;
55 dst += n;
56 bytes_left -= n;
57 }
58 return bytecount;
59}
60
61static int
62read_default_ldt (void __user * ptr, unsigned long bytecount)
63{
64 unsigned long size;
65 int err;
66
67 /* XXX fix me: should return equivalent of default_ldt[0] */
68 err = 0;
69 size = 8;
70 if (size > bytecount)
71 size = bytecount;
72
73 err = size;
74 if (clear_user(ptr, size))
75 err = -EFAULT;
76
77 return err;
78}
79
80static int
81write_ldt (void __user * ptr, unsigned long bytecount, int oldmode)
82{
83 struct ia32_user_desc ldt_info;
84 __u64 entry;
85 int ret;
86
87 if (bytecount != sizeof(ldt_info))
88 return -EINVAL;
89 if (copy_from_user(&ldt_info, ptr, sizeof(ldt_info)))
90 return -EFAULT;
91
92 if (ldt_info.entry_number >= IA32_LDT_ENTRIES)
93 return -EINVAL;
94 if (ldt_info.contents == 3) {
95 if (oldmode)
96 return -EINVAL;
97 if (ldt_info.seg_not_present == 0)
98 return -EINVAL;
99 }
100
101 if (ldt_info.base_addr == 0 && ldt_info.limit == 0
102 && (oldmode || (ldt_info.contents == 0 && ldt_info.read_exec_only == 1
103 && ldt_info.seg_32bit == 0 && ldt_info.limit_in_pages == 0
104 && ldt_info.seg_not_present == 1 && ldt_info.useable == 0)))
105 /* allow LDTs to be cleared by the user */
106 entry = 0;
107 else
108 /* we must set the "Accessed" bit as IVE doesn't emulate it */
109 entry = IA32_SEG_DESCRIPTOR(ldt_info.base_addr, ldt_info.limit,
110 (((ldt_info.read_exec_only ^ 1) << 1)
111 | (ldt_info.contents << 2)) | 1,
112 1, 3, ldt_info.seg_not_present ^ 1,
113 (oldmode ? 0 : ldt_info.useable),
114 ldt_info.seg_32bit,
115 ldt_info.limit_in_pages);
116 /*
117 * Install the new entry. We know we're accessing valid (mapped) user-level
118 * memory, but we still need to guard against out-of-memory, hence we must use
119 * put_user().
120 */
121 ret = __put_user(entry, (__u64 __user *) IA32_LDT_OFFSET + ldt_info.entry_number);
122 ia32_load_segment_descriptors(current);
123 return ret;
124}
125
126asmlinkage int
127sys32_modify_ldt (int func, unsigned int ptr, unsigned int bytecount)
128{
129 int ret = -ENOSYS;
130
131 switch (func) {
132 case 0:
133 ret = read_ldt(compat_ptr(ptr), bytecount);
134 break;
135 case 1:
136 ret = write_ldt(compat_ptr(ptr), bytecount, 1);
137 break;
138 case 2:
139 ret = read_default_ldt(compat_ptr(ptr), bytecount);
140 break;
141 case 0x11:
142 ret = write_ldt(compat_ptr(ptr), bytecount, 0);
143 break;
144 }
145 return ret;
146}
diff --git a/arch/ia64/ia32/ia32_signal.c b/arch/ia64/ia32/ia32_signal.c
deleted file mode 100644
index b763ca19ef17..000000000000
--- a/arch/ia64/ia32/ia32_signal.c
+++ /dev/null
@@ -1,1010 +0,0 @@
1/*
2 * IA32 Architecture-specific signal handling support.
3 *
4 * Copyright (C) 1999, 2001-2002, 2005 Hewlett-Packard Co
5 * David Mosberger-Tang <davidm@hpl.hp.com>
6 * Copyright (C) 1999 Arun Sharma <arun.sharma@intel.com>
7 * Copyright (C) 2000 VA Linux Co
8 * Copyright (C) 2000 Don Dugger <n0ano@valinux.com>
9 *
10 * Derived from i386 and Alpha versions.
11 */
12
13#include <linux/errno.h>
14#include <linux/kernel.h>
15#include <linux/mm.h>
16#include <linux/personality.h>
17#include <linux/ptrace.h>
18#include <linux/sched.h>
19#include <linux/signal.h>
20#include <linux/smp.h>
21#include <linux/stddef.h>
22#include <linux/syscalls.h>
23#include <linux/unistd.h>
24#include <linux/wait.h>
25#include <linux/compat.h>
26
27#include <asm/intrinsics.h>
28#include <asm/uaccess.h>
29#include <asm/rse.h>
30#include <asm/sigcontext.h>
31
32#include "ia32priv.h"
33
34#include "../kernel/sigframe.h"
35
36#define A(__x) ((unsigned long)(__x))
37
38#define DEBUG_SIG 0
39#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
40
41#define __IA32_NR_sigreturn 119
42#define __IA32_NR_rt_sigreturn 173
43
44struct sigframe_ia32
45{
46 int pretcode;
47 int sig;
48 struct sigcontext_ia32 sc;
49 struct _fpstate_ia32 fpstate;
50 unsigned int extramask[_COMPAT_NSIG_WORDS-1];
51 char retcode[8];
52};
53
54struct rt_sigframe_ia32
55{
56 int pretcode;
57 int sig;
58 int pinfo;
59 int puc;
60 compat_siginfo_t info;
61 struct ucontext_ia32 uc;
62 struct _fpstate_ia32 fpstate;
63 char retcode[8];
64};
65
66int
67copy_siginfo_from_user32 (siginfo_t *to, compat_siginfo_t __user *from)
68{
69 unsigned long tmp;
70 int err;
71
72 if (!access_ok(VERIFY_READ, from, sizeof(compat_siginfo_t)))
73 return -EFAULT;
74
75 err = __get_user(to->si_signo, &from->si_signo);
76 err |= __get_user(to->si_errno, &from->si_errno);
77 err |= __get_user(to->si_code, &from->si_code);
78
79 if (to->si_code < 0)
80 err |= __copy_from_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
81 else {
82 switch (to->si_code >> 16) {
83 case __SI_CHLD >> 16:
84 err |= __get_user(to->si_utime, &from->si_utime);
85 err |= __get_user(to->si_stime, &from->si_stime);
86 err |= __get_user(to->si_status, &from->si_status);
87 default:
88 err |= __get_user(to->si_pid, &from->si_pid);
89 err |= __get_user(to->si_uid, &from->si_uid);
90 break;
91 case __SI_FAULT >> 16:
92 err |= __get_user(tmp, &from->si_addr);
93 to->si_addr = (void __user *) tmp;
94 break;
95 case __SI_POLL >> 16:
96 err |= __get_user(to->si_band, &from->si_band);
97 err |= __get_user(to->si_fd, &from->si_fd);
98 break;
99 case __SI_RT >> 16: /* This is not generated by the kernel as of now. */
100 case __SI_MESGQ >> 16:
101 err |= __get_user(to->si_pid, &from->si_pid);
102 err |= __get_user(to->si_uid, &from->si_uid);
103 err |= __get_user(to->si_int, &from->si_int);
104 break;
105 }
106 }
107 return err;
108}
109
110int
111copy_siginfo_to_user32 (compat_siginfo_t __user *to, siginfo_t *from)
112{
113 unsigned int addr;
114 int err;
115
116 if (!access_ok(VERIFY_WRITE, to, sizeof(compat_siginfo_t)))
117 return -EFAULT;
118
119 /* If you change siginfo_t structure, please be sure
120 this code is fixed accordingly.
121 It should never copy any pad contained in the structure
122 to avoid security leaks, but must copy the generic
123 3 ints plus the relevant union member.
124 This routine must convert siginfo from 64bit to 32bit as well
125 at the same time. */
126 err = __put_user(from->si_signo, &to->si_signo);
127 err |= __put_user(from->si_errno, &to->si_errno);
128 err |= __put_user((short)from->si_code, &to->si_code);
129 if (from->si_code < 0)
130 err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
131 else {
132 switch (from->si_code >> 16) {
133 case __SI_CHLD >> 16:
134 err |= __put_user(from->si_utime, &to->si_utime);
135 err |= __put_user(from->si_stime, &to->si_stime);
136 err |= __put_user(from->si_status, &to->si_status);
137 default:
138 err |= __put_user(from->si_pid, &to->si_pid);
139 err |= __put_user(from->si_uid, &to->si_uid);
140 break;
141 case __SI_FAULT >> 16:
142 /* avoid type-checking warnings by copying _pad[0] in lieu of si_addr... */
143 err |= __put_user(from->_sifields._pad[0], &to->si_addr);
144 break;
145 case __SI_POLL >> 16:
146 err |= __put_user(from->si_band, &to->si_band);
147 err |= __put_user(from->si_fd, &to->si_fd);
148 break;
149 case __SI_TIMER >> 16:
150 err |= __put_user(from->si_tid, &to->si_tid);
151 err |= __put_user(from->si_overrun, &to->si_overrun);
152 addr = (unsigned long) from->si_ptr;
153 err |= __put_user(addr, &to->si_ptr);
154 break;
155 case __SI_RT >> 16: /* Not generated by the kernel as of now. */
156 case __SI_MESGQ >> 16:
157 err |= __put_user(from->si_uid, &to->si_uid);
158 err |= __put_user(from->si_pid, &to->si_pid);
159 addr = (unsigned long) from->si_ptr;
160 err |= __put_user(addr, &to->si_ptr);
161 break;
162 }
163 }
164 return err;
165}
166
167
168/*
169 * SAVE and RESTORE of ia32 fpstate info, from ia64 current state
170 * Used in exception handler to pass the fpstate to the user, and restore
171 * the fpstate while returning from the exception handler.
172 *
173 * fpstate info and their mapping to IA64 regs:
174 * fpstate REG(BITS) Attribute Comments
175 * cw ar.fcr(0:12) with bits 7 and 6 not used
176 * sw ar.fsr(0:15)
177 * tag ar.fsr(16:31) with odd numbered bits not used
178 * (read returns 0, writes ignored)
179 * ipoff ar.fir(0:31)
180 * cssel ar.fir(32:47)
181 * dataoff ar.fdr(0:31)
182 * datasel ar.fdr(32:47)
183 *
184 * _st[(0+TOS)%8] f8
185 * _st[(1+TOS)%8] f9
186 * _st[(2+TOS)%8] f10
187 * _st[(3+TOS)%8] f11 (f8..f11 from ptregs)
188 * : : : (f12..f15 from live reg)
189 * : : :
190 * _st[(7+TOS)%8] f15 TOS=sw.top(bits11:13)
191 *
192 * status Same as sw RO
193 * magic 0 as X86_FXSR_MAGIC in ia32
194 * mxcsr Bits(7:15)=ar.fcr(39:47)
195 * Bits(0:5) =ar.fsr(32:37) with bit 6 reserved
196 * _xmm[0..7] f16..f31 (live registers)
197 * with _xmm[0]
198 * Bit(64:127)=f17(0:63)
199 * Bit(0:63)=f16(0:63)
200 * All other fields unused...
201 */
202
203static int
204save_ia32_fpstate_live (struct _fpstate_ia32 __user *save)
205{
206 struct task_struct *tsk = current;
207 struct pt_regs *ptp;
208 struct _fpreg_ia32 *fpregp;
209 char buf[32];
210 unsigned long fsr, fcr, fir, fdr;
211 unsigned long new_fsr;
212 unsigned long num128[2];
213 unsigned long mxcsr=0;
214 int fp_tos, fr8_st_map;
215
216 if (!access_ok(VERIFY_WRITE, save, sizeof(*save)))
217 return -EFAULT;
218
219 /* Read in fsr, fcr, fir, fdr and copy onto fpstate */
220 fsr = ia64_getreg(_IA64_REG_AR_FSR);
221 fcr = ia64_getreg(_IA64_REG_AR_FCR);
222 fir = ia64_getreg(_IA64_REG_AR_FIR);
223 fdr = ia64_getreg(_IA64_REG_AR_FDR);
224
225 /*
226 * We need to clear the exception state before calling the signal handler. Clear
227 * the bits 15, bits 0-7 in fp status word. Similar to the functionality of fnclex
228 * instruction.
229 */
230 new_fsr = fsr & ~0x80ff;
231 ia64_setreg(_IA64_REG_AR_FSR, new_fsr);
232
233 __put_user(fcr & 0xffff, &save->cw);
234 __put_user(fsr & 0xffff, &save->sw);
235 __put_user((fsr>>16) & 0xffff, &save->tag);
236 __put_user(fir, &save->ipoff);
237 __put_user((fir>>32) & 0xffff, &save->cssel);
238 __put_user(fdr, &save->dataoff);
239 __put_user((fdr>>32) & 0xffff, &save->datasel);
240 __put_user(fsr & 0xffff, &save->status);
241
242 mxcsr = ((fcr>>32) & 0xff80) | ((fsr>>32) & 0x3f);
243 __put_user(mxcsr & 0xffff, &save->mxcsr);
244 __put_user( 0, &save->magic); //#define X86_FXSR_MAGIC 0x0000
245
246 /*
247 * save f8..f11 from pt_regs
248 * save f12..f15 from live register set
249 */
250 /*
251 * Find the location where f8 has to go in fp reg stack. This depends on
252 * TOP(11:13) field of sw. Other f reg continue sequentially from where f8 maps
253 * to.
254 */
255 fp_tos = (fsr>>11)&0x7;
256 fr8_st_map = (8-fp_tos)&0x7;
257 ptp = task_pt_regs(tsk);
258 fpregp = (struct _fpreg_ia32 *)(((unsigned long)buf + 15) & ~15);
259 ia64f2ia32f(fpregp, &ptp->f8);
260 copy_to_user(&save->_st[(0+fr8_st_map)&0x7], fpregp, sizeof(struct _fpreg_ia32));
261 ia64f2ia32f(fpregp, &ptp->f9);
262 copy_to_user(&save->_st[(1+fr8_st_map)&0x7], fpregp, sizeof(struct _fpreg_ia32));
263 ia64f2ia32f(fpregp, &ptp->f10);
264 copy_to_user(&save->_st[(2+fr8_st_map)&0x7], fpregp, sizeof(struct _fpreg_ia32));
265 ia64f2ia32f(fpregp, &ptp->f11);
266 copy_to_user(&save->_st[(3+fr8_st_map)&0x7], fpregp, sizeof(struct _fpreg_ia32));
267
268 ia64_stfe(fpregp, 12);
269 copy_to_user(&save->_st[(4+fr8_st_map)&0x7], fpregp, sizeof(struct _fpreg_ia32));
270 ia64_stfe(fpregp, 13);
271 copy_to_user(&save->_st[(5+fr8_st_map)&0x7], fpregp, sizeof(struct _fpreg_ia32));
272 ia64_stfe(fpregp, 14);
273 copy_to_user(&save->_st[(6+fr8_st_map)&0x7], fpregp, sizeof(struct _fpreg_ia32));
274 ia64_stfe(fpregp, 15);
275 copy_to_user(&save->_st[(7+fr8_st_map)&0x7], fpregp, sizeof(struct _fpreg_ia32));
276
277 ia64_stf8(&num128[0], 16);
278 ia64_stf8(&num128[1], 17);
279 copy_to_user(&save->_xmm[0], num128, sizeof(struct _xmmreg_ia32));
280
281 ia64_stf8(&num128[0], 18);
282 ia64_stf8(&num128[1], 19);
283 copy_to_user(&save->_xmm[1], num128, sizeof(struct _xmmreg_ia32));
284
285 ia64_stf8(&num128[0], 20);
286 ia64_stf8(&num128[1], 21);
287 copy_to_user(&save->_xmm[2], num128, sizeof(struct _xmmreg_ia32));
288
289 ia64_stf8(&num128[0], 22);
290 ia64_stf8(&num128[1], 23);
291 copy_to_user(&save->_xmm[3], num128, sizeof(struct _xmmreg_ia32));
292
293 ia64_stf8(&num128[0], 24);
294 ia64_stf8(&num128[1], 25);
295 copy_to_user(&save->_xmm[4], num128, sizeof(struct _xmmreg_ia32));
296
297 ia64_stf8(&num128[0], 26);
298 ia64_stf8(&num128[1], 27);
299 copy_to_user(&save->_xmm[5], num128, sizeof(struct _xmmreg_ia32));
300
301 ia64_stf8(&num128[0], 28);
302 ia64_stf8(&num128[1], 29);
303 copy_to_user(&save->_xmm[6], num128, sizeof(struct _xmmreg_ia32));
304
305 ia64_stf8(&num128[0], 30);
306 ia64_stf8(&num128[1], 31);
307 copy_to_user(&save->_xmm[7], num128, sizeof(struct _xmmreg_ia32));
308 return 0;
309}
310
311static int
312restore_ia32_fpstate_live (struct _fpstate_ia32 __user *save)
313{
314 struct task_struct *tsk = current;
315 struct pt_regs *ptp;
316 unsigned int lo, hi;
317 unsigned long num128[2];
318 unsigned long num64, mxcsr;
319 struct _fpreg_ia32 *fpregp;
320 char buf[32];
321 unsigned long fsr, fcr, fir, fdr;
322 int fp_tos, fr8_st_map;
323
324 if (!access_ok(VERIFY_READ, save, sizeof(*save)))
325 return(-EFAULT);
326
327 /*
328 * Updating fsr, fcr, fir, fdr.
329 * Just a bit more complicated than save.
330 * - Need to make sure that we don't write any value other than the
331 * specific fpstate info
332 * - Need to make sure that the untouched part of frs, fdr, fir, fcr
333 * should remain same while writing.
334 * So, we do a read, change specific fields and write.
335 */
336 fsr = ia64_getreg(_IA64_REG_AR_FSR);
337 fcr = ia64_getreg(_IA64_REG_AR_FCR);
338 fir = ia64_getreg(_IA64_REG_AR_FIR);
339 fdr = ia64_getreg(_IA64_REG_AR_FDR);
340
341 __get_user(mxcsr, (unsigned int __user *)&save->mxcsr);
342 /* setting bits 0..5 8..12 with cw and 39..47 from mxcsr */
343 __get_user(lo, (unsigned int __user *)&save->cw);
344 num64 = mxcsr & 0xff10;
345 num64 = (num64 << 32) | (lo & 0x1f3f);
346 fcr = (fcr & (~0xff1000001f3fUL)) | num64;
347
348 /* setting bits 0..31 with sw and tag and 32..37 from mxcsr */
349 __get_user(lo, (unsigned int __user *)&save->sw);
350 /* set bits 15,7 (fsw.b, fsw.es) to reflect the current error status */
351 if ( !(lo & 0x7f) )
352 lo &= (~0x8080);
353 __get_user(hi, (unsigned int __user *)&save->tag);
354 num64 = mxcsr & 0x3f;
355 num64 = (num64 << 16) | (hi & 0xffff);
356 num64 = (num64 << 16) | (lo & 0xffff);
357 fsr = (fsr & (~0x3fffffffffUL)) | num64;
358
359 /* setting bits 0..47 with cssel and ipoff */
360 __get_user(lo, (unsigned int __user *)&save->ipoff);
361 __get_user(hi, (unsigned int __user *)&save->cssel);
362 num64 = hi & 0xffff;
363 num64 = (num64 << 32) | lo;
364 fir = (fir & (~0xffffffffffffUL)) | num64;
365
366 /* setting bits 0..47 with datasel and dataoff */
367 __get_user(lo, (unsigned int __user *)&save->dataoff);
368 __get_user(hi, (unsigned int __user *)&save->datasel);
369 num64 = hi & 0xffff;
370 num64 = (num64 << 32) | lo;
371 fdr = (fdr & (~0xffffffffffffUL)) | num64;
372
373 ia64_setreg(_IA64_REG_AR_FSR, fsr);
374 ia64_setreg(_IA64_REG_AR_FCR, fcr);
375 ia64_setreg(_IA64_REG_AR_FIR, fir);
376 ia64_setreg(_IA64_REG_AR_FDR, fdr);
377
378 /*
379 * restore f8..f11 onto pt_regs
380 * restore f12..f15 onto live registers
381 */
382 /*
383 * Find the location where f8 has to go in fp reg stack. This depends on
384 * TOP(11:13) field of sw. Other f reg continue sequentially from where f8 maps
385 * to.
386 */
387 fp_tos = (fsr>>11)&0x7;
388 fr8_st_map = (8-fp_tos)&0x7;
389 fpregp = (struct _fpreg_ia32 *)(((unsigned long)buf + 15) & ~15);
390
391 ptp = task_pt_regs(tsk);
392 copy_from_user(fpregp, &save->_st[(0+fr8_st_map)&0x7], sizeof(struct _fpreg_ia32));
393 ia32f2ia64f(&ptp->f8, fpregp);
394 copy_from_user(fpregp, &save->_st[(1+fr8_st_map)&0x7], sizeof(struct _fpreg_ia32));
395 ia32f2ia64f(&ptp->f9, fpregp);
396 copy_from_user(fpregp, &save->_st[(2+fr8_st_map)&0x7], sizeof(struct _fpreg_ia32));
397 ia32f2ia64f(&ptp->f10, fpregp);
398 copy_from_user(fpregp, &save->_st[(3+fr8_st_map)&0x7], sizeof(struct _fpreg_ia32));
399 ia32f2ia64f(&ptp->f11, fpregp);
400
401 copy_from_user(fpregp, &save->_st[(4+fr8_st_map)&0x7], sizeof(struct _fpreg_ia32));
402 ia64_ldfe(12, fpregp);
403 copy_from_user(fpregp, &save->_st[(5+fr8_st_map)&0x7], sizeof(struct _fpreg_ia32));
404 ia64_ldfe(13, fpregp);
405 copy_from_user(fpregp, &save->_st[(6+fr8_st_map)&0x7], sizeof(struct _fpreg_ia32));
406 ia64_ldfe(14, fpregp);
407 copy_from_user(fpregp, &save->_st[(7+fr8_st_map)&0x7], sizeof(struct _fpreg_ia32));
408 ia64_ldfe(15, fpregp);
409
410 copy_from_user(num128, &save->_xmm[0], sizeof(struct _xmmreg_ia32));
411 ia64_ldf8(16, &num128[0]);
412 ia64_ldf8(17, &num128[1]);
413
414 copy_from_user(num128, &save->_xmm[1], sizeof(struct _xmmreg_ia32));
415 ia64_ldf8(18, &num128[0]);
416 ia64_ldf8(19, &num128[1]);
417
418 copy_from_user(num128, &save->_xmm[2], sizeof(struct _xmmreg_ia32));
419 ia64_ldf8(20, &num128[0]);
420 ia64_ldf8(21, &num128[1]);
421
422 copy_from_user(num128, &save->_xmm[3], sizeof(struct _xmmreg_ia32));
423 ia64_ldf8(22, &num128[0]);
424 ia64_ldf8(23, &num128[1]);
425
426 copy_from_user(num128, &save->_xmm[4], sizeof(struct _xmmreg_ia32));
427 ia64_ldf8(24, &num128[0]);
428 ia64_ldf8(25, &num128[1]);
429
430 copy_from_user(num128, &save->_xmm[5], sizeof(struct _xmmreg_ia32));
431 ia64_ldf8(26, &num128[0]);
432 ia64_ldf8(27, &num128[1]);
433
434 copy_from_user(num128, &save->_xmm[6], sizeof(struct _xmmreg_ia32));
435 ia64_ldf8(28, &num128[0]);
436 ia64_ldf8(29, &num128[1]);
437
438 copy_from_user(num128, &save->_xmm[7], sizeof(struct _xmmreg_ia32));
439 ia64_ldf8(30, &num128[0]);
440 ia64_ldf8(31, &num128[1]);
441 return 0;
442}
443
444static inline void
445sigact_set_handler (struct k_sigaction *sa, unsigned int handler, unsigned int restorer)
446{
447 if (handler + 1 <= 2)
448 /* SIG_DFL, SIG_IGN, or SIG_ERR: must sign-extend to 64-bits */
449 sa->sa.sa_handler = (__sighandler_t) A((int) handler);
450 else
451 sa->sa.sa_handler = (__sighandler_t) (((unsigned long) restorer << 32) | handler);
452}
453
454asmlinkage long
455sys32_sigsuspend (int history0, int history1, old_sigset_t mask)
456{
457 mask &= _BLOCKABLE;
458 spin_lock_irq(&current->sighand->siglock);
459 current->saved_sigmask = current->blocked;
460 siginitset(&current->blocked, mask);
461 recalc_sigpending();
462 spin_unlock_irq(&current->sighand->siglock);
463
464 current->state = TASK_INTERRUPTIBLE;
465 schedule();
466 set_restore_sigmask();
467 return -ERESTARTNOHAND;
468}
469
470asmlinkage long
471sys32_signal (int sig, unsigned int handler)
472{
473 struct k_sigaction new_sa, old_sa;
474 int ret;
475
476 sigact_set_handler(&new_sa, handler, 0);
477 new_sa.sa.sa_flags = SA_ONESHOT | SA_NOMASK;
478 sigemptyset(&new_sa.sa.sa_mask);
479
480 ret = do_sigaction(sig, &new_sa, &old_sa);
481
482 return ret ? ret : IA32_SA_HANDLER(&old_sa);
483}
484
485asmlinkage long
486sys32_rt_sigaction (int sig, struct sigaction32 __user *act,
487 struct sigaction32 __user *oact, unsigned int sigsetsize)
488{
489 struct k_sigaction new_ka, old_ka;
490 unsigned int handler, restorer;
491 int ret;
492
493 /* XXX: Don't preclude handling different sized sigset_t's. */
494 if (sigsetsize != sizeof(compat_sigset_t))
495 return -EINVAL;
496
497 if (act) {
498 ret = get_user(handler, &act->sa_handler);
499 ret |= get_user(new_ka.sa.sa_flags, &act->sa_flags);
500 ret |= get_user(restorer, &act->sa_restorer);
501 ret |= copy_from_user(&new_ka.sa.sa_mask, &act->sa_mask, sizeof(compat_sigset_t));
502 if (ret)
503 return -EFAULT;
504
505 sigact_set_handler(&new_ka, handler, restorer);
506 }
507
508 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
509
510 if (!ret && oact) {
511 ret = put_user(IA32_SA_HANDLER(&old_ka), &oact->sa_handler);
512 ret |= put_user(old_ka.sa.sa_flags, &oact->sa_flags);
513 ret |= put_user(IA32_SA_RESTORER(&old_ka), &oact->sa_restorer);
514 ret |= copy_to_user(&oact->sa_mask, &old_ka.sa.sa_mask, sizeof(compat_sigset_t));
515 }
516 return ret;
517}
518
519
520asmlinkage long
521sys32_rt_sigprocmask (int how, compat_sigset_t __user *set, compat_sigset_t __user *oset,
522 unsigned int sigsetsize)
523{
524 mm_segment_t old_fs = get_fs();
525 sigset_t s;
526 long ret;
527
528 if (sigsetsize > sizeof(s))
529 return -EINVAL;
530
531 if (set) {
532 memset(&s, 0, sizeof(s));
533 if (copy_from_user(&s.sig, set, sigsetsize))
534 return -EFAULT;
535 }
536 set_fs(KERNEL_DS);
537 ret = sys_rt_sigprocmask(how,
538 set ? (sigset_t __user *) &s : NULL,
539 oset ? (sigset_t __user *) &s : NULL, sizeof(s));
540 set_fs(old_fs);
541 if (ret)
542 return ret;
543 if (oset) {
544 if (copy_to_user(oset, &s.sig, sigsetsize))
545 return -EFAULT;
546 }
547 return 0;
548}
549
550asmlinkage long
551sys32_rt_sigqueueinfo (int pid, int sig, compat_siginfo_t __user *uinfo)
552{
553 mm_segment_t old_fs = get_fs();
554 siginfo_t info;
555 int ret;
556
557 if (copy_siginfo_from_user32(&info, uinfo))
558 return -EFAULT;
559 set_fs(KERNEL_DS);
560 ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *) &info);
561 set_fs(old_fs);
562 return ret;
563}
564
565asmlinkage long
566sys32_sigaction (int sig, struct old_sigaction32 __user *act, struct old_sigaction32 __user *oact)
567{
568 struct k_sigaction new_ka, old_ka;
569 unsigned int handler, restorer;
570 int ret;
571
572 if (act) {
573 compat_old_sigset_t mask;
574
575 ret = get_user(handler, &act->sa_handler);
576 ret |= get_user(new_ka.sa.sa_flags, &act->sa_flags);
577 ret |= get_user(restorer, &act->sa_restorer);
578 ret |= get_user(mask, &act->sa_mask);
579 if (ret)
580 return ret;
581
582 sigact_set_handler(&new_ka, handler, restorer);
583 siginitset(&new_ka.sa.sa_mask, mask);
584 }
585
586 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
587
588 if (!ret && oact) {
589 ret = put_user(IA32_SA_HANDLER(&old_ka), &oact->sa_handler);
590 ret |= put_user(old_ka.sa.sa_flags, &oact->sa_flags);
591 ret |= put_user(IA32_SA_RESTORER(&old_ka), &oact->sa_restorer);
592 ret |= put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
593 }
594
595 return ret;
596}
597
598static int
599setup_sigcontext_ia32 (struct sigcontext_ia32 __user *sc, struct _fpstate_ia32 __user *fpstate,
600 struct pt_regs *regs, unsigned long mask)
601{
602 int err = 0;
603 unsigned long flag;
604
605 if (!access_ok(VERIFY_WRITE, sc, sizeof(*sc)))
606 return -EFAULT;
607
608 err |= __put_user((regs->r16 >> 32) & 0xffff, (unsigned int __user *)&sc->fs);
609 err |= __put_user((regs->r16 >> 48) & 0xffff, (unsigned int __user *)&sc->gs);
610 err |= __put_user((regs->r16 >> 16) & 0xffff, (unsigned int __user *)&sc->es);
611 err |= __put_user(regs->r16 & 0xffff, (unsigned int __user *)&sc->ds);
612 err |= __put_user(regs->r15, &sc->edi);
613 err |= __put_user(regs->r14, &sc->esi);
614 err |= __put_user(regs->r13, &sc->ebp);
615 err |= __put_user(regs->r12, &sc->esp);
616 err |= __put_user(regs->r11, &sc->ebx);
617 err |= __put_user(regs->r10, &sc->edx);
618 err |= __put_user(regs->r9, &sc->ecx);
619 err |= __put_user(regs->r8, &sc->eax);
620#if 0
621 err |= __put_user(current->tss.trap_no, &sc->trapno);
622 err |= __put_user(current->tss.error_code, &sc->err);
623#endif
624 err |= __put_user(regs->cr_iip, &sc->eip);
625 err |= __put_user(regs->r17 & 0xffff, (unsigned int __user *)&sc->cs);
626 /*
627 * `eflags' is in an ar register for this context
628 */
629 flag = ia64_getreg(_IA64_REG_AR_EFLAG);
630 err |= __put_user((unsigned int)flag, &sc->eflags);
631 err |= __put_user(regs->r12, &sc->esp_at_signal);
632 err |= __put_user((regs->r17 >> 16) & 0xffff, (unsigned int __user *)&sc->ss);
633
634 if ( save_ia32_fpstate_live(fpstate) < 0 )
635 err = -EFAULT;
636 else
637 err |= __put_user((u32)(u64)fpstate, &sc->fpstate);
638
639#if 0
640 tmp = save_i387(fpstate);
641 if (tmp < 0)
642 err = 1;
643 else
644 err |= __put_user(tmp ? fpstate : NULL, &sc->fpstate);
645
646 /* non-iBCS2 extensions.. */
647#endif
648 err |= __put_user(mask, &sc->oldmask);
649#if 0
650 err |= __put_user(current->tss.cr2, &sc->cr2);
651#endif
652 return err;
653}
654
655static int
656restore_sigcontext_ia32 (struct pt_regs *regs, struct sigcontext_ia32 __user *sc, int *peax)
657{
658 unsigned int err = 0;
659
660 /* Always make any pending restarted system calls return -EINTR */
661 current_thread_info()->restart_block.fn = do_no_restart_syscall;
662
663 if (!access_ok(VERIFY_READ, sc, sizeof(*sc)))
664 return(-EFAULT);
665
666#define COPY(ia64x, ia32x) err |= __get_user(regs->ia64x, &sc->ia32x)
667
668#define copyseg_gs(tmp) (regs->r16 |= (unsigned long) (tmp) << 48)
669#define copyseg_fs(tmp) (regs->r16 |= (unsigned long) (tmp) << 32)
670#define copyseg_cs(tmp) (regs->r17 |= tmp)
671#define copyseg_ss(tmp) (regs->r17 |= (unsigned long) (tmp) << 16)
672#define copyseg_es(tmp) (regs->r16 |= (unsigned long) (tmp) << 16)
673#define copyseg_ds(tmp) (regs->r16 |= tmp)
674
675#define COPY_SEG(seg) \
676 { \
677 unsigned short tmp; \
678 err |= __get_user(tmp, &sc->seg); \
679 copyseg_##seg(tmp); \
680 }
681#define COPY_SEG_STRICT(seg) \
682 { \
683 unsigned short tmp; \
684 err |= __get_user(tmp, &sc->seg); \
685 copyseg_##seg(tmp|3); \
686 }
687
688 /* To make COPY_SEGs easier, we zero r16, r17 */
689 regs->r16 = 0;
690 regs->r17 = 0;
691
692 COPY_SEG(gs);
693 COPY_SEG(fs);
694 COPY_SEG(es);
695 COPY_SEG(ds);
696 COPY(r15, edi);
697 COPY(r14, esi);
698 COPY(r13, ebp);
699 COPY(r12, esp);
700 COPY(r11, ebx);
701 COPY(r10, edx);
702 COPY(r9, ecx);
703 COPY(cr_iip, eip);
704 COPY_SEG_STRICT(cs);
705 COPY_SEG_STRICT(ss);
706 ia32_load_segment_descriptors(current);
707 {
708 unsigned int tmpflags;
709 unsigned long flag;
710
711 /*
712 * IA32 `eflags' is not part of `pt_regs', it's in an ar register which
713 * is part of the thread context. Fortunately, we are executing in the
714 * IA32 process's context.
715 */
716 err |= __get_user(tmpflags, &sc->eflags);
717 flag = ia64_getreg(_IA64_REG_AR_EFLAG);
718 flag &= ~0x40DD5;
719 flag |= (tmpflags & 0x40DD5);
720 ia64_setreg(_IA64_REG_AR_EFLAG, flag);
721
722 regs->r1 = -1; /* disable syscall checks, r1 is orig_eax */
723 }
724
725 {
726 struct _fpstate_ia32 __user *buf = NULL;
727 u32 fpstate_ptr;
728 err |= get_user(fpstate_ptr, &(sc->fpstate));
729 buf = compat_ptr(fpstate_ptr);
730 if (buf) {
731 err |= restore_ia32_fpstate_live(buf);
732 }
733 }
734
735#if 0
736 {
737 struct _fpstate * buf;
738 err |= __get_user(buf, &sc->fpstate);
739 if (buf) {
740 if (!access_ok(VERIFY_READ, buf, sizeof(*buf)))
741 goto badframe;
742 err |= restore_i387(buf);
743 }
744 }
745#endif
746
747 err |= __get_user(*peax, &sc->eax);
748 return err;
749
750#if 0
751 badframe:
752 return 1;
753#endif
754}
755
756/*
757 * Determine which stack to use..
758 */
759static inline void __user *
760get_sigframe (struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size)
761{
762 unsigned long esp;
763
764 /* Default to using normal stack (truncate off sign-extension of bit 31: */
765 esp = (unsigned int) regs->r12;
766
767 /* This is the X/Open sanctioned signal stack switching. */
768 if (ka->sa.sa_flags & SA_ONSTACK) {
769 int onstack = sas_ss_flags(esp);
770
771 if (onstack == 0)
772 esp = current->sas_ss_sp + current->sas_ss_size;
773 else if (onstack == SS_ONSTACK) {
774 /*
775 * If we are on the alternate signal stack and would
776 * overflow it, don't. Return an always-bogus address
777 * instead so we will die with SIGSEGV.
778 */
779 if (!likely(on_sig_stack(esp - frame_size)))
780 return (void __user *) -1L;
781 }
782 }
783 /* Legacy stack switching not supported */
784
785 esp -= frame_size;
786 /* Align the stack pointer according to the i386 ABI,
787 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
788 esp = ((esp + 4) & -16ul) - 4;
789 return (void __user *) esp;
790}
791
792static int
793setup_frame_ia32 (int sig, struct k_sigaction *ka, sigset_t *set, struct pt_regs * regs)
794{
795 struct exec_domain *ed = current_thread_info()->exec_domain;
796 struct sigframe_ia32 __user *frame;
797 int err = 0;
798
799 frame = get_sigframe(ka, regs, sizeof(*frame));
800
801 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
802 goto give_sigsegv;
803
804 err |= __put_user((ed && ed->signal_invmap && sig < 32
805 ? (int)(ed->signal_invmap[sig]) : sig), &frame->sig);
806
807 err |= setup_sigcontext_ia32(&frame->sc, &frame->fpstate, regs, set->sig[0]);
808
809 if (_COMPAT_NSIG_WORDS > 1)
810 err |= __copy_to_user(frame->extramask, (char *) &set->sig + 4,
811 sizeof(frame->extramask));
812
813 /* Set up to return from userspace. If provided, use a stub
814 already in userspace. */
815 if (ka->sa.sa_flags & SA_RESTORER) {
816 unsigned int restorer = IA32_SA_RESTORER(ka);
817 err |= __put_user(restorer, &frame->pretcode);
818 } else {
819 /* Pointing to restorer in ia32 gate page */
820 err |= __put_user(IA32_GATE_OFFSET, &frame->pretcode);
821 }
822
823 /* This is popl %eax ; movl $,%eax ; int $0x80
824 * and there for historical reasons only.
825 * See arch/i386/kernel/signal.c
826 */
827
828 err |= __put_user(0xb858, (short __user *)(frame->retcode+0));
829 err |= __put_user(__IA32_NR_sigreturn, (int __user *)(frame->retcode+2));
830 err |= __put_user(0x80cd, (short __user *)(frame->retcode+6));
831
832 if (err)
833 goto give_sigsegv;
834
835 /* Set up registers for signal handler */
836 regs->r12 = (unsigned long) frame;
837 regs->cr_iip = IA32_SA_HANDLER(ka);
838
839 set_fs(USER_DS);
840
841#if 0
842 regs->eflags &= ~TF_MASK;
843#endif
844
845#if 0
846 printk("SIG deliver (%s:%d): sig=%d sp=%p pc=%lx ra=%x\n",
847 current->comm, current->pid, sig, (void *) frame, regs->cr_iip, frame->pretcode);
848#endif
849
850 return 1;
851
852 give_sigsegv:
853 force_sigsegv(sig, current);
854 return 0;
855}
856
857static int
858setup_rt_frame_ia32 (int sig, struct k_sigaction *ka, siginfo_t *info,
859 sigset_t *set, struct pt_regs * regs)
860{
861 struct exec_domain *ed = current_thread_info()->exec_domain;
862 compat_uptr_t pinfo, puc;
863 struct rt_sigframe_ia32 __user *frame;
864 int err = 0;
865
866 frame = get_sigframe(ka, regs, sizeof(*frame));
867
868 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
869 goto give_sigsegv;
870
871 err |= __put_user((ed && ed->signal_invmap
872 && sig < 32 ? ed->signal_invmap[sig] : sig), &frame->sig);
873
874 pinfo = (long __user) &frame->info;
875 puc = (long __user) &frame->uc;
876 err |= __put_user(pinfo, &frame->pinfo);
877 err |= __put_user(puc, &frame->puc);
878 err |= copy_siginfo_to_user32(&frame->info, info);
879
880 /* Create the ucontext. */
881 err |= __put_user(0, &frame->uc.uc_flags);
882 err |= __put_user(0, &frame->uc.uc_link);
883 err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
884 err |= __put_user(sas_ss_flags(regs->r12), &frame->uc.uc_stack.ss_flags);
885 err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
886 err |= setup_sigcontext_ia32(&frame->uc.uc_mcontext, &frame->fpstate, regs, set->sig[0]);
887 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
888 if (err)
889 goto give_sigsegv;
890
891 /* Set up to return from userspace. If provided, use a stub
892 already in userspace. */
893 if (ka->sa.sa_flags & SA_RESTORER) {
894 unsigned int restorer = IA32_SA_RESTORER(ka);
895 err |= __put_user(restorer, &frame->pretcode);
896 } else {
897 /* Pointing to rt_restorer in ia32 gate page */
898 err |= __put_user(IA32_GATE_OFFSET + 8, &frame->pretcode);
899 }
900
901 /* This is movl $,%eax ; int $0x80
902 * and there for historical reasons only.
903 * See arch/i386/kernel/signal.c
904 */
905
906 err |= __put_user(0xb8, (char __user *)(frame->retcode+0));
907 err |= __put_user(__IA32_NR_rt_sigreturn, (int __user *)(frame->retcode+1));
908 err |= __put_user(0x80cd, (short __user *)(frame->retcode+5));
909
910 if (err)
911 goto give_sigsegv;
912
913 /* Set up registers for signal handler */
914 regs->r12 = (unsigned long) frame;
915 regs->cr_iip = IA32_SA_HANDLER(ka);
916
917 set_fs(USER_DS);
918
919#if 0
920 regs->eflags &= ~TF_MASK;
921#endif
922
923#if 0
924 printk("SIG deliver (%s:%d): sp=%p pc=%lx ra=%x\n",
925 current->comm, current->pid, (void *) frame, regs->cr_iip, frame->pretcode);
926#endif
927
928 return 1;
929
930give_sigsegv:
931 force_sigsegv(sig, current);
932 return 0;
933}
934
935int
936ia32_setup_frame1 (int sig, struct k_sigaction *ka, siginfo_t *info,
937 sigset_t *set, struct pt_regs *regs)
938{
939 /* Set up the stack frame */
940 if (ka->sa.sa_flags & SA_SIGINFO)
941 return setup_rt_frame_ia32(sig, ka, info, set, regs);
942 else
943 return setup_frame_ia32(sig, ka, set, regs);
944}
945
946asmlinkage long
947sys32_sigreturn (int arg0, int arg1, int arg2, int arg3, int arg4, int arg5,
948 int arg6, int arg7, struct pt_regs regs)
949{
950 unsigned long esp = (unsigned int) regs.r12;
951 struct sigframe_ia32 __user *frame = (struct sigframe_ia32 __user *)(esp - 8);
952 sigset_t set;
953 int eax;
954
955 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
956 goto badframe;
957
958 if (__get_user(set.sig[0], &frame->sc.oldmask)
959 || (_COMPAT_NSIG_WORDS > 1 && __copy_from_user((char *) &set.sig + 4, &frame->extramask,
960 sizeof(frame->extramask))))
961 goto badframe;
962
963 sigdelsetmask(&set, ~_BLOCKABLE);
964 spin_lock_irq(&current->sighand->siglock);
965 current->blocked = set;
966 recalc_sigpending();
967 spin_unlock_irq(&current->sighand->siglock);
968
969 if (restore_sigcontext_ia32(&regs, &frame->sc, &eax))
970 goto badframe;
971 return eax;
972
973 badframe:
974 force_sig(SIGSEGV, current);
975 return 0;
976}
977
978asmlinkage long
979sys32_rt_sigreturn (int arg0, int arg1, int arg2, int arg3, int arg4,
980 int arg5, int arg6, int arg7, struct pt_regs regs)
981{
982 unsigned long esp = (unsigned int) regs.r12;
983 struct rt_sigframe_ia32 __user *frame = (struct rt_sigframe_ia32 __user *)(esp - 4);
984 sigset_t set;
985 int eax;
986
987 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
988 goto badframe;
989 if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
990 goto badframe;
991
992 sigdelsetmask(&set, ~_BLOCKABLE);
993 spin_lock_irq(&current->sighand->siglock);
994 current->blocked = set;
995 recalc_sigpending();
996 spin_unlock_irq(&current->sighand->siglock);
997
998 if (restore_sigcontext_ia32(&regs, &frame->uc.uc_mcontext, &eax))
999 goto badframe;
1000
1001 /* It is more difficult to avoid calling this function than to
1002 call it and ignore errors. */
1003 do_sigaltstack((stack_t __user *) &frame->uc.uc_stack, NULL, esp);
1004
1005 return eax;
1006
1007 badframe:
1008 force_sig(SIGSEGV, current);
1009 return 0;
1010}
diff --git a/arch/ia64/ia32/ia32_support.c b/arch/ia64/ia32/ia32_support.c
deleted file mode 100644
index a6965ddafc46..000000000000
--- a/arch/ia64/ia32/ia32_support.c
+++ /dev/null
@@ -1,253 +0,0 @@
1/*
2 * IA32 helper functions
3 *
4 * Copyright (C) 1999 Arun Sharma <arun.sharma@intel.com>
5 * Copyright (C) 2000 Asit K. Mallick <asit.k.mallick@intel.com>
6 * Copyright (C) 2001-2002 Hewlett-Packard Co
7 * David Mosberger-Tang <davidm@hpl.hp.com>
8 *
9 * 06/16/00 A. Mallick added csd/ssd/tssd for ia32 thread context
10 * 02/19/01 D. Mosberger dropped tssd; it's not needed
11 * 09/14/01 D. Mosberger fixed memory management for gdt/tss page
12 * 09/29/01 D. Mosberger added ia32_load_segment_descriptors()
13 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/mm.h>
18#include <linux/sched.h>
19
20#include <asm/intrinsics.h>
21#include <asm/page.h>
22#include <asm/pgtable.h>
23#include <asm/system.h>
24#include <asm/processor.h>
25#include <asm/uaccess.h>
26
27#include "ia32priv.h"
28
29extern int die_if_kernel (char *str, struct pt_regs *regs, long err);
30
31struct page *ia32_shared_page[NR_CPUS];
32unsigned long *ia32_boot_gdt;
33unsigned long *cpu_gdt_table[NR_CPUS];
34struct page *ia32_gate_page;
35
36static unsigned long
37load_desc (u16 selector)
38{
39 unsigned long *table, limit, index;
40
41 if (!selector)
42 return 0;
43 if (selector & IA32_SEGSEL_TI) {
44 table = (unsigned long *) IA32_LDT_OFFSET;
45 limit = IA32_LDT_ENTRIES;
46 } else {
47 table = cpu_gdt_table[smp_processor_id()];
48 limit = IA32_PAGE_SIZE / sizeof(ia32_boot_gdt[0]);
49 }
50 index = selector >> IA32_SEGSEL_INDEX_SHIFT;
51 if (index >= limit)
52 return 0;
53 return IA32_SEG_UNSCRAMBLE(table[index]);
54}
55
56void
57ia32_load_segment_descriptors (struct task_struct *task)
58{
59 struct pt_regs *regs = task_pt_regs(task);
60
61 /* Setup the segment descriptors */
62 regs->r24 = load_desc(regs->r16 >> 16); /* ESD */
63 regs->r27 = load_desc(regs->r16 >> 0); /* DSD */
64 regs->r28 = load_desc(regs->r16 >> 32); /* FSD */
65 regs->r29 = load_desc(regs->r16 >> 48); /* GSD */
66 regs->ar_csd = load_desc(regs->r17 >> 0); /* CSD */
67 regs->ar_ssd = load_desc(regs->r17 >> 16); /* SSD */
68}
69
70int
71ia32_clone_tls (struct task_struct *child, struct pt_regs *childregs)
72{
73 struct desc_struct *desc;
74 struct ia32_user_desc info;
75 int idx;
76
77 if (copy_from_user(&info, (void __user *)(childregs->r14 & 0xffffffff), sizeof(info)))
78 return -EFAULT;
79 if (LDT_empty(&info))
80 return -EINVAL;
81
82 idx = info.entry_number;
83 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
84 return -EINVAL;
85
86 desc = child->thread.tls_array + idx - GDT_ENTRY_TLS_MIN;
87 desc->a = LDT_entry_a(&info);
88 desc->b = LDT_entry_b(&info);
89
90 /* XXX: can this be done in a cleaner way ? */
91 load_TLS(&child->thread, smp_processor_id());
92 ia32_load_segment_descriptors(child);
93 load_TLS(&current->thread, smp_processor_id());
94
95 return 0;
96}
97
98void
99ia32_save_state (struct task_struct *t)
100{
101 t->thread.eflag = ia64_getreg(_IA64_REG_AR_EFLAG);
102 t->thread.fsr = ia64_getreg(_IA64_REG_AR_FSR);
103 t->thread.fcr = ia64_getreg(_IA64_REG_AR_FCR);
104 t->thread.fir = ia64_getreg(_IA64_REG_AR_FIR);
105 t->thread.fdr = ia64_getreg(_IA64_REG_AR_FDR);
106 ia64_set_kr(IA64_KR_IO_BASE, t->thread.old_iob);
107 ia64_set_kr(IA64_KR_TSSD, t->thread.old_k1);
108}
109
110void
111ia32_load_state (struct task_struct *t)
112{
113 unsigned long eflag, fsr, fcr, fir, fdr, tssd;
114 struct pt_regs *regs = task_pt_regs(t);
115
116 eflag = t->thread.eflag;
117 fsr = t->thread.fsr;
118 fcr = t->thread.fcr;
119 fir = t->thread.fir;
120 fdr = t->thread.fdr;
121 tssd = load_desc(_TSS); /* TSSD */
122
123 ia64_setreg(_IA64_REG_AR_EFLAG, eflag);
124 ia64_setreg(_IA64_REG_AR_FSR, fsr);
125 ia64_setreg(_IA64_REG_AR_FCR, fcr);
126 ia64_setreg(_IA64_REG_AR_FIR, fir);
127 ia64_setreg(_IA64_REG_AR_FDR, fdr);
128 current->thread.old_iob = ia64_get_kr(IA64_KR_IO_BASE);
129 current->thread.old_k1 = ia64_get_kr(IA64_KR_TSSD);
130 ia64_set_kr(IA64_KR_IO_BASE, IA32_IOBASE);
131 ia64_set_kr(IA64_KR_TSSD, tssd);
132
133 regs->r17 = (_TSS << 48) | (_LDT << 32) | (__u32) regs->r17;
134 regs->r30 = load_desc(_LDT); /* LDTD */
135 load_TLS(&t->thread, smp_processor_id());
136}
137
138/*
139 * Setup IA32 GDT and TSS
140 */
141void
142ia32_gdt_init (void)
143{
144 int cpu = smp_processor_id();
145
146 ia32_shared_page[cpu] = alloc_page(GFP_KERNEL);
147 if (!ia32_shared_page[cpu])
148 panic("failed to allocate ia32_shared_page[%d]\n", cpu);
149
150 cpu_gdt_table[cpu] = page_address(ia32_shared_page[cpu]);
151
152 /* Copy from the boot cpu's GDT */
153 memcpy(cpu_gdt_table[cpu], ia32_boot_gdt, PAGE_SIZE);
154}
155
156
157/*
158 * Setup IA32 GDT and TSS
159 */
160static void
161ia32_boot_gdt_init (void)
162{
163 unsigned long ldt_size;
164
165 ia32_shared_page[0] = alloc_page(GFP_KERNEL);
166 if (!ia32_shared_page[0])
167 panic("failed to allocate ia32_shared_page[0]\n");
168
169 ia32_boot_gdt = page_address(ia32_shared_page[0]);
170 cpu_gdt_table[0] = ia32_boot_gdt;
171
172 /* CS descriptor in IA-32 (scrambled) format */
173 ia32_boot_gdt[__USER_CS >> 3]
174 = IA32_SEG_DESCRIPTOR(0, (IA32_GATE_END-1) >> IA32_PAGE_SHIFT,
175 0xb, 1, 3, 1, 1, 1, 1);
176
177 /* DS descriptor in IA-32 (scrambled) format */
178 ia32_boot_gdt[__USER_DS >> 3]
179 = IA32_SEG_DESCRIPTOR(0, (IA32_GATE_END-1) >> IA32_PAGE_SHIFT,
180 0x3, 1, 3, 1, 1, 1, 1);
181
182 ldt_size = PAGE_ALIGN(IA32_LDT_ENTRIES*IA32_LDT_ENTRY_SIZE);
183 ia32_boot_gdt[TSS_ENTRY] = IA32_SEG_DESCRIPTOR(IA32_TSS_OFFSET, 235,
184 0xb, 0, 3, 1, 1, 1, 0);
185 ia32_boot_gdt[LDT_ENTRY] = IA32_SEG_DESCRIPTOR(IA32_LDT_OFFSET, ldt_size - 1,
186 0x2, 0, 3, 1, 1, 1, 0);
187}
188
189static void
190ia32_gate_page_init(void)
191{
192 unsigned long *sr;
193
194 ia32_gate_page = alloc_page(GFP_KERNEL);
195 sr = page_address(ia32_gate_page);
196 /* This is popl %eax ; movl $,%eax ; int $0x80 */
197 *sr++ = 0xb858 | (__IA32_NR_sigreturn << 16) | (0x80cdUL << 48);
198
199 /* This is movl $,%eax ; int $0x80 */
200 *sr = 0xb8 | (__IA32_NR_rt_sigreturn << 8) | (0x80cdUL << 40);
201}
202
203void
204ia32_mem_init(void)
205{
206 ia32_boot_gdt_init();
207 ia32_gate_page_init();
208}
209
210/*
211 * Handle bad IA32 interrupt via syscall
212 */
213void
214ia32_bad_interrupt (unsigned long int_num, struct pt_regs *regs)
215{
216 siginfo_t siginfo;
217
218 if (die_if_kernel("Bad IA-32 interrupt", regs, int_num))
219 return;
220
221 siginfo.si_signo = SIGTRAP;
222 siginfo.si_errno = int_num; /* XXX is it OK to abuse si_errno like this? */
223 siginfo.si_flags = 0;
224 siginfo.si_isr = 0;
225 siginfo.si_addr = NULL;
226 siginfo.si_imm = 0;
227 siginfo.si_code = TRAP_BRKPT;
228 force_sig_info(SIGTRAP, &siginfo, current);
229}
230
231void
232ia32_cpu_init (void)
233{
234 /* initialize global ia32 state - CR0 and CR4 */
235 ia64_setreg(_IA64_REG_AR_CFLAG, (((ulong) IA32_CR4 << 32) | IA32_CR0));
236}
237
238static int __init
239ia32_init (void)
240{
241#if PAGE_SHIFT > IA32_PAGE_SHIFT
242 {
243 extern struct kmem_cache *ia64_partial_page_cachep;
244
245 ia64_partial_page_cachep = kmem_cache_create("ia64_partial_page_cache",
246 sizeof(struct ia64_partial_page),
247 0, SLAB_PANIC, NULL);
248 }
249#endif
250 return 0;
251}
252
253__initcall(ia32_init);
diff --git a/arch/ia64/ia32/ia32_traps.c b/arch/ia64/ia32/ia32_traps.c
deleted file mode 100644
index e486042672f1..000000000000
--- a/arch/ia64/ia32/ia32_traps.c
+++ /dev/null
@@ -1,156 +0,0 @@
1/*
2 * IA-32 exception handlers
3 *
4 * Copyright (C) 2000 Asit K. Mallick <asit.k.mallick@intel.com>
5 * Copyright (C) 2001-2002 Hewlett-Packard Co
6 * David Mosberger-Tang <davidm@hpl.hp.com>
7 *
8 * 06/16/00 A. Mallick added siginfo for most cases (close to IA32)
9 * 09/29/00 D. Mosberger added ia32_intercept()
10 */
11
12#include <linux/kernel.h>
13#include <linux/sched.h>
14
15#include "ia32priv.h"
16
17#include <asm/intrinsics.h>
18#include <asm/ptrace.h>
19
20int
21ia32_intercept (struct pt_regs *regs, unsigned long isr)
22{
23 switch ((isr >> 16) & 0xff) {
24 case 0: /* Instruction intercept fault */
25 case 4: /* Locked Data reference fault */
26 case 1: /* Gate intercept trap */
27 return -1;
28
29 case 2: /* System flag trap */
30 if (((isr >> 14) & 0x3) >= 2) {
31 /* MOV SS, POP SS instructions */
32 ia64_psr(regs)->id = 1;
33 return 0;
34 } else
35 return -1;
36 }
37 return -1;
38}
39
40int
41ia32_exception (struct pt_regs *regs, unsigned long isr)
42{
43 struct siginfo siginfo;
44
45 /* initialize these fields to avoid leaking kernel bits to user space: */
46 siginfo.si_errno = 0;
47 siginfo.si_flags = 0;
48 siginfo.si_isr = 0;
49 siginfo.si_imm = 0;
50 switch ((isr >> 16) & 0xff) {
51 case 1:
52 case 2:
53 siginfo.si_signo = SIGTRAP;
54 if (isr == 0)
55 siginfo.si_code = TRAP_TRACE;
56 else if (isr & 0x4)
57 siginfo.si_code = TRAP_BRANCH;
58 else
59 siginfo.si_code = TRAP_BRKPT;
60 break;
61
62 case 3:
63 siginfo.si_signo = SIGTRAP;
64 siginfo.si_code = TRAP_BRKPT;
65 break;
66
67 case 0: /* Divide fault */
68 siginfo.si_signo = SIGFPE;
69 siginfo.si_code = FPE_INTDIV;
70 break;
71
72 case 4: /* Overflow */
73 case 5: /* Bounds fault */
74 siginfo.si_signo = SIGFPE;
75 siginfo.si_code = 0;
76 break;
77
78 case 6: /* Invalid Op-code */
79 siginfo.si_signo = SIGILL;
80 siginfo.si_code = ILL_ILLOPN;
81 break;
82
83 case 7: /* FP DNA */
84 case 8: /* Double Fault */
85 case 9: /* Invalid TSS */
86 case 11: /* Segment not present */
87 case 12: /* Stack fault */
88 case 13: /* General Protection Fault */
89 siginfo.si_signo = SIGSEGV;
90 siginfo.si_code = 0;
91 break;
92
93 case 16: /* Pending FP error */
94 {
95 unsigned long fsr, fcr;
96
97 fsr = ia64_getreg(_IA64_REG_AR_FSR);
98 fcr = ia64_getreg(_IA64_REG_AR_FCR);
99
100 siginfo.si_signo = SIGFPE;
101 /*
102 * (~cwd & swd) will mask out exceptions that are not set to unmasked
103 * status. 0x3f is the exception bits in these regs, 0x200 is the
104 * C1 reg you need in case of a stack fault, 0x040 is the stack
105 * fault bit. We should only be taking one exception at a time,
106 * so if this combination doesn't produce any single exception,
107 * then we have a bad program that isn't synchronizing its FPU usage
108 * and it will suffer the consequences since we won't be able to
109 * fully reproduce the context of the exception
110 */
111 siginfo.si_isr = isr;
112 siginfo.si_flags = __ISR_VALID;
113 switch(((~fcr) & (fsr & 0x3f)) | (fsr & 0x240)) {
114 case 0x000:
115 default:
116 siginfo.si_code = 0;
117 break;
118 case 0x001: /* Invalid Op */
119 case 0x040: /* Stack Fault */
120 case 0x240: /* Stack Fault | Direction */
121 siginfo.si_code = FPE_FLTINV;
122 break;
123 case 0x002: /* Denormalize */
124 case 0x010: /* Underflow */
125 siginfo.si_code = FPE_FLTUND;
126 break;
127 case 0x004: /* Zero Divide */
128 siginfo.si_code = FPE_FLTDIV;
129 break;
130 case 0x008: /* Overflow */
131 siginfo.si_code = FPE_FLTOVF;
132 break;
133 case 0x020: /* Precision */
134 siginfo.si_code = FPE_FLTRES;
135 break;
136 }
137
138 break;
139 }
140
141 case 17: /* Alignment check */
142 siginfo.si_signo = SIGSEGV;
143 siginfo.si_code = BUS_ADRALN;
144 break;
145
146 case 19: /* SSE Numeric error */
147 siginfo.si_signo = SIGFPE;
148 siginfo.si_code = 0;
149 break;
150
151 default:
152 return -1;
153 }
154 force_sig_info(siginfo.si_signo, &siginfo, current);
155 return 0;
156}
diff --git a/arch/ia64/ia32/ia32priv.h b/arch/ia64/ia32/ia32priv.h
deleted file mode 100644
index 0f15349c3c6b..000000000000
--- a/arch/ia64/ia32/ia32priv.h
+++ /dev/null
@@ -1,532 +0,0 @@
1#ifndef _ASM_IA64_IA32_PRIV_H
2#define _ASM_IA64_IA32_PRIV_H
3
4
5#include <asm/ia32.h>
6
7#ifdef CONFIG_IA32_SUPPORT
8
9#include <linux/binfmts.h>
10#include <linux/compat.h>
11#include <linux/rbtree.h>
12
13#include <asm/processor.h>
14
15/*
16 * 32 bit structures for IA32 support.
17 */
18
19#define IA32_PAGE_SIZE (1UL << IA32_PAGE_SHIFT)
20#define IA32_PAGE_MASK (~(IA32_PAGE_SIZE - 1))
21#define IA32_PAGE_ALIGN(addr) (((addr) + IA32_PAGE_SIZE - 1) & IA32_PAGE_MASK)
22#define IA32_CLOCKS_PER_SEC 100 /* Cast in stone for IA32 Linux */
23
24/*
25 * partially mapped pages provide precise accounting of which 4k sub pages
26 * are mapped and which ones are not, thereby improving IA-32 compatibility.
27 */
28struct ia64_partial_page {
29 struct ia64_partial_page *next; /* linked list, sorted by address */
30 struct rb_node pp_rb;
31 /* 64K is the largest "normal" page supported by ia64 ABI. So 4K*64
32 * should suffice.*/
33 unsigned long bitmap;
34 unsigned int base;
35};
36
37struct ia64_partial_page_list {
38 struct ia64_partial_page *pp_head; /* list head, points to the lowest
39 * addressed partial page */
40 struct rb_root ppl_rb;
41 struct ia64_partial_page *pp_hint; /* pp_hint->next is the last
42 * accessed partial page */
43 atomic_t pp_count; /* reference count */
44};
45
46#if PAGE_SHIFT > IA32_PAGE_SHIFT
47struct ia64_partial_page_list* ia32_init_pp_list (void);
48#else
49# define ia32_init_pp_list() 0
50#endif
51
52/* sigcontext.h */
53/*
54 * As documented in the iBCS2 standard..
55 *
56 * The first part of "struct _fpstate" is just the
57 * normal i387 hardware setup, the extra "status"
58 * word is used to save the coprocessor status word
59 * before entering the handler.
60 */
61struct _fpreg_ia32 {
62 unsigned short significand[4];
63 unsigned short exponent;
64};
65
66struct _fpxreg_ia32 {
67 unsigned short significand[4];
68 unsigned short exponent;
69 unsigned short padding[3];
70};
71
72struct _xmmreg_ia32 {
73 unsigned int element[4];
74};
75
76
77struct _fpstate_ia32 {
78 unsigned int cw,
79 sw,
80 tag,
81 ipoff,
82 cssel,
83 dataoff,
84 datasel;
85 struct _fpreg_ia32 _st[8];
86 unsigned short status;
87 unsigned short magic; /* 0xffff = regular FPU data only */
88
89 /* FXSR FPU environment */
90 unsigned int _fxsr_env[6]; /* FXSR FPU env is ignored */
91 unsigned int mxcsr;
92 unsigned int reserved;
93 struct _fpxreg_ia32 _fxsr_st[8]; /* FXSR FPU reg data is ignored */
94 struct _xmmreg_ia32 _xmm[8];
95 unsigned int padding[56];
96};
97
98struct sigcontext_ia32 {
99 unsigned short gs, __gsh;
100 unsigned short fs, __fsh;
101 unsigned short es, __esh;
102 unsigned short ds, __dsh;
103 unsigned int edi;
104 unsigned int esi;
105 unsigned int ebp;
106 unsigned int esp;
107 unsigned int ebx;
108 unsigned int edx;
109 unsigned int ecx;
110 unsigned int eax;
111 unsigned int trapno;
112 unsigned int err;
113 unsigned int eip;
114 unsigned short cs, __csh;
115 unsigned int eflags;
116 unsigned int esp_at_signal;
117 unsigned short ss, __ssh;
118 unsigned int fpstate; /* really (struct _fpstate_ia32 *) */
119 unsigned int oldmask;
120 unsigned int cr2;
121};
122
123/* user.h */
124/*
125 * IA32 (Pentium III/4) FXSR, SSE support
126 *
127 * Provide support for the GDB 5.0+ PTRACE_{GET|SET}FPXREGS requests for
128 * interacting with the FXSR-format floating point environment. Floating
129 * point data can be accessed in the regular format in the usual manner,
130 * and both the standard and SIMD floating point data can be accessed via
131 * the new ptrace requests. In either case, changes to the FPU environment
132 * will be reflected in the task's state as expected.
133 */
134struct ia32_user_i387_struct {
135 int cwd;
136 int swd;
137 int twd;
138 int fip;
139 int fcs;
140 int foo;
141 int fos;
142 /* 8*10 bytes for each FP-reg = 80 bytes */
143 struct _fpreg_ia32 st_space[8];
144};
145
146struct ia32_user_fxsr_struct {
147 unsigned short cwd;
148 unsigned short swd;
149 unsigned short twd;
150 unsigned short fop;
151 int fip;
152 int fcs;
153 int foo;
154 int fos;
155 int mxcsr;
156 int reserved;
157 int st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
158 int xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */
159 int padding[56];
160};
161
162/* signal.h */
163#define IA32_SET_SA_HANDLER(ka,handler,restorer) \
164 ((ka)->sa.sa_handler = (__sighandler_t) \
165 (((unsigned long)(restorer) << 32) \
166 | ((handler) & 0xffffffff)))
167#define IA32_SA_HANDLER(ka) ((unsigned long) (ka)->sa.sa_handler & 0xffffffff)
168#define IA32_SA_RESTORER(ka) ((unsigned long) (ka)->sa.sa_handler >> 32)
169
170#define __IA32_NR_sigreturn 119
171#define __IA32_NR_rt_sigreturn 173
172
173struct sigaction32 {
174 unsigned int sa_handler; /* Really a pointer, but need to deal with 32 bits */
175 unsigned int sa_flags;
176 unsigned int sa_restorer; /* Another 32 bit pointer */
177 compat_sigset_t sa_mask; /* A 32 bit mask */
178};
179
180struct old_sigaction32 {
181 unsigned int sa_handler; /* Really a pointer, but need to deal
182 with 32 bits */
183 compat_old_sigset_t sa_mask; /* A 32 bit mask */
184 unsigned int sa_flags;
185 unsigned int sa_restorer; /* Another 32 bit pointer */
186};
187
188typedef struct sigaltstack_ia32 {
189 unsigned int ss_sp;
190 int ss_flags;
191 unsigned int ss_size;
192} stack_ia32_t;
193
194struct ucontext_ia32 {
195 unsigned int uc_flags;
196 unsigned int uc_link;
197 stack_ia32_t uc_stack;
198 struct sigcontext_ia32 uc_mcontext;
199 sigset_t uc_sigmask; /* mask last for extensibility */
200};
201
202struct stat64 {
203 unsigned long long st_dev;
204 unsigned char __pad0[4];
205 unsigned int __st_ino;
206 unsigned int st_mode;
207 unsigned int st_nlink;
208 unsigned int st_uid;
209 unsigned int st_gid;
210 unsigned long long st_rdev;
211 unsigned char __pad3[4];
212 unsigned int st_size_lo;
213 unsigned int st_size_hi;
214 unsigned int st_blksize;
215 unsigned int st_blocks; /* Number 512-byte blocks allocated. */
216 unsigned int __pad4; /* future possible st_blocks high bits */
217 unsigned int st_atime;
218 unsigned int st_atime_nsec;
219 unsigned int st_mtime;
220 unsigned int st_mtime_nsec;
221 unsigned int st_ctime;
222 unsigned int st_ctime_nsec;
223 unsigned int st_ino_lo;
224 unsigned int st_ino_hi;
225};
226
227typedef struct compat_siginfo {
228 int si_signo;
229 int si_errno;
230 int si_code;
231
232 union {
233 int _pad[((128/sizeof(int)) - 3)];
234
235 /* kill() */
236 struct {
237 unsigned int _pid; /* sender's pid */
238 unsigned int _uid; /* sender's uid */
239 } _kill;
240
241 /* POSIX.1b timers */
242 struct {
243 compat_timer_t _tid; /* timer id */
244 int _overrun; /* overrun count */
245 char _pad[sizeof(unsigned int) - sizeof(int)];
246 compat_sigval_t _sigval; /* same as below */
247 int _sys_private; /* not to be passed to user */
248 } _timer;
249
250 /* POSIX.1b signals */
251 struct {
252 unsigned int _pid; /* sender's pid */
253 unsigned int _uid; /* sender's uid */
254 compat_sigval_t _sigval;
255 } _rt;
256
257 /* SIGCHLD */
258 struct {
259 unsigned int _pid; /* which child */
260 unsigned int _uid; /* sender's uid */
261 int _status; /* exit code */
262 compat_clock_t _utime;
263 compat_clock_t _stime;
264 } _sigchld;
265
266 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
267 struct {
268 unsigned int _addr; /* faulting insn/memory ref. */
269 } _sigfault;
270
271 /* SIGPOLL */
272 struct {
273 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
274 int _fd;
275 } _sigpoll;
276 } _sifields;
277} compat_siginfo_t;
278
279/*
280 * IA-32 ELF specific definitions for IA-64.
281 */
282
283#define _ASM_IA64_ELF_H /* Don't include elf.h */
284
285#include <linux/sched.h>
286
287/*
288 * This is used to ensure we don't load something for the wrong architecture.
289 */
290#define elf_check_arch(x) ((x)->e_machine == EM_386)
291
292/*
293 * These are used to set parameters in the core dumps.
294 */
295#define ELF_CLASS ELFCLASS32
296#define ELF_DATA ELFDATA2LSB
297#define ELF_ARCH EM_386
298
299#define IA32_STACK_TOP IA32_PAGE_OFFSET
300#define IA32_GATE_OFFSET IA32_PAGE_OFFSET
301#define IA32_GATE_END IA32_PAGE_OFFSET + PAGE_SIZE
302
303/*
304 * The system segments (GDT, TSS, LDT) have to be mapped below 4GB so the IA-32 engine can
305 * access them.
306 */
307#define IA32_GDT_OFFSET (IA32_PAGE_OFFSET + PAGE_SIZE)
308#define IA32_TSS_OFFSET (IA32_PAGE_OFFSET + 2*PAGE_SIZE)
309#define IA32_LDT_OFFSET (IA32_PAGE_OFFSET + 3*PAGE_SIZE)
310
311#define ELF_EXEC_PAGESIZE IA32_PAGE_SIZE
312
313/*
314 * This is the location that an ET_DYN program is loaded if exec'ed.
315 * Typical use of this is to invoke "./ld.so someprog" to test out a
316 * new version of the loader. We need to make sure that it is out of
317 * the way of the program that it will "exec", and that there is
318 * sufficient room for the brk.
319 */
320#define ELF_ET_DYN_BASE (IA32_PAGE_OFFSET/3 + 0x1000000)
321
322void ia64_elf32_init(struct pt_regs *regs);
323#define ELF_PLAT_INIT(_r, load_addr) ia64_elf32_init(_r)
324
325/* This macro yields a bitmask that programs can use to figure out
326 what instruction set this CPU supports. */
327#define ELF_HWCAP 0
328
329/* This macro yields a string that ld.so will use to load
330 implementation specific libraries for optimization. Not terribly
331 relevant until we have real hardware to play with... */
332#define ELF_PLATFORM NULL
333
334#ifdef __KERNEL__
335# define SET_PERSONALITY(EX) \
336 (current->personality = PER_LINUX)
337#endif
338
339#define IA32_EFLAG 0x200
340
341/*
342 * IA-32 ELF specific definitions for IA-64.
343 */
344
345#define __USER_CS 0x23
346#define __USER_DS 0x2B
347
348/*
349 * The per-cpu GDT has 32 entries: see <asm-i386/segment.h>
350 */
351#define GDT_ENTRIES 32
352
353#define GDT_SIZE (GDT_ENTRIES * 8)
354
355#define TSS_ENTRY 14
356#define LDT_ENTRY (TSS_ENTRY + 1)
357
358#define IA32_SEGSEL_RPL (0x3 << 0)
359#define IA32_SEGSEL_TI (0x1 << 2)
360#define IA32_SEGSEL_INDEX_SHIFT 3
361
362#define _TSS ((unsigned long) TSS_ENTRY << IA32_SEGSEL_INDEX_SHIFT)
363#define _LDT ((unsigned long) LDT_ENTRY << IA32_SEGSEL_INDEX_SHIFT)
364
365#define IA32_SEG_BASE 16
366#define IA32_SEG_TYPE 40
367#define IA32_SEG_SYS 44
368#define IA32_SEG_DPL 45
369#define IA32_SEG_P 47
370#define IA32_SEG_HIGH_LIMIT 48
371#define IA32_SEG_AVL 52
372#define IA32_SEG_DB 54
373#define IA32_SEG_G 55
374#define IA32_SEG_HIGH_BASE 56
375
376#define IA32_SEG_DESCRIPTOR(base, limit, segtype, nonsysseg, dpl, segpresent, avl, segdb, gran) \
377 (((limit) & 0xffff) \
378 | (((unsigned long) (base) & 0xffffff) << IA32_SEG_BASE) \
379 | ((unsigned long) (segtype) << IA32_SEG_TYPE) \
380 | ((unsigned long) (nonsysseg) << IA32_SEG_SYS) \
381 | ((unsigned long) (dpl) << IA32_SEG_DPL) \
382 | ((unsigned long) (segpresent) << IA32_SEG_P) \
383 | ((((unsigned long) (limit) >> 16) & 0xf) << IA32_SEG_HIGH_LIMIT) \
384 | ((unsigned long) (avl) << IA32_SEG_AVL) \
385 | ((unsigned long) (segdb) << IA32_SEG_DB) \
386 | ((unsigned long) (gran) << IA32_SEG_G) \
387 | ((((unsigned long) (base) >> 24) & 0xff) << IA32_SEG_HIGH_BASE))
388
389#define SEG_LIM 32
390#define SEG_TYPE 52
391#define SEG_SYS 56
392#define SEG_DPL 57
393#define SEG_P 59
394#define SEG_AVL 60
395#define SEG_DB 62
396#define SEG_G 63
397
398/* Unscramble an IA-32 segment descriptor into the IA-64 format. */
399#define IA32_SEG_UNSCRAMBLE(sd) \
400 ( (((sd) >> IA32_SEG_BASE) & 0xffffff) | ((((sd) >> IA32_SEG_HIGH_BASE) & 0xff) << 24) \
401 | ((((sd) & 0xffff) | ((((sd) >> IA32_SEG_HIGH_LIMIT) & 0xf) << 16)) << SEG_LIM) \
402 | ((((sd) >> IA32_SEG_TYPE) & 0xf) << SEG_TYPE) \
403 | ((((sd) >> IA32_SEG_SYS) & 0x1) << SEG_SYS) \
404 | ((((sd) >> IA32_SEG_DPL) & 0x3) << SEG_DPL) \
405 | ((((sd) >> IA32_SEG_P) & 0x1) << SEG_P) \
406 | ((((sd) >> IA32_SEG_AVL) & 0x1) << SEG_AVL) \
407 | ((((sd) >> IA32_SEG_DB) & 0x1) << SEG_DB) \
408 | ((((sd) >> IA32_SEG_G) & 0x1) << SEG_G))
409
410#define IA32_IOBASE 0x2000000000000000UL /* Virtual address for I/O space */
411
412#define IA32_CR0 0x80000001 /* Enable PG and PE bits */
413#define IA32_CR4 0x600 /* MMXEX and FXSR on */
414
415/*
416 * IA32 floating point control registers starting values
417 */
418
419#define IA32_FSR_DEFAULT 0x55550000 /* set all tag bits */
420#define IA32_FCR_DEFAULT 0x17800000037fUL /* extended precision, all masks */
421
422#define IA32_PTRACE_GETREGS 12
423#define IA32_PTRACE_SETREGS 13
424#define IA32_PTRACE_GETFPREGS 14
425#define IA32_PTRACE_SETFPREGS 15
426#define IA32_PTRACE_GETFPXREGS 18
427#define IA32_PTRACE_SETFPXREGS 19
428
429#define ia32_start_thread(regs,new_ip,new_sp) do { \
430 set_fs(USER_DS); \
431 ia64_psr(regs)->cpl = 3; /* set user mode */ \
432 ia64_psr(regs)->ri = 0; /* clear return slot number */ \
433 ia64_psr(regs)->is = 1; /* IA-32 instruction set */ \
434 regs->cr_iip = new_ip; \
435 regs->ar_rsc = 0xc; /* enforced lazy mode, priv. level 3 */ \
436 regs->ar_rnat = 0; \
437 regs->loadrs = 0; \
438 regs->r12 = new_sp; \
439} while (0)
440
441/*
442 * Local Descriptor Table (LDT) related declarations.
443 */
444
445#define IA32_LDT_ENTRIES 8192 /* Maximum number of LDT entries supported. */
446#define IA32_LDT_ENTRY_SIZE 8 /* The size of each LDT entry. */
447
448#define LDT_entry_a(info) \
449 ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
450
451#define LDT_entry_b(info) \
452 (((info)->base_addr & 0xff000000) | \
453 (((info)->base_addr & 0x00ff0000) >> 16) | \
454 ((info)->limit & 0xf0000) | \
455 (((info)->read_exec_only ^ 1) << 9) | \
456 ((info)->contents << 10) | \
457 (((info)->seg_not_present ^ 1) << 15) | \
458 ((info)->seg_32bit << 22) | \
459 ((info)->limit_in_pages << 23) | \
460 ((info)->useable << 20) | \
461 0x7100)
462
463#define LDT_empty(info) ( \
464 (info)->base_addr == 0 && \
465 (info)->limit == 0 && \
466 (info)->contents == 0 && \
467 (info)->read_exec_only == 1 && \
468 (info)->seg_32bit == 0 && \
469 (info)->limit_in_pages == 0 && \
470 (info)->seg_not_present == 1 && \
471 (info)->useable == 0 )
472
473static inline void
474load_TLS (struct thread_struct *t, unsigned int cpu)
475{
476 extern unsigned long *cpu_gdt_table[NR_CPUS];
477
478 memcpy(cpu_gdt_table[cpu] + GDT_ENTRY_TLS_MIN + 0, &t->tls_array[0], sizeof(long));
479 memcpy(cpu_gdt_table[cpu] + GDT_ENTRY_TLS_MIN + 1, &t->tls_array[1], sizeof(long));
480 memcpy(cpu_gdt_table[cpu] + GDT_ENTRY_TLS_MIN + 2, &t->tls_array[2], sizeof(long));
481}
482
483struct ia32_user_desc {
484 unsigned int entry_number;
485 unsigned int base_addr;
486 unsigned int limit;
487 unsigned int seg_32bit:1;
488 unsigned int contents:2;
489 unsigned int read_exec_only:1;
490 unsigned int limit_in_pages:1;
491 unsigned int seg_not_present:1;
492 unsigned int useable:1;
493};
494
495struct linux_binprm;
496
497extern void ia32_init_addr_space (struct pt_regs *regs);
498extern int ia32_setup_arg_pages (struct linux_binprm *bprm, int exec_stack);
499extern unsigned long ia32_do_mmap (struct file *, unsigned long, unsigned long, int, int, loff_t);
500extern void ia32_load_segment_descriptors (struct task_struct *task);
501
502#define ia32f2ia64f(dst,src) \
503do { \
504 ia64_ldfe(6,src); \
505 ia64_stop(); \
506 ia64_stf_spill(dst, 6); \
507} while(0)
508
509#define ia64f2ia32f(dst,src) \
510do { \
511 ia64_ldf_fill(6, src); \
512 ia64_stop(); \
513 ia64_stfe(dst, 6); \
514} while(0)
515
516struct user_regs_struct32 {
517 __u32 ebx, ecx, edx, esi, edi, ebp, eax;
518 unsigned short ds, __ds, es, __es;
519 unsigned short fs, __fs, gs, __gs;
520 __u32 orig_eax, eip;
521 unsigned short cs, __cs;
522 __u32 eflags, esp;
523 unsigned short ss, __ss;
524};
525
526/* Prototypes for use in elfcore32.h */
527extern int save_ia32_fpstate (struct task_struct *, struct ia32_user_i387_struct __user *);
528extern int save_ia32_fpxstate (struct task_struct *, struct ia32_user_fxsr_struct __user *);
529
530#endif /* !CONFIG_IA32_SUPPORT */
531
532#endif /* _ASM_IA64_IA32_PRIV_H */
diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
deleted file mode 100644
index 045b746b9808..000000000000
--- a/arch/ia64/ia32/sys_ia32.c
+++ /dev/null
@@ -1,2765 +0,0 @@
1/*
2 * sys_ia32.c: Conversion between 32bit and 64bit native syscalls. Derived from sys_sparc32.c.
3 *
4 * Copyright (C) 2000 VA Linux Co
5 * Copyright (C) 2000 Don Dugger <n0ano@valinux.com>
6 * Copyright (C) 1999 Arun Sharma <arun.sharma@intel.com>
7 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
8 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
9 * Copyright (C) 2000-2003, 2005 Hewlett-Packard Co
10 * David Mosberger-Tang <davidm@hpl.hp.com>
11 * Copyright (C) 2004 Gordon Jin <gordon.jin@intel.com>
12 *
13 * These routines maintain argument size conversion between 32bit and 64bit
14 * environment.
15 */
16
17#include <linux/kernel.h>
18#include <linux/syscalls.h>
19#include <linux/sysctl.h>
20#include <linux/sched.h>
21#include <linux/fs.h>
22#include <linux/file.h>
23#include <linux/signal.h>
24#include <linux/resource.h>
25#include <linux/times.h>
26#include <linux/utsname.h>
27#include <linux/smp.h>
28#include <linux/smp_lock.h>
29#include <linux/sem.h>
30#include <linux/msg.h>
31#include <linux/mm.h>
32#include <linux/shm.h>
33#include <linux/slab.h>
34#include <linux/uio.h>
35#include <linux/socket.h>
36#include <linux/quota.h>
37#include <linux/poll.h>
38#include <linux/eventpoll.h>
39#include <linux/personality.h>
40#include <linux/ptrace.h>
41#include <linux/regset.h>
42#include <linux/stat.h>
43#include <linux/ipc.h>
44#include <linux/capability.h>
45#include <linux/compat.h>
46#include <linux/vfs.h>
47#include <linux/mman.h>
48#include <linux/mutex.h>
49
50#include <asm/intrinsics.h>
51#include <asm/types.h>
52#include <asm/uaccess.h>
53#include <asm/unistd.h>
54
55#include "ia32priv.h"
56
57#include <net/scm.h>
58#include <net/sock.h>
59
60#define DEBUG 0
61
62#if DEBUG
63# define DBG(fmt...) printk(KERN_DEBUG fmt)
64#else
65# define DBG(fmt...)
66#endif
67
68#define ROUND_UP(x,a) ((__typeof__(x))(((unsigned long)(x) + ((a) - 1)) & ~((a) - 1)))
69
70#define OFFSET4K(a) ((a) & 0xfff)
71#define PAGE_START(addr) ((addr) & PAGE_MASK)
72#define MINSIGSTKSZ_IA32 2048
73
74#define high2lowuid(uid) ((uid) > 65535 ? 65534 : (uid))
75#define high2lowgid(gid) ((gid) > 65535 ? 65534 : (gid))
76
77/*
78 * Anything that modifies or inspects ia32 user virtual memory must hold this semaphore
79 * while doing so.
80 */
81/* XXX make per-mm: */
82static DEFINE_MUTEX(ia32_mmap_mutex);
83
84asmlinkage long
85sys32_execve (char __user *name, compat_uptr_t __user *argv, compat_uptr_t __user *envp,
86 struct pt_regs *regs)
87{
88 long error;
89 char *filename;
90 unsigned long old_map_base, old_task_size, tssd;
91
92 filename = getname(name);
93 error = PTR_ERR(filename);
94 if (IS_ERR(filename))
95 return error;
96
97 old_map_base = current->thread.map_base;
98 old_task_size = current->thread.task_size;
99 tssd = ia64_get_kr(IA64_KR_TSSD);
100
101 /* we may be exec'ing a 64-bit process: reset map base, task-size, and io-base: */
102 current->thread.map_base = DEFAULT_MAP_BASE;
103 current->thread.task_size = DEFAULT_TASK_SIZE;
104 ia64_set_kr(IA64_KR_IO_BASE, current->thread.old_iob);
105 ia64_set_kr(IA64_KR_TSSD, current->thread.old_k1);
106
107 error = compat_do_execve(filename, argv, envp, regs);
108 putname(filename);
109
110 if (error < 0) {
111 /* oops, execve failed, switch back to old values... */
112 ia64_set_kr(IA64_KR_IO_BASE, IA32_IOBASE);
113 ia64_set_kr(IA64_KR_TSSD, tssd);
114 current->thread.map_base = old_map_base;
115 current->thread.task_size = old_task_size;
116 }
117
118 return error;
119}
120
121
122#if PAGE_SHIFT > IA32_PAGE_SHIFT
123
124
125static int
126get_page_prot (struct vm_area_struct *vma, unsigned long addr)
127{
128 int prot = 0;
129
130 if (!vma || vma->vm_start > addr)
131 return 0;
132
133 if (vma->vm_flags & VM_READ)
134 prot |= PROT_READ;
135 if (vma->vm_flags & VM_WRITE)
136 prot |= PROT_WRITE;
137 if (vma->vm_flags & VM_EXEC)
138 prot |= PROT_EXEC;
139 return prot;
140}
141
142/*
143 * Map a subpage by creating an anonymous page that contains the union of the old page and
144 * the subpage.
145 */
146static unsigned long
147mmap_subpage (struct file *file, unsigned long start, unsigned long end, int prot, int flags,
148 loff_t off)
149{
150 void *page = NULL;
151 struct inode *inode;
152 unsigned long ret = 0;
153 struct vm_area_struct *vma = find_vma(current->mm, start);
154 int old_prot = get_page_prot(vma, start);
155
156 DBG("mmap_subpage(file=%p,start=0x%lx,end=0x%lx,prot=%x,flags=%x,off=0x%llx)\n",
157 file, start, end, prot, flags, off);
158
159
160 /* Optimize the case where the old mmap and the new mmap are both anonymous */
161 if ((old_prot & PROT_WRITE) && (flags & MAP_ANONYMOUS) && !vma->vm_file) {
162 if (clear_user((void __user *) start, end - start)) {
163 ret = -EFAULT;
164 goto out;
165 }
166 goto skip_mmap;
167 }
168
169 page = (void *) get_zeroed_page(GFP_KERNEL);
170 if (!page)
171 return -ENOMEM;
172
173 if (old_prot)
174 copy_from_user(page, (void __user *) PAGE_START(start), PAGE_SIZE);
175
176 down_write(&current->mm->mmap_sem);
177 {
178 ret = do_mmap(NULL, PAGE_START(start), PAGE_SIZE, prot | PROT_WRITE,
179 flags | MAP_FIXED | MAP_ANONYMOUS, 0);
180 }
181 up_write(&current->mm->mmap_sem);
182
183 if (IS_ERR((void *) ret))
184 goto out;
185
186 if (old_prot) {
187 /* copy back the old page contents. */
188 if (offset_in_page(start))
189 copy_to_user((void __user *) PAGE_START(start), page,
190 offset_in_page(start));
191 if (offset_in_page(end))
192 copy_to_user((void __user *) end, page + offset_in_page(end),
193 PAGE_SIZE - offset_in_page(end));
194 }
195
196 if (!(flags & MAP_ANONYMOUS)) {
197 /* read the file contents */
198 inode = file->f_path.dentry->d_inode;
199 if (!inode->i_fop || !file->f_op->read
200 || ((*file->f_op->read)(file, (char __user *) start, end - start, &off) < 0))
201 {
202 ret = -EINVAL;
203 goto out;
204 }
205 }
206
207 skip_mmap:
208 if (!(prot & PROT_WRITE))
209 ret = sys_mprotect(PAGE_START(start), PAGE_SIZE, prot | old_prot);
210 out:
211 if (page)
212 free_page((unsigned long) page);
213 return ret;
214}
215
216/* SLAB cache for ia64_partial_page structures */
217struct kmem_cache *ia64_partial_page_cachep;
218
219/*
220 * init ia64_partial_page_list.
221 * return 0 means kmalloc fail.
222 */
223struct ia64_partial_page_list*
224ia32_init_pp_list(void)
225{
226 struct ia64_partial_page_list *p;
227
228 if ((p = kmalloc(sizeof(*p), GFP_KERNEL)) == NULL)
229 return p;
230 p->pp_head = NULL;
231 p->ppl_rb = RB_ROOT;
232 p->pp_hint = NULL;
233 atomic_set(&p->pp_count, 1);
234 return p;
235}
236
237/*
238 * Search for the partial page with @start in partial page list @ppl.
239 * If finds the partial page, return the found partial page.
240 * Else, return 0 and provide @pprev, @rb_link, @rb_parent to
241 * be used by later __ia32_insert_pp().
242 */
243static struct ia64_partial_page *
244__ia32_find_pp(struct ia64_partial_page_list *ppl, unsigned int start,
245 struct ia64_partial_page **pprev, struct rb_node ***rb_link,
246 struct rb_node **rb_parent)
247{
248 struct ia64_partial_page *pp;
249 struct rb_node **__rb_link, *__rb_parent, *rb_prev;
250
251 pp = ppl->pp_hint;
252 if (pp && pp->base == start)
253 return pp;
254
255 __rb_link = &ppl->ppl_rb.rb_node;
256 rb_prev = __rb_parent = NULL;
257
258 while (*__rb_link) {
259 __rb_parent = *__rb_link;
260 pp = rb_entry(__rb_parent, struct ia64_partial_page, pp_rb);
261
262 if (pp->base == start) {
263 ppl->pp_hint = pp;
264 return pp;
265 } else if (pp->base < start) {
266 rb_prev = __rb_parent;
267 __rb_link = &__rb_parent->rb_right;
268 } else {
269 __rb_link = &__rb_parent->rb_left;
270 }
271 }
272
273 *rb_link = __rb_link;
274 *rb_parent = __rb_parent;
275 *pprev = NULL;
276 if (rb_prev)
277 *pprev = rb_entry(rb_prev, struct ia64_partial_page, pp_rb);
278 return NULL;
279}
280
281/*
282 * insert @pp into @ppl.
283 */
284static void
285__ia32_insert_pp(struct ia64_partial_page_list *ppl,
286 struct ia64_partial_page *pp, struct ia64_partial_page *prev,
287 struct rb_node **rb_link, struct rb_node *rb_parent)
288{
289 /* link list */
290 if (prev) {
291 pp->next = prev->next;
292 prev->next = pp;
293 } else {
294 ppl->pp_head = pp;
295 if (rb_parent)
296 pp->next = rb_entry(rb_parent,
297 struct ia64_partial_page, pp_rb);
298 else
299 pp->next = NULL;
300 }
301
302 /* link rb */
303 rb_link_node(&pp->pp_rb, rb_parent, rb_link);
304 rb_insert_color(&pp->pp_rb, &ppl->ppl_rb);
305
306 ppl->pp_hint = pp;
307}
308
309/*
310 * delete @pp from partial page list @ppl.
311 */
312static void
313__ia32_delete_pp(struct ia64_partial_page_list *ppl,
314 struct ia64_partial_page *pp, struct ia64_partial_page *prev)
315{
316 if (prev) {
317 prev->next = pp->next;
318 if (ppl->pp_hint == pp)
319 ppl->pp_hint = prev;
320 } else {
321 ppl->pp_head = pp->next;
322 if (ppl->pp_hint == pp)
323 ppl->pp_hint = pp->next;
324 }
325 rb_erase(&pp->pp_rb, &ppl->ppl_rb);
326 kmem_cache_free(ia64_partial_page_cachep, pp);
327}
328
329static struct ia64_partial_page *
330__pp_prev(struct ia64_partial_page *pp)
331{
332 struct rb_node *prev = rb_prev(&pp->pp_rb);
333 if (prev)
334 return rb_entry(prev, struct ia64_partial_page, pp_rb);
335 else
336 return NULL;
337}
338
339/*
340 * Delete partial pages with address between @start and @end.
341 * @start and @end are page aligned.
342 */
343static void
344__ia32_delete_pp_range(unsigned int start, unsigned int end)
345{
346 struct ia64_partial_page *pp, *prev;
347 struct rb_node **rb_link, *rb_parent;
348
349 if (start >= end)
350 return;
351
352 pp = __ia32_find_pp(current->thread.ppl, start, &prev,
353 &rb_link, &rb_parent);
354 if (pp)
355 prev = __pp_prev(pp);
356 else {
357 if (prev)
358 pp = prev->next;
359 else
360 pp = current->thread.ppl->pp_head;
361 }
362
363 while (pp && pp->base < end) {
364 struct ia64_partial_page *tmp = pp->next;
365 __ia32_delete_pp(current->thread.ppl, pp, prev);
366 pp = tmp;
367 }
368}
369
370/*
371 * Set the range between @start and @end in bitmap.
372 * @start and @end should be IA32 page aligned and in the same IA64 page.
373 */
374static int
375__ia32_set_pp(unsigned int start, unsigned int end, int flags)
376{
377 struct ia64_partial_page *pp, *prev;
378 struct rb_node ** rb_link, *rb_parent;
379 unsigned int pstart, start_bit, end_bit, i;
380
381 pstart = PAGE_START(start);
382 start_bit = (start % PAGE_SIZE) / IA32_PAGE_SIZE;
383 end_bit = (end % PAGE_SIZE) / IA32_PAGE_SIZE;
384 if (end_bit == 0)
385 end_bit = PAGE_SIZE / IA32_PAGE_SIZE;
386 pp = __ia32_find_pp(current->thread.ppl, pstart, &prev,
387 &rb_link, &rb_parent);
388 if (pp) {
389 for (i = start_bit; i < end_bit; i++)
390 set_bit(i, &pp->bitmap);
391 /*
392 * Check: if this partial page has been set to a full page,
393 * then delete it.
394 */
395 if (find_first_zero_bit(&pp->bitmap, sizeof(pp->bitmap)*8) >=
396 PAGE_SIZE/IA32_PAGE_SIZE) {
397 __ia32_delete_pp(current->thread.ppl, pp, __pp_prev(pp));
398 }
399 return 0;
400 }
401
402 /*
403 * MAP_FIXED may lead to overlapping mmap.
404 * In this case, the requested mmap area may already mmaped as a full
405 * page. So check vma before adding a new partial page.
406 */
407 if (flags & MAP_FIXED) {
408 struct vm_area_struct *vma = find_vma(current->mm, pstart);
409 if (vma && vma->vm_start <= pstart)
410 return 0;
411 }
412
413 /* new a ia64_partial_page */
414 pp = kmem_cache_alloc(ia64_partial_page_cachep, GFP_KERNEL);
415 if (!pp)
416 return -ENOMEM;
417 pp->base = pstart;
418 pp->bitmap = 0;
419 for (i=start_bit; i<end_bit; i++)
420 set_bit(i, &(pp->bitmap));
421 pp->next = NULL;
422 __ia32_insert_pp(current->thread.ppl, pp, prev, rb_link, rb_parent);
423 return 0;
424}
425
426/*
427 * @start and @end should be IA32 page aligned, but don't need to be in the
428 * same IA64 page. Split @start and @end to make sure they're in the same IA64
429 * page, then call __ia32_set_pp().
430 */
431static void
432ia32_set_pp(unsigned int start, unsigned int end, int flags)
433{
434 down_write(&current->mm->mmap_sem);
435 if (flags & MAP_FIXED) {
436 /*
437 * MAP_FIXED may lead to overlapping mmap. When this happens,
438 * a series of complete IA64 pages results in deletion of
439 * old partial pages in that range.
440 */
441 __ia32_delete_pp_range(PAGE_ALIGN(start), PAGE_START(end));
442 }
443
444 if (end < PAGE_ALIGN(start)) {
445 __ia32_set_pp(start, end, flags);
446 } else {
447 if (offset_in_page(start))
448 __ia32_set_pp(start, PAGE_ALIGN(start), flags);
449 if (offset_in_page(end))
450 __ia32_set_pp(PAGE_START(end), end, flags);
451 }
452 up_write(&current->mm->mmap_sem);
453}
454
455/*
456 * Unset the range between @start and @end in bitmap.
457 * @start and @end should be IA32 page aligned and in the same IA64 page.
458 * After doing that, if the bitmap is 0, then free the page and return 1,
459 * else return 0;
460 * If not find the partial page in the list, then
461 * If the vma exists, then the full page is set to a partial page;
462 * Else return -ENOMEM.
463 */
464static int
465__ia32_unset_pp(unsigned int start, unsigned int end)
466{
467 struct ia64_partial_page *pp, *prev;
468 struct rb_node ** rb_link, *rb_parent;
469 unsigned int pstart, start_bit, end_bit, i;
470 struct vm_area_struct *vma;
471
472 pstart = PAGE_START(start);
473 start_bit = (start % PAGE_SIZE) / IA32_PAGE_SIZE;
474 end_bit = (end % PAGE_SIZE) / IA32_PAGE_SIZE;
475 if (end_bit == 0)
476 end_bit = PAGE_SIZE / IA32_PAGE_SIZE;
477
478 pp = __ia32_find_pp(current->thread.ppl, pstart, &prev,
479 &rb_link, &rb_parent);
480 if (pp) {
481 for (i = start_bit; i < end_bit; i++)
482 clear_bit(i, &pp->bitmap);
483 if (pp->bitmap == 0) {
484 __ia32_delete_pp(current->thread.ppl, pp, __pp_prev(pp));
485 return 1;
486 }
487 return 0;
488 }
489
490 vma = find_vma(current->mm, pstart);
491 if (!vma || vma->vm_start > pstart) {
492 return -ENOMEM;
493 }
494
495 /* new a ia64_partial_page */
496 pp = kmem_cache_alloc(ia64_partial_page_cachep, GFP_KERNEL);
497 if (!pp)
498 return -ENOMEM;
499 pp->base = pstart;
500 pp->bitmap = 0;
501 for (i = 0; i < start_bit; i++)
502 set_bit(i, &(pp->bitmap));
503 for (i = end_bit; i < PAGE_SIZE / IA32_PAGE_SIZE; i++)
504 set_bit(i, &(pp->bitmap));
505 pp->next = NULL;
506 __ia32_insert_pp(current->thread.ppl, pp, prev, rb_link, rb_parent);
507 return 0;
508}
509
510/*
511 * Delete pp between PAGE_ALIGN(start) and PAGE_START(end) by calling
512 * __ia32_delete_pp_range(). Unset possible partial pages by calling
513 * __ia32_unset_pp().
514 * The returned value see __ia32_unset_pp().
515 */
516static int
517ia32_unset_pp(unsigned int *startp, unsigned int *endp)
518{
519 unsigned int start = *startp, end = *endp;
520 int ret = 0;
521
522 down_write(&current->mm->mmap_sem);
523
524 __ia32_delete_pp_range(PAGE_ALIGN(start), PAGE_START(end));
525
526 if (end < PAGE_ALIGN(start)) {
527 ret = __ia32_unset_pp(start, end);
528 if (ret == 1) {
529 *startp = PAGE_START(start);
530 *endp = PAGE_ALIGN(end);
531 }
532 if (ret == 0) {
533 /* to shortcut sys_munmap() in sys32_munmap() */
534 *startp = PAGE_START(start);
535 *endp = PAGE_START(end);
536 }
537 } else {
538 if (offset_in_page(start)) {
539 ret = __ia32_unset_pp(start, PAGE_ALIGN(start));
540 if (ret == 1)
541 *startp = PAGE_START(start);
542 if (ret == 0)
543 *startp = PAGE_ALIGN(start);
544 if (ret < 0)
545 goto out;
546 }
547 if (offset_in_page(end)) {
548 ret = __ia32_unset_pp(PAGE_START(end), end);
549 if (ret == 1)
550 *endp = PAGE_ALIGN(end);
551 if (ret == 0)
552 *endp = PAGE_START(end);
553 }
554 }
555
556 out:
557 up_write(&current->mm->mmap_sem);
558 return ret;
559}
560
561/*
562 * Compare the range between @start and @end with bitmap in partial page.
563 * @start and @end should be IA32 page aligned and in the same IA64 page.
564 */
565static int
566__ia32_compare_pp(unsigned int start, unsigned int end)
567{
568 struct ia64_partial_page *pp, *prev;
569 struct rb_node ** rb_link, *rb_parent;
570 unsigned int pstart, start_bit, end_bit, size;
571 unsigned int first_bit, next_zero_bit; /* the first range in bitmap */
572
573 pstart = PAGE_START(start);
574
575 pp = __ia32_find_pp(current->thread.ppl, pstart, &prev,
576 &rb_link, &rb_parent);
577 if (!pp)
578 return 1;
579
580 start_bit = (start % PAGE_SIZE) / IA32_PAGE_SIZE;
581 end_bit = (end % PAGE_SIZE) / IA32_PAGE_SIZE;
582 size = sizeof(pp->bitmap) * 8;
583 first_bit = find_first_bit(&pp->bitmap, size);
584 next_zero_bit = find_next_zero_bit(&pp->bitmap, size, first_bit);
585 if ((start_bit < first_bit) || (end_bit > next_zero_bit)) {
586 /* exceeds the first range in bitmap */
587 return -ENOMEM;
588 } else if ((start_bit == first_bit) && (end_bit == next_zero_bit)) {
589 first_bit = find_next_bit(&pp->bitmap, size, next_zero_bit);
590 if ((next_zero_bit < first_bit) && (first_bit < size))
591 return 1; /* has next range */
592 else
593 return 0; /* no next range */
594 } else
595 return 1;
596}
597
598/*
599 * @start and @end should be IA32 page aligned, but don't need to be in the
600 * same IA64 page. Split @start and @end to make sure they're in the same IA64
601 * page, then call __ia32_compare_pp().
602 *
603 * Take this as example: the range is the 1st and 2nd 4K page.
604 * Return 0 if they fit bitmap exactly, i.e. bitmap = 00000011;
605 * Return 1 if the range doesn't cover whole bitmap, e.g. bitmap = 00001111;
606 * Return -ENOMEM if the range exceeds the bitmap, e.g. bitmap = 00000001 or
607 * bitmap = 00000101.
608 */
609static int
610ia32_compare_pp(unsigned int *startp, unsigned int *endp)
611{
612 unsigned int start = *startp, end = *endp;
613 int retval = 0;
614
615 down_write(&current->mm->mmap_sem);
616
617 if (end < PAGE_ALIGN(start)) {
618 retval = __ia32_compare_pp(start, end);
619 if (retval == 0) {
620 *startp = PAGE_START(start);
621 *endp = PAGE_ALIGN(end);
622 }
623 } else {
624 if (offset_in_page(start)) {
625 retval = __ia32_compare_pp(start,
626 PAGE_ALIGN(start));
627 if (retval == 0)
628 *startp = PAGE_START(start);
629 if (retval < 0)
630 goto out;
631 }
632 if (offset_in_page(end)) {
633 retval = __ia32_compare_pp(PAGE_START(end), end);
634 if (retval == 0)
635 *endp = PAGE_ALIGN(end);
636 }
637 }
638
639 out:
640 up_write(&current->mm->mmap_sem);
641 return retval;
642}
643
644static void
645__ia32_drop_pp_list(struct ia64_partial_page_list *ppl)
646{
647 struct ia64_partial_page *pp = ppl->pp_head;
648
649 while (pp) {
650 struct ia64_partial_page *next = pp->next;
651 kmem_cache_free(ia64_partial_page_cachep, pp);
652 pp = next;
653 }
654
655 kfree(ppl);
656}
657
658void
659ia32_drop_ia64_partial_page_list(struct task_struct *task)
660{
661 struct ia64_partial_page_list* ppl = task->thread.ppl;
662
663 if (ppl && atomic_dec_and_test(&ppl->pp_count))
664 __ia32_drop_pp_list(ppl);
665}
666
667/*
668 * Copy current->thread.ppl to ppl (already initialized).
669 */
670static int
671__ia32_copy_pp_list(struct ia64_partial_page_list *ppl)
672{
673 struct ia64_partial_page *pp, *tmp, *prev;
674 struct rb_node **rb_link, *rb_parent;
675
676 ppl->pp_head = NULL;
677 ppl->pp_hint = NULL;
678 ppl->ppl_rb = RB_ROOT;
679 rb_link = &ppl->ppl_rb.rb_node;
680 rb_parent = NULL;
681 prev = NULL;
682
683 for (pp = current->thread.ppl->pp_head; pp; pp = pp->next) {
684 tmp = kmem_cache_alloc(ia64_partial_page_cachep, GFP_KERNEL);
685 if (!tmp)
686 return -ENOMEM;
687 *tmp = *pp;
688 __ia32_insert_pp(ppl, tmp, prev, rb_link, rb_parent);
689 prev = tmp;
690 rb_link = &tmp->pp_rb.rb_right;
691 rb_parent = &tmp->pp_rb;
692 }
693 return 0;
694}
695
696int
697ia32_copy_ia64_partial_page_list(struct task_struct *p,
698 unsigned long clone_flags)
699{
700 int retval = 0;
701
702 if (clone_flags & CLONE_VM) {
703 atomic_inc(&current->thread.ppl->pp_count);
704 p->thread.ppl = current->thread.ppl;
705 } else {
706 p->thread.ppl = ia32_init_pp_list();
707 if (!p->thread.ppl)
708 return -ENOMEM;
709 down_write(&current->mm->mmap_sem);
710 {
711 retval = __ia32_copy_pp_list(p->thread.ppl);
712 }
713 up_write(&current->mm->mmap_sem);
714 }
715
716 return retval;
717}
718
719static unsigned long
720emulate_mmap (struct file *file, unsigned long start, unsigned long len, int prot, int flags,
721 loff_t off)
722{
723 unsigned long tmp, end, pend, pstart, ret, is_congruent, fudge = 0;
724 struct inode *inode;
725 loff_t poff;
726
727 end = start + len;
728 pstart = PAGE_START(start);
729 pend = PAGE_ALIGN(end);
730
731 if (flags & MAP_FIXED) {
732 ia32_set_pp((unsigned int)start, (unsigned int)end, flags);
733 if (start > pstart) {
734 if (flags & MAP_SHARED)
735 printk(KERN_INFO
736 "%s(%d): emulate_mmap() can't share head (addr=0x%lx)\n",
737 current->comm, task_pid_nr(current), start);
738 ret = mmap_subpage(file, start, min(PAGE_ALIGN(start), end), prot, flags,
739 off);
740 if (IS_ERR((void *) ret))
741 return ret;
742 pstart += PAGE_SIZE;
743 if (pstart >= pend)
744 goto out; /* done */
745 }
746 if (end < pend) {
747 if (flags & MAP_SHARED)
748 printk(KERN_INFO
749 "%s(%d): emulate_mmap() can't share tail (end=0x%lx)\n",
750 current->comm, task_pid_nr(current), end);
751 ret = mmap_subpage(file, max(start, PAGE_START(end)), end, prot, flags,
752 (off + len) - offset_in_page(end));
753 if (IS_ERR((void *) ret))
754 return ret;
755 pend -= PAGE_SIZE;
756 if (pstart >= pend)
757 goto out; /* done */
758 }
759 } else {
760 /*
761 * If a start address was specified, use it if the entire rounded out area
762 * is available.
763 */
764 if (start && !pstart)
765 fudge = 1; /* handle case of mapping to range (0,PAGE_SIZE) */
766 tmp = arch_get_unmapped_area(file, pstart - fudge, pend - pstart, 0, flags);
767 if (tmp != pstart) {
768 pstart = tmp;
769 start = pstart + offset_in_page(off); /* make start congruent with off */
770 end = start + len;
771 pend = PAGE_ALIGN(end);
772 }
773 }
774
775 poff = off + (pstart - start); /* note: (pstart - start) may be negative */
776 is_congruent = (flags & MAP_ANONYMOUS) || (offset_in_page(poff) == 0);
777
778 if ((flags & MAP_SHARED) && !is_congruent)
779 printk(KERN_INFO "%s(%d): emulate_mmap() can't share contents of incongruent mmap "
780 "(addr=0x%lx,off=0x%llx)\n", current->comm, task_pid_nr(current), start, off);
781
782 DBG("mmap_body: mapping [0x%lx-0x%lx) %s with poff 0x%llx\n", pstart, pend,
783 is_congruent ? "congruent" : "not congruent", poff);
784
785 down_write(&current->mm->mmap_sem);
786 {
787 if (!(flags & MAP_ANONYMOUS) && is_congruent)
788 ret = do_mmap(file, pstart, pend - pstart, prot, flags | MAP_FIXED, poff);
789 else
790 ret = do_mmap(NULL, pstart, pend - pstart,
791 prot | ((flags & MAP_ANONYMOUS) ? 0 : PROT_WRITE),
792 flags | MAP_FIXED | MAP_ANONYMOUS, 0);
793 }
794 up_write(&current->mm->mmap_sem);
795
796 if (IS_ERR((void *) ret))
797 return ret;
798
799 if (!is_congruent) {
800 /* read the file contents */
801 inode = file->f_path.dentry->d_inode;
802 if (!inode->i_fop || !file->f_op->read
803 || ((*file->f_op->read)(file, (char __user *) pstart, pend - pstart, &poff)
804 < 0))
805 {
806 sys_munmap(pstart, pend - pstart);
807 return -EINVAL;
808 }
809 if (!(prot & PROT_WRITE) && sys_mprotect(pstart, pend - pstart, prot) < 0)
810 return -EINVAL;
811 }
812
813 if (!(flags & MAP_FIXED))
814 ia32_set_pp((unsigned int)start, (unsigned int)end, flags);
815out:
816 return start;
817}
818
819#endif /* PAGE_SHIFT > IA32_PAGE_SHIFT */
820
821static inline unsigned int
822get_prot32 (unsigned int prot)
823{
824 if (prot & PROT_WRITE)
825 /* on x86, PROT_WRITE implies PROT_READ which implies PROT_EEC */
826 prot |= PROT_READ | PROT_WRITE | PROT_EXEC;
827 else if (prot & (PROT_READ | PROT_EXEC))
828 /* on x86, there is no distinction between PROT_READ and PROT_EXEC */
829 prot |= (PROT_READ | PROT_EXEC);
830
831 return prot;
832}
833
834unsigned long
835ia32_do_mmap (struct file *file, unsigned long addr, unsigned long len, int prot, int flags,
836 loff_t offset)
837{
838 DBG("ia32_do_mmap(file=%p,addr=0x%lx,len=0x%lx,prot=%x,flags=%x,offset=0x%llx)\n",
839 file, addr, len, prot, flags, offset);
840
841 if (file && (!file->f_op || !file->f_op->mmap))
842 return -ENODEV;
843
844 len = IA32_PAGE_ALIGN(len);
845 if (len == 0)
846 return addr;
847
848 if (len > IA32_PAGE_OFFSET || addr > IA32_PAGE_OFFSET - len)
849 {
850 if (flags & MAP_FIXED)
851 return -ENOMEM;
852 else
853 return -EINVAL;
854 }
855
856 if (OFFSET4K(offset))
857 return -EINVAL;
858
859 prot = get_prot32(prot);
860
861 if (flags & MAP_HUGETLB)
862 return -ENOMEM;
863
864#if PAGE_SHIFT > IA32_PAGE_SHIFT
865 mutex_lock(&ia32_mmap_mutex);
866 {
867 addr = emulate_mmap(file, addr, len, prot, flags, offset);
868 }
869 mutex_unlock(&ia32_mmap_mutex);
870#else
871 down_write(&current->mm->mmap_sem);
872 {
873 addr = do_mmap(file, addr, len, prot, flags, offset);
874 }
875 up_write(&current->mm->mmap_sem);
876#endif
877 DBG("ia32_do_mmap: returning 0x%lx\n", addr);
878 return addr;
879}
880
881/*
882 * Linux/i386 didn't use to be able to handle more than 4 system call parameters, so these
883 * system calls used a memory block for parameter passing..
884 */
885
886struct mmap_arg_struct {
887 unsigned int addr;
888 unsigned int len;
889 unsigned int prot;
890 unsigned int flags;
891 unsigned int fd;
892 unsigned int offset;
893};
894
895asmlinkage long
896sys32_mmap (struct mmap_arg_struct __user *arg)
897{
898 struct mmap_arg_struct a;
899 struct file *file = NULL;
900 unsigned long addr;
901 int flags;
902
903 if (copy_from_user(&a, arg, sizeof(a)))
904 return -EFAULT;
905
906 if (OFFSET4K(a.offset))
907 return -EINVAL;
908
909 flags = a.flags;
910
911 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
912 if (!(flags & MAP_ANONYMOUS)) {
913 file = fget(a.fd);
914 if (!file)
915 return -EBADF;
916 }
917
918 addr = ia32_do_mmap(file, a.addr, a.len, a.prot, flags, a.offset);
919
920 if (file)
921 fput(file);
922 return addr;
923}
924
925asmlinkage long
926sys32_mmap2 (unsigned int addr, unsigned int len, unsigned int prot, unsigned int flags,
927 unsigned int fd, unsigned int pgoff)
928{
929 struct file *file = NULL;
930 unsigned long retval;
931
932 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
933 if (!(flags & MAP_ANONYMOUS)) {
934 file = fget(fd);
935 if (!file)
936 return -EBADF;
937 }
938
939 retval = ia32_do_mmap(file, addr, len, prot, flags,
940 (unsigned long) pgoff << IA32_PAGE_SHIFT);
941
942 if (file)
943 fput(file);
944 return retval;
945}
946
947asmlinkage long
948sys32_munmap (unsigned int start, unsigned int len)
949{
950 unsigned int end = start + len;
951 long ret;
952
953#if PAGE_SHIFT <= IA32_PAGE_SHIFT
954 ret = sys_munmap(start, end - start);
955#else
956 if (OFFSET4K(start))
957 return -EINVAL;
958
959 end = IA32_PAGE_ALIGN(end);
960 if (start >= end)
961 return -EINVAL;
962
963 ret = ia32_unset_pp(&start, &end);
964 if (ret < 0)
965 return ret;
966
967 if (start >= end)
968 return 0;
969
970 mutex_lock(&ia32_mmap_mutex);
971 ret = sys_munmap(start, end - start);
972 mutex_unlock(&ia32_mmap_mutex);
973#endif
974 return ret;
975}
976
977#if PAGE_SHIFT > IA32_PAGE_SHIFT
978
979/*
980 * When mprotect()ing a partial page, we set the permission to the union of the old
981 * settings and the new settings. In other words, it's only possible to make access to a
982 * partial page less restrictive.
983 */
984static long
985mprotect_subpage (unsigned long address, int new_prot)
986{
987 int old_prot;
988 struct vm_area_struct *vma;
989
990 if (new_prot == PROT_NONE)
991 return 0; /* optimize case where nothing changes... */
992 vma = find_vma(current->mm, address);
993 old_prot = get_page_prot(vma, address);
994 return sys_mprotect(address, PAGE_SIZE, new_prot | old_prot);
995}
996
997#endif /* PAGE_SHIFT > IA32_PAGE_SHIFT */
998
999asmlinkage long
1000sys32_mprotect (unsigned int start, unsigned int len, int prot)
1001{
1002 unsigned int end = start + len;
1003#if PAGE_SHIFT > IA32_PAGE_SHIFT
1004 long retval = 0;
1005#endif
1006
1007 prot = get_prot32(prot);
1008
1009#if PAGE_SHIFT <= IA32_PAGE_SHIFT
1010 return sys_mprotect(start, end - start, prot);
1011#else
1012 if (OFFSET4K(start))
1013 return -EINVAL;
1014
1015 end = IA32_PAGE_ALIGN(end);
1016 if (end < start)
1017 return -EINVAL;
1018
1019 retval = ia32_compare_pp(&start, &end);
1020
1021 if (retval < 0)
1022 return retval;
1023
1024 mutex_lock(&ia32_mmap_mutex);
1025 {
1026 if (offset_in_page(start)) {
1027 /* start address is 4KB aligned but not page aligned. */
1028 retval = mprotect_subpage(PAGE_START(start), prot);
1029 if (retval < 0)
1030 goto out;
1031
1032 start = PAGE_ALIGN(start);
1033 if (start >= end)
1034 goto out; /* retval is already zero... */
1035 }
1036
1037 if (offset_in_page(end)) {
1038 /* end address is 4KB aligned but not page aligned. */
1039 retval = mprotect_subpage(PAGE_START(end), prot);
1040 if (retval < 0)
1041 goto out;
1042
1043 end = PAGE_START(end);
1044 }
1045 retval = sys_mprotect(start, end - start, prot);
1046 }
1047 out:
1048 mutex_unlock(&ia32_mmap_mutex);
1049 return retval;
1050#endif
1051}
1052
1053asmlinkage long
1054sys32_mremap (unsigned int addr, unsigned int old_len, unsigned int new_len,
1055 unsigned int flags, unsigned int new_addr)
1056{
1057 long ret;
1058
1059#if PAGE_SHIFT <= IA32_PAGE_SHIFT
1060 ret = sys_mremap(addr, old_len, new_len, flags, new_addr);
1061#else
1062 unsigned int old_end, new_end;
1063
1064 if (OFFSET4K(addr))
1065 return -EINVAL;
1066
1067 old_len = IA32_PAGE_ALIGN(old_len);
1068 new_len = IA32_PAGE_ALIGN(new_len);
1069 old_end = addr + old_len;
1070 new_end = addr + new_len;
1071
1072 if (!new_len)
1073 return -EINVAL;
1074
1075 if ((flags & MREMAP_FIXED) && (OFFSET4K(new_addr)))
1076 return -EINVAL;
1077
1078 if (old_len >= new_len) {
1079 ret = sys32_munmap(addr + new_len, old_len - new_len);
1080 if (ret && old_len != new_len)
1081 return ret;
1082 ret = addr;
1083 if (!(flags & MREMAP_FIXED) || (new_addr == addr))
1084 return ret;
1085 old_len = new_len;
1086 }
1087
1088 addr = PAGE_START(addr);
1089 old_len = PAGE_ALIGN(old_end) - addr;
1090 new_len = PAGE_ALIGN(new_end) - addr;
1091
1092 mutex_lock(&ia32_mmap_mutex);
1093 ret = sys_mremap(addr, old_len, new_len, flags, new_addr);
1094 mutex_unlock(&ia32_mmap_mutex);
1095
1096 if ((ret >= 0) && (old_len < new_len)) {
1097 /* mremap expanded successfully */
1098 ia32_set_pp(old_end, new_end, flags);
1099 }
1100#endif
1101 return ret;
1102}
1103
1104asmlinkage unsigned long
1105sys32_alarm (unsigned int seconds)
1106{
1107 return alarm_setitimer(seconds);
1108}
1109
1110struct sel_arg_struct {
1111 unsigned int n;
1112 unsigned int inp;
1113 unsigned int outp;
1114 unsigned int exp;
1115 unsigned int tvp;
1116};
1117
1118asmlinkage long
1119sys32_old_select (struct sel_arg_struct __user *arg)
1120{
1121 struct sel_arg_struct a;
1122
1123 if (copy_from_user(&a, arg, sizeof(a)))
1124 return -EFAULT;
1125 return compat_sys_select(a.n, compat_ptr(a.inp), compat_ptr(a.outp),
1126 compat_ptr(a.exp), compat_ptr(a.tvp));
1127}
1128
1129#define SEMOP 1
1130#define SEMGET 2
1131#define SEMCTL 3
1132#define SEMTIMEDOP 4
1133#define MSGSND 11
1134#define MSGRCV 12
1135#define MSGGET 13
1136#define MSGCTL 14
1137#define SHMAT 21
1138#define SHMDT 22
1139#define SHMGET 23
1140#define SHMCTL 24
1141
1142asmlinkage long
1143sys32_ipc(u32 call, int first, int second, int third, u32 ptr, u32 fifth)
1144{
1145 int version;
1146
1147 version = call >> 16; /* hack for backward compatibility */
1148 call &= 0xffff;
1149
1150 switch (call) {
1151 case SEMTIMEDOP:
1152 if (fifth)
1153 return compat_sys_semtimedop(first, compat_ptr(ptr),
1154 second, compat_ptr(fifth));
1155 /* else fall through for normal semop() */
1156 case SEMOP:
1157 /* struct sembuf is the same on 32 and 64bit :)) */
1158 return sys_semtimedop(first, compat_ptr(ptr), second,
1159 NULL);
1160 case SEMGET:
1161 return sys_semget(first, second, third);
1162 case SEMCTL:
1163 return compat_sys_semctl(first, second, third, compat_ptr(ptr));
1164
1165 case MSGSND:
1166 return compat_sys_msgsnd(first, second, third, compat_ptr(ptr));
1167 case MSGRCV:
1168 return compat_sys_msgrcv(first, second, fifth, third, version, compat_ptr(ptr));
1169 case MSGGET:
1170 return sys_msgget((key_t) first, second);
1171 case MSGCTL:
1172 return compat_sys_msgctl(first, second, compat_ptr(ptr));
1173
1174 case SHMAT:
1175 return compat_sys_shmat(first, second, third, version, compat_ptr(ptr));
1176 break;
1177 case SHMDT:
1178 return sys_shmdt(compat_ptr(ptr));
1179 case SHMGET:
1180 return sys_shmget(first, (unsigned)second, third);
1181 case SHMCTL:
1182 return compat_sys_shmctl(first, second, compat_ptr(ptr));
1183
1184 default:
1185 return -ENOSYS;
1186 }
1187 return -EINVAL;
1188}
1189
1190asmlinkage long
1191compat_sys_wait4 (compat_pid_t pid, compat_uint_t * stat_addr, int options,
1192 struct compat_rusage *ru);
1193
1194asmlinkage long
1195sys32_waitpid (int pid, unsigned int *stat_addr, int options)
1196{
1197 return compat_sys_wait4(pid, stat_addr, options, NULL);
1198}
1199
1200/*
1201 * The order in which registers are stored in the ptrace regs structure
1202 */
1203#define PT_EBX 0
1204#define PT_ECX 1
1205#define PT_EDX 2
1206#define PT_ESI 3
1207#define PT_EDI 4
1208#define PT_EBP 5
1209#define PT_EAX 6
1210#define PT_DS 7
1211#define PT_ES 8
1212#define PT_FS 9
1213#define PT_GS 10
1214#define PT_ORIG_EAX 11
1215#define PT_EIP 12
1216#define PT_CS 13
1217#define PT_EFL 14
1218#define PT_UESP 15
1219#define PT_SS 16
1220
1221static unsigned int
1222getreg (struct task_struct *child, int regno)
1223{
1224 struct pt_regs *child_regs;
1225
1226 child_regs = task_pt_regs(child);
1227 switch (regno / sizeof(int)) {
1228 case PT_EBX: return child_regs->r11;
1229 case PT_ECX: return child_regs->r9;
1230 case PT_EDX: return child_regs->r10;
1231 case PT_ESI: return child_regs->r14;
1232 case PT_EDI: return child_regs->r15;
1233 case PT_EBP: return child_regs->r13;
1234 case PT_EAX: return child_regs->r8;
1235 case PT_ORIG_EAX: return child_regs->r1; /* see dispatch_to_ia32_handler() */
1236 case PT_EIP: return child_regs->cr_iip;
1237 case PT_UESP: return child_regs->r12;
1238 case PT_EFL: return child->thread.eflag;
1239 case PT_DS: case PT_ES: case PT_FS: case PT_GS: case PT_SS:
1240 return __USER_DS;
1241 case PT_CS: return __USER_CS;
1242 default:
1243 printk(KERN_ERR "ia32.getreg(): unknown register %d\n", regno);
1244 break;
1245 }
1246 return 0;
1247}
1248
1249static void
1250putreg (struct task_struct *child, int regno, unsigned int value)
1251{
1252 struct pt_regs *child_regs;
1253
1254 child_regs = task_pt_regs(child);
1255 switch (regno / sizeof(int)) {
1256 case PT_EBX: child_regs->r11 = value; break;
1257 case PT_ECX: child_regs->r9 = value; break;
1258 case PT_EDX: child_regs->r10 = value; break;
1259 case PT_ESI: child_regs->r14 = value; break;
1260 case PT_EDI: child_regs->r15 = value; break;
1261 case PT_EBP: child_regs->r13 = value; break;
1262 case PT_EAX: child_regs->r8 = value; break;
1263 case PT_ORIG_EAX: child_regs->r1 = value; break;
1264 case PT_EIP: child_regs->cr_iip = value; break;
1265 case PT_UESP: child_regs->r12 = value; break;
1266 case PT_EFL: child->thread.eflag = value; break;
1267 case PT_DS: case PT_ES: case PT_FS: case PT_GS: case PT_SS:
1268 if (value != __USER_DS)
1269 printk(KERN_ERR
1270 "ia32.putreg: attempt to set invalid segment register %d = %x\n",
1271 regno, value);
1272 break;
1273 case PT_CS:
1274 if (value != __USER_CS)
1275 printk(KERN_ERR
1276 "ia32.putreg: attempt to set invalid segment register %d = %x\n",
1277 regno, value);
1278 break;
1279 default:
1280 printk(KERN_ERR "ia32.putreg: unknown register %d\n", regno);
1281 break;
1282 }
1283}
1284
1285static void
1286put_fpreg (int regno, struct _fpreg_ia32 __user *reg, struct pt_regs *ptp,
1287 struct switch_stack *swp, int tos)
1288{
1289 struct _fpreg_ia32 *f;
1290 char buf[32];
1291
1292 f = (struct _fpreg_ia32 *)(((unsigned long)buf + 15) & ~15);
1293 if ((regno += tos) >= 8)
1294 regno -= 8;
1295 switch (regno) {
1296 case 0:
1297 ia64f2ia32f(f, &ptp->f8);
1298 break;
1299 case 1:
1300 ia64f2ia32f(f, &ptp->f9);
1301 break;
1302 case 2:
1303 ia64f2ia32f(f, &ptp->f10);
1304 break;
1305 case 3:
1306 ia64f2ia32f(f, &ptp->f11);
1307 break;
1308 case 4:
1309 case 5:
1310 case 6:
1311 case 7:
1312 ia64f2ia32f(f, &swp->f12 + (regno - 4));
1313 break;
1314 }
1315 copy_to_user(reg, f, sizeof(*reg));
1316}
1317
1318static void
1319get_fpreg (int regno, struct _fpreg_ia32 __user *reg, struct pt_regs *ptp,
1320 struct switch_stack *swp, int tos)
1321{
1322
1323 if ((regno += tos) >= 8)
1324 regno -= 8;
1325 switch (regno) {
1326 case 0:
1327 copy_from_user(&ptp->f8, reg, sizeof(*reg));
1328 break;
1329 case 1:
1330 copy_from_user(&ptp->f9, reg, sizeof(*reg));
1331 break;
1332 case 2:
1333 copy_from_user(&ptp->f10, reg, sizeof(*reg));
1334 break;
1335 case 3:
1336 copy_from_user(&ptp->f11, reg, sizeof(*reg));
1337 break;
1338 case 4:
1339 case 5:
1340 case 6:
1341 case 7:
1342 copy_from_user(&swp->f12 + (regno - 4), reg, sizeof(*reg));
1343 break;
1344 }
1345 return;
1346}
1347
1348int
1349save_ia32_fpstate (struct task_struct *tsk, struct ia32_user_i387_struct __user *save)
1350{
1351 struct switch_stack *swp;
1352 struct pt_regs *ptp;
1353 int i, tos;
1354
1355 if (!access_ok(VERIFY_WRITE, save, sizeof(*save)))
1356 return -EFAULT;
1357
1358 __put_user(tsk->thread.fcr & 0xffff, &save->cwd);
1359 __put_user(tsk->thread.fsr & 0xffff, &save->swd);
1360 __put_user((tsk->thread.fsr>>16) & 0xffff, &save->twd);
1361 __put_user(tsk->thread.fir, &save->fip);
1362 __put_user((tsk->thread.fir>>32) & 0xffff, &save->fcs);
1363 __put_user(tsk->thread.fdr, &save->foo);
1364 __put_user((tsk->thread.fdr>>32) & 0xffff, &save->fos);
1365
1366 /*
1367 * Stack frames start with 16-bytes of temp space
1368 */
1369 swp = (struct switch_stack *)(tsk->thread.ksp + 16);
1370 ptp = task_pt_regs(tsk);
1371 tos = (tsk->thread.fsr >> 11) & 7;
1372 for (i = 0; i < 8; i++)
1373 put_fpreg(i, &save->st_space[i], ptp, swp, tos);
1374 return 0;
1375}
1376
1377static int
1378restore_ia32_fpstate (struct task_struct *tsk, struct ia32_user_i387_struct __user *save)
1379{
1380 struct switch_stack *swp;
1381 struct pt_regs *ptp;
1382 int i, tos;
1383 unsigned int fsrlo, fsrhi, num32;
1384
1385 if (!access_ok(VERIFY_READ, save, sizeof(*save)))
1386 return(-EFAULT);
1387
1388 __get_user(num32, (unsigned int __user *)&save->cwd);
1389 tsk->thread.fcr = (tsk->thread.fcr & (~0x1f3f)) | (num32 & 0x1f3f);
1390 __get_user(fsrlo, (unsigned int __user *)&save->swd);
1391 __get_user(fsrhi, (unsigned int __user *)&save->twd);
1392 num32 = (fsrhi << 16) | fsrlo;
1393 tsk->thread.fsr = (tsk->thread.fsr & (~0xffffffff)) | num32;
1394 __get_user(num32, (unsigned int __user *)&save->fip);
1395 tsk->thread.fir = (tsk->thread.fir & (~0xffffffff)) | num32;
1396 __get_user(num32, (unsigned int __user *)&save->foo);
1397 tsk->thread.fdr = (tsk->thread.fdr & (~0xffffffff)) | num32;
1398
1399 /*
1400 * Stack frames start with 16-bytes of temp space
1401 */
1402 swp = (struct switch_stack *)(tsk->thread.ksp + 16);
1403 ptp = task_pt_regs(tsk);
1404 tos = (tsk->thread.fsr >> 11) & 7;
1405 for (i = 0; i < 8; i++)
1406 get_fpreg(i, &save->st_space[i], ptp, swp, tos);
1407 return 0;
1408}
1409
1410int
1411save_ia32_fpxstate (struct task_struct *tsk, struct ia32_user_fxsr_struct __user *save)
1412{
1413 struct switch_stack *swp;
1414 struct pt_regs *ptp;
1415 int i, tos;
1416 unsigned long mxcsr=0;
1417 unsigned long num128[2];
1418
1419 if (!access_ok(VERIFY_WRITE, save, sizeof(*save)))
1420 return -EFAULT;
1421
1422 __put_user(tsk->thread.fcr & 0xffff, &save->cwd);
1423 __put_user(tsk->thread.fsr & 0xffff, &save->swd);
1424 __put_user((tsk->thread.fsr>>16) & 0xffff, &save->twd);
1425 __put_user(tsk->thread.fir, &save->fip);
1426 __put_user((tsk->thread.fir>>32) & 0xffff, &save->fcs);
1427 __put_user(tsk->thread.fdr, &save->foo);
1428 __put_user((tsk->thread.fdr>>32) & 0xffff, &save->fos);
1429
1430 /*
1431 * Stack frames start with 16-bytes of temp space
1432 */
1433 swp = (struct switch_stack *)(tsk->thread.ksp + 16);
1434 ptp = task_pt_regs(tsk);
1435 tos = (tsk->thread.fsr >> 11) & 7;
1436 for (i = 0; i < 8; i++)
1437 put_fpreg(i, (struct _fpreg_ia32 __user *)&save->st_space[4*i], ptp, swp, tos);
1438
1439 mxcsr = ((tsk->thread.fcr>>32) & 0xff80) | ((tsk->thread.fsr>>32) & 0x3f);
1440 __put_user(mxcsr & 0xffff, &save->mxcsr);
1441 for (i = 0; i < 8; i++) {
1442 memcpy(&(num128[0]), &(swp->f16) + i*2, sizeof(unsigned long));
1443 memcpy(&(num128[1]), &(swp->f17) + i*2, sizeof(unsigned long));
1444 copy_to_user(&save->xmm_space[0] + 4*i, num128, sizeof(struct _xmmreg_ia32));
1445 }
1446 return 0;
1447}
1448
1449static int
1450restore_ia32_fpxstate (struct task_struct *tsk, struct ia32_user_fxsr_struct __user *save)
1451{
1452 struct switch_stack *swp;
1453 struct pt_regs *ptp;
1454 int i, tos;
1455 unsigned int fsrlo, fsrhi, num32;
1456 int mxcsr;
1457 unsigned long num64;
1458 unsigned long num128[2];
1459
1460 if (!access_ok(VERIFY_READ, save, sizeof(*save)))
1461 return(-EFAULT);
1462
1463 __get_user(num32, (unsigned int __user *)&save->cwd);
1464 tsk->thread.fcr = (tsk->thread.fcr & (~0x1f3f)) | (num32 & 0x1f3f);
1465 __get_user(fsrlo, (unsigned int __user *)&save->swd);
1466 __get_user(fsrhi, (unsigned int __user *)&save->twd);
1467 num32 = (fsrhi << 16) | fsrlo;
1468 tsk->thread.fsr = (tsk->thread.fsr & (~0xffffffff)) | num32;
1469 __get_user(num32, (unsigned int __user *)&save->fip);
1470 tsk->thread.fir = (tsk->thread.fir & (~0xffffffff)) | num32;
1471 __get_user(num32, (unsigned int __user *)&save->foo);
1472 tsk->thread.fdr = (tsk->thread.fdr & (~0xffffffff)) | num32;
1473
1474 /*
1475 * Stack frames start with 16-bytes of temp space
1476 */
1477 swp = (struct switch_stack *)(tsk->thread.ksp + 16);
1478 ptp = task_pt_regs(tsk);
1479 tos = (tsk->thread.fsr >> 11) & 7;
1480 for (i = 0; i < 8; i++)
1481 get_fpreg(i, (struct _fpreg_ia32 __user *)&save->st_space[4*i], ptp, swp, tos);
1482
1483 __get_user(mxcsr, (unsigned int __user *)&save->mxcsr);
1484 num64 = mxcsr & 0xff10;
1485 tsk->thread.fcr = (tsk->thread.fcr & (~0xff1000000000UL)) | (num64<<32);
1486 num64 = mxcsr & 0x3f;
1487 tsk->thread.fsr = (tsk->thread.fsr & (~0x3f00000000UL)) | (num64<<32);
1488
1489 for (i = 0; i < 8; i++) {
1490 copy_from_user(num128, &save->xmm_space[0] + 4*i, sizeof(struct _xmmreg_ia32));
1491 memcpy(&(swp->f16) + i*2, &(num128[0]), sizeof(unsigned long));
1492 memcpy(&(swp->f17) + i*2, &(num128[1]), sizeof(unsigned long));
1493 }
1494 return 0;
1495}
1496
1497long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
1498 compat_ulong_t caddr, compat_ulong_t cdata)
1499{
1500 unsigned long addr = caddr;
1501 unsigned long data = cdata;
1502 unsigned int tmp;
1503 long i, ret;
1504
1505 switch (request) {
1506 case PTRACE_PEEKUSR: /* read word at addr in USER area */
1507 ret = -EIO;
1508 if ((addr & 3) || addr > 17*sizeof(int))
1509 break;
1510
1511 tmp = getreg(child, addr);
1512 if (!put_user(tmp, (unsigned int __user *) compat_ptr(data)))
1513 ret = 0;
1514 break;
1515
1516 case PTRACE_POKEUSR: /* write word at addr in USER area */
1517 ret = -EIO;
1518 if ((addr & 3) || addr > 17*sizeof(int))
1519 break;
1520
1521 putreg(child, addr, data);
1522 ret = 0;
1523 break;
1524
1525 case IA32_PTRACE_GETREGS:
1526 if (!access_ok(VERIFY_WRITE, compat_ptr(data), 17*sizeof(int))) {
1527 ret = -EIO;
1528 break;
1529 }
1530 for (i = 0; i < (int) (17*sizeof(int)); i += sizeof(int) ) {
1531 put_user(getreg(child, i), (unsigned int __user *) compat_ptr(data));
1532 data += sizeof(int);
1533 }
1534 ret = 0;
1535 break;
1536
1537 case IA32_PTRACE_SETREGS:
1538 if (!access_ok(VERIFY_READ, compat_ptr(data), 17*sizeof(int))) {
1539 ret = -EIO;
1540 break;
1541 }
1542 for (i = 0; i < (int) (17*sizeof(int)); i += sizeof(int) ) {
1543 get_user(tmp, (unsigned int __user *) compat_ptr(data));
1544 putreg(child, i, tmp);
1545 data += sizeof(int);
1546 }
1547 ret = 0;
1548 break;
1549
1550 case IA32_PTRACE_GETFPREGS:
1551 ret = save_ia32_fpstate(child, (struct ia32_user_i387_struct __user *)
1552 compat_ptr(data));
1553 break;
1554
1555 case IA32_PTRACE_GETFPXREGS:
1556 ret = save_ia32_fpxstate(child, (struct ia32_user_fxsr_struct __user *)
1557 compat_ptr(data));
1558 break;
1559
1560 case IA32_PTRACE_SETFPREGS:
1561 ret = restore_ia32_fpstate(child, (struct ia32_user_i387_struct __user *)
1562 compat_ptr(data));
1563 break;
1564
1565 case IA32_PTRACE_SETFPXREGS:
1566 ret = restore_ia32_fpxstate(child, (struct ia32_user_fxsr_struct __user *)
1567 compat_ptr(data));
1568 break;
1569
1570 default:
1571 return compat_ptrace_request(child, request, caddr, cdata);
1572 }
1573 return ret;
1574}
1575
1576typedef struct {
1577 unsigned int ss_sp;
1578 unsigned int ss_flags;
1579 unsigned int ss_size;
1580} ia32_stack_t;
1581
1582asmlinkage long
1583sys32_sigaltstack (ia32_stack_t __user *uss32, ia32_stack_t __user *uoss32,
1584 long arg2, long arg3, long arg4, long arg5, long arg6,
1585 long arg7, struct pt_regs pt)
1586{
1587 stack_t uss, uoss;
1588 ia32_stack_t buf32;
1589 int ret;
1590 mm_segment_t old_fs = get_fs();
1591
1592 if (uss32) {
1593 if (copy_from_user(&buf32, uss32, sizeof(ia32_stack_t)))
1594 return -EFAULT;
1595 uss.ss_sp = (void __user *) (long) buf32.ss_sp;
1596 uss.ss_flags = buf32.ss_flags;
1597 /* MINSIGSTKSZ is different for ia32 vs ia64. We lie here to pass the
1598 check and set it to the user requested value later */
1599 if ((buf32.ss_flags != SS_DISABLE) && (buf32.ss_size < MINSIGSTKSZ_IA32)) {
1600 ret = -ENOMEM;
1601 goto out;
1602 }
1603 uss.ss_size = MINSIGSTKSZ;
1604 }
1605 set_fs(KERNEL_DS);
1606 ret = do_sigaltstack(uss32 ? (stack_t __user *) &uss : NULL,
1607 (stack_t __user *) &uoss, pt.r12);
1608 current->sas_ss_size = buf32.ss_size;
1609 set_fs(old_fs);
1610out:
1611 if (ret < 0)
1612 return(ret);
1613 if (uoss32) {
1614 buf32.ss_sp = (long __user) uoss.ss_sp;
1615 buf32.ss_flags = uoss.ss_flags;
1616 buf32.ss_size = uoss.ss_size;
1617 if (copy_to_user(uoss32, &buf32, sizeof(ia32_stack_t)))
1618 return -EFAULT;
1619 }
1620 return ret;
1621}
1622
1623asmlinkage int
1624sys32_msync (unsigned int start, unsigned int len, int flags)
1625{
1626 unsigned int addr;
1627
1628 if (OFFSET4K(start))
1629 return -EINVAL;
1630 addr = PAGE_START(start);
1631 return sys_msync(addr, len + (start - addr), flags);
1632}
1633
1634asmlinkage long
1635sys32_newuname (struct new_utsname __user *name)
1636{
1637 int ret = sys_newuname(name);
1638
1639 if (!ret)
1640 if (copy_to_user(name->machine, "i686\0\0\0", 8))
1641 ret = -EFAULT;
1642 return ret;
1643}
1644
1645asmlinkage long
1646sys32_getresuid16 (u16 __user *ruid, u16 __user *euid, u16 __user *suid)
1647{
1648 uid_t a, b, c;
1649 int ret;
1650 mm_segment_t old_fs = get_fs();
1651
1652 set_fs(KERNEL_DS);
1653 ret = sys_getresuid((uid_t __user *) &a, (uid_t __user *) &b, (uid_t __user *) &c);
1654 set_fs(old_fs);
1655
1656 if (put_user(a, ruid) || put_user(b, euid) || put_user(c, suid))
1657 return -EFAULT;
1658 return ret;
1659}
1660
1661asmlinkage long
1662sys32_getresgid16 (u16 __user *rgid, u16 __user *egid, u16 __user *sgid)
1663{
1664 gid_t a, b, c;
1665 int ret;
1666 mm_segment_t old_fs = get_fs();
1667
1668 set_fs(KERNEL_DS);
1669 ret = sys_getresgid((gid_t __user *) &a, (gid_t __user *) &b, (gid_t __user *) &c);
1670 set_fs(old_fs);
1671
1672 if (ret)
1673 return ret;
1674
1675 return put_user(a, rgid) | put_user(b, egid) | put_user(c, sgid);
1676}
1677
1678asmlinkage long
1679sys32_lseek (unsigned int fd, int offset, unsigned int whence)
1680{
1681 /* Sign-extension of "offset" is important here... */
1682 return sys_lseek(fd, offset, whence);
1683}
1684
1685static int
1686groups16_to_user(short __user *grouplist, struct group_info *group_info)
1687{
1688 int i;
1689 short group;
1690
1691 for (i = 0; i < group_info->ngroups; i++) {
1692 group = (short)GROUP_AT(group_info, i);
1693 if (put_user(group, grouplist+i))
1694 return -EFAULT;
1695 }
1696
1697 return 0;
1698}
1699
1700static int
1701groups16_from_user(struct group_info *group_info, short __user *grouplist)
1702{
1703 int i;
1704 short group;
1705
1706 for (i = 0; i < group_info->ngroups; i++) {
1707 if (get_user(group, grouplist+i))
1708 return -EFAULT;
1709 GROUP_AT(group_info, i) = (gid_t)group;
1710 }
1711
1712 return 0;
1713}
1714
1715asmlinkage long
1716sys32_getgroups16 (int gidsetsize, short __user *grouplist)
1717{
1718 const struct cred *cred = current_cred();
1719 int i;
1720
1721 if (gidsetsize < 0)
1722 return -EINVAL;
1723
1724 i = cred->group_info->ngroups;
1725 if (gidsetsize) {
1726 if (i > gidsetsize) {
1727 i = -EINVAL;
1728 goto out;
1729 }
1730 if (groups16_to_user(grouplist, cred->group_info)) {
1731 i = -EFAULT;
1732 goto out;
1733 }
1734 }
1735out:
1736 return i;
1737}
1738
1739asmlinkage long
1740sys32_setgroups16 (int gidsetsize, short __user *grouplist)
1741{
1742 struct group_info *group_info;
1743 int retval;
1744
1745 if (!capable(CAP_SETGID))
1746 return -EPERM;
1747 if ((unsigned)gidsetsize > NGROUPS_MAX)
1748 return -EINVAL;
1749
1750 group_info = groups_alloc(gidsetsize);
1751 if (!group_info)
1752 return -ENOMEM;
1753 retval = groups16_from_user(group_info, grouplist);
1754 if (retval) {
1755 put_group_info(group_info);
1756 return retval;
1757 }
1758
1759 retval = set_current_groups(group_info);
1760 put_group_info(group_info);
1761
1762 return retval;
1763}
1764
1765asmlinkage long
1766sys32_truncate64 (unsigned int path, unsigned int len_lo, unsigned int len_hi)
1767{
1768 return sys_truncate(compat_ptr(path), ((unsigned long) len_hi << 32) | len_lo);
1769}
1770
1771asmlinkage long
1772sys32_ftruncate64 (int fd, unsigned int len_lo, unsigned int len_hi)
1773{
1774 return sys_ftruncate(fd, ((unsigned long) len_hi << 32) | len_lo);
1775}
1776
1777static int
1778putstat64 (struct stat64 __user *ubuf, struct kstat *kbuf)
1779{
1780 int err;
1781 u64 hdev;
1782
1783 if (clear_user(ubuf, sizeof(*ubuf)))
1784 return -EFAULT;
1785
1786 hdev = huge_encode_dev(kbuf->dev);
1787 err = __put_user(hdev, (u32 __user*)&ubuf->st_dev);
1788 err |= __put_user(hdev >> 32, ((u32 __user*)&ubuf->st_dev) + 1);
1789 err |= __put_user(kbuf->ino, &ubuf->__st_ino);
1790 err |= __put_user(kbuf->ino, &ubuf->st_ino_lo);
1791 err |= __put_user(kbuf->ino >> 32, &ubuf->st_ino_hi);
1792 err |= __put_user(kbuf->mode, &ubuf->st_mode);
1793 err |= __put_user(kbuf->nlink, &ubuf->st_nlink);
1794 err |= __put_user(kbuf->uid, &ubuf->st_uid);
1795 err |= __put_user(kbuf->gid, &ubuf->st_gid);
1796 hdev = huge_encode_dev(kbuf->rdev);
1797 err = __put_user(hdev, (u32 __user*)&ubuf->st_rdev);
1798 err |= __put_user(hdev >> 32, ((u32 __user*)&ubuf->st_rdev) + 1);
1799 err |= __put_user(kbuf->size, &ubuf->st_size_lo);
1800 err |= __put_user((kbuf->size >> 32), &ubuf->st_size_hi);
1801 err |= __put_user(kbuf->atime.tv_sec, &ubuf->st_atime);
1802 err |= __put_user(kbuf->atime.tv_nsec, &ubuf->st_atime_nsec);
1803 err |= __put_user(kbuf->mtime.tv_sec, &ubuf->st_mtime);
1804 err |= __put_user(kbuf->mtime.tv_nsec, &ubuf->st_mtime_nsec);
1805 err |= __put_user(kbuf->ctime.tv_sec, &ubuf->st_ctime);
1806 err |= __put_user(kbuf->ctime.tv_nsec, &ubuf->st_ctime_nsec);
1807 err |= __put_user(kbuf->blksize, &ubuf->st_blksize);
1808 err |= __put_user(kbuf->blocks, &ubuf->st_blocks);
1809 return err;
1810}
1811
1812asmlinkage long
1813sys32_stat64 (char __user *filename, struct stat64 __user *statbuf)
1814{
1815 struct kstat s;
1816 long ret = vfs_stat(filename, &s);
1817 if (!ret)
1818 ret = putstat64(statbuf, &s);
1819 return ret;
1820}
1821
1822asmlinkage long
1823sys32_lstat64 (char __user *filename, struct stat64 __user *statbuf)
1824{
1825 struct kstat s;
1826 long ret = vfs_lstat(filename, &s);
1827 if (!ret)
1828 ret = putstat64(statbuf, &s);
1829 return ret;
1830}
1831
1832asmlinkage long
1833sys32_fstat64 (unsigned int fd, struct stat64 __user *statbuf)
1834{
1835 struct kstat s;
1836 long ret = vfs_fstat(fd, &s);
1837 if (!ret)
1838 ret = putstat64(statbuf, &s);
1839 return ret;
1840}
1841
1842asmlinkage long
1843sys32_sched_rr_get_interval (pid_t pid, struct compat_timespec __user *interval)
1844{
1845 mm_segment_t old_fs = get_fs();
1846 struct timespec t;
1847 long ret;
1848
1849 set_fs(KERNEL_DS);
1850 ret = sys_sched_rr_get_interval(pid, (struct timespec __user *) &t);
1851 set_fs(old_fs);
1852 if (put_compat_timespec(&t, interval))
1853 return -EFAULT;
1854 return ret;
1855}
1856
1857asmlinkage long
1858sys32_pread (unsigned int fd, void __user *buf, unsigned int count, u32 pos_lo, u32 pos_hi)
1859{
1860 return sys_pread64(fd, buf, count, ((unsigned long) pos_hi << 32) | pos_lo);
1861}
1862
1863asmlinkage long
1864sys32_pwrite (unsigned int fd, void __user *buf, unsigned int count, u32 pos_lo, u32 pos_hi)
1865{
1866 return sys_pwrite64(fd, buf, count, ((unsigned long) pos_hi << 32) | pos_lo);
1867}
1868
1869asmlinkage long
1870sys32_sendfile (int out_fd, int in_fd, int __user *offset, unsigned int count)
1871{
1872 mm_segment_t old_fs = get_fs();
1873 long ret;
1874 off_t of;
1875
1876 if (offset && get_user(of, offset))
1877 return -EFAULT;
1878
1879 set_fs(KERNEL_DS);
1880 ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *) &of : NULL, count);
1881 set_fs(old_fs);
1882
1883 if (offset && put_user(of, offset))
1884 return -EFAULT;
1885
1886 return ret;
1887}
1888
1889asmlinkage long
1890sys32_personality (unsigned int personality)
1891{
1892 long ret;
1893
1894 if (current->personality == PER_LINUX32 && personality == PER_LINUX)
1895 personality = PER_LINUX32;
1896 ret = sys_personality(personality);
1897 if (ret == PER_LINUX32)
1898 ret = PER_LINUX;
1899 return ret;
1900}
1901
1902asmlinkage unsigned long
1903sys32_brk (unsigned int brk)
1904{
1905 unsigned long ret, obrk;
1906 struct mm_struct *mm = current->mm;
1907
1908 obrk = mm->brk;
1909 ret = sys_brk(brk);
1910 if (ret < obrk)
1911 clear_user(compat_ptr(ret), PAGE_ALIGN(ret) - ret);
1912 return ret;
1913}
1914
1915/* Structure for ia32 emulation on ia64 */
1916struct epoll_event32
1917{
1918 u32 events;
1919 u32 data[2];
1920};
1921
1922asmlinkage long
1923sys32_epoll_ctl(int epfd, int op, int fd, struct epoll_event32 __user *event)
1924{
1925 mm_segment_t old_fs = get_fs();
1926 struct epoll_event event64;
1927 int error;
1928 u32 data_halfword;
1929
1930 if (!access_ok(VERIFY_READ, event, sizeof(struct epoll_event32)))
1931 return -EFAULT;
1932
1933 __get_user(event64.events, &event->events);
1934 __get_user(data_halfword, &event->data[0]);
1935 event64.data = data_halfword;
1936 __get_user(data_halfword, &event->data[1]);
1937 event64.data |= (u64)data_halfword << 32;
1938
1939 set_fs(KERNEL_DS);
1940 error = sys_epoll_ctl(epfd, op, fd, (struct epoll_event __user *) &event64);
1941 set_fs(old_fs);
1942
1943 return error;
1944}
1945
1946asmlinkage long
1947sys32_epoll_wait(int epfd, struct epoll_event32 __user * events, int maxevents,
1948 int timeout)
1949{
1950 struct epoll_event *events64 = NULL;
1951 mm_segment_t old_fs = get_fs();
1952 int numevents, size;
1953 int evt_idx;
1954 int do_free_pages = 0;
1955
1956 if (maxevents <= 0) {
1957 return -EINVAL;
1958 }
1959
1960 /* Verify that the area passed by the user is writeable */
1961 if (!access_ok(VERIFY_WRITE, events, maxevents * sizeof(struct epoll_event32)))
1962 return -EFAULT;
1963
1964 /*
1965 * Allocate space for the intermediate copy. If the space needed
1966 * is large enough to cause kmalloc to fail, then try again with
1967 * __get_free_pages.
1968 */
1969 size = maxevents * sizeof(struct epoll_event);
1970 events64 = kmalloc(size, GFP_KERNEL);
1971 if (events64 == NULL) {
1972 events64 = (struct epoll_event *)
1973 __get_free_pages(GFP_KERNEL, get_order(size));
1974 if (events64 == NULL)
1975 return -ENOMEM;
1976 do_free_pages = 1;
1977 }
1978
1979 /* Do the system call */
1980 set_fs(KERNEL_DS); /* copy_to/from_user should work on kernel mem*/
1981 numevents = sys_epoll_wait(epfd, (struct epoll_event __user *) events64,
1982 maxevents, timeout);
1983 set_fs(old_fs);
1984
1985 /* Don't modify userspace memory if we're returning an error */
1986 if (numevents > 0) {
1987 /* Translate the 64-bit structures back into the 32-bit
1988 structures */
1989 for (evt_idx = 0; evt_idx < numevents; evt_idx++) {
1990 __put_user(events64[evt_idx].events,
1991 &events[evt_idx].events);
1992 __put_user((u32)events64[evt_idx].data,
1993 &events[evt_idx].data[0]);
1994 __put_user((u32)(events64[evt_idx].data >> 32),
1995 &events[evt_idx].data[1]);
1996 }
1997 }
1998
1999 if (do_free_pages)
2000 free_pages((unsigned long) events64, get_order(size));
2001 else
2002 kfree(events64);
2003 return numevents;
2004}
2005
2006/*
2007 * Get a yet unused TLS descriptor index.
2008 */
2009static int
2010get_free_idx (void)
2011{
2012 struct thread_struct *t = &current->thread;
2013 int idx;
2014
2015 for (idx = 0; idx < GDT_ENTRY_TLS_ENTRIES; idx++)
2016 if (desc_empty(t->tls_array + idx))
2017 return idx + GDT_ENTRY_TLS_MIN;
2018 return -ESRCH;
2019}
2020
2021static void set_tls_desc(struct task_struct *p, int idx,
2022 const struct ia32_user_desc *info, int n)
2023{
2024 struct thread_struct *t = &p->thread;
2025 struct desc_struct *desc = &t->tls_array[idx - GDT_ENTRY_TLS_MIN];
2026 int cpu;
2027
2028 /*
2029 * We must not get preempted while modifying the TLS.
2030 */
2031 cpu = get_cpu();
2032
2033 while (n-- > 0) {
2034 if (LDT_empty(info)) {
2035 desc->a = 0;
2036 desc->b = 0;
2037 } else {
2038 desc->a = LDT_entry_a(info);
2039 desc->b = LDT_entry_b(info);
2040 }
2041
2042 ++info;
2043 ++desc;
2044 }
2045
2046 if (t == &current->thread)
2047 load_TLS(t, cpu);
2048
2049 put_cpu();
2050}
2051
2052/*
2053 * Set a given TLS descriptor:
2054 */
2055asmlinkage int
2056sys32_set_thread_area (struct ia32_user_desc __user *u_info)
2057{
2058 struct ia32_user_desc info;
2059 int idx;
2060
2061 if (copy_from_user(&info, u_info, sizeof(info)))
2062 return -EFAULT;
2063 idx = info.entry_number;
2064
2065 /*
2066 * index -1 means the kernel should try to find and allocate an empty descriptor:
2067 */
2068 if (idx == -1) {
2069 idx = get_free_idx();
2070 if (idx < 0)
2071 return idx;
2072 if (put_user(idx, &u_info->entry_number))
2073 return -EFAULT;
2074 }
2075
2076 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
2077 return -EINVAL;
2078
2079 set_tls_desc(current, idx, &info, 1);
2080 return 0;
2081}
2082
2083/*
2084 * Get the current Thread-Local Storage area:
2085 */
2086
2087#define GET_BASE(desc) ( \
2088 (((desc)->a >> 16) & 0x0000ffff) | \
2089 (((desc)->b << 16) & 0x00ff0000) | \
2090 ( (desc)->b & 0xff000000) )
2091
2092#define GET_LIMIT(desc) ( \
2093 ((desc)->a & 0x0ffff) | \
2094 ((desc)->b & 0xf0000) )
2095
2096#define GET_32BIT(desc) (((desc)->b >> 22) & 1)
2097#define GET_CONTENTS(desc) (((desc)->b >> 10) & 3)
2098#define GET_WRITABLE(desc) (((desc)->b >> 9) & 1)
2099#define GET_LIMIT_PAGES(desc) (((desc)->b >> 23) & 1)
2100#define GET_PRESENT(desc) (((desc)->b >> 15) & 1)
2101#define GET_USEABLE(desc) (((desc)->b >> 20) & 1)
2102
2103static void fill_user_desc(struct ia32_user_desc *info, int idx,
2104 const struct desc_struct *desc)
2105{
2106 info->entry_number = idx;
2107 info->base_addr = GET_BASE(desc);
2108 info->limit = GET_LIMIT(desc);
2109 info->seg_32bit = GET_32BIT(desc);
2110 info->contents = GET_CONTENTS(desc);
2111 info->read_exec_only = !GET_WRITABLE(desc);
2112 info->limit_in_pages = GET_LIMIT_PAGES(desc);
2113 info->seg_not_present = !GET_PRESENT(desc);
2114 info->useable = GET_USEABLE(desc);
2115}
2116
2117asmlinkage int
2118sys32_get_thread_area (struct ia32_user_desc __user *u_info)
2119{
2120 struct ia32_user_desc info;
2121 struct desc_struct *desc;
2122 int idx;
2123
2124 if (get_user(idx, &u_info->entry_number))
2125 return -EFAULT;
2126 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
2127 return -EINVAL;
2128
2129 desc = current->thread.tls_array + idx - GDT_ENTRY_TLS_MIN;
2130 fill_user_desc(&info, idx, desc);
2131
2132 if (copy_to_user(u_info, &info, sizeof(info)))
2133 return -EFAULT;
2134 return 0;
2135}
2136
2137struct regset_get {
2138 void *kbuf;
2139 void __user *ubuf;
2140};
2141
2142struct regset_set {
2143 const void *kbuf;
2144 const void __user *ubuf;
2145};
2146
2147struct regset_getset {
2148 struct task_struct *target;
2149 const struct user_regset *regset;
2150 union {
2151 struct regset_get get;
2152 struct regset_set set;
2153 } u;
2154 unsigned int pos;
2155 unsigned int count;
2156 int ret;
2157};
2158
2159static void getfpreg(struct task_struct *task, int regno, int *val)
2160{
2161 switch (regno / sizeof(int)) {
2162 case 0:
2163 *val = task->thread.fcr & 0xffff;
2164 break;
2165 case 1:
2166 *val = task->thread.fsr & 0xffff;
2167 break;
2168 case 2:
2169 *val = (task->thread.fsr>>16) & 0xffff;
2170 break;
2171 case 3:
2172 *val = task->thread.fir;
2173 break;
2174 case 4:
2175 *val = (task->thread.fir>>32) & 0xffff;
2176 break;
2177 case 5:
2178 *val = task->thread.fdr;
2179 break;
2180 case 6:
2181 *val = (task->thread.fdr >> 32) & 0xffff;
2182 break;
2183 }
2184}
2185
2186static void setfpreg(struct task_struct *task, int regno, int val)
2187{
2188 switch (regno / sizeof(int)) {
2189 case 0:
2190 task->thread.fcr = (task->thread.fcr & (~0x1f3f))
2191 | (val & 0x1f3f);
2192 break;
2193 case 1:
2194 task->thread.fsr = (task->thread.fsr & (~0xffff)) | val;
2195 break;
2196 case 2:
2197 task->thread.fsr = (task->thread.fsr & (~0xffff0000))
2198 | (val << 16);
2199 break;
2200 case 3:
2201 task->thread.fir = (task->thread.fir & (~0xffffffff)) | val;
2202 break;
2203 case 5:
2204 task->thread.fdr = (task->thread.fdr & (~0xffffffff)) | val;
2205 break;
2206 }
2207}
2208
2209static void access_fpreg_ia32(int regno, void *reg,
2210 struct pt_regs *pt, struct switch_stack *sw,
2211 int tos, int write)
2212{
2213 void *f;
2214
2215 if ((regno += tos) >= 8)
2216 regno -= 8;
2217 if (regno < 4)
2218 f = &pt->f8 + regno;
2219 else if (regno <= 7)
2220 f = &sw->f12 + (regno - 4);
2221 else {
2222 printk(KERN_ERR "regno must be less than 7 \n");
2223 return;
2224 }
2225
2226 if (write)
2227 memcpy(f, reg, sizeof(struct _fpreg_ia32));
2228 else
2229 memcpy(reg, f, sizeof(struct _fpreg_ia32));
2230}
2231
2232static void do_fpregs_get(struct unw_frame_info *info, void *arg)
2233{
2234 struct regset_getset *dst = arg;
2235 struct task_struct *task = dst->target;
2236 struct pt_regs *pt;
2237 int start, end, tos;
2238 char buf[80];
2239
2240 if (dst->count == 0 || unw_unwind_to_user(info) < 0)
2241 return;
2242 if (dst->pos < 7 * sizeof(int)) {
2243 end = min((dst->pos + dst->count),
2244 (unsigned int)(7 * sizeof(int)));
2245 for (start = dst->pos; start < end; start += sizeof(int))
2246 getfpreg(task, start, (int *)(buf + start));
2247 dst->ret = user_regset_copyout(&dst->pos, &dst->count,
2248 &dst->u.get.kbuf, &dst->u.get.ubuf, buf,
2249 0, 7 * sizeof(int));
2250 if (dst->ret || dst->count == 0)
2251 return;
2252 }
2253 if (dst->pos < sizeof(struct ia32_user_i387_struct)) {
2254 pt = task_pt_regs(task);
2255 tos = (task->thread.fsr >> 11) & 7;
2256 end = min(dst->pos + dst->count,
2257 (unsigned int)(sizeof(struct ia32_user_i387_struct)));
2258 start = (dst->pos - 7 * sizeof(int)) /
2259 sizeof(struct _fpreg_ia32);
2260 end = (end - 7 * sizeof(int)) / sizeof(struct _fpreg_ia32);
2261 for (; start < end; start++)
2262 access_fpreg_ia32(start,
2263 (struct _fpreg_ia32 *)buf + start,
2264 pt, info->sw, tos, 0);
2265 dst->ret = user_regset_copyout(&dst->pos, &dst->count,
2266 &dst->u.get.kbuf, &dst->u.get.ubuf,
2267 buf, 7 * sizeof(int),
2268 sizeof(struct ia32_user_i387_struct));
2269 if (dst->ret || dst->count == 0)
2270 return;
2271 }
2272}
2273
2274static void do_fpregs_set(struct unw_frame_info *info, void *arg)
2275{
2276 struct regset_getset *dst = arg;
2277 struct task_struct *task = dst->target;
2278 struct pt_regs *pt;
2279 char buf[80];
2280 int end, start, tos;
2281
2282 if (dst->count == 0 || unw_unwind_to_user(info) < 0)
2283 return;
2284
2285 if (dst->pos < 7 * sizeof(int)) {
2286 start = dst->pos;
2287 dst->ret = user_regset_copyin(&dst->pos, &dst->count,
2288 &dst->u.set.kbuf, &dst->u.set.ubuf, buf,
2289 0, 7 * sizeof(int));
2290 if (dst->ret)
2291 return;
2292 for (; start < dst->pos; start += sizeof(int))
2293 setfpreg(task, start, *((int *)(buf + start)));
2294 if (dst->count == 0)
2295 return;
2296 }
2297 if (dst->pos < sizeof(struct ia32_user_i387_struct)) {
2298 start = (dst->pos - 7 * sizeof(int)) /
2299 sizeof(struct _fpreg_ia32);
2300 dst->ret = user_regset_copyin(&dst->pos, &dst->count,
2301 &dst->u.set.kbuf, &dst->u.set.ubuf,
2302 buf, 7 * sizeof(int),
2303 sizeof(struct ia32_user_i387_struct));
2304 if (dst->ret)
2305 return;
2306 pt = task_pt_regs(task);
2307 tos = (task->thread.fsr >> 11) & 7;
2308 end = (dst->pos - 7 * sizeof(int)) / sizeof(struct _fpreg_ia32);
2309 for (; start < end; start++)
2310 access_fpreg_ia32(start,
2311 (struct _fpreg_ia32 *)buf + start,
2312 pt, info->sw, tos, 1);
2313 if (dst->count == 0)
2314 return;
2315 }
2316}
2317
2318#define OFFSET(member) ((int)(offsetof(struct ia32_user_fxsr_struct, member)))
2319static void getfpxreg(struct task_struct *task, int start, int end, char *buf)
2320{
2321 int min_val;
2322
2323 min_val = min(end, OFFSET(fop));
2324 while (start < min_val) {
2325 if (start == OFFSET(cwd))
2326 *((short *)buf) = task->thread.fcr & 0xffff;
2327 else if (start == OFFSET(swd))
2328 *((short *)buf) = task->thread.fsr & 0xffff;
2329 else if (start == OFFSET(twd))
2330 *((short *)buf) = (task->thread.fsr>>16) & 0xffff;
2331 buf += 2;
2332 start += 2;
2333 }
2334 /* skip fop element */
2335 if (start == OFFSET(fop)) {
2336 start += 2;
2337 buf += 2;
2338 }
2339 while (start < end) {
2340 if (start == OFFSET(fip))
2341 *((int *)buf) = task->thread.fir;
2342 else if (start == OFFSET(fcs))
2343 *((int *)buf) = (task->thread.fir>>32) & 0xffff;
2344 else if (start == OFFSET(foo))
2345 *((int *)buf) = task->thread.fdr;
2346 else if (start == OFFSET(fos))
2347 *((int *)buf) = (task->thread.fdr>>32) & 0xffff;
2348 else if (start == OFFSET(mxcsr))
2349 *((int *)buf) = ((task->thread.fcr>>32) & 0xff80)
2350 | ((task->thread.fsr>>32) & 0x3f);
2351 buf += 4;
2352 start += 4;
2353 }
2354}
2355
2356static void setfpxreg(struct task_struct *task, int start, int end, char *buf)
2357{
2358 int min_val, num32;
2359 short num;
2360 unsigned long num64;
2361
2362 min_val = min(end, OFFSET(fop));
2363 while (start < min_val) {
2364 num = *((short *)buf);
2365 if (start == OFFSET(cwd)) {
2366 task->thread.fcr = (task->thread.fcr & (~0x1f3f))
2367 | (num & 0x1f3f);
2368 } else if (start == OFFSET(swd)) {
2369 task->thread.fsr = (task->thread.fsr & (~0xffff)) | num;
2370 } else if (start == OFFSET(twd)) {
2371 task->thread.fsr = (task->thread.fsr & (~0xffff0000))
2372 | (((int)num) << 16);
2373 }
2374 buf += 2;
2375 start += 2;
2376 }
2377 /* skip fop element */
2378 if (start == OFFSET(fop)) {
2379 start += 2;
2380 buf += 2;
2381 }
2382 while (start < end) {
2383 num32 = *((int *)buf);
2384 if (start == OFFSET(fip))
2385 task->thread.fir = (task->thread.fir & (~0xffffffff))
2386 | num32;
2387 else if (start == OFFSET(foo))
2388 task->thread.fdr = (task->thread.fdr & (~0xffffffff))
2389 | num32;
2390 else if (start == OFFSET(mxcsr)) {
2391 num64 = num32 & 0xff10;
2392 task->thread.fcr = (task->thread.fcr &
2393 (~0xff1000000000UL)) | (num64<<32);
2394 num64 = num32 & 0x3f;
2395 task->thread.fsr = (task->thread.fsr &
2396 (~0x3f00000000UL)) | (num64<<32);
2397 }
2398 buf += 4;
2399 start += 4;
2400 }
2401}
2402
2403static void do_fpxregs_get(struct unw_frame_info *info, void *arg)
2404{
2405 struct regset_getset *dst = arg;
2406 struct task_struct *task = dst->target;
2407 struct pt_regs *pt;
2408 char buf[128];
2409 int start, end, tos;
2410
2411 if (dst->count == 0 || unw_unwind_to_user(info) < 0)
2412 return;
2413 if (dst->pos < OFFSET(st_space[0])) {
2414 end = min(dst->pos + dst->count, (unsigned int)32);
2415 getfpxreg(task, dst->pos, end, buf);
2416 dst->ret = user_regset_copyout(&dst->pos, &dst->count,
2417 &dst->u.get.kbuf, &dst->u.get.ubuf, buf,
2418 0, OFFSET(st_space[0]));
2419 if (dst->ret || dst->count == 0)
2420 return;
2421 }
2422 if (dst->pos < OFFSET(xmm_space[0])) {
2423 pt = task_pt_regs(task);
2424 tos = (task->thread.fsr >> 11) & 7;
2425 end = min(dst->pos + dst->count,
2426 (unsigned int)OFFSET(xmm_space[0]));
2427 start = (dst->pos - OFFSET(st_space[0])) / 16;
2428 end = (end - OFFSET(st_space[0])) / 16;
2429 for (; start < end; start++)
2430 access_fpreg_ia32(start, buf + 16 * start, pt,
2431 info->sw, tos, 0);
2432 dst->ret = user_regset_copyout(&dst->pos, &dst->count,
2433 &dst->u.get.kbuf, &dst->u.get.ubuf,
2434 buf, OFFSET(st_space[0]), OFFSET(xmm_space[0]));
2435 if (dst->ret || dst->count == 0)
2436 return;
2437 }
2438 if (dst->pos < OFFSET(padding[0]))
2439 dst->ret = user_regset_copyout(&dst->pos, &dst->count,
2440 &dst->u.get.kbuf, &dst->u.get.ubuf,
2441 &info->sw->f16, OFFSET(xmm_space[0]),
2442 OFFSET(padding[0]));
2443}
2444
2445static void do_fpxregs_set(struct unw_frame_info *info, void *arg)
2446{
2447 struct regset_getset *dst = arg;
2448 struct task_struct *task = dst->target;
2449 char buf[128];
2450 int start, end;
2451
2452 if (dst->count == 0 || unw_unwind_to_user(info) < 0)
2453 return;
2454
2455 if (dst->pos < OFFSET(st_space[0])) {
2456 start = dst->pos;
2457 dst->ret = user_regset_copyin(&dst->pos, &dst->count,
2458 &dst->u.set.kbuf, &dst->u.set.ubuf,
2459 buf, 0, OFFSET(st_space[0]));
2460 if (dst->ret)
2461 return;
2462 setfpxreg(task, start, dst->pos, buf);
2463 if (dst->count == 0)
2464 return;
2465 }
2466 if (dst->pos < OFFSET(xmm_space[0])) {
2467 struct pt_regs *pt;
2468 int tos;
2469 pt = task_pt_regs(task);
2470 tos = (task->thread.fsr >> 11) & 7;
2471 start = (dst->pos - OFFSET(st_space[0])) / 16;
2472 dst->ret = user_regset_copyin(&dst->pos, &dst->count,
2473 &dst->u.set.kbuf, &dst->u.set.ubuf,
2474 buf, OFFSET(st_space[0]), OFFSET(xmm_space[0]));
2475 if (dst->ret)
2476 return;
2477 end = (dst->pos - OFFSET(st_space[0])) / 16;
2478 for (; start < end; start++)
2479 access_fpreg_ia32(start, buf + 16 * start, pt, info->sw,
2480 tos, 1);
2481 if (dst->count == 0)
2482 return;
2483 }
2484 if (dst->pos < OFFSET(padding[0]))
2485 dst->ret = user_regset_copyin(&dst->pos, &dst->count,
2486 &dst->u.set.kbuf, &dst->u.set.ubuf,
2487 &info->sw->f16, OFFSET(xmm_space[0]),
2488 OFFSET(padding[0]));
2489}
2490#undef OFFSET
2491
2492static int do_regset_call(void (*call)(struct unw_frame_info *, void *),
2493 struct task_struct *target,
2494 const struct user_regset *regset,
2495 unsigned int pos, unsigned int count,
2496 const void *kbuf, const void __user *ubuf)
2497{
2498 struct regset_getset info = { .target = target, .regset = regset,
2499 .pos = pos, .count = count,
2500 .u.set = { .kbuf = kbuf, .ubuf = ubuf },
2501 .ret = 0 };
2502
2503 if (target == current)
2504 unw_init_running(call, &info);
2505 else {
2506 struct unw_frame_info ufi;
2507 memset(&ufi, 0, sizeof(ufi));
2508 unw_init_from_blocked_task(&ufi, target);
2509 (*call)(&ufi, &info);
2510 }
2511
2512 return info.ret;
2513}
2514
2515static int ia32_fpregs_get(struct task_struct *target,
2516 const struct user_regset *regset,
2517 unsigned int pos, unsigned int count,
2518 void *kbuf, void __user *ubuf)
2519{
2520 return do_regset_call(do_fpregs_get, target, regset, pos, count,
2521 kbuf, ubuf);
2522}
2523
2524static int ia32_fpregs_set(struct task_struct *target,
2525 const struct user_regset *regset,
2526 unsigned int pos, unsigned int count,
2527 const void *kbuf, const void __user *ubuf)
2528{
2529 return do_regset_call(do_fpregs_set, target, regset, pos, count,
2530 kbuf, ubuf);
2531}
2532
2533static int ia32_fpxregs_get(struct task_struct *target,
2534 const struct user_regset *regset,
2535 unsigned int pos, unsigned int count,
2536 void *kbuf, void __user *ubuf)
2537{
2538 return do_regset_call(do_fpxregs_get, target, regset, pos, count,
2539 kbuf, ubuf);
2540}
2541
2542static int ia32_fpxregs_set(struct task_struct *target,
2543 const struct user_regset *regset,
2544 unsigned int pos, unsigned int count,
2545 const void *kbuf, const void __user *ubuf)
2546{
2547 return do_regset_call(do_fpxregs_set, target, regset, pos, count,
2548 kbuf, ubuf);
2549}
2550
2551static int ia32_genregs_get(struct task_struct *target,
2552 const struct user_regset *regset,
2553 unsigned int pos, unsigned int count,
2554 void *kbuf, void __user *ubuf)
2555{
2556 if (kbuf) {
2557 u32 *kp = kbuf;
2558 while (count > 0) {
2559 *kp++ = getreg(target, pos);
2560 pos += 4;
2561 count -= 4;
2562 }
2563 } else {
2564 u32 __user *up = ubuf;
2565 while (count > 0) {
2566 if (__put_user(getreg(target, pos), up++))
2567 return -EFAULT;
2568 pos += 4;
2569 count -= 4;
2570 }
2571 }
2572 return 0;
2573}
2574
2575static int ia32_genregs_set(struct task_struct *target,
2576 const struct user_regset *regset,
2577 unsigned int pos, unsigned int count,
2578 const void *kbuf, const void __user *ubuf)
2579{
2580 int ret = 0;
2581
2582 if (kbuf) {
2583 const u32 *kp = kbuf;
2584 while (!ret && count > 0) {
2585 putreg(target, pos, *kp++);
2586 pos += 4;
2587 count -= 4;
2588 }
2589 } else {
2590 const u32 __user *up = ubuf;
2591 u32 val;
2592 while (!ret && count > 0) {
2593 ret = __get_user(val, up++);
2594 if (!ret)
2595 putreg(target, pos, val);
2596 pos += 4;
2597 count -= 4;
2598 }
2599 }
2600 return ret;
2601}
2602
2603static int ia32_tls_active(struct task_struct *target,
2604 const struct user_regset *regset)
2605{
2606 struct thread_struct *t = &target->thread;
2607 int n = GDT_ENTRY_TLS_ENTRIES;
2608 while (n > 0 && desc_empty(&t->tls_array[n -1]))
2609 --n;
2610 return n;
2611}
2612
2613static int ia32_tls_get(struct task_struct *target,
2614 const struct user_regset *regset, unsigned int pos,
2615 unsigned int count, void *kbuf, void __user *ubuf)
2616{
2617 const struct desc_struct *tls;
2618
2619 if (pos > GDT_ENTRY_TLS_ENTRIES * sizeof(struct ia32_user_desc) ||
2620 (pos % sizeof(struct ia32_user_desc)) != 0 ||
2621 (count % sizeof(struct ia32_user_desc)) != 0)
2622 return -EINVAL;
2623
2624 pos /= sizeof(struct ia32_user_desc);
2625 count /= sizeof(struct ia32_user_desc);
2626
2627 tls = &target->thread.tls_array[pos];
2628
2629 if (kbuf) {
2630 struct ia32_user_desc *info = kbuf;
2631 while (count-- > 0)
2632 fill_user_desc(info++, GDT_ENTRY_TLS_MIN + pos++,
2633 tls++);
2634 } else {
2635 struct ia32_user_desc __user *u_info = ubuf;
2636 while (count-- > 0) {
2637 struct ia32_user_desc info;
2638 fill_user_desc(&info, GDT_ENTRY_TLS_MIN + pos++, tls++);
2639 if (__copy_to_user(u_info++, &info, sizeof(info)))
2640 return -EFAULT;
2641 }
2642 }
2643
2644 return 0;
2645}
2646
2647static int ia32_tls_set(struct task_struct *target,
2648 const struct user_regset *regset, unsigned int pos,
2649 unsigned int count, const void *kbuf, const void __user *ubuf)
2650{
2651 struct ia32_user_desc infobuf[GDT_ENTRY_TLS_ENTRIES];
2652 const struct ia32_user_desc *info;
2653
2654 if (pos > GDT_ENTRY_TLS_ENTRIES * sizeof(struct ia32_user_desc) ||
2655 (pos % sizeof(struct ia32_user_desc)) != 0 ||
2656 (count % sizeof(struct ia32_user_desc)) != 0)
2657 return -EINVAL;
2658
2659 if (kbuf)
2660 info = kbuf;
2661 else if (__copy_from_user(infobuf, ubuf, count))
2662 return -EFAULT;
2663 else
2664 info = infobuf;
2665
2666 set_tls_desc(target,
2667 GDT_ENTRY_TLS_MIN + (pos / sizeof(struct ia32_user_desc)),
2668 info, count / sizeof(struct ia32_user_desc));
2669
2670 return 0;
2671}
2672
2673/*
2674 * This should match arch/i386/kernel/ptrace.c:native_regsets.
2675 * XXX ioperm? vm86?
2676 */
2677static const struct user_regset ia32_regsets[] = {
2678 {
2679 .core_note_type = NT_PRSTATUS,
2680 .n = sizeof(struct user_regs_struct32)/4,
2681 .size = 4, .align = 4,
2682 .get = ia32_genregs_get, .set = ia32_genregs_set
2683 },
2684 {
2685 .core_note_type = NT_PRFPREG,
2686 .n = sizeof(struct ia32_user_i387_struct) / 4,
2687 .size = 4, .align = 4,
2688 .get = ia32_fpregs_get, .set = ia32_fpregs_set
2689 },
2690 {
2691 .core_note_type = NT_PRXFPREG,
2692 .n = sizeof(struct ia32_user_fxsr_struct) / 4,
2693 .size = 4, .align = 4,
2694 .get = ia32_fpxregs_get, .set = ia32_fpxregs_set
2695 },
2696 {
2697 .core_note_type = NT_386_TLS,
2698 .n = GDT_ENTRY_TLS_ENTRIES,
2699 .bias = GDT_ENTRY_TLS_MIN,
2700 .size = sizeof(struct ia32_user_desc),
2701 .align = sizeof(struct ia32_user_desc),
2702 .active = ia32_tls_active,
2703 .get = ia32_tls_get, .set = ia32_tls_set,
2704 },
2705};
2706
2707const struct user_regset_view user_ia32_view = {
2708 .name = "i386", .e_machine = EM_386,
2709 .regsets = ia32_regsets, .n = ARRAY_SIZE(ia32_regsets)
2710};
2711
2712long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high,
2713 __u32 len_low, __u32 len_high, int advice)
2714{
2715 return sys_fadvise64_64(fd,
2716 (((u64)offset_high)<<32) | offset_low,
2717 (((u64)len_high)<<32) | len_low,
2718 advice);
2719}
2720
2721#ifdef NOTYET /* UNTESTED FOR IA64 FROM HERE DOWN */
2722
2723asmlinkage long sys32_setreuid(compat_uid_t ruid, compat_uid_t euid)
2724{
2725 uid_t sruid, seuid;
2726
2727 sruid = (ruid == (compat_uid_t)-1) ? ((uid_t)-1) : ((uid_t)ruid);
2728 seuid = (euid == (compat_uid_t)-1) ? ((uid_t)-1) : ((uid_t)euid);
2729 return sys_setreuid(sruid, seuid);
2730}
2731
2732asmlinkage long
2733sys32_setresuid(compat_uid_t ruid, compat_uid_t euid,
2734 compat_uid_t suid)
2735{
2736 uid_t sruid, seuid, ssuid;
2737
2738 sruid = (ruid == (compat_uid_t)-1) ? ((uid_t)-1) : ((uid_t)ruid);
2739 seuid = (euid == (compat_uid_t)-1) ? ((uid_t)-1) : ((uid_t)euid);
2740 ssuid = (suid == (compat_uid_t)-1) ? ((uid_t)-1) : ((uid_t)suid);
2741 return sys_setresuid(sruid, seuid, ssuid);
2742}
2743
2744asmlinkage long
2745sys32_setregid(compat_gid_t rgid, compat_gid_t egid)
2746{
2747 gid_t srgid, segid;
2748
2749 srgid = (rgid == (compat_gid_t)-1) ? ((gid_t)-1) : ((gid_t)rgid);
2750 segid = (egid == (compat_gid_t)-1) ? ((gid_t)-1) : ((gid_t)egid);
2751 return sys_setregid(srgid, segid);
2752}
2753
2754asmlinkage long
2755sys32_setresgid(compat_gid_t rgid, compat_gid_t egid,
2756 compat_gid_t sgid)
2757{
2758 gid_t srgid, segid, ssgid;
2759
2760 srgid = (rgid == (compat_gid_t)-1) ? ((gid_t)-1) : ((gid_t)rgid);
2761 segid = (egid == (compat_gid_t)-1) ? ((gid_t)-1) : ((gid_t)egid);
2762 ssgid = (sgid == (compat_gid_t)-1) ? ((gid_t)-1) : ((gid_t)sgid);
2763 return sys_setresgid(srgid, segid, ssgid);
2764}
2765#endif /* NOTYET */
diff --git a/arch/ia64/include/asm/acpi.h b/arch/ia64/include/asm/acpi.h
index 7ae58892ba8d..837dc82a013e 100644
--- a/arch/ia64/include/asm/acpi.h
+++ b/arch/ia64/include/asm/acpi.h
@@ -97,8 +97,34 @@ ia64_acpi_release_global_lock (unsigned int *lock)
97#endif 97#endif
98#define acpi_processor_cstate_check(x) (x) /* no idle limits on IA64 :) */ 98#define acpi_processor_cstate_check(x) (x) /* no idle limits on IA64 :) */
99static inline void disable_acpi(void) { } 99static inline void disable_acpi(void) { }
100static inline void pci_acpi_crs_quirks(void) { }
100 101
102#ifdef CONFIG_IA64_GENERIC
101const char *acpi_get_sysname (void); 103const char *acpi_get_sysname (void);
104#else
105static inline const char *acpi_get_sysname (void)
106{
107# if defined (CONFIG_IA64_HP_SIM)
108 return "hpsim";
109# elif defined (CONFIG_IA64_HP_ZX1)
110 return "hpzx1";
111# elif defined (CONFIG_IA64_HP_ZX1_SWIOTLB)
112 return "hpzx1_swiotlb";
113# elif defined (CONFIG_IA64_SGI_SN2)
114 return "sn2";
115# elif defined (CONFIG_IA64_SGI_UV)
116 return "uv";
117# elif defined (CONFIG_IA64_DIG)
118 return "dig";
119# elif defined (CONFIG_IA64_XEN_GUEST)
120 return "xen";
121# elif defined(CONFIG_IA64_DIG_VTD)
122 return "dig_vtd";
123# else
124# error Unknown platform. Fix acpi.c.
125# endif
126}
127#endif
102int acpi_request_vector (u32 int_type); 128int acpi_request_vector (u32 int_type);
103int acpi_gsi_to_irq (u32 gsi, unsigned int *irq); 129int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
104 130
diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
index 88405cb0832a..4e1948447a00 100644
--- a/arch/ia64/include/asm/atomic.h
+++ b/arch/ia64/include/asm/atomic.h
@@ -21,8 +21,8 @@
21#define ATOMIC_INIT(i) ((atomic_t) { (i) }) 21#define ATOMIC_INIT(i) ((atomic_t) { (i) })
22#define ATOMIC64_INIT(i) ((atomic64_t) { (i) }) 22#define ATOMIC64_INIT(i) ((atomic64_t) { (i) })
23 23
24#define atomic_read(v) ((v)->counter) 24#define atomic_read(v) (*(volatile int *)&(v)->counter)
25#define atomic64_read(v) ((v)->counter) 25#define atomic64_read(v) (*(volatile long *)&(v)->counter)
26 26
27#define atomic_set(v,i) (((v)->counter) = (i)) 27#define atomic_set(v,i) (((v)->counter) = (i))
28#define atomic64_set(v,i) (((v)->counter) = (i)) 28#define atomic64_set(v,i) (((v)->counter) = (i))
diff --git a/arch/ia64/include/asm/bitops.h b/arch/ia64/include/asm/bitops.h
index 6ebc229a1c51..9da3df6f1a52 100644
--- a/arch/ia64/include/asm/bitops.h
+++ b/arch/ia64/include/asm/bitops.h
@@ -437,17 +437,18 @@ __fls (unsigned long x)
437 * hweightN: returns the hamming weight (i.e. the number 437 * hweightN: returns the hamming weight (i.e. the number
438 * of bits set) of a N-bit word 438 * of bits set) of a N-bit word
439 */ 439 */
440static __inline__ unsigned long 440static __inline__ unsigned long __arch_hweight64(unsigned long x)
441hweight64 (unsigned long x)
442{ 441{
443 unsigned long result; 442 unsigned long result;
444 result = ia64_popcnt(x); 443 result = ia64_popcnt(x);
445 return result; 444 return result;
446} 445}
447 446
448#define hweight32(x) (unsigned int) hweight64((x) & 0xfffffffful) 447#define __arch_hweight32(x) ((unsigned int) __arch_hweight64((x) & 0xfffffffful))
449#define hweight16(x) (unsigned int) hweight64((x) & 0xfffful) 448#define __arch_hweight16(x) ((unsigned int) __arch_hweight64((x) & 0xfffful))
450#define hweight8(x) (unsigned int) hweight64((x) & 0xfful) 449#define __arch_hweight8(x) ((unsigned int) __arch_hweight64((x) & 0xfful))
450
451#include <asm-generic/bitops/const_hweight.h>
451 452
452#endif /* __KERNEL__ */ 453#endif /* __KERNEL__ */
453 454
diff --git a/arch/ia64/include/asm/compat.h b/arch/ia64/include/asm/compat.h
index dfcf75b8426d..f90edc85b509 100644
--- a/arch/ia64/include/asm/compat.h
+++ b/arch/ia64/include/asm/compat.h
@@ -5,7 +5,8 @@
5 */ 5 */
6#include <linux/types.h> 6#include <linux/types.h>
7 7
8#define COMPAT_USER_HZ 100 8#define COMPAT_USER_HZ 100
9#define COMPAT_UTS_MACHINE "i686\0\0\0"
9 10
10typedef u32 compat_size_t; 11typedef u32 compat_size_t;
11typedef s32 compat_ssize_t; 12typedef s32 compat_ssize_t;
diff --git a/arch/ia64/include/asm/dmi.h b/arch/ia64/include/asm/dmi.h
index 00eb1b130b63..1ed4c8fedb83 100644
--- a/arch/ia64/include/asm/dmi.h
+++ b/arch/ia64/include/asm/dmi.h
@@ -1,6 +1,7 @@
1#ifndef _ASM_DMI_H 1#ifndef _ASM_DMI_H
2#define _ASM_DMI_H 1 2#define _ASM_DMI_H 1
3 3
4#include <linux/slab.h>
4#include <asm/io.h> 5#include <asm/io.h>
5 6
6/* Use normal IO mappings for DMI */ 7/* Use normal IO mappings for DMI */
diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
index e14108b19c09..b5298eb09adb 100644
--- a/arch/ia64/include/asm/elf.h
+++ b/arch/ia64/include/asm/elf.h
@@ -201,7 +201,9 @@ extern void ia64_elf_core_copy_regs (struct pt_regs *src, elf_gregset_t dst);
201 relevant until we have real hardware to play with... */ 201 relevant until we have real hardware to play with... */
202#define ELF_PLATFORM NULL 202#define ELF_PLATFORM NULL
203 203
204#define SET_PERSONALITY(ex) set_personality(PER_LINUX) 204#define SET_PERSONALITY(ex) \
205 set_personality((current->personality & ~PER_MASK) | PER_LINUX)
206
205#define elf_read_implies_exec(ex, executable_stack) \ 207#define elf_read_implies_exec(ex, executable_stack) \
206 ((executable_stack!=EXSTACK_DISABLE_X) && ((ex).e_flags & EF_IA_64_LINUX_EXECUTABLE_STACK) != 0) 208 ((executable_stack!=EXSTACK_DISABLE_X) && ((ex).e_flags & EF_IA_64_LINUX_EXECUTABLE_STACK) != 0)
207 209
@@ -217,54 +219,6 @@ do { \
217 NEW_AUX_ENT(AT_SYSINFO_EHDR, (unsigned long) GATE_EHDR); \ 219 NEW_AUX_ENT(AT_SYSINFO_EHDR, (unsigned long) GATE_EHDR); \
218} while (0) 220} while (0)
219 221
220
221/*
222 * These macros parameterize elf_core_dump in fs/binfmt_elf.c to write out
223 * extra segments containing the gate DSO contents. Dumping its
224 * contents makes post-mortem fully interpretable later without matching up
225 * the same kernel and hardware config to see what PC values meant.
226 * Dumping its extra ELF program headers includes all the other information
227 * a debugger needs to easily find how the gate DSO was being used.
228 */
229#define ELF_CORE_EXTRA_PHDRS (GATE_EHDR->e_phnum)
230#define ELF_CORE_WRITE_EXTRA_PHDRS \
231do { \
232 const struct elf_phdr *const gate_phdrs = \
233 (const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff); \
234 int i; \
235 Elf64_Off ofs = 0; \
236 for (i = 0; i < GATE_EHDR->e_phnum; ++i) { \
237 struct elf_phdr phdr = gate_phdrs[i]; \
238 if (phdr.p_type == PT_LOAD) { \
239 phdr.p_memsz = PAGE_ALIGN(phdr.p_memsz); \
240 phdr.p_filesz = phdr.p_memsz; \
241 if (ofs == 0) { \
242 ofs = phdr.p_offset = offset; \
243 offset += phdr.p_filesz; \
244 } \
245 else \
246 phdr.p_offset = ofs; \
247 } \
248 else \
249 phdr.p_offset += ofs; \
250 phdr.p_paddr = 0; /* match other core phdrs */ \
251 DUMP_WRITE(&phdr, sizeof(phdr)); \
252 } \
253} while (0)
254#define ELF_CORE_WRITE_EXTRA_DATA \
255do { \
256 const struct elf_phdr *const gate_phdrs = \
257 (const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff); \
258 int i; \
259 for (i = 0; i < GATE_EHDR->e_phnum; ++i) { \
260 if (gate_phdrs[i].p_type == PT_LOAD) { \
261 DUMP_WRITE((void *) gate_phdrs[i].p_vaddr, \
262 PAGE_ALIGN(gate_phdrs[i].p_memsz)); \
263 break; \
264 } \
265 } \
266} while (0)
267
268/* 222/*
269 * format for entries in the Global Offset Table 223 * format for entries in the Global Offset Table
270 */ 224 */
diff --git a/arch/ia64/include/asm/ia32.h b/arch/ia64/include/asm/ia32.h
deleted file mode 100644
index 2390ee145aa1..000000000000
--- a/arch/ia64/include/asm/ia32.h
+++ /dev/null
@@ -1,40 +0,0 @@
1#ifndef _ASM_IA64_IA32_H
2#define _ASM_IA64_IA32_H
3
4
5#include <asm/ptrace.h>
6#include <asm/signal.h>
7
8#define IA32_NR_syscalls 285 /* length of syscall table */
9#define IA32_PAGE_SHIFT 12 /* 4KB pages */
10
11#ifndef __ASSEMBLY__
12
13# ifdef CONFIG_IA32_SUPPORT
14
15#define IA32_PAGE_OFFSET 0xc0000000
16
17extern void ia32_cpu_init (void);
18extern void ia32_mem_init (void);
19extern void ia32_gdt_init (void);
20extern int ia32_exception (struct pt_regs *regs, unsigned long isr);
21extern int ia32_intercept (struct pt_regs *regs, unsigned long isr);
22extern int ia32_clone_tls (struct task_struct *child, struct pt_regs *childregs);
23
24# endif /* !CONFIG_IA32_SUPPORT */
25
26/* Declare this unconditionally, so we don't get warnings for unreachable code. */
27extern int ia32_setup_frame1 (int sig, struct k_sigaction *ka, siginfo_t *info,
28 sigset_t *set, struct pt_regs *regs);
29#if PAGE_SHIFT > IA32_PAGE_SHIFT
30extern int ia32_copy_ia64_partial_page_list(struct task_struct *,
31 unsigned long);
32extern void ia32_drop_ia64_partial_page_list(struct task_struct *);
33#else
34# define ia32_copy_ia64_partial_page_list(a1, a2) 0
35# define ia32_drop_ia64_partial_page_list(a1) do { ; } while (0)
36#endif
37
38#endif /* !__ASSEMBLY__ */
39
40#endif /* _ASM_IA64_IA32_H */
diff --git a/arch/ia64/include/asm/mmzone.h b/arch/ia64/include/asm/mmzone.h
index f2ca32069b3f..e0de61709cf1 100644
--- a/arch/ia64/include/asm/mmzone.h
+++ b/arch/ia64/include/asm/mmzone.h
@@ -19,16 +19,12 @@
19 19
20static inline int pfn_to_nid(unsigned long pfn) 20static inline int pfn_to_nid(unsigned long pfn)
21{ 21{
22#ifdef CONFIG_NUMA
23 extern int paddr_to_nid(unsigned long); 22 extern int paddr_to_nid(unsigned long);
24 int nid = paddr_to_nid(pfn << PAGE_SHIFT); 23 int nid = paddr_to_nid(pfn << PAGE_SHIFT);
25 if (nid < 0) 24 if (nid < 0)
26 return 0; 25 return 0;
27 else 26 else
28 return nid; 27 return nid;
29#else
30 return 0;
31#endif
32} 28}
33 29
34#ifdef CONFIG_IA64_DIG /* DIG systems are small */ 30#ifdef CONFIG_IA64_DIG /* DIG systems are small */
diff --git a/arch/ia64/include/asm/pci.h b/arch/ia64/include/asm/pci.h
index 55281aabe5f2..73b5f785e70c 100644
--- a/arch/ia64/include/asm/pci.h
+++ b/arch/ia64/include/asm/pci.h
@@ -56,20 +56,6 @@ pcibios_penalize_isa_irq (int irq, int active)
56 56
57#include <asm-generic/pci-dma-compat.h> 57#include <asm-generic/pci-dma-compat.h>
58 58
59/* pci_unmap_{single,page} is not a nop, thus... */
60#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
61 dma_addr_t ADDR_NAME;
62#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
63 __u32 LEN_NAME;
64#define pci_unmap_addr(PTR, ADDR_NAME) \
65 ((PTR)->ADDR_NAME)
66#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
67 (((PTR)->ADDR_NAME) = (VAL))
68#define pci_unmap_len(PTR, LEN_NAME) \
69 ((PTR)->LEN_NAME)
70#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
71 (((PTR)->LEN_NAME) = (VAL))
72
73#ifdef CONFIG_PCI 59#ifdef CONFIG_PCI
74static inline void pci_dma_burst_advice(struct pci_dev *pdev, 60static inline void pci_dma_burst_advice(struct pci_dev *pdev,
75 enum pci_dma_burst_strategy *strat, 61 enum pci_dma_burst_strategy *strat,
diff --git a/arch/ia64/include/asm/percpu.h b/arch/ia64/include/asm/percpu.h
index 35d9aeb6d85f..14aa1c58912b 100644
--- a/arch/ia64/include/asm/percpu.h
+++ b/arch/ia64/include/asm/percpu.h
@@ -9,7 +9,7 @@
9#define PERCPU_ENOUGH_ROOM PERCPU_PAGE_SIZE 9#define PERCPU_ENOUGH_ROOM PERCPU_PAGE_SIZE
10 10
11#ifdef __ASSEMBLY__ 11#ifdef __ASSEMBLY__
12# define THIS_CPU(var) (per_cpu__##var) /* use this to mark accesses to per-CPU variables... */ 12# define THIS_CPU(var) (var) /* use this to mark accesses to per-CPU variables... */
13#else /* !__ASSEMBLY__ */ 13#else /* !__ASSEMBLY__ */
14 14
15 15
@@ -39,7 +39,10 @@ extern void *per_cpu_init(void);
39 * On the positive side, using __ia64_per_cpu_var() instead of __get_cpu_var() is slightly 39 * On the positive side, using __ia64_per_cpu_var() instead of __get_cpu_var() is slightly
40 * more efficient. 40 * more efficient.
41 */ 41 */
42#define __ia64_per_cpu_var(var) per_cpu__##var 42#define __ia64_per_cpu_var(var) (*({ \
43 __verify_pcpu_ptr(&(var)); \
44 ((typeof(var) __kernel __force *)&(var)); \
45}))
43 46
44#include <asm-generic/percpu.h> 47#include <asm-generic/percpu.h>
45 48
diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
index 69bf13857a9f..c3286f42e501 100644
--- a/arch/ia64/include/asm/pgtable.h
+++ b/arch/ia64/include/asm/pgtable.h
@@ -462,7 +462,7 @@ pte_same (pte_t a, pte_t b)
462 return pte_val(a) == pte_val(b); 462 return pte_val(a) == pte_val(b);
463} 463}
464 464
465#define update_mmu_cache(vma, address, pte) do { } while (0) 465#define update_mmu_cache(vma, address, ptep) do { } while (0)
466 466
467extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; 467extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
468extern void paging_init (void); 468extern void paging_init (void);
diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h
index 7fa90f73f6be..348e44d08ce3 100644
--- a/arch/ia64/include/asm/processor.h
+++ b/arch/ia64/include/asm/processor.h
@@ -270,23 +270,6 @@ typedef struct {
270 (int __user *) (addr)); \ 270 (int __user *) (addr)); \
271}) 271})
272 272
273#ifdef CONFIG_IA32_SUPPORT
274struct desc_struct {
275 unsigned int a, b;
276};
277
278#define desc_empty(desc) (!((desc)->a | (desc)->b))
279#define desc_equal(desc1, desc2) (((desc1)->a == (desc2)->a) && ((desc1)->b == (desc2)->b))
280
281#define GDT_ENTRY_TLS_ENTRIES 3
282#define GDT_ENTRY_TLS_MIN 6
283#define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
284
285#define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8)
286
287struct ia64_partial_page_list;
288#endif
289
290struct thread_struct { 273struct thread_struct {
291 __u32 flags; /* various thread flags (see IA64_THREAD_*) */ 274 __u32 flags; /* various thread flags (see IA64_THREAD_*) */
292 /* writing on_ustack is performance-critical, so it's worth spending 8 bits on it... */ 275 /* writing on_ustack is performance-critical, so it's worth spending 8 bits on it... */
@@ -298,29 +281,6 @@ struct thread_struct {
298 __u64 rbs_bot; /* the base address for the RBS */ 281 __u64 rbs_bot; /* the base address for the RBS */
299 int last_fph_cpu; /* CPU that may hold the contents of f32-f127 */ 282 int last_fph_cpu; /* CPU that may hold the contents of f32-f127 */
300 283
301#ifdef CONFIG_IA32_SUPPORT
302 __u64 eflag; /* IA32 EFLAGS reg */
303 __u64 fsr; /* IA32 floating pt status reg */
304 __u64 fcr; /* IA32 floating pt control reg */
305 __u64 fir; /* IA32 fp except. instr. reg */
306 __u64 fdr; /* IA32 fp except. data reg */
307 __u64 old_k1; /* old value of ar.k1 */
308 __u64 old_iob; /* old IOBase value */
309 struct ia64_partial_page_list *ppl; /* partial page list for 4K page size issue */
310 /* cached TLS descriptors. */
311 struct desc_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
312
313# define INIT_THREAD_IA32 .eflag = 0, \
314 .fsr = 0, \
315 .fcr = 0x17800000037fULL, \
316 .fir = 0, \
317 .fdr = 0, \
318 .old_k1 = 0, \
319 .old_iob = 0, \
320 .ppl = NULL,
321#else
322# define INIT_THREAD_IA32
323#endif /* CONFIG_IA32_SUPPORT */
324#ifdef CONFIG_PERFMON 284#ifdef CONFIG_PERFMON
325 void *pfm_context; /* pointer to detailed PMU context */ 285 void *pfm_context; /* pointer to detailed PMU context */
326 unsigned long pfm_needs_checking; /* when >0, pending perfmon work on kernel exit */ 286 unsigned long pfm_needs_checking; /* when >0, pending perfmon work on kernel exit */
@@ -342,7 +302,6 @@ struct thread_struct {
342 .rbs_bot = STACK_TOP - DEFAULT_USER_STACK_SIZE, \ 302 .rbs_bot = STACK_TOP - DEFAULT_USER_STACK_SIZE, \
343 .task_size = DEFAULT_TASK_SIZE, \ 303 .task_size = DEFAULT_TASK_SIZE, \
344 .last_fph_cpu = -1, \ 304 .last_fph_cpu = -1, \
345 INIT_THREAD_IA32 \
346 INIT_THREAD_PM \ 305 INIT_THREAD_PM \
347 .dbr = {0, }, \ 306 .dbr = {0, }, \
348 .ibr = {0, }, \ 307 .ibr = {0, }, \
@@ -485,11 +444,6 @@ extern void __ia64_load_fpu (struct ia64_fpreg *fph);
485extern void ia64_save_debug_regs (unsigned long *save_area); 444extern void ia64_save_debug_regs (unsigned long *save_area);
486extern void ia64_load_debug_regs (unsigned long *save_area); 445extern void ia64_load_debug_regs (unsigned long *save_area);
487 446
488#ifdef CONFIG_IA32_SUPPORT
489extern void ia32_save_state (struct task_struct *task);
490extern void ia32_load_state (struct task_struct *task);
491#endif
492
493#define ia64_fph_enable() do { ia64_rsm(IA64_PSR_DFH); ia64_srlz_d(); } while (0) 447#define ia64_fph_enable() do { ia64_rsm(IA64_PSR_DFH); ia64_srlz_d(); } while (0)
494#define ia64_fph_disable() do { ia64_ssm(IA64_PSR_DFH); ia64_srlz_d(); } while (0) 448#define ia64_fph_disable() do { ia64_ssm(IA64_PSR_DFH); ia64_srlz_d(); } while (0)
495 449
diff --git a/arch/ia64/include/asm/ptrace.h b/arch/ia64/include/asm/ptrace.h
index 14055c636adf..7ae9c3f15a1c 100644
--- a/arch/ia64/include/asm/ptrace.h
+++ b/arch/ia64/include/asm/ptrace.h
@@ -319,11 +319,7 @@ static inline unsigned long user_stack_pointer(struct pt_regs *regs)
319 ptrace_attach_sync_user_rbs(child) 319 ptrace_attach_sync_user_rbs(child)
320 320
321 #define arch_has_single_step() (1) 321 #define arch_has_single_step() (1)
322 extern void user_enable_single_step(struct task_struct *);
323 extern void user_disable_single_step(struct task_struct *);
324
325 #define arch_has_block_step() (1) 322 #define arch_has_block_step() (1)
326 extern void user_enable_block_step(struct task_struct *);
327 323
328#endif /* !__KERNEL__ */ 324#endif /* !__KERNEL__ */
329 325
diff --git a/arch/ia64/include/asm/scatterlist.h b/arch/ia64/include/asm/scatterlist.h
index d6f57874041d..f299a4fb25c8 100644
--- a/arch/ia64/include/asm/scatterlist.h
+++ b/arch/ia64/include/asm/scatterlist.h
@@ -1,25 +1,7 @@
1#ifndef _ASM_IA64_SCATTERLIST_H 1#ifndef _ASM_IA64_SCATTERLIST_H
2#define _ASM_IA64_SCATTERLIST_H 2#define _ASM_IA64_SCATTERLIST_H
3 3
4/* 4#include <asm-generic/scatterlist.h>
5 * Modified 1998-1999, 2001-2002, 2004
6 * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co
7 */
8
9#include <asm/types.h>
10
11struct scatterlist {
12#ifdef CONFIG_DEBUG_SG
13 unsigned long sg_magic;
14#endif
15 unsigned long page_link;
16 unsigned int offset;
17 unsigned int length; /* buffer length */
18
19 dma_addr_t dma_address;
20 unsigned int dma_length;
21};
22
23/* 5/*
24 * It used to be that ISA_DMA_THRESHOLD had something to do with the 6 * It used to be that ISA_DMA_THRESHOLD had something to do with the
25 * DMA-limits of ISA-devices. Nowadays, its only remaining use (apart 7 * DMA-limits of ISA-devices. Nowadays, its only remaining use (apart
@@ -29,10 +11,6 @@ struct scatterlist {
29 * that's 4GB - 1. 11 * that's 4GB - 1.
30 */ 12 */
31#define ISA_DMA_THRESHOLD 0xffffffff 13#define ISA_DMA_THRESHOLD 0xffffffff
32 14#define ARCH_HAS_SG_CHAIN
33#define sg_dma_len(sg) ((sg)->dma_length)
34#define sg_dma_address(sg) ((sg)->dma_address)
35
36#define ARCH_HAS_SG_CHAIN
37 15
38#endif /* _ASM_IA64_SCATTERLIST_H */ 16#endif /* _ASM_IA64_SCATTERLIST_H */
diff --git a/arch/ia64/include/asm/syscall.h b/arch/ia64/include/asm/syscall.h
index 2f758a42f94b..a7ff1c6ab068 100644
--- a/arch/ia64/include/asm/syscall.h
+++ b/arch/ia64/include/asm/syscall.h
@@ -22,33 +22,18 @@ static inline long syscall_get_nr(struct task_struct *task,
22 if ((long)regs->cr_ifs < 0) /* Not a syscall */ 22 if ((long)regs->cr_ifs < 0) /* Not a syscall */
23 return -1; 23 return -1;
24 24
25#ifdef CONFIG_IA32_SUPPORT
26 if (IS_IA32_PROCESS(regs))
27 return regs->r1;
28#endif
29
30 return regs->r15; 25 return regs->r15;
31} 26}
32 27
33static inline void syscall_rollback(struct task_struct *task, 28static inline void syscall_rollback(struct task_struct *task,
34 struct pt_regs *regs) 29 struct pt_regs *regs)
35{ 30{
36#ifdef CONFIG_IA32_SUPPORT
37 if (IS_IA32_PROCESS(regs))
38 regs->r8 = regs->r1;
39#endif
40
41 /* do nothing */ 31 /* do nothing */
42} 32}
43 33
44static inline long syscall_get_error(struct task_struct *task, 34static inline long syscall_get_error(struct task_struct *task,
45 struct pt_regs *regs) 35 struct pt_regs *regs)
46{ 36{
47#ifdef CONFIG_IA32_SUPPORT
48 if (IS_IA32_PROCESS(regs))
49 return regs->r8;
50#endif
51
52 return regs->r10 == -1 ? regs->r8:0; 37 return regs->r10 == -1 ? regs->r8:0;
53} 38}
54 39
@@ -62,13 +47,6 @@ static inline void syscall_set_return_value(struct task_struct *task,
62 struct pt_regs *regs, 47 struct pt_regs *regs,
63 int error, long val) 48 int error, long val)
64{ 49{
65#ifdef CONFIG_IA32_SUPPORT
66 if (IS_IA32_PROCESS(regs)) {
67 regs->r8 = (long) error ? error : val;
68 return;
69 }
70#endif
71
72 if (error) { 50 if (error) {
73 /* error < 0, but ia64 uses > 0 return value */ 51 /* error < 0, but ia64 uses > 0 return value */
74 regs->r8 = -error; 52 regs->r8 = -error;
@@ -89,37 +67,6 @@ static inline void syscall_get_arguments(struct task_struct *task,
89{ 67{
90 BUG_ON(i + n > 6); 68 BUG_ON(i + n > 6);
91 69
92#ifdef CONFIG_IA32_SUPPORT
93 if (IS_IA32_PROCESS(regs)) {
94 switch (i + n) {
95 case 6:
96 if (!n--) break;
97 *args++ = regs->r13;
98 case 5:
99 if (!n--) break;
100 *args++ = regs->r15;
101 case 4:
102 if (!n--) break;
103 *args++ = regs->r14;
104 case 3:
105 if (!n--) break;
106 *args++ = regs->r10;
107 case 2:
108 if (!n--) break;
109 *args++ = regs->r9;
110 case 1:
111 if (!n--) break;
112 *args++ = regs->r11;
113 case 0:
114 if (!n--) break;
115 default:
116 BUG();
117 break;
118 }
119
120 return;
121 }
122#endif
123 ia64_syscall_get_set_arguments(task, regs, i, n, args, 0); 70 ia64_syscall_get_set_arguments(task, regs, i, n, args, 0);
124} 71}
125 72
@@ -130,34 +77,6 @@ static inline void syscall_set_arguments(struct task_struct *task,
130{ 77{
131 BUG_ON(i + n > 6); 78 BUG_ON(i + n > 6);
132 79
133#ifdef CONFIG_IA32_SUPPORT
134 if (IS_IA32_PROCESS(regs)) {
135 switch (i + n) {
136 case 6:
137 if (!n--) break;
138 regs->r13 = *args++;
139 case 5:
140 if (!n--) break;
141 regs->r15 = *args++;
142 case 4:
143 if (!n--) break;
144 regs->r14 = *args++;
145 case 3:
146 if (!n--) break;
147 regs->r10 = *args++;
148 case 2:
149 if (!n--) break;
150 regs->r9 = *args++;
151 case 1:
152 if (!n--) break;
153 regs->r11 = *args++;
154 case 0:
155 if (!n--) break;
156 }
157
158 return;
159 }
160#endif
161 ia64_syscall_get_set_arguments(task, regs, i, n, args, 1); 80 ia64_syscall_get_set_arguments(task, regs, i, n, args, 1);
162} 81}
163#endif /* _ASM_SYSCALL_H */ 82#endif /* _ASM_SYSCALL_H */
diff --git a/arch/ia64/include/asm/system.h b/arch/ia64/include/asm/system.h
index 927a381c20ca..9f342a574ce8 100644
--- a/arch/ia64/include/asm/system.h
+++ b/arch/ia64/include/asm/system.h
@@ -191,15 +191,6 @@ do { \
191 191
192#ifdef __KERNEL__ 192#ifdef __KERNEL__
193 193
194#ifdef CONFIG_IA32_SUPPORT
195# define IS_IA32_PROCESS(regs) (ia64_psr(regs)->is != 0)
196#else
197# define IS_IA32_PROCESS(regs) 0
198struct task_struct;
199static inline void ia32_save_state(struct task_struct *t __attribute__((unused))){}
200static inline void ia32_load_state(struct task_struct *t __attribute__((unused))){}
201#endif
202
203/* 194/*
204 * Context switch from one thread to another. If the two threads have 195 * Context switch from one thread to another. If the two threads have
205 * different address spaces, schedule() has already taken care of 196 * different address spaces, schedule() has already taken care of
@@ -233,7 +224,7 @@ extern void ia64_account_on_switch (struct task_struct *prev, struct task_struct
233 224
234#define IA64_HAS_EXTRA_STATE(t) \ 225#define IA64_HAS_EXTRA_STATE(t) \
235 ((t)->thread.flags & (IA64_THREAD_DBG_VALID|IA64_THREAD_PM_VALID) \ 226 ((t)->thread.flags & (IA64_THREAD_DBG_VALID|IA64_THREAD_PM_VALID) \
236 || IS_IA32_PROCESS(task_pt_regs(t)) || PERFMON_IS_SYSWIDE()) 227 || PERFMON_IS_SYSWIDE())
237 228
238#define __switch_to(prev,next,last) do { \ 229#define __switch_to(prev,next,last) do { \
239 IA64_ACCOUNT_ON_SWITCH(prev, next); \ 230 IA64_ACCOUNT_ON_SWITCH(prev, next); \
diff --git a/arch/ia64/include/asm/thread_info.h b/arch/ia64/include/asm/thread_info.h
index 8ce2e388e37c..b6a5ba2aca34 100644
--- a/arch/ia64/include/asm/thread_info.h
+++ b/arch/ia64/include/asm/thread_info.h
@@ -102,7 +102,7 @@ struct thread_info {
102#define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */ 102#define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */
103#define TIF_NOTIFY_RESUME 6 /* resumption notification requested */ 103#define TIF_NOTIFY_RESUME 6 /* resumption notification requested */
104#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 104#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
105#define TIF_MEMDIE 17 105#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
106#define TIF_MCA_INIT 18 /* this task is processing MCA or INIT */ 106#define TIF_MCA_INIT 18 /* this task is processing MCA or INIT */
107#define TIF_DB_DISABLED 19 /* debug trap disabled for fsyscall */ 107#define TIF_DB_DISABLED 19 /* debug trap disabled for fsyscall */
108#define TIF_FREEZE 20 /* is freezing for suspend */ 108#define TIF_FREEZE 20 /* is freezing for suspend */
diff --git a/arch/ia64/include/asm/topology.h b/arch/ia64/include/asm/topology.h
index d323071d0f91..09f646753d1a 100644
--- a/arch/ia64/include/asm/topology.h
+++ b/arch/ia64/include/asm/topology.h
@@ -26,11 +26,6 @@
26#define RECLAIM_DISTANCE 15 26#define RECLAIM_DISTANCE 15
27 27
28/* 28/*
29 * Returns the number of the node containing CPU 'cpu'
30 */
31#define cpu_to_node(cpu) (int)(cpu_to_node_map[cpu])
32
33/*
34 * Returns a bitmask of CPUs on Node 'node'. 29 * Returns a bitmask of CPUs on Node 'node'.
35 */ 30 */
36#define cpumask_of_node(node) ((node) == -1 ? \ 31#define cpumask_of_node(node) ((node) == -1 ? \
diff --git a/arch/ia64/include/asm/unistd.h b/arch/ia64/include/asm/unistd.h
index 10a8f21ca9e3..bb8b0fff32b3 100644
--- a/arch/ia64/include/asm/unistd.h
+++ b/arch/ia64/include/asm/unistd.h
@@ -335,20 +335,6 @@
335#define __ARCH_WANT_SYS_RT_SIGACTION 335#define __ARCH_WANT_SYS_RT_SIGACTION
336#define __ARCH_WANT_SYS_RT_SIGSUSPEND 336#define __ARCH_WANT_SYS_RT_SIGSUSPEND
337 337
338#ifdef CONFIG_IA32_SUPPORT
339# define __ARCH_WANT_SYS_FADVISE64
340# define __ARCH_WANT_SYS_GETPGRP
341# define __ARCH_WANT_SYS_LLSEEK
342# define __ARCH_WANT_SYS_NICE
343# define __ARCH_WANT_SYS_OLD_GETRLIMIT
344# define __ARCH_WANT_SYS_OLDUMOUNT
345# define __ARCH_WANT_SYS_PAUSE
346# define __ARCH_WANT_SYS_SIGPENDING
347# define __ARCH_WANT_SYS_SIGPROCMASK
348# define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND
349# define __ARCH_WANT_COMPAT_SYS_TIME
350#endif
351
352#if !defined(__ASSEMBLY__) && !defined(ASSEMBLER) 338#if !defined(__ASSEMBLY__) && !defined(ASSEMBLER)
353 339
354#include <linux/types.h> 340#include <linux/types.h>
diff --git a/arch/ia64/include/asm/xen/events.h b/arch/ia64/include/asm/xen/events.h
index b8370c8b6198..baa74c82aa71 100644
--- a/arch/ia64/include/asm/xen/events.h
+++ b/arch/ia64/include/asm/xen/events.h
@@ -36,10 +36,6 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)
36 return !(ia64_psr(regs)->i); 36 return !(ia64_psr(regs)->i);
37} 37}
38 38
39static inline void handle_irq(int irq, struct pt_regs *regs)
40{
41 __do_IRQ(irq);
42}
43#define irq_ctx_init(cpu) do { } while (0) 39#define irq_ctx_init(cpu) do { } while (0)
44 40
45#endif /* _ASM_IA64_XEN_EVENTS_H */ 41#endif /* _ASM_IA64_XEN_EVENTS_H */
diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile
index e1236349c99f..db10b1e378b0 100644
--- a/arch/ia64/kernel/Makefile
+++ b/arch/ia64/kernel/Makefile
@@ -8,15 +8,13 @@ endif
8 8
9extra-y := head.o init_task.o vmlinux.lds 9extra-y := head.o init_task.o vmlinux.lds
10 10
11obj-y := acpi.o entry.o efi.o efi_stub.o gate-data.o fsys.o ia64_ksyms.o irq.o irq_ia64.o \ 11obj-y := entry.o efi.o efi_stub.o gate-data.o fsys.o ia64_ksyms.o irq.o irq_ia64.o \
12 irq_lsapic.o ivt.o machvec.o pal.o paravirt_patchlist.o patch.o process.o perfmon.o ptrace.o sal.o \ 12 irq_lsapic.o ivt.o machvec.o pal.o paravirt_patchlist.o patch.o process.o perfmon.o ptrace.o sal.o \
13 salinfo.o setup.o signal.o sys_ia64.o time.o traps.o unaligned.o \ 13 salinfo.o setup.o signal.o sys_ia64.o time.o traps.o unaligned.o \
14 unwind.o mca.o mca_asm.o topology.o dma-mapping.o 14 unwind.o mca.o mca_asm.o topology.o dma-mapping.o
15 15
16obj-$(CONFIG_ACPI) += acpi.o acpi-ext.o
16obj-$(CONFIG_IA64_BRL_EMU) += brl_emu.o 17obj-$(CONFIG_IA64_BRL_EMU) += brl_emu.o
17obj-$(CONFIG_IA64_GENERIC) += acpi-ext.o
18obj-$(CONFIG_IA64_HP_ZX1) += acpi-ext.o
19obj-$(CONFIG_IA64_HP_ZX1_SWIOTLB) += acpi-ext.o
20 18
21obj-$(CONFIG_IA64_PALINFO) += palinfo.o 19obj-$(CONFIG_IA64_PALINFO) += palinfo.o
22obj-$(CONFIG_IOSAPIC) += iosapic.o 20obj-$(CONFIG_IOSAPIC) += iosapic.o
@@ -47,6 +45,8 @@ endif
47obj-$(CONFIG_DMAR) += pci-dma.o 45obj-$(CONFIG_DMAR) += pci-dma.o
48obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o 46obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o
49 47
48obj-$(CONFIG_BINFMT_ELF) += elfcore.o
49
50# fp_emulate() expects f2-f5,f16-f31 to contain the user-level state. 50# fp_emulate() expects f2-f5,f16-f31 to contain the user-level state.
51CFLAGS_traps.o += -mfixed-range=f2-f5,f16-f31 51CFLAGS_traps.o += -mfixed-range=f2-f5,f16-f31
52 52
diff --git a/arch/ia64/kernel/acpi-ext.c b/arch/ia64/kernel/acpi-ext.c
index b7515bc808a8..8b9318d311a0 100644
--- a/arch/ia64/kernel/acpi-ext.c
+++ b/arch/ia64/kernel/acpi-ext.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/slab.h>
13#include <linux/acpi.h> 14#include <linux/acpi.h>
14 15
15#include <asm/acpi-ext.h> 16#include <asm/acpi-ext.h>
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 40574ae11401..c6c90f39f4d9 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -44,6 +44,8 @@
44#include <linux/efi.h> 44#include <linux/efi.h>
45#include <linux/mmzone.h> 45#include <linux/mmzone.h>
46#include <linux/nodemask.h> 46#include <linux/nodemask.h>
47#include <linux/slab.h>
48#include <acpi/processor.h>
47#include <asm/io.h> 49#include <asm/io.h>
48#include <asm/iosapic.h> 50#include <asm/iosapic.h>
49#include <asm/machvec.h> 51#include <asm/machvec.h>
@@ -60,11 +62,6 @@
60 62
61#define PREFIX "ACPI: " 63#define PREFIX "ACPI: "
62 64
63void (*pm_idle) (void);
64EXPORT_SYMBOL(pm_idle);
65void (*pm_power_off) (void);
66EXPORT_SYMBOL(pm_power_off);
67
68u32 acpi_rsdt_forced; 65u32 acpi_rsdt_forced;
69unsigned int acpi_cpei_override; 66unsigned int acpi_cpei_override;
70unsigned int acpi_cpei_phys_cpuid; 67unsigned int acpi_cpei_phys_cpuid;
@@ -83,12 +80,10 @@ static unsigned long __init acpi_find_rsdp(void)
83 "v1.0/r0.71 tables no longer supported\n"); 80 "v1.0/r0.71 tables no longer supported\n");
84 return rsdp_phys; 81 return rsdp_phys;
85} 82}
86#endif
87 83
88const char __init * 84const char __init *
89acpi_get_sysname(void) 85acpi_get_sysname(void)
90{ 86{
91#ifdef CONFIG_IA64_GENERIC
92 unsigned long rsdp_phys; 87 unsigned long rsdp_phys;
93 struct acpi_table_rsdp *rsdp; 88 struct acpi_table_rsdp *rsdp;
94 struct acpi_table_xsdt *xsdt; 89 struct acpi_table_xsdt *xsdt;
@@ -143,30 +138,8 @@ acpi_get_sysname(void)
143#endif 138#endif
144 139
145 return "dig"; 140 return "dig";
146#else
147# if defined (CONFIG_IA64_HP_SIM)
148 return "hpsim";
149# elif defined (CONFIG_IA64_HP_ZX1)
150 return "hpzx1";
151# elif defined (CONFIG_IA64_HP_ZX1_SWIOTLB)
152 return "hpzx1_swiotlb";
153# elif defined (CONFIG_IA64_SGI_SN2)
154 return "sn2";
155# elif defined (CONFIG_IA64_SGI_UV)
156 return "uv";
157# elif defined (CONFIG_IA64_DIG)
158 return "dig";
159# elif defined (CONFIG_IA64_XEN_GUEST)
160 return "xen";
161# elif defined(CONFIG_IA64_DIG_VTD)
162 return "dig_vtd";
163# else
164# error Unknown platform. Fix acpi.c.
165# endif
166#endif
167} 141}
168 142#endif /* CONFIG_IA64_GENERIC */
169#ifdef CONFIG_ACPI
170 143
171#define ACPI_MAX_PLATFORM_INTERRUPTS 256 144#define ACPI_MAX_PLATFORM_INTERRUPTS 256
172 145
@@ -812,6 +785,14 @@ int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
812 return 0; 785 return 0;
813} 786}
814 787
788int acpi_isa_irq_to_gsi(unsigned isa_irq, u32 *gsi)
789{
790 if (isa_irq >= 16)
791 return -1;
792 *gsi = isa_irq;
793 return 0;
794}
795
815/* 796/*
816 * ACPI based hotplug CPU support 797 * ACPI based hotplug CPU support
817 */ 798 */
@@ -881,8 +862,8 @@ __init void prefill_possible_map(void)
881 862
882 possible = available_cpus + additional_cpus; 863 possible = available_cpus + additional_cpus;
883 864
884 if (possible > NR_CPUS) 865 if (possible > nr_cpu_ids)
885 possible = NR_CPUS; 866 possible = nr_cpu_ids;
886 867
887 printk(KERN_INFO "SMP: Allowing %d CPUs, %d hotplug CPUs\n", 868 printk(KERN_INFO "SMP: Allowing %d CPUs, %d hotplug CPUs\n",
888 possible, max((possible - available_cpus), 0)); 869 possible, max((possible - available_cpus), 0));
@@ -936,6 +917,8 @@ int acpi_map_lsapic(acpi_handle handle, int *pcpu)
936 cpu_set(cpu, cpu_present_map); 917 cpu_set(cpu, cpu_present_map);
937 ia64_cpu_to_sapicid[cpu] = physid; 918 ia64_cpu_to_sapicid[cpu] = physid;
938 919
920 acpi_processor_set_pdc(handle);
921
939 *pcpu = cpu; 922 *pcpu = cpu;
940 return (0); 923 return (0);
941} 924}
@@ -1060,5 +1043,3 @@ void acpi_restore_state_mem(void) {}
1060 * do_suspend_lowlevel() 1043 * do_suspend_lowlevel()
1061 */ 1044 */
1062void do_suspend_lowlevel(void) {} 1045void do_suspend_lowlevel(void) {}
1063
1064#endif /* CONFIG_ACPI */
diff --git a/arch/ia64/kernel/audit.c b/arch/ia64/kernel/audit.c
index f3802ae89b10..96a9d18ff4c4 100644
--- a/arch/ia64/kernel/audit.c
+++ b/arch/ia64/kernel/audit.c
@@ -30,20 +30,11 @@ static unsigned signal_class[] = {
30 30
31int audit_classify_arch(int arch) 31int audit_classify_arch(int arch)
32{ 32{
33#ifdef CONFIG_IA32_SUPPORT
34 if (arch == AUDIT_ARCH_I386)
35 return 1;
36#endif
37 return 0; 33 return 0;
38} 34}
39 35
40int audit_classify_syscall(int abi, unsigned syscall) 36int audit_classify_syscall(int abi, unsigned syscall)
41{ 37{
42#ifdef CONFIG_IA32_SUPPORT
43 extern int ia32_classify_syscall(unsigned);
44 if (abi == AUDIT_ARCH_I386)
45 return ia32_classify_syscall(syscall);
46#endif
47 switch(syscall) { 38 switch(syscall) {
48 case __NR_open: 39 case __NR_open:
49 return 2; 40 return 2;
@@ -58,18 +49,6 @@ int audit_classify_syscall(int abi, unsigned syscall)
58 49
59static int __init audit_classes_init(void) 50static int __init audit_classes_init(void)
60{ 51{
61#ifdef CONFIG_IA32_SUPPORT
62 extern __u32 ia32_dir_class[];
63 extern __u32 ia32_write_class[];
64 extern __u32 ia32_read_class[];
65 extern __u32 ia32_chattr_class[];
66 extern __u32 ia32_signal_class[];
67 audit_register_class(AUDIT_CLASS_WRITE_32, ia32_write_class);
68 audit_register_class(AUDIT_CLASS_READ_32, ia32_read_class);
69 audit_register_class(AUDIT_CLASS_DIR_WRITE_32, ia32_dir_class);
70 audit_register_class(AUDIT_CLASS_CHATTR_32, ia32_chattr_class);
71 audit_register_class(AUDIT_CLASS_SIGNAL_32, ia32_signal_class);
72#endif
73 audit_register_class(AUDIT_CLASS_WRITE, write_class); 52 audit_register_class(AUDIT_CLASS_WRITE, write_class);
74 audit_register_class(AUDIT_CLASS_READ, read_class); 53 audit_register_class(AUDIT_CLASS_READ, read_class);
75 audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class); 54 audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
diff --git a/arch/ia64/kernel/cpufreq/acpi-cpufreq.c b/arch/ia64/kernel/cpufreq/acpi-cpufreq.c
index 7b435451b3dc..22f61526a8e1 100644
--- a/arch/ia64/kernel/cpufreq/acpi-cpufreq.c
+++ b/arch/ia64/kernel/cpufreq/acpi-cpufreq.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/slab.h>
13#include <linux/module.h> 14#include <linux/module.h>
14#include <linux/init.h> 15#include <linux/init.h>
15#include <linux/cpufreq.h> 16#include <linux/cpufreq.h>
@@ -112,7 +113,7 @@ processor_get_freq (
112 dprintk("processor_get_freq\n"); 113 dprintk("processor_get_freq\n");
113 114
114 saved_mask = current->cpus_allowed; 115 saved_mask = current->cpus_allowed;
115 set_cpus_allowed(current, cpumask_of_cpu(cpu)); 116 set_cpus_allowed_ptr(current, cpumask_of(cpu));
116 if (smp_processor_id() != cpu) 117 if (smp_processor_id() != cpu)
117 goto migrate_end; 118 goto migrate_end;
118 119
@@ -120,7 +121,7 @@ processor_get_freq (
120 ret = processor_get_pstate(&value); 121 ret = processor_get_pstate(&value);
121 122
122 if (ret) { 123 if (ret) {
123 set_cpus_allowed(current, saved_mask); 124 set_cpus_allowed_ptr(current, &saved_mask);
124 printk(KERN_WARNING "get performance failed with error %d\n", 125 printk(KERN_WARNING "get performance failed with error %d\n",
125 ret); 126 ret);
126 ret = 0; 127 ret = 0;
@@ -130,7 +131,7 @@ processor_get_freq (
130 ret = (clock_freq*1000); 131 ret = (clock_freq*1000);
131 132
132migrate_end: 133migrate_end:
133 set_cpus_allowed(current, saved_mask); 134 set_cpus_allowed_ptr(current, &saved_mask);
134 return ret; 135 return ret;
135} 136}
136 137
@@ -150,7 +151,7 @@ processor_set_freq (
150 dprintk("processor_set_freq\n"); 151 dprintk("processor_set_freq\n");
151 152
152 saved_mask = current->cpus_allowed; 153 saved_mask = current->cpus_allowed;
153 set_cpus_allowed(current, cpumask_of_cpu(cpu)); 154 set_cpus_allowed_ptr(current, cpumask_of(cpu));
154 if (smp_processor_id() != cpu) { 155 if (smp_processor_id() != cpu) {
155 retval = -EAGAIN; 156 retval = -EAGAIN;
156 goto migrate_end; 157 goto migrate_end;
@@ -207,7 +208,7 @@ processor_set_freq (
207 retval = 0; 208 retval = 0;
208 209
209migrate_end: 210migrate_end:
210 set_cpus_allowed(current, saved_mask); 211 set_cpus_allowed_ptr(current, &saved_mask);
211 return (retval); 212 return (retval);
212} 213}
213 214
diff --git a/arch/ia64/kernel/efi.c b/arch/ia64/kernel/efi.c
index c745d0aeb6e0..a0f001928502 100644
--- a/arch/ia64/kernel/efi.c
+++ b/arch/ia64/kernel/efi.c
@@ -26,6 +26,7 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/types.h> 28#include <linux/types.h>
29#include <linux/slab.h>
29#include <linux/time.h> 30#include <linux/time.h>
30#include <linux/efi.h> 31#include <linux/efi.h>
31#include <linux/kexec.h> 32#include <linux/kexec.h>
diff --git a/arch/ia64/kernel/elfcore.c b/arch/ia64/kernel/elfcore.c
new file mode 100644
index 000000000000..bac1639bc320
--- /dev/null
+++ b/arch/ia64/kernel/elfcore.c
@@ -0,0 +1,80 @@
1#include <linux/elf.h>
2#include <linux/coredump.h>
3#include <linux/fs.h>
4#include <linux/mm.h>
5
6#include <asm/elf.h>
7
8
9Elf64_Half elf_core_extra_phdrs(void)
10{
11 return GATE_EHDR->e_phnum;
12}
13
14int elf_core_write_extra_phdrs(struct file *file, loff_t offset, size_t *size,
15 unsigned long limit)
16{
17 const struct elf_phdr *const gate_phdrs =
18 (const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff);
19 int i;
20 Elf64_Off ofs = 0;
21
22 for (i = 0; i < GATE_EHDR->e_phnum; ++i) {
23 struct elf_phdr phdr = gate_phdrs[i];
24
25 if (phdr.p_type == PT_LOAD) {
26 phdr.p_memsz = PAGE_ALIGN(phdr.p_memsz);
27 phdr.p_filesz = phdr.p_memsz;
28 if (ofs == 0) {
29 ofs = phdr.p_offset = offset;
30 offset += phdr.p_filesz;
31 } else {
32 phdr.p_offset = ofs;
33 }
34 } else {
35 phdr.p_offset += ofs;
36 }
37 phdr.p_paddr = 0; /* match other core phdrs */
38 *size += sizeof(phdr);
39 if (*size > limit || !dump_write(file, &phdr, sizeof(phdr)))
40 return 0;
41 }
42 return 1;
43}
44
45int elf_core_write_extra_data(struct file *file, size_t *size,
46 unsigned long limit)
47{
48 const struct elf_phdr *const gate_phdrs =
49 (const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff);
50 int i;
51
52 for (i = 0; i < GATE_EHDR->e_phnum; ++i) {
53 if (gate_phdrs[i].p_type == PT_LOAD) {
54 void *addr = (void *)gate_phdrs[i].p_vaddr;
55 size_t memsz = PAGE_ALIGN(gate_phdrs[i].p_memsz);
56
57 *size += memsz;
58 if (*size > limit || !dump_write(file, addr, memsz))
59 return 0;
60 break;
61 }
62 }
63 return 1;
64}
65
66size_t elf_core_extra_data_size(void)
67{
68 const struct elf_phdr *const gate_phdrs =
69 (const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff);
70 int i;
71 size_t size = 0;
72
73 for (i = 0; i < GATE_EHDR->e_phnum; ++i) {
74 if (gate_phdrs[i].p_type == PT_LOAD) {
75 size += PAGE_ALIGN(gate_phdrs[i].p_memsz);
76 break;
77 }
78 }
79 return size;
80}
diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
index d75b872ca4dc..9a260b317d8d 100644
--- a/arch/ia64/kernel/entry.S
+++ b/arch/ia64/kernel/entry.S
@@ -71,15 +71,6 @@ ENTRY(ia64_execve)
71 add out3=16,sp // regs 71 add out3=16,sp // regs
72 br.call.sptk.many rp=sys_execve 72 br.call.sptk.many rp=sys_execve
73.ret0: 73.ret0:
74#ifdef CONFIG_IA32_SUPPORT
75 /*
76 * Check if we're returning to ia32 mode. If so, we need to restore ia32 registers
77 * from pt_regs.
78 */
79 adds r16=PT(CR_IPSR)+16,sp
80 ;;
81 ld8 r16=[r16]
82#endif
83 cmp4.ge p6,p7=r8,r0 74 cmp4.ge p6,p7=r8,r0
84 mov ar.pfs=loc1 // restore ar.pfs 75 mov ar.pfs=loc1 // restore ar.pfs
85 sxt4 r8=r8 // return 64-bit result 76 sxt4 r8=r8 // return 64-bit result
@@ -108,12 +99,6 @@ ENTRY(ia64_execve)
108 ldf.fill f23=[sp]; ldf.fill f24=[sp]; mov f25=f0 99 ldf.fill f23=[sp]; ldf.fill f24=[sp]; mov f25=f0
109 ldf.fill f26=[sp]; ldf.fill f27=[sp]; mov f28=f0 100 ldf.fill f26=[sp]; ldf.fill f27=[sp]; mov f28=f0
110 ldf.fill f29=[sp]; ldf.fill f30=[sp]; mov f31=f0 101 ldf.fill f29=[sp]; ldf.fill f30=[sp]; mov f31=f0
111#ifdef CONFIG_IA32_SUPPORT
112 tbit.nz p6,p0=r16, IA64_PSR_IS_BIT
113 movl loc0=ia64_ret_from_ia32_execve
114 ;;
115(p6) mov rp=loc0
116#endif
117 br.ret.sptk.many rp 102 br.ret.sptk.many rp
118END(ia64_execve) 103END(ia64_execve)
119 104
@@ -848,30 +833,6 @@ __paravirt_work_processed_syscall:
848 br.cond.sptk.many rbs_switch // B 833 br.cond.sptk.many rbs_switch // B
849END(__paravirt_leave_syscall) 834END(__paravirt_leave_syscall)
850 835
851#ifdef __IA64_ASM_PARAVIRTUALIZED_NATIVE
852#ifdef CONFIG_IA32_SUPPORT
853GLOBAL_ENTRY(ia64_ret_from_ia32_execve)
854 PT_REGS_UNWIND_INFO(0)
855 adds r2=PT(R8)+16,sp // r2 = &pt_regs.r8
856 adds r3=PT(R10)+16,sp // r3 = &pt_regs.r10
857 ;;
858 .mem.offset 0,0
859 st8.spill [r2]=r8 // store return value in slot for r8 and set unat bit
860 .mem.offset 8,0
861 st8.spill [r3]=r0 // clear error indication in slot for r10 and set unat bit
862#ifdef CONFIG_PARAVIRT
863 ;;
864 // don't fall through, ia64_leave_kernel may be #define'd
865 br.cond.sptk.few ia64_leave_kernel
866 ;;
867#endif /* CONFIG_PARAVIRT */
868END(ia64_ret_from_ia32_execve)
869#ifndef CONFIG_PARAVIRT
870 // fall through
871#endif
872#endif /* CONFIG_IA32_SUPPORT */
873#endif /* __IA64_ASM_PARAVIRTUALIZED_NATIVE */
874
875GLOBAL_ENTRY(__paravirt_leave_kernel) 836GLOBAL_ENTRY(__paravirt_leave_kernel)
876 PT_REGS_UNWIND_INFO(0) 837 PT_REGS_UNWIND_INFO(0)
877 /* 838 /*
diff --git a/arch/ia64/kernel/ia64_ksyms.c b/arch/ia64/kernel/ia64_ksyms.c
index 461b99902bf6..7f4a0ed24152 100644
--- a/arch/ia64/kernel/ia64_ksyms.c
+++ b/arch/ia64/kernel/ia64_ksyms.c
@@ -30,9 +30,9 @@ EXPORT_SYMBOL(max_low_pfn); /* defined by bootmem.c, but not exported by generic
30#endif 30#endif
31 31
32#include <asm/processor.h> 32#include <asm/processor.h>
33EXPORT_SYMBOL(per_cpu__ia64_cpu_info); 33EXPORT_SYMBOL(ia64_cpu_info);
34#ifdef CONFIG_SMP 34#ifdef CONFIG_SMP
35EXPORT_SYMBOL(per_cpu__local_per_cpu_offset); 35EXPORT_SYMBOL(local_per_cpu_offset);
36#endif 36#endif
37 37
38#include <asm/uaccess.h> 38#include <asm/uaccess.h>
diff --git a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c
index 95ac77aeae9b..7ded76658d2d 100644
--- a/arch/ia64/kernel/iosapic.c
+++ b/arch/ia64/kernel/iosapic.c
@@ -86,6 +86,7 @@
86#include <linux/kernel.h> 86#include <linux/kernel.h>
87#include <linux/list.h> 87#include <linux/list.h>
88#include <linux/pci.h> 88#include <linux/pci.h>
89#include <linux/slab.h>
89#include <linux/smp.h> 90#include <linux/smp.h>
90#include <linux/string.h> 91#include <linux/string.h>
91#include <linux/bootmem.h> 92#include <linux/bootmem.h>
diff --git a/arch/ia64/kernel/irq_ia64.c b/arch/ia64/kernel/irq_ia64.c
index d4093a173a3e..f14c35f9b03a 100644
--- a/arch/ia64/kernel/irq_ia64.c
+++ b/arch/ia64/kernel/irq_ia64.c
@@ -22,7 +22,6 @@
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/ioport.h> 23#include <linux/ioport.h>
24#include <linux/kernel_stat.h> 24#include <linux/kernel_stat.h>
25#include <linux/slab.h>
26#include <linux/ptrace.h> 25#include <linux/ptrace.h>
27#include <linux/random.h> /* for rand_initialize_irq() */ 26#include <linux/random.h> /* for rand_initialize_irq() */
28#include <linux/signal.h> 27#include <linux/signal.h>
@@ -30,6 +29,7 @@
30#include <linux/threads.h> 29#include <linux/threads.h>
31#include <linux/bitops.h> 30#include <linux/bitops.h>
32#include <linux/irq.h> 31#include <linux/irq.h>
32#include <linux/ratelimit.h>
33 33
34#include <asm/delay.h> 34#include <asm/delay.h>
35#include <asm/intrinsics.h> 35#include <asm/intrinsics.h>
@@ -468,13 +468,9 @@ ia64_handle_irq (ia64_vector vector, struct pt_regs *regs)
468 sp = ia64_getreg(_IA64_REG_SP); 468 sp = ia64_getreg(_IA64_REG_SP);
469 469
470 if ((sp - bsp) < 1024) { 470 if ((sp - bsp) < 1024) {
471 static unsigned char count; 471 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
472 static long last_time;
473 472
474 if (time_after(jiffies, last_time + 5 * HZ)) 473 if (__ratelimit(&ratelimit)) {
475 count = 0;
476 if (++count < 5) {
477 last_time = jiffies;
478 printk("ia64_handle_irq: DANGER: less than " 474 printk("ia64_handle_irq: DANGER: less than "
479 "1KB of free stack space!!\n" 475 "1KB of free stack space!!\n"
480 "(bsp=0x%lx, sp=%lx)\n", bsp, sp); 476 "(bsp=0x%lx, sp=%lx)\n", bsp, sp);
diff --git a/arch/ia64/kernel/ivt.S b/arch/ia64/kernel/ivt.S
index 0c14512b12dc..d93e396bf599 100644
--- a/arch/ia64/kernel/ivt.S
+++ b/arch/ia64/kernel/ivt.S
@@ -49,7 +49,6 @@
49 49
50#include <asm/asmmacro.h> 50#include <asm/asmmacro.h>
51#include <asm/break.h> 51#include <asm/break.h>
52#include <asm/ia32.h>
53#include <asm/kregs.h> 52#include <asm/kregs.h>
54#include <asm/asm-offsets.h> 53#include <asm/asm-offsets.h>
55#include <asm/pgtable.h> 54#include <asm/pgtable.h>
@@ -1386,28 +1385,6 @@ END(ia32_exception)
1386// 0x6a00 Entry 46 (size 16 bundles) IA-32 Intercept (30,31,59,70,71) 1385// 0x6a00 Entry 46 (size 16 bundles) IA-32 Intercept (30,31,59,70,71)
1387ENTRY(ia32_intercept) 1386ENTRY(ia32_intercept)
1388 DBG_FAULT(46) 1387 DBG_FAULT(46)
1389#ifdef CONFIG_IA32_SUPPORT
1390 mov r31=pr
1391 MOV_FROM_ISR(r16)
1392 ;;
1393 extr.u r17=r16,16,8 // get ISR.code
1394 mov r18=ar.eflag
1395 MOV_FROM_IIM(r19) // old eflag value
1396 ;;
1397 cmp.ne p6,p0=2,r17
1398(p6) br.cond.spnt 1f // not a system flag fault
1399 xor r16=r18,r19
1400 ;;
1401 extr.u r17=r16,18,1 // get the eflags.ac bit
1402 ;;
1403 cmp.eq p6,p0=0,r17
1404(p6) br.cond.spnt 1f // eflags.ac bit didn't change
1405 ;;
1406 mov pr=r31,-1 // restore predicate registers
1407 RFI
1408
14091:
1410#endif // CONFIG_IA32_SUPPORT
1411 FAULT(46) 1388 FAULT(46)
1412END(ia32_intercept) 1389END(ia32_intercept)
1413 1390
@@ -1416,12 +1393,7 @@ END(ia32_intercept)
1416// 0x6b00 Entry 47 (size 16 bundles) IA-32 Interrupt (74) 1393// 0x6b00 Entry 47 (size 16 bundles) IA-32 Interrupt (74)
1417ENTRY(ia32_interrupt) 1394ENTRY(ia32_interrupt)
1418 DBG_FAULT(47) 1395 DBG_FAULT(47)
1419#ifdef CONFIG_IA32_SUPPORT
1420 mov r31=pr
1421 br.sptk.many dispatch_to_ia32_handler
1422#else
1423 FAULT(47) 1396 FAULT(47)
1424#endif
1425END(ia32_interrupt) 1397END(ia32_interrupt)
1426 1398
1427 .org ia64_ivt+0x6c00 1399 .org ia64_ivt+0x6c00
@@ -1715,89 +1687,3 @@ ENTRY(dispatch_illegal_op_fault)
1715(p6) br.call.dpnt.many b6=b6 // call returns to ia64_leave_kernel 1687(p6) br.call.dpnt.many b6=b6 // call returns to ia64_leave_kernel
1716 br.sptk.many ia64_leave_kernel 1688 br.sptk.many ia64_leave_kernel
1717END(dispatch_illegal_op_fault) 1689END(dispatch_illegal_op_fault)
1718
1719#ifdef CONFIG_IA32_SUPPORT
1720
1721 /*
1722 * There is no particular reason for this code to be here, other than that
1723 * there happens to be space here that would go unused otherwise. If this
1724 * fault ever gets "unreserved", simply moved the following code to a more
1725 * suitable spot...
1726 */
1727
1728 // IA32 interrupt entry point
1729
1730ENTRY(dispatch_to_ia32_handler)
1731 SAVE_MIN
1732 ;;
1733 MOV_FROM_ISR(r14)
1734 SSM_PSR_IC_AND_DEFAULT_BITS_AND_SRLZ_I(r3, r24)
1735 // guarantee that interruption collection is on
1736 ;;
1737 SSM_PSR_I(p15, p15, r3)
1738 adds r3=8,r2 // Base pointer for SAVE_REST
1739 ;;
1740 SAVE_REST
1741 ;;
1742 mov r15=0x80
1743 shr r14=r14,16 // Get interrupt number
1744 ;;
1745 cmp.ne p6,p0=r14,r15
1746(p6) br.call.dpnt.many b6=non_ia32_syscall
1747
1748 adds r14=IA64_PT_REGS_R8_OFFSET + 16,sp // 16 byte hole per SW conventions
1749 adds r15=IA64_PT_REGS_R1_OFFSET + 16,sp
1750 ;;
1751 cmp.eq pSys,pNonSys=r0,r0 // set pSys=1, pNonSys=0
1752 ld8 r8=[r14] // get r8
1753 ;;
1754 st8 [r15]=r8 // save original EAX in r1 (IA32 procs don't use the GP)
1755 ;;
1756 alloc r15=ar.pfs,0,0,6,0 // must first in an insn group
1757 ;;
1758 ld4 r8=[r14],8 // r8 == eax (syscall number)
1759 mov r15=IA32_NR_syscalls
1760 ;;
1761 cmp.ltu.unc p6,p7=r8,r15
1762 ld4 out1=[r14],8 // r9 == ecx
1763 ;;
1764 ld4 out2=[r14],8 // r10 == edx
1765 ;;
1766 ld4 out0=[r14] // r11 == ebx
1767 adds r14=(IA64_PT_REGS_R13_OFFSET) + 16,sp
1768 ;;
1769 ld4 out5=[r14],PT(R14)-PT(R13) // r13 == ebp
1770 ;;
1771 ld4 out3=[r14],PT(R15)-PT(R14) // r14 == esi
1772 adds r2=TI_FLAGS+IA64_TASK_SIZE,r13
1773 ;;
1774 ld4 out4=[r14] // r15 == edi
1775 movl r16=ia32_syscall_table
1776 ;;
1777(p6) shladd r16=r8,3,r16 // force ni_syscall if not valid syscall number
1778 ld4 r2=[r2] // r2 = current_thread_info()->flags
1779 ;;
1780 ld8 r16=[r16]
1781 and r2=_TIF_SYSCALL_TRACEAUDIT,r2 // mask trace or audit
1782 ;;
1783 mov b6=r16
1784 movl r15=ia32_ret_from_syscall
1785 cmp.eq p8,p0=r2,r0
1786 ;;
1787 mov rp=r15
1788(p8) br.call.sptk.many b6=b6
1789 br.cond.sptk ia32_trace_syscall
1790
1791non_ia32_syscall:
1792 alloc r15=ar.pfs,0,0,2,0
1793 mov out0=r14 // interrupt #
1794 add out1=16,sp // pointer to pt_regs
1795 ;; // avoid WAW on CFM
1796 br.call.sptk.many rp=ia32_bad_interrupt
1797.ret1: movl r15=ia64_leave_kernel
1798 ;;
1799 mov rp=r15
1800 br.ret.sptk.many rp
1801END(dispatch_to_ia32_handler)
1802
1803#endif /* CONFIG_IA32_SUPPORT */
diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c
index 9adac441ac9b..7026b29e277a 100644
--- a/arch/ia64/kernel/kprobes.c
+++ b/arch/ia64/kernel/kprobes.c
@@ -870,7 +870,7 @@ static int __kprobes pre_kprobes_handler(struct die_args *args)
870 return 1; 870 return 1;
871 871
872ss_probe: 872ss_probe:
873#if !defined(CONFIG_PREEMPT) || defined(CONFIG_FREEZER) 873#if !defined(CONFIG_PREEMPT)
874 if (p->ainsn.inst_flag == INST_FLAG_BOOSTABLE && !p->post_handler) { 874 if (p->ainsn.inst_flag == INST_FLAG_BOOSTABLE && !p->post_handler) {
875 /* Boost up -- we can execute copied instructions directly */ 875 /* Boost up -- we can execute copied instructions directly */
876 ia64_psr(regs)->ri = p->ainsn.slot; 876 ia64_psr(regs)->ri = p->ainsn.slot;
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index 378b4833024f..a0220dc5ff42 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -85,6 +85,7 @@
85#include <linux/cpumask.h> 85#include <linux/cpumask.h>
86#include <linux/kdebug.h> 86#include <linux/kdebug.h>
87#include <linux/cpu.h> 87#include <linux/cpu.h>
88#include <linux/gfp.h>
88 89
89#include <asm/delay.h> 90#include <asm/delay.h>
90#include <asm/machvec.h> 91#include <asm/machvec.h>
diff --git a/arch/ia64/kernel/mca_drv.c b/arch/ia64/kernel/mca_drv.c
index f94aaa86933f..09b4d6828c45 100644
--- a/arch/ia64/kernel/mca_drv.c
+++ b/arch/ia64/kernel/mca_drv.c
@@ -22,6 +22,7 @@
22#include <linux/smp.h> 22#include <linux/smp.h>
23#include <linux/workqueue.h> 23#include <linux/workqueue.h>
24#include <linux/mm.h> 24#include <linux/mm.h>
25#include <linux/slab.h>
25 26
26#include <asm/delay.h> 27#include <asm/delay.h>
27#include <asm/machvec.h> 28#include <asm/machvec.h>
diff --git a/arch/ia64/kernel/pci-swiotlb.c b/arch/ia64/kernel/pci-swiotlb.c
index 53292abf846c..d9485d952ed0 100644
--- a/arch/ia64/kernel/pci-swiotlb.c
+++ b/arch/ia64/kernel/pci-swiotlb.c
@@ -1,6 +1,7 @@
1/* Glue code to lib/swiotlb.c */ 1/* Glue code to lib/swiotlb.c */
2 2
3#include <linux/pci.h> 3#include <linux/pci.h>
4#include <linux/gfp.h>
4#include <linux/cache.h> 5#include <linux/cache.h>
5#include <linux/module.h> 6#include <linux/module.h>
6#include <linux/dma-mapping.h> 7#include <linux/dma-mapping.h>
@@ -30,8 +31,6 @@ struct dma_map_ops swiotlb_dma_ops = {
30 .unmap_sg = swiotlb_unmap_sg_attrs, 31 .unmap_sg = swiotlb_unmap_sg_attrs,
31 .sync_single_for_cpu = swiotlb_sync_single_for_cpu, 32 .sync_single_for_cpu = swiotlb_sync_single_for_cpu,
32 .sync_single_for_device = swiotlb_sync_single_for_device, 33 .sync_single_for_device = swiotlb_sync_single_for_device,
33 .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu,
34 .sync_single_range_for_device = swiotlb_sync_single_range_for_device,
35 .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, 34 .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
36 .sync_sg_for_device = swiotlb_sync_sg_for_device, 35 .sync_sg_for_device = swiotlb_sync_sg_for_device,
37 .dma_supported = swiotlb_dma_supported, 36 .dma_supported = swiotlb_dma_supported,
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 6bcbe215b9a4..ab985f785c14 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -41,6 +41,7 @@
41#include <linux/rcupdate.h> 41#include <linux/rcupdate.h>
42#include <linux/completion.h> 42#include <linux/completion.h>
43#include <linux/tracehook.h> 43#include <linux/tracehook.h>
44#include <linux/slab.h>
44 45
45#include <asm/errno.h> 46#include <asm/errno.h>
46#include <asm/intrinsics.h> 47#include <asm/intrinsics.h>
@@ -2315,6 +2316,7 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t
2315 DPRINT(("Cannot allocate vma\n")); 2316 DPRINT(("Cannot allocate vma\n"));
2316 goto error_kmem; 2317 goto error_kmem;
2317 } 2318 }
2319 INIT_LIST_HEAD(&vma->anon_vma_chain);
2318 2320
2319 /* 2321 /*
2320 * partially initialize the vma for the sampling buffer 2322 * partially initialize the vma for the sampling buffer
@@ -2713,7 +2715,7 @@ pfm_context_create(pfm_context_t *ctx, void *arg, int count, struct pt_regs *reg
2713 goto buffer_error; 2715 goto buffer_error;
2714 } 2716 }
2715 2717
2716 DPRINT(("ctx=%p flags=0x%x system=%d notify_block=%d excl_idle=%d no_msg=%d ctx_fd=%d \n", 2718 DPRINT(("ctx=%p flags=0x%x system=%d notify_block=%d excl_idle=%d no_msg=%d ctx_fd=%d\n",
2717 ctx, 2719 ctx,
2718 ctx_flags, 2720 ctx_flags,
2719 ctx->ctx_fl_system, 2721 ctx->ctx_fl_system,
@@ -3677,7 +3679,7 @@ pfm_restart(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
3677 * "self-monitoring". 3679 * "self-monitoring".
3678 */ 3680 */
3679 if (CTX_OVFL_NOBLOCK(ctx) == 0 && state == PFM_CTX_MASKED) { 3681 if (CTX_OVFL_NOBLOCK(ctx) == 0 && state == PFM_CTX_MASKED) {
3680 DPRINT(("unblocking [%d] \n", task_pid_nr(task))); 3682 DPRINT(("unblocking [%d]\n", task_pid_nr(task)));
3681 complete(&ctx->ctx_restart_done); 3683 complete(&ctx->ctx_restart_done);
3682 } else { 3684 } else {
3683 DPRINT(("[%d] armed exit trap\n", task_pid_nr(task))); 3685 DPRINT(("[%d] armed exit trap\n", task_pid_nr(task)));
diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
index 9bcec9945c12..53f1648c8b81 100644
--- a/arch/ia64/kernel/process.c
+++ b/arch/ia64/kernel/process.c
@@ -15,11 +15,11 @@
15#include <linux/kallsyms.h> 15#include <linux/kallsyms.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/slab.h>
18#include <linux/module.h> 19#include <linux/module.h>
19#include <linux/notifier.h> 20#include <linux/notifier.h>
20#include <linux/personality.h> 21#include <linux/personality.h>
21#include <linux/sched.h> 22#include <linux/sched.h>
22#include <linux/slab.h>
23#include <linux/stddef.h> 23#include <linux/stddef.h>
24#include <linux/thread_info.h> 24#include <linux/thread_info.h>
25#include <linux/unistd.h> 25#include <linux/unistd.h>
@@ -33,7 +33,6 @@
33#include <asm/cpu.h> 33#include <asm/cpu.h>
34#include <asm/delay.h> 34#include <asm/delay.h>
35#include <asm/elf.h> 35#include <asm/elf.h>
36#include <asm/ia32.h>
37#include <asm/irq.h> 36#include <asm/irq.h>
38#include <asm/kexec.h> 37#include <asm/kexec.h>
39#include <asm/pgalloc.h> 38#include <asm/pgalloc.h>
@@ -60,6 +59,10 @@ unsigned long idle_halt;
60EXPORT_SYMBOL(idle_halt); 59EXPORT_SYMBOL(idle_halt);
61unsigned long idle_nomwait; 60unsigned long idle_nomwait;
62EXPORT_SYMBOL(idle_nomwait); 61EXPORT_SYMBOL(idle_nomwait);
62void (*pm_idle) (void);
63EXPORT_SYMBOL(pm_idle);
64void (*pm_power_off) (void);
65EXPORT_SYMBOL(pm_power_off);
63 66
64void 67void
65ia64_do_show_stack (struct unw_frame_info *info, void *arg) 68ia64_do_show_stack (struct unw_frame_info *info, void *arg)
@@ -358,11 +361,6 @@ ia64_save_extra (struct task_struct *task)
358 if (info & PFM_CPUINFO_SYST_WIDE) 361 if (info & PFM_CPUINFO_SYST_WIDE)
359 pfm_syst_wide_update_task(task, info, 0); 362 pfm_syst_wide_update_task(task, info, 0);
360#endif 363#endif
361
362#ifdef CONFIG_IA32_SUPPORT
363 if (IS_IA32_PROCESS(task_pt_regs(task)))
364 ia32_save_state(task);
365#endif
366} 364}
367 365
368void 366void
@@ -383,11 +381,6 @@ ia64_load_extra (struct task_struct *task)
383 if (info & PFM_CPUINFO_SYST_WIDE) 381 if (info & PFM_CPUINFO_SYST_WIDE)
384 pfm_syst_wide_update_task(task, info, 1); 382 pfm_syst_wide_update_task(task, info, 1);
385#endif 383#endif
386
387#ifdef CONFIG_IA32_SUPPORT
388 if (IS_IA32_PROCESS(task_pt_regs(task)))
389 ia32_load_state(task);
390#endif
391} 384}
392 385
393/* 386/*
@@ -426,7 +419,7 @@ copy_thread(unsigned long clone_flags,
426 unsigned long user_stack_base, unsigned long user_stack_size, 419 unsigned long user_stack_base, unsigned long user_stack_size,
427 struct task_struct *p, struct pt_regs *regs) 420 struct task_struct *p, struct pt_regs *regs)
428{ 421{
429 extern char ia64_ret_from_clone, ia32_ret_from_clone; 422 extern char ia64_ret_from_clone;
430 struct switch_stack *child_stack, *stack; 423 struct switch_stack *child_stack, *stack;
431 unsigned long rbs, child_rbs, rbs_size; 424 unsigned long rbs, child_rbs, rbs_size;
432 struct pt_regs *child_ptregs; 425 struct pt_regs *child_ptregs;
@@ -457,7 +450,7 @@ copy_thread(unsigned long clone_flags,
457 memcpy((void *) child_rbs, (void *) rbs, rbs_size); 450 memcpy((void *) child_rbs, (void *) rbs, rbs_size);
458 451
459 if (likely(user_mode(child_ptregs))) { 452 if (likely(user_mode(child_ptregs))) {
460 if ((clone_flags & CLONE_SETTLS) && !IS_IA32_PROCESS(regs)) 453 if (clone_flags & CLONE_SETTLS)
461 child_ptregs->r13 = regs->r16; /* see sys_clone2() in entry.S */ 454 child_ptregs->r13 = regs->r16; /* see sys_clone2() in entry.S */
462 if (user_stack_base) { 455 if (user_stack_base) {
463 child_ptregs->r12 = user_stack_base + user_stack_size - 16; 456 child_ptregs->r12 = user_stack_base + user_stack_size - 16;
@@ -477,10 +470,7 @@ copy_thread(unsigned long clone_flags,
477 child_ptregs->r13 = (unsigned long) p; /* set `current' pointer */ 470 child_ptregs->r13 = (unsigned long) p; /* set `current' pointer */
478 } 471 }
479 child_stack->ar_bspstore = child_rbs + rbs_size; 472 child_stack->ar_bspstore = child_rbs + rbs_size;
480 if (IS_IA32_PROCESS(regs)) 473 child_stack->b0 = (unsigned long) &ia64_ret_from_clone;
481 child_stack->b0 = (unsigned long) &ia32_ret_from_clone;
482 else
483 child_stack->b0 = (unsigned long) &ia64_ret_from_clone;
484 474
485 /* copy parts of thread_struct: */ 475 /* copy parts of thread_struct: */
486 p->thread.ksp = (unsigned long) child_stack - 16; 476 p->thread.ksp = (unsigned long) child_stack - 16;
@@ -515,22 +505,6 @@ copy_thread(unsigned long clone_flags,
515 p->thread.flags = ((current->thread.flags & ~THREAD_FLAGS_TO_CLEAR) 505 p->thread.flags = ((current->thread.flags & ~THREAD_FLAGS_TO_CLEAR)
516 | THREAD_FLAGS_TO_SET); 506 | THREAD_FLAGS_TO_SET);
517 ia64_drop_fpu(p); /* don't pick up stale state from a CPU's fph */ 507 ia64_drop_fpu(p); /* don't pick up stale state from a CPU's fph */
518#ifdef CONFIG_IA32_SUPPORT
519 /*
520 * If we're cloning an IA32 task then save the IA32 extra
521 * state from the current task to the new task
522 */
523 if (IS_IA32_PROCESS(task_pt_regs(current))) {
524 ia32_save_state(p);
525 if (clone_flags & CLONE_SETTLS)
526 retval = ia32_clone_tls(p, child_ptregs);
527
528 /* Copy partially mapped page list */
529 if (!retval)
530 retval = ia32_copy_ia64_partial_page_list(p,
531 clone_flags);
532 }
533#endif
534 508
535#ifdef CONFIG_PERFMON 509#ifdef CONFIG_PERFMON
536 if (current->thread.pfm_context) 510 if (current->thread.pfm_context)
@@ -704,15 +678,6 @@ EXPORT_SYMBOL(kernel_thread);
704int 678int
705kernel_thread_helper (int (*fn)(void *), void *arg) 679kernel_thread_helper (int (*fn)(void *), void *arg)
706{ 680{
707#ifdef CONFIG_IA32_SUPPORT
708 if (IS_IA32_PROCESS(task_pt_regs(current))) {
709 /* A kernel thread is always a 64-bit process. */
710 current->thread.map_base = DEFAULT_MAP_BASE;
711 current->thread.task_size = DEFAULT_TASK_SIZE;
712 ia64_set_kr(IA64_KR_IO_BASE, current->thread.old_iob);
713 ia64_set_kr(IA64_KR_TSSD, current->thread.old_k1);
714 }
715#endif
716 return (*fn)(arg); 681 return (*fn)(arg);
717} 682}
718 683
@@ -725,14 +690,6 @@ flush_thread (void)
725 /* drop floating-point and debug-register state if it exists: */ 690 /* drop floating-point and debug-register state if it exists: */
726 current->thread.flags &= ~(IA64_THREAD_FPH_VALID | IA64_THREAD_DBG_VALID); 691 current->thread.flags &= ~(IA64_THREAD_FPH_VALID | IA64_THREAD_DBG_VALID);
727 ia64_drop_fpu(current); 692 ia64_drop_fpu(current);
728#ifdef CONFIG_IA32_SUPPORT
729 if (IS_IA32_PROCESS(task_pt_regs(current))) {
730 ia32_drop_ia64_partial_page_list(current);
731 current->thread.task_size = IA32_PAGE_OFFSET;
732 set_fs(USER_DS);
733 memset(current->thread.tls_array, 0, sizeof(current->thread.tls_array));
734 }
735#endif
736} 693}
737 694
738/* 695/*
@@ -753,8 +710,6 @@ exit_thread (void)
753 if (current->thread.flags & IA64_THREAD_DBG_VALID) 710 if (current->thread.flags & IA64_THREAD_DBG_VALID)
754 pfm_release_debug_registers(current); 711 pfm_release_debug_registers(current);
755#endif 712#endif
756 if (IS_IA32_PROCESS(task_pt_regs(current)))
757 ia32_drop_ia64_partial_page_list(current);
758} 713}
759 714
760unsigned long 715unsigned long
diff --git a/arch/ia64/kernel/ptrace.c b/arch/ia64/kernel/ptrace.c
index 9daa87fdb018..7c7909f9bc93 100644
--- a/arch/ia64/kernel/ptrace.c
+++ b/arch/ia64/kernel/ptrace.c
@@ -11,7 +11,6 @@
11 */ 11 */
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/sched.h> 13#include <linux/sched.h>
14#include <linux/slab.h>
15#include <linux/mm.h> 14#include <linux/mm.h>
16#include <linux/errno.h> 15#include <linux/errno.h>
17#include <linux/ptrace.h> 16#include <linux/ptrace.h>
@@ -639,7 +638,7 @@ ptrace_attach_sync_user_rbs (struct task_struct *child)
639 */ 638 */
640 639
641 read_lock(&tasklist_lock); 640 read_lock(&tasklist_lock);
642 if (child->signal) { 641 if (child->sighand) {
643 spin_lock_irq(&child->sighand->siglock); 642 spin_lock_irq(&child->sighand->siglock);
644 if (child->state == TASK_STOPPED && 643 if (child->state == TASK_STOPPED &&
645 !test_and_set_tsk_thread_flag(child, TIF_RESTORE_RSE)) { 644 !test_and_set_tsk_thread_flag(child, TIF_RESTORE_RSE)) {
@@ -663,7 +662,7 @@ ptrace_attach_sync_user_rbs (struct task_struct *child)
663 * job control stop, so that SIGCONT can be used to wake it up. 662 * job control stop, so that SIGCONT can be used to wake it up.
664 */ 663 */
665 read_lock(&tasklist_lock); 664 read_lock(&tasklist_lock);
666 if (child->signal) { 665 if (child->sighand) {
667 spin_lock_irq(&child->sighand->siglock); 666 spin_lock_irq(&child->sighand->siglock);
668 if (child->state == TASK_TRACED && 667 if (child->state == TASK_TRACED &&
669 (child->signal->flags & SIGNAL_STOP_STOPPED)) { 668 (child->signal->flags & SIGNAL_STOP_STOPPED)) {
@@ -1250,13 +1249,8 @@ syscall_trace_enter (long arg0, long arg1, long arg2, long arg3,
1250 long syscall; 1249 long syscall;
1251 int arch; 1250 int arch;
1252 1251
1253 if (IS_IA32_PROCESS(&regs)) { 1252 syscall = regs.r15;
1254 syscall = regs.r1; 1253 arch = AUDIT_ARCH_IA64;
1255 arch = AUDIT_ARCH_I386;
1256 } else {
1257 syscall = regs.r15;
1258 arch = AUDIT_ARCH_IA64;
1259 }
1260 1254
1261 audit_syscall_entry(arch, syscall, arg0, arg1, arg2, arg3); 1255 audit_syscall_entry(arch, syscall, arg0, arg1, arg2, arg3);
1262 } 1256 }
@@ -2172,11 +2166,6 @@ static const struct user_regset_view user_ia64_view = {
2172 2166
2173const struct user_regset_view *task_user_regset_view(struct task_struct *tsk) 2167const struct user_regset_view *task_user_regset_view(struct task_struct *tsk)
2174{ 2168{
2175#ifdef CONFIG_IA32_SUPPORT
2176 extern const struct user_regset_view user_ia32_view;
2177 if (IS_IA32_PROCESS(task_pt_regs(tsk)))
2178 return &user_ia32_view;
2179#endif
2180 return &user_ia64_view; 2169 return &user_ia64_view;
2181} 2170}
2182 2171
diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
index e6676fca4828..aa8b5fa1a8de 100644
--- a/arch/ia64/kernel/salinfo.c
+++ b/arch/ia64/kernel/salinfo.c
@@ -404,10 +404,9 @@ static void
404call_on_cpu(int cpu, void (*fn)(void *), void *arg) 404call_on_cpu(int cpu, void (*fn)(void *), void *arg)
405{ 405{
406 cpumask_t save_cpus_allowed = current->cpus_allowed; 406 cpumask_t save_cpus_allowed = current->cpus_allowed;
407 cpumask_t new_cpus_allowed = cpumask_of_cpu(cpu); 407 set_cpus_allowed_ptr(current, cpumask_of(cpu));
408 set_cpus_allowed(current, new_cpus_allowed);
409 (*fn)(arg); 408 (*fn)(arg);
410 set_cpus_allowed(current, save_cpus_allowed); 409 set_cpus_allowed_ptr(current, &save_cpus_allowed);
411} 410}
412 411
413static void 412static void
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index a1ea87919777..41ae6a596b50 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -46,7 +46,6 @@
46#include <linux/kexec.h> 46#include <linux/kexec.h>
47#include <linux/crash_dump.h> 47#include <linux/crash_dump.h>
48 48
49#include <asm/ia32.h>
50#include <asm/machvec.h> 49#include <asm/machvec.h>
51#include <asm/mca.h> 50#include <asm/mca.h>
52#include <asm/meminit.h> 51#include <asm/meminit.h>
@@ -1016,10 +1015,6 @@ cpu_init (void)
1016 ia64_mmu_init(ia64_imva(cpu_data)); 1015 ia64_mmu_init(ia64_imva(cpu_data));
1017 ia64_mca_cpu_init(ia64_imva(cpu_data)); 1016 ia64_mca_cpu_init(ia64_imva(cpu_data));
1018 1017
1019#ifdef CONFIG_IA32_SUPPORT
1020 ia32_cpu_init();
1021#endif
1022
1023 /* Clear ITC to eliminate sched_clock() overflows in human time. */ 1018 /* Clear ITC to eliminate sched_clock() overflows in human time. */
1024 ia64_set_itc(0); 1019 ia64_set_itc(0);
1025 1020
diff --git a/arch/ia64/kernel/signal.c b/arch/ia64/kernel/signal.c
index e1821ca4c7df..7bdafc8788bd 100644
--- a/arch/ia64/kernel/signal.c
+++ b/arch/ia64/kernel/signal.c
@@ -21,7 +21,6 @@
21#include <linux/unistd.h> 21#include <linux/unistd.h>
22#include <linux/wait.h> 22#include <linux/wait.h>
23 23
24#include <asm/ia32.h>
25#include <asm/intrinsics.h> 24#include <asm/intrinsics.h>
26#include <asm/uaccess.h> 25#include <asm/uaccess.h>
27#include <asm/rse.h> 26#include <asm/rse.h>
@@ -425,14 +424,8 @@ static long
425handle_signal (unsigned long sig, struct k_sigaction *ka, siginfo_t *info, sigset_t *oldset, 424handle_signal (unsigned long sig, struct k_sigaction *ka, siginfo_t *info, sigset_t *oldset,
426 struct sigscratch *scr) 425 struct sigscratch *scr)
427{ 426{
428 if (IS_IA32_PROCESS(&scr->pt)) { 427 if (!setup_frame(sig, ka, info, oldset, scr))
429 /* send signal to IA-32 process */ 428 return 0;
430 if (!ia32_setup_frame1(sig, ka, info, oldset, &scr->pt))
431 return 0;
432 } else
433 /* send signal to IA-64 process */
434 if (!setup_frame(sig, ka, info, oldset, scr))
435 return 0;
436 429
437 spin_lock_irq(&current->sighand->siglock); 430 spin_lock_irq(&current->sighand->siglock);
438 sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask); 431 sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
@@ -462,7 +455,6 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall)
462 siginfo_t info; 455 siginfo_t info;
463 long restart = in_syscall; 456 long restart = in_syscall;
464 long errno = scr->pt.r8; 457 long errno = scr->pt.r8;
465# define ERR_CODE(c) (IS_IA32_PROCESS(&scr->pt) ? -(c) : (c))
466 458
467 /* 459 /*
468 * In the ia64_leave_kernel code path, we want the common case to go fast, which 460 * In the ia64_leave_kernel code path, we want the common case to go fast, which
@@ -490,14 +482,7 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall)
490 * inferior call), thus it's important to check for restarting _after_ 482 * inferior call), thus it's important to check for restarting _after_
491 * get_signal_to_deliver(). 483 * get_signal_to_deliver().
492 */ 484 */
493 if (IS_IA32_PROCESS(&scr->pt)) { 485 if ((long) scr->pt.r10 != -1)
494 if (in_syscall) {
495 if (errno >= 0)
496 restart = 0;
497 else
498 errno = -errno;
499 }
500 } else if ((long) scr->pt.r10 != -1)
501 /* 486 /*
502 * A system calls has to be restarted only if one of the error codes 487 * A system calls has to be restarted only if one of the error codes
503 * ERESTARTNOHAND, ERESTARTSYS, or ERESTARTNOINTR is returned. If r10 488 * ERESTARTNOHAND, ERESTARTSYS, or ERESTARTNOINTR is returned. If r10
@@ -513,22 +498,18 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall)
513 switch (errno) { 498 switch (errno) {
514 case ERESTART_RESTARTBLOCK: 499 case ERESTART_RESTARTBLOCK:
515 case ERESTARTNOHAND: 500 case ERESTARTNOHAND:
516 scr->pt.r8 = ERR_CODE(EINTR); 501 scr->pt.r8 = EINTR;
517 /* note: scr->pt.r10 is already -1 */ 502 /* note: scr->pt.r10 is already -1 */
518 break; 503 break;
519 504
520 case ERESTARTSYS: 505 case ERESTARTSYS:
521 if ((ka.sa.sa_flags & SA_RESTART) == 0) { 506 if ((ka.sa.sa_flags & SA_RESTART) == 0) {
522 scr->pt.r8 = ERR_CODE(EINTR); 507 scr->pt.r8 = EINTR;
523 /* note: scr->pt.r10 is already -1 */ 508 /* note: scr->pt.r10 is already -1 */
524 break; 509 break;
525 } 510 }
526 case ERESTARTNOINTR: 511 case ERESTARTNOINTR:
527 if (IS_IA32_PROCESS(&scr->pt)) { 512 ia64_decrement_ip(&scr->pt);
528 scr->pt.r8 = scr->pt.r1;
529 scr->pt.cr_iip -= 2;
530 } else
531 ia64_decrement_ip(&scr->pt);
532 restart = 0; /* don't restart twice if handle_signal() fails... */ 513 restart = 0; /* don't restart twice if handle_signal() fails... */
533 } 514 }
534 } 515 }
@@ -555,21 +536,14 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall)
555 if (errno == ERESTARTNOHAND || errno == ERESTARTSYS || errno == ERESTARTNOINTR 536 if (errno == ERESTARTNOHAND || errno == ERESTARTSYS || errno == ERESTARTNOINTR
556 || errno == ERESTART_RESTARTBLOCK) 537 || errno == ERESTART_RESTARTBLOCK)
557 { 538 {
558 if (IS_IA32_PROCESS(&scr->pt)) { 539 /*
559 scr->pt.r8 = scr->pt.r1; 540 * Note: the syscall number is in r15 which is saved in
560 scr->pt.cr_iip -= 2; 541 * pt_regs so all we need to do here is adjust ip so that
561 if (errno == ERESTART_RESTARTBLOCK) 542 * the "break" instruction gets re-executed.
562 scr->pt.r8 = 0; /* x86 version of __NR_restart_syscall */ 543 */
563 } else { 544 ia64_decrement_ip(&scr->pt);
564 /* 545 if (errno == ERESTART_RESTARTBLOCK)
565 * Note: the syscall number is in r15 which is saved in 546 scr->pt.r15 = __NR_restart_syscall;
566 * pt_regs so all we need to do here is adjust ip so that
567 * the "break" instruction gets re-executed.
568 */
569 ia64_decrement_ip(&scr->pt);
570 if (errno == ERESTART_RESTARTBLOCK)
571 scr->pt.r15 = __NR_restart_syscall;
572 }
573 } 547 }
574 } 548 }
575 549
diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
index de100aa7ff03..6a1380e90f87 100644
--- a/arch/ia64/kernel/smpboot.c
+++ b/arch/ia64/kernel/smpboot.c
@@ -44,7 +44,6 @@
44#include <asm/cache.h> 44#include <asm/cache.h>
45#include <asm/current.h> 45#include <asm/current.h>
46#include <asm/delay.h> 46#include <asm/delay.h>
47#include <asm/ia32.h>
48#include <asm/io.h> 47#include <asm/io.h>
49#include <asm/irq.h> 48#include <asm/irq.h>
50#include <asm/machvec.h> 49#include <asm/machvec.h>
@@ -391,6 +390,14 @@ smp_callin (void)
391 390
392 fix_b0_for_bsp(); 391 fix_b0_for_bsp();
393 392
393#ifdef CONFIG_NUMA
394 /*
395 * numa_node_id() works after this.
396 */
397 set_numa_node(cpu_to_node_map[cpuid]);
398 set_numa_mem(local_memory_node(cpu_to_node_map[cpuid]));
399#endif
400
394 ipi_call_lock_irq(); 401 ipi_call_lock_irq();
395 spin_lock(&vector_lock); 402 spin_lock(&vector_lock);
396 /* Setup the per cpu irq handling data structures */ 403 /* Setup the per cpu irq handling data structures */
@@ -443,10 +450,6 @@ smp_callin (void)
443 calibrate_delay(); 450 calibrate_delay();
444 local_cpu_data->loops_per_jiffy = loops_per_jiffy; 451 local_cpu_data->loops_per_jiffy = loops_per_jiffy;
445 452
446#ifdef CONFIG_IA32_SUPPORT
447 ia32_gdt_init();
448#endif
449
450 /* 453 /*
451 * Allow the master to continue. 454 * Allow the master to continue.
452 */ 455 */
@@ -637,6 +640,9 @@ void __devinit smp_prepare_boot_cpu(void)
637{ 640{
638 cpu_set(smp_processor_id(), cpu_online_map); 641 cpu_set(smp_processor_id(), cpu_online_map);
639 cpu_set(smp_processor_id(), cpu_callin_map); 642 cpu_set(smp_processor_id(), cpu_callin_map);
643#ifdef CONFIG_NUMA
644 set_numa_node(cpu_to_node_map[smp_processor_id()]);
645#endif
640 per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE; 646 per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
641 paravirt_post_smp_prepare_boot_cpu(); 647 paravirt_post_smp_prepare_boot_cpu();
642} 648}
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c
index a35c661e5e89..653b3c46ea82 100644
--- a/arch/ia64/kernel/time.c
+++ b/arch/ia64/kernel/time.c
@@ -61,7 +61,7 @@ unsigned long long sched_clock(void)
61 61
62#ifdef CONFIG_PARAVIRT 62#ifdef CONFIG_PARAVIRT
63static void 63static void
64paravirt_clocksource_resume(void) 64paravirt_clocksource_resume(struct clocksource *cs)
65{ 65{
66 if (pv_time_ops.clocksource_resume) 66 if (pv_time_ops.clocksource_resume)
67 pv_time_ops.clocksource_resume(); 67 pv_time_ops.clocksource_resume();
@@ -430,18 +430,16 @@ static int __init rtc_init(void)
430} 430}
431module_init(rtc_init); 431module_init(rtc_init);
432 432
433void read_persistent_clock(struct timespec *ts)
434{
435 efi_gettimeofday(ts);
436}
437
433void __init 438void __init
434time_init (void) 439time_init (void)
435{ 440{
436 register_percpu_irq(IA64_TIMER_VECTOR, &timer_irqaction); 441 register_percpu_irq(IA64_TIMER_VECTOR, &timer_irqaction);
437 efi_gettimeofday(&xtime);
438 ia64_init_itm(); 442 ia64_init_itm();
439
440 /*
441 * Initialize wall_to_monotonic such that adding it to xtime will yield zero, the
442 * tv_nsec field must be normalized (i.e., 0 <= nsec < NSEC_PER_SEC).
443 */
444 set_normalized_timespec(&wall_to_monotonic, -xtime.tv_sec, -xtime.tv_nsec);
445} 443}
446 444
447/* 445/*
diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
index 8f060352e129..0baa1bbb65fe 100644
--- a/arch/ia64/kernel/topology.c
+++ b/arch/ia64/kernel/topology.c
@@ -17,6 +17,7 @@
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/node.h> 19#include <linux/node.h>
20#include <linux/slab.h>
20#include <linux/init.h> 21#include <linux/init.h>
21#include <linux/bootmem.h> 22#include <linux/bootmem.h>
22#include <linux/nodemask.h> 23#include <linux/nodemask.h>
@@ -282,7 +283,7 @@ static ssize_t cache_show(struct kobject * kobj, struct attribute * attr, char *
282 return ret; 283 return ret;
283} 284}
284 285
285static struct sysfs_ops cache_sysfs_ops = { 286static const struct sysfs_ops cache_sysfs_ops = {
286 .show = cache_show 287 .show = cache_show
287}; 288};
288 289
@@ -360,12 +361,12 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
360 return 0; 361 return 0;
361 362
362 oldmask = current->cpus_allowed; 363 oldmask = current->cpus_allowed;
363 retval = set_cpus_allowed(current, cpumask_of_cpu(cpu)); 364 retval = set_cpus_allowed_ptr(current, cpumask_of(cpu));
364 if (unlikely(retval)) 365 if (unlikely(retval))
365 return retval; 366 return retval;
366 367
367 retval = cpu_cache_sysfs_init(cpu); 368 retval = cpu_cache_sysfs_init(cpu);
368 set_cpus_allowed(current, oldmask); 369 set_cpus_allowed_ptr(current, &oldmask);
369 if (unlikely(retval < 0)) 370 if (unlikely(retval < 0))
370 return retval; 371 return retval;
371 372
diff --git a/arch/ia64/kernel/traps.c b/arch/ia64/kernel/traps.c
index f0cda765e681..fd80e70018a9 100644
--- a/arch/ia64/kernel/traps.c
+++ b/arch/ia64/kernel/traps.c
@@ -19,7 +19,6 @@
19#include <linux/kdebug.h> 19#include <linux/kdebug.h>
20 20
21#include <asm/fpswa.h> 21#include <asm/fpswa.h>
22#include <asm/ia32.h>
23#include <asm/intrinsics.h> 22#include <asm/intrinsics.h>
24#include <asm/processor.h> 23#include <asm/processor.h>
25#include <asm/uaccess.h> 24#include <asm/uaccess.h>
@@ -626,10 +625,6 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,
626 break; 625 break;
627 626
628 case 45: 627 case 45:
629#ifdef CONFIG_IA32_SUPPORT
630 if (ia32_exception(&regs, isr) == 0)
631 return;
632#endif
633 printk(KERN_ERR "Unexpected IA-32 exception (Trap 45)\n"); 628 printk(KERN_ERR "Unexpected IA-32 exception (Trap 45)\n");
634 printk(KERN_ERR " iip - 0x%lx, ifa - 0x%lx, isr - 0x%lx\n", 629 printk(KERN_ERR " iip - 0x%lx, ifa - 0x%lx, isr - 0x%lx\n",
635 iip, ifa, isr); 630 iip, ifa, isr);
@@ -637,10 +632,6 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,
637 break; 632 break;
638 633
639 case 46: 634 case 46:
640#ifdef CONFIG_IA32_SUPPORT
641 if (ia32_intercept(&regs, isr) == 0)
642 return;
643#endif
644 printk(KERN_ERR "Unexpected IA-32 intercept trap (Trap 46)\n"); 635 printk(KERN_ERR "Unexpected IA-32 intercept trap (Trap 46)\n");
645 printk(KERN_ERR " iip - 0x%lx, ifa - 0x%lx, isr - 0x%lx, iim - 0x%lx\n", 636 printk(KERN_ERR " iip - 0x%lx, ifa - 0x%lx, isr - 0x%lx, iim - 0x%lx\n",
646 iip, ifa, isr, iim); 637 iip, ifa, isr, iim);
diff --git a/arch/ia64/kernel/unaligned.c b/arch/ia64/kernel/unaligned.c
index 776dd40397e2..622772b7fb6c 100644
--- a/arch/ia64/kernel/unaligned.c
+++ b/arch/ia64/kernel/unaligned.c
@@ -17,6 +17,7 @@
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <linux/tty.h> 19#include <linux/tty.h>
20#include <linux/ratelimit.h>
20 21
21#include <asm/intrinsics.h> 22#include <asm/intrinsics.h>
22#include <asm/processor.h> 23#include <asm/processor.h>
@@ -1283,24 +1284,9 @@ emulate_store_float (unsigned long ifa, load_store_t ld, struct pt_regs *regs)
1283/* 1284/*
1284 * Make sure we log the unaligned access, so that user/sysadmin can notice it and 1285 * Make sure we log the unaligned access, so that user/sysadmin can notice it and
1285 * eventually fix the program. However, we don't want to do that for every access so we 1286 * eventually fix the program. However, we don't want to do that for every access so we
1286 * pace it with jiffies. This isn't really MP-safe, but it doesn't really have to be 1287 * pace it with jiffies.
1287 * either...
1288 */ 1288 */
1289static int 1289static DEFINE_RATELIMIT_STATE(logging_rate_limit, 5 * HZ, 5);
1290within_logging_rate_limit (void)
1291{
1292 static unsigned long count, last_time;
1293
1294 if (time_after(jiffies, last_time + 5 * HZ))
1295 count = 0;
1296 if (count < 5) {
1297 last_time = jiffies;
1298 count++;
1299 return 1;
1300 }
1301 return 0;
1302
1303}
1304 1290
1305void 1291void
1306ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs) 1292ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs)
@@ -1337,7 +1323,7 @@ ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs)
1337 1323
1338 if (!no_unaligned_warning && 1324 if (!no_unaligned_warning &&
1339 !(current->thread.flags & IA64_THREAD_UAC_NOPRINT) && 1325 !(current->thread.flags & IA64_THREAD_UAC_NOPRINT) &&
1340 within_logging_rate_limit()) 1326 __ratelimit(&logging_rate_limit))
1341 { 1327 {
1342 char buf[200]; /* comm[] is at most 16 bytes... */ 1328 char buf[200]; /* comm[] is at most 16 bytes... */
1343 size_t len; 1329 size_t len;
@@ -1370,7 +1356,7 @@ ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs)
1370 } 1356 }
1371 } 1357 }
1372 } else { 1358 } else {
1373 if (within_logging_rate_limit()) { 1359 if (__ratelimit(&logging_rate_limit)) {
1374 printk(KERN_WARNING "kernel unaligned access to 0x%016lx, ip=0x%016lx\n", 1360 printk(KERN_WARNING "kernel unaligned access to 0x%016lx, ip=0x%016lx\n",
1375 ifa, regs->cr_iip + ipsr->ri); 1361 ifa, regs->cr_iip + ipsr->ri);
1376 if (unaligned_dump_stack) 1362 if (unaligned_dump_stack)
diff --git a/arch/ia64/kernel/uncached.c b/arch/ia64/kernel/uncached.c
index a595823582d9..c4696d217ce0 100644
--- a/arch/ia64/kernel/uncached.c
+++ b/arch/ia64/kernel/uncached.c
@@ -18,9 +18,9 @@
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/errno.h> 19#include <linux/errno.h>
20#include <linux/string.h> 20#include <linux/string.h>
21#include <linux/slab.h>
22#include <linux/efi.h> 21#include <linux/efi.h>
23#include <linux/genalloc.h> 22#include <linux/genalloc.h>
23#include <linux/gfp.h>
24#include <asm/page.h> 24#include <asm/page.h>
25#include <asm/pal.h> 25#include <asm/pal.h>
26#include <asm/system.h> 26#include <asm/system.h>
diff --git a/arch/ia64/kvm/Kconfig b/arch/ia64/kvm/Kconfig
index ef3e7be29caf..fa4d1e59deb0 100644
--- a/arch/ia64/kvm/Kconfig
+++ b/arch/ia64/kvm/Kconfig
@@ -26,6 +26,7 @@ config KVM
26 select ANON_INODES 26 select ANON_INODES
27 select HAVE_KVM_IRQCHIP 27 select HAVE_KVM_IRQCHIP
28 select KVM_APIC_ARCHITECTURE 28 select KVM_APIC_ARCHITECTURE
29 select KVM_MMIO
29 ---help--- 30 ---help---
30 Support hosting fully virtualized guest machines using hardware 31 Support hosting fully virtualized guest machines using hardware
31 virtualization extensions. You will need a fairly recent 32 virtualization extensions. You will need a fairly recent
@@ -47,6 +48,7 @@ config KVM_INTEL
47 Provides support for KVM on Itanium 2 processors equipped with the VT 48 Provides support for KVM on Itanium 2 processors equipped with the VT
48 extensions. 49 extensions.
49 50
51source drivers/vhost/Kconfig
50source drivers/virtio/Kconfig 52source drivers/virtio/Kconfig
51 53
52endif # VIRTUALIZATION 54endif # VIRTUALIZATION
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index 5fdeec5fddcf..21b701374f72 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -23,8 +23,8 @@
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/percpu.h> 25#include <linux/percpu.h>
26#include <linux/gfp.h>
27#include <linux/fs.h> 26#include <linux/fs.h>
27#include <linux/slab.h>
28#include <linux/smp.h> 28#include <linux/smp.h>
29#include <linux/kvm_host.h> 29#include <linux/kvm_host.h>
30#include <linux/kvm.h> 30#include <linux/kvm.h>
@@ -144,6 +144,7 @@ int kvm_arch_hardware_enable(void *garbage)
144 VP_INIT_ENV : VP_INIT_ENV_INITALIZE, 144 VP_INIT_ENV : VP_INIT_ENV_INITALIZE,
145 __pa(kvm_vm_buffer), KVM_VM_BUFFER_BASE, &tmp_base); 145 __pa(kvm_vm_buffer), KVM_VM_BUFFER_BASE, &tmp_base);
146 if (status != 0) { 146 if (status != 0) {
147 spin_unlock(&vp_lock);
147 printk(KERN_WARNING"kvm: Failed to Enable VT Support!!!!\n"); 148 printk(KERN_WARNING"kvm: Failed to Enable VT Support!!!!\n");
148 return -EINVAL; 149 return -EINVAL;
149 } 150 }
@@ -241,10 +242,10 @@ static int handle_mmio(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
241 return 0; 242 return 0;
242mmio: 243mmio:
243 if (p->dir) 244 if (p->dir)
244 r = kvm_io_bus_read(&vcpu->kvm->mmio_bus, p->addr, 245 r = kvm_io_bus_read(vcpu->kvm, KVM_MMIO_BUS, p->addr,
245 p->size, &p->data); 246 p->size, &p->data);
246 else 247 else
247 r = kvm_io_bus_write(&vcpu->kvm->mmio_bus, p->addr, 248 r = kvm_io_bus_write(vcpu->kvm, KVM_MMIO_BUS, p->addr,
248 p->size, &p->data); 249 p->size, &p->data);
249 if (r) 250 if (r)
250 printk(KERN_ERR"kvm: No iodevice found! addr:%lx\n", p->addr); 251 printk(KERN_ERR"kvm: No iodevice found! addr:%lx\n", p->addr);
@@ -636,12 +637,9 @@ static void kvm_vcpu_post_transition(struct kvm_vcpu *vcpu)
636static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 637static int __vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
637{ 638{
638 union context *host_ctx, *guest_ctx; 639 union context *host_ctx, *guest_ctx;
639 int r; 640 int r, idx;
640 641
641 /* 642 idx = srcu_read_lock(&vcpu->kvm->srcu);
642 * down_read() may sleep and return with interrupts enabled
643 */
644 down_read(&vcpu->kvm->slots_lock);
645 643
646again: 644again:
647 if (signal_pending(current)) { 645 if (signal_pending(current)) {
@@ -663,7 +661,7 @@ again:
663 if (r < 0) 661 if (r < 0)
664 goto vcpu_run_fail; 662 goto vcpu_run_fail;
665 663
666 up_read(&vcpu->kvm->slots_lock); 664 srcu_read_unlock(&vcpu->kvm->srcu, idx);
667 kvm_guest_enter(); 665 kvm_guest_enter();
668 666
669 /* 667 /*
@@ -687,7 +685,7 @@ again:
687 kvm_guest_exit(); 685 kvm_guest_exit();
688 preempt_enable(); 686 preempt_enable();
689 687
690 down_read(&vcpu->kvm->slots_lock); 688 idx = srcu_read_lock(&vcpu->kvm->srcu);
691 689
692 r = kvm_handle_exit(kvm_run, vcpu); 690 r = kvm_handle_exit(kvm_run, vcpu);
693 691
@@ -697,10 +695,10 @@ again:
697 } 695 }
698 696
699out: 697out:
700 up_read(&vcpu->kvm->slots_lock); 698 srcu_read_unlock(&vcpu->kvm->srcu, idx);
701 if (r > 0) { 699 if (r > 0) {
702 kvm_resched(vcpu); 700 kvm_resched(vcpu);
703 down_read(&vcpu->kvm->slots_lock); 701 idx = srcu_read_lock(&vcpu->kvm->srcu);
704 goto again; 702 goto again;
705 } 703 }
706 704
@@ -971,7 +969,7 @@ long kvm_arch_vm_ioctl(struct file *filp,
971 goto out; 969 goto out;
972 r = kvm_setup_default_irq_routing(kvm); 970 r = kvm_setup_default_irq_routing(kvm);
973 if (r) { 971 if (r) {
974 kfree(kvm->arch.vioapic); 972 kvm_ioapic_destroy(kvm);
975 goto out; 973 goto out;
976 } 974 }
977 break; 975 break;
@@ -982,11 +980,13 @@ long kvm_arch_vm_ioctl(struct file *filp,
982 r = -EFAULT; 980 r = -EFAULT;
983 if (copy_from_user(&irq_event, argp, sizeof irq_event)) 981 if (copy_from_user(&irq_event, argp, sizeof irq_event))
984 goto out; 982 goto out;
983 r = -ENXIO;
985 if (irqchip_in_kernel(kvm)) { 984 if (irqchip_in_kernel(kvm)) {
986 __s32 status; 985 __s32 status;
987 status = kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, 986 status = kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID,
988 irq_event.irq, irq_event.level); 987 irq_event.irq, irq_event.level);
989 if (ioctl == KVM_IRQ_LINE_STATUS) { 988 if (ioctl == KVM_IRQ_LINE_STATUS) {
989 r = -EFAULT;
990 irq_event.status = status; 990 irq_event.status = status;
991 if (copy_to_user(argp, &irq_event, 991 if (copy_to_user(argp, &irq_event,
992 sizeof irq_event)) 992 sizeof irq_event))
@@ -1377,12 +1377,14 @@ static void free_kvm(struct kvm *kvm)
1377 1377
1378static void kvm_release_vm_pages(struct kvm *kvm) 1378static void kvm_release_vm_pages(struct kvm *kvm)
1379{ 1379{
1380 struct kvm_memslots *slots;
1380 struct kvm_memory_slot *memslot; 1381 struct kvm_memory_slot *memslot;
1381 int i, j; 1382 int i, j;
1382 unsigned long base_gfn; 1383 unsigned long base_gfn;
1383 1384
1384 for (i = 0; i < kvm->nmemslots; i++) { 1385 slots = kvm_memslots(kvm);
1385 memslot = &kvm->memslots[i]; 1386 for (i = 0; i < slots->nmemslots; i++) {
1387 memslot = &slots->memslots[i];
1386 base_gfn = memslot->base_gfn; 1388 base_gfn = memslot->base_gfn;
1387 1389
1388 for (j = 0; j < memslot->npages; j++) { 1390 for (j = 0; j < memslot->npages; j++) {
@@ -1405,6 +1407,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
1405 kfree(kvm->arch.vioapic); 1407 kfree(kvm->arch.vioapic);
1406 kvm_release_vm_pages(kvm); 1408 kvm_release_vm_pages(kvm);
1407 kvm_free_physmem(kvm); 1409 kvm_free_physmem(kvm);
1410 cleanup_srcu_struct(&kvm->srcu);
1408 free_kvm(kvm); 1411 free_kvm(kvm);
1409} 1412}
1410 1413
@@ -1535,8 +1538,10 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
1535 goto out; 1538 goto out;
1536 1539
1537 if (copy_to_user(user_stack, stack, 1540 if (copy_to_user(user_stack, stack,
1538 sizeof(struct kvm_ia64_vcpu_stack))) 1541 sizeof(struct kvm_ia64_vcpu_stack))) {
1542 r = -EFAULT;
1539 goto out; 1543 goto out;
1544 }
1540 1545
1541 break; 1546 break;
1542 } 1547 }
@@ -1576,15 +1581,15 @@ out:
1576 return r; 1581 return r;
1577} 1582}
1578 1583
1579int kvm_arch_set_memory_region(struct kvm *kvm, 1584int kvm_arch_prepare_memory_region(struct kvm *kvm,
1580 struct kvm_userspace_memory_region *mem, 1585 struct kvm_memory_slot *memslot,
1581 struct kvm_memory_slot old, 1586 struct kvm_memory_slot old,
1587 struct kvm_userspace_memory_region *mem,
1582 int user_alloc) 1588 int user_alloc)
1583{ 1589{
1584 unsigned long i; 1590 unsigned long i;
1585 unsigned long pfn; 1591 unsigned long pfn;
1586 int npages = mem->memory_size >> PAGE_SHIFT; 1592 int npages = memslot->npages;
1587 struct kvm_memory_slot *memslot = &kvm->memslots[mem->slot];
1588 unsigned long base_gfn = memslot->base_gfn; 1593 unsigned long base_gfn = memslot->base_gfn;
1589 1594
1590 if (base_gfn + npages > (KVM_MAX_MEM_SIZE >> PAGE_SHIFT)) 1595 if (base_gfn + npages > (KVM_MAX_MEM_SIZE >> PAGE_SHIFT))
@@ -1608,6 +1613,14 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
1608 return 0; 1613 return 0;
1609} 1614}
1610 1615
1616void kvm_arch_commit_memory_region(struct kvm *kvm,
1617 struct kvm_userspace_memory_region *mem,
1618 struct kvm_memory_slot old,
1619 int user_alloc)
1620{
1621 return;
1622}
1623
1611void kvm_arch_flush_shadow(struct kvm *kvm) 1624void kvm_arch_flush_shadow(struct kvm *kvm)
1612{ 1625{
1613 kvm_flush_remote_tlbs(kvm); 1626 kvm_flush_remote_tlbs(kvm);
@@ -1794,7 +1807,8 @@ static int kvm_ia64_sync_dirty_log(struct kvm *kvm,
1794{ 1807{
1795 struct kvm_memory_slot *memslot; 1808 struct kvm_memory_slot *memslot;
1796 int r, i; 1809 int r, i;
1797 long n, base; 1810 long base;
1811 unsigned long n;
1798 unsigned long *dirty_bitmap = (unsigned long *)(kvm->arch.vm_base + 1812 unsigned long *dirty_bitmap = (unsigned long *)(kvm->arch.vm_base +
1799 offsetof(struct kvm_vm_data, kvm_mem_dirty_log)); 1813 offsetof(struct kvm_vm_data, kvm_mem_dirty_log));
1800 1814
@@ -1802,12 +1816,12 @@ static int kvm_ia64_sync_dirty_log(struct kvm *kvm,
1802 if (log->slot >= KVM_MEMORY_SLOTS) 1816 if (log->slot >= KVM_MEMORY_SLOTS)
1803 goto out; 1817 goto out;
1804 1818
1805 memslot = &kvm->memslots[log->slot]; 1819 memslot = &kvm->memslots->memslots[log->slot];
1806 r = -ENOENT; 1820 r = -ENOENT;
1807 if (!memslot->dirty_bitmap) 1821 if (!memslot->dirty_bitmap)
1808 goto out; 1822 goto out;
1809 1823
1810 n = ALIGN(memslot->npages, BITS_PER_LONG) / 8; 1824 n = kvm_dirty_bitmap_bytes(memslot);
1811 base = memslot->base_gfn / BITS_PER_LONG; 1825 base = memslot->base_gfn / BITS_PER_LONG;
1812 1826
1813 for (i = 0; i < n/sizeof(long); ++i) { 1827 for (i = 0; i < n/sizeof(long); ++i) {
@@ -1823,10 +1837,11 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
1823 struct kvm_dirty_log *log) 1837 struct kvm_dirty_log *log)
1824{ 1838{
1825 int r; 1839 int r;
1826 int n; 1840 unsigned long n;
1827 struct kvm_memory_slot *memslot; 1841 struct kvm_memory_slot *memslot;
1828 int is_dirty = 0; 1842 int is_dirty = 0;
1829 1843
1844 mutex_lock(&kvm->slots_lock);
1830 spin_lock(&kvm->arch.dirty_log_lock); 1845 spin_lock(&kvm->arch.dirty_log_lock);
1831 1846
1832 r = kvm_ia64_sync_dirty_log(kvm, log); 1847 r = kvm_ia64_sync_dirty_log(kvm, log);
@@ -1840,12 +1855,13 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
1840 /* If nothing is dirty, don't bother messing with page tables. */ 1855 /* If nothing is dirty, don't bother messing with page tables. */
1841 if (is_dirty) { 1856 if (is_dirty) {
1842 kvm_flush_remote_tlbs(kvm); 1857 kvm_flush_remote_tlbs(kvm);
1843 memslot = &kvm->memslots[log->slot]; 1858 memslot = &kvm->memslots->memslots[log->slot];
1844 n = ALIGN(memslot->npages, BITS_PER_LONG) / 8; 1859 n = kvm_dirty_bitmap_bytes(memslot);
1845 memset(memslot->dirty_bitmap, 0, n); 1860 memset(memslot->dirty_bitmap, 0, n);
1846 } 1861 }
1847 r = 0; 1862 r = 0;
1848out: 1863out:
1864 mutex_unlock(&kvm->slots_lock);
1849 spin_unlock(&kvm->arch.dirty_log_lock); 1865 spin_unlock(&kvm->arch.dirty_log_lock);
1850 return r; 1866 return r;
1851} 1867}
diff --git a/arch/ia64/kvm/kvm_fw.c b/arch/ia64/kvm/kvm_fw.c
index e4b82319881d..cb548ee9fcae 100644
--- a/arch/ia64/kvm/kvm_fw.c
+++ b/arch/ia64/kvm/kvm_fw.c
@@ -75,7 +75,7 @@ static void set_pal_result(struct kvm_vcpu *vcpu,
75 struct exit_ctl_data *p; 75 struct exit_ctl_data *p;
76 76
77 p = kvm_get_exit_data(vcpu); 77 p = kvm_get_exit_data(vcpu);
78 if (p && p->exit_reason == EXIT_REASON_PAL_CALL) { 78 if (p->exit_reason == EXIT_REASON_PAL_CALL) {
79 p->u.pal_data.ret = result; 79 p->u.pal_data.ret = result;
80 return ; 80 return ;
81 } 81 }
@@ -87,7 +87,7 @@ static void set_sal_result(struct kvm_vcpu *vcpu,
87 struct exit_ctl_data *p; 87 struct exit_ctl_data *p;
88 88
89 p = kvm_get_exit_data(vcpu); 89 p = kvm_get_exit_data(vcpu);
90 if (p && p->exit_reason == EXIT_REASON_SAL_CALL) { 90 if (p->exit_reason == EXIT_REASON_SAL_CALL) {
91 p->u.sal_data.ret = result; 91 p->u.sal_data.ret = result;
92 return ; 92 return ;
93 } 93 }
@@ -322,7 +322,7 @@ static u64 kvm_get_pal_call_index(struct kvm_vcpu *vcpu)
322 struct exit_ctl_data *p; 322 struct exit_ctl_data *p;
323 323
324 p = kvm_get_exit_data(vcpu); 324 p = kvm_get_exit_data(vcpu);
325 if (p && (p->exit_reason == EXIT_REASON_PAL_CALL)) 325 if (p->exit_reason == EXIT_REASON_PAL_CALL)
326 index = p->u.pal_data.gr28; 326 index = p->u.pal_data.gr28;
327 327
328 return index; 328 return index;
@@ -646,18 +646,16 @@ static void kvm_get_sal_call_data(struct kvm_vcpu *vcpu, u64 *in0, u64 *in1,
646 646
647 p = kvm_get_exit_data(vcpu); 647 p = kvm_get_exit_data(vcpu);
648 648
649 if (p) { 649 if (p->exit_reason == EXIT_REASON_SAL_CALL) {
650 if (p->exit_reason == EXIT_REASON_SAL_CALL) { 650 *in0 = p->u.sal_data.in0;
651 *in0 = p->u.sal_data.in0; 651 *in1 = p->u.sal_data.in1;
652 *in1 = p->u.sal_data.in1; 652 *in2 = p->u.sal_data.in2;
653 *in2 = p->u.sal_data.in2; 653 *in3 = p->u.sal_data.in3;
654 *in3 = p->u.sal_data.in3; 654 *in4 = p->u.sal_data.in4;
655 *in4 = p->u.sal_data.in4; 655 *in5 = p->u.sal_data.in5;
656 *in5 = p->u.sal_data.in5; 656 *in6 = p->u.sal_data.in6;
657 *in6 = p->u.sal_data.in6; 657 *in7 = p->u.sal_data.in7;
658 *in7 = p->u.sal_data.in7; 658 return ;
659 return ;
660 }
661 } 659 }
662 *in0 = 0; 660 *in0 = 0;
663} 661}
diff --git a/arch/ia64/kvm/mmio.c b/arch/ia64/kvm/mmio.c
index 9bf55afd08d0..fb8f9f59a1ed 100644
--- a/arch/ia64/kvm/mmio.c
+++ b/arch/ia64/kvm/mmio.c
@@ -316,8 +316,8 @@ void emulate_io_inst(struct kvm_vcpu *vcpu, u64 padr, u64 ma)
316 return; 316 return;
317 } else { 317 } else {
318 inst_type = -1; 318 inst_type = -1;
319 panic_vm(vcpu, "Unsupported MMIO access instruction! \ 319 panic_vm(vcpu, "Unsupported MMIO access instruction! "
320 Bunld[0]=0x%lx, Bundle[1]=0x%lx\n", 320 "Bunld[0]=0x%lx, Bundle[1]=0x%lx\n",
321 bundle.i64[0], bundle.i64[1]); 321 bundle.i64[0], bundle.i64[1]);
322 } 322 }
323 323
diff --git a/arch/ia64/kvm/vcpu.c b/arch/ia64/kvm/vcpu.c
index dce75b70cdd5..958815c9787d 100644
--- a/arch/ia64/kvm/vcpu.c
+++ b/arch/ia64/kvm/vcpu.c
@@ -1639,8 +1639,8 @@ void vcpu_set_psr(struct kvm_vcpu *vcpu, unsigned long val)
1639 * Otherwise panic 1639 * Otherwise panic
1640 */ 1640 */
1641 if (val & (IA64_PSR_PK | IA64_PSR_IS | IA64_PSR_VM)) 1641 if (val & (IA64_PSR_PK | IA64_PSR_IS | IA64_PSR_VM))
1642 panic_vm(vcpu, "Only support guests with vpsr.pk =0 \ 1642 panic_vm(vcpu, "Only support guests with vpsr.pk =0 "
1643 & vpsr.is=0\n"); 1643 "& vpsr.is=0\n");
1644 1644
1645 /* 1645 /*
1646 * For those IA64_PSR bits: id/da/dd/ss/ed/ia 1646 * For those IA64_PSR bits: id/da/dd/ss/ed/ia
diff --git a/arch/ia64/kvm/vmm.c b/arch/ia64/kvm/vmm.c
index 7a62f75778c5..f0b9cac82414 100644
--- a/arch/ia64/kvm/vmm.c
+++ b/arch/ia64/kvm/vmm.c
@@ -51,7 +51,7 @@ static int __init kvm_vmm_init(void)
51 vmm_fpswa_interface = fpswa_interface; 51 vmm_fpswa_interface = fpswa_interface;
52 52
53 /*Register vmm data to kvm side*/ 53 /*Register vmm data to kvm side*/
54 return kvm_init(&vmm_info, 1024, THIS_MODULE); 54 return kvm_init(&vmm_info, 1024, 0, THIS_MODULE);
55} 55}
56 56
57static void __exit kvm_vmm_exit(void) 57static void __exit kvm_vmm_exit(void)
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index 19c4b2195dce..61620323bb60 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -22,6 +22,7 @@
22#include <linux/acpi.h> 22#include <linux/acpi.h>
23#include <linux/efi.h> 23#include <linux/efi.h>
24#include <linux/nodemask.h> 24#include <linux/nodemask.h>
25#include <linux/slab.h>
25#include <asm/pgalloc.h> 26#include <asm/pgalloc.h>
26#include <asm/tlb.h> 27#include <asm/tlb.h>
27#include <asm/meminit.h> 28#include <asm/meminit.h>
@@ -459,7 +460,7 @@ static void __init initialize_pernode_data(void)
459 cpu = 0; 460 cpu = 0;
460 node = node_cpuid[cpu].nid; 461 node = node_cpuid[cpu].nid;
461 cpu0_cpu_info = (struct cpuinfo_ia64 *)(__phys_per_cpu_start + 462 cpu0_cpu_info = (struct cpuinfo_ia64 *)(__phys_per_cpu_start +
462 ((char *)&per_cpu__ia64_cpu_info - __per_cpu_start)); 463 ((char *)&ia64_cpu_info - __per_cpu_start));
463 cpu0_cpu_info->node_data = mem_data[node].node_data; 464 cpu0_cpu_info->node_data = mem_data[node].node_data;
464 } 465 }
465#endif /* CONFIG_SMP */ 466#endif /* CONFIG_SMP */
diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
index 19261a99e623..0799fea4c588 100644
--- a/arch/ia64/mm/fault.c
+++ b/arch/ia64/mm/fault.c
@@ -148,7 +148,6 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
148 if ((vma->vm_flags & mask) != mask) 148 if ((vma->vm_flags & mask) != mask)
149 goto bad_area; 149 goto bad_area;
150 150
151 survive:
152 /* 151 /*
153 * If for any reason at all we couldn't handle the fault, make 152 * If for any reason at all we couldn't handle the fault, make
154 * sure we exit gracefully rather than endlessly redo the 153 * sure we exit gracefully rather than endlessly redo the
@@ -276,13 +275,7 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
276 275
277 out_of_memory: 276 out_of_memory:
278 up_read(&mm->mmap_sem); 277 up_read(&mm->mmap_sem);
279 if (is_global_init(current)) { 278 if (!user_mode(regs))
280 yield(); 279 goto no_context;
281 down_read(&mm->mmap_sem); 280 pagefault_out_of_memory();
282 goto survive;
283 }
284 printk(KERN_CRIT "VM: killing process %s\n", current->comm);
285 if (user_mode(regs))
286 do_group_exit(SIGKILL);
287 goto no_context;
288} 281}
diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
index b0f615759e97..1841ee7e65f9 100644
--- a/arch/ia64/mm/hugetlbpage.c
+++ b/arch/ia64/mm/hugetlbpage.c
@@ -14,7 +14,6 @@
14#include <linux/hugetlb.h> 14#include <linux/hugetlb.h>
15#include <linux/pagemap.h> 15#include <linux/pagemap.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/slab.h>
18#include <linux/sysctl.h> 17#include <linux/sysctl.h>
19#include <linux/log2.h> 18#include <linux/log2.h>
20#include <asm/mman.h> 19#include <asm/mman.h>
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 7c0d4814a68d..ed41759efcac 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -22,7 +22,6 @@
22#include <linux/kexec.h> 22#include <linux/kexec.h>
23 23
24#include <asm/dma.h> 24#include <asm/dma.h>
25#include <asm/ia32.h>
26#include <asm/io.h> 25#include <asm/io.h>
27#include <asm/machvec.h> 26#include <asm/machvec.h>
28#include <asm/numa.h> 27#include <asm/numa.h>
@@ -118,6 +117,7 @@ ia64_init_addr_space (void)
118 */ 117 */
119 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); 118 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
120 if (vma) { 119 if (vma) {
120 INIT_LIST_HEAD(&vma->anon_vma_chain);
121 vma->vm_mm = current->mm; 121 vma->vm_mm = current->mm;
122 vma->vm_start = current->thread.rbs_bot & PAGE_MASK; 122 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
123 vma->vm_end = vma->vm_start + PAGE_SIZE; 123 vma->vm_end = vma->vm_start + PAGE_SIZE;
@@ -136,6 +136,7 @@ ia64_init_addr_space (void)
136 if (!(current->personality & MMAP_PAGE_ZERO)) { 136 if (!(current->personality & MMAP_PAGE_ZERO)) {
137 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL); 137 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
138 if (vma) { 138 if (vma) {
139 INIT_LIST_HEAD(&vma->anon_vma_chain);
139 vma->vm_mm = current->mm; 140 vma->vm_mm = current->mm;
140 vma->vm_end = PAGE_SIZE; 141 vma->vm_end = PAGE_SIZE;
141 vma->vm_page_prot = __pgprot(pgprot_val(PAGE_READONLY) | _PAGE_MA_NAT); 142 vma->vm_page_prot = __pgprot(pgprot_val(PAGE_READONLY) | _PAGE_MA_NAT);
@@ -668,10 +669,6 @@ mem_init (void)
668 fsyscall_table[i] = sys_call_table[i] | 1; 669 fsyscall_table[i] = sys_call_table[i] | 1;
669 } 670 }
670 setup_gate(); 671 setup_gate();
671
672#ifdef CONFIG_IA32_SUPPORT
673 ia32_mem_init();
674#endif
675} 672}
676 673
677#ifdef CONFIG_MEMORY_HOTPLUG 674#ifdef CONFIG_MEMORY_HOTPLUG
diff --git a/arch/ia64/mm/tlb.c b/arch/ia64/mm/tlb.c
index f3de9d7a98b4..7b3cdc6c6d91 100644
--- a/arch/ia64/mm/tlb.c
+++ b/arch/ia64/mm/tlb.c
@@ -22,6 +22,7 @@
22#include <linux/smp.h> 22#include <linux/smp.h>
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/bootmem.h> 24#include <linux/bootmem.h>
25#include <linux/slab.h>
25 26
26#include <asm/delay.h> 27#include <asm/delay.h>
27#include <asm/mmu_context.h> 28#include <asm/mmu_context.h>
@@ -120,7 +121,7 @@ static inline void down_spin(struct spinaphore *ss)
120 ia64_invala(); 121 ia64_invala();
121 122
122 for (;;) { 123 for (;;) {
123 asm volatile ("ld4.c.nc %0=[%1]" : "=r"(serve) : "r"(&ss->serve) : "memory"); 124 asm volatile ("ld8.c.nc %0=[%1]" : "=r"(serve) : "r"(&ss->serve) : "memory");
124 if (time_before(t, serve)) 125 if (time_before(t, serve))
125 return; 126 return;
126 cpu_relax(); 127 cpu_relax();
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index df639db779f9..aa2533ae7e9e 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -320,9 +320,9 @@ static __devinit acpi_status add_window(struct acpi_resource *res, void *data)
320static void __devinit 320static void __devinit
321pcibios_setup_root_windows(struct pci_bus *bus, struct pci_controller *ctrl) 321pcibios_setup_root_windows(struct pci_bus *bus, struct pci_controller *ctrl)
322{ 322{
323 int i, j; 323 int i;
324 324
325 j = 0; 325 pci_bus_remove_resources(bus);
326 for (i = 0; i < ctrl->windows; i++) { 326 for (i = 0; i < ctrl->windows; i++) {
327 struct resource *res = &ctrl->window[i].resource; 327 struct resource *res = &ctrl->window[i].resource;
328 /* HP's firmware has a hack to work around a Windows bug. 328 /* HP's firmware has a hack to work around a Windows bug.
@@ -330,19 +330,16 @@ pcibios_setup_root_windows(struct pci_bus *bus, struct pci_controller *ctrl)
330 if ((res->flags & IORESOURCE_MEM) && 330 if ((res->flags & IORESOURCE_MEM) &&
331 (res->end - res->start < 16)) 331 (res->end - res->start < 16))
332 continue; 332 continue;
333 if (j >= PCI_BUS_NUM_RESOURCES) { 333 pci_bus_add_resource(bus, res, 0);
334 dev_warn(&bus->dev,
335 "ignoring host bridge window %pR (no space)\n",
336 res);
337 continue;
338 }
339 bus->resource[j++] = res;
340 } 334 }
341} 335}
342 336
343struct pci_bus * __devinit 337struct pci_bus * __devinit
344pci_acpi_scan_root(struct acpi_device *device, int domain, int bus) 338pci_acpi_scan_root(struct acpi_pci_root *root)
345{ 339{
340 struct acpi_device *device = root->device;
341 int domain = root->segment;
342 int bus = root->secondary.start;
346 struct pci_controller *controller; 343 struct pci_controller *controller;
347 unsigned int windows = 0; 344 unsigned int windows = 0;
348 struct pci_bus *pbus; 345 struct pci_bus *pbus;
@@ -452,13 +449,12 @@ EXPORT_SYMBOL(pcibios_bus_to_resource);
452static int __devinit is_valid_resource(struct pci_dev *dev, int idx) 449static int __devinit is_valid_resource(struct pci_dev *dev, int idx)
453{ 450{
454 unsigned int i, type_mask = IORESOURCE_IO | IORESOURCE_MEM; 451 unsigned int i, type_mask = IORESOURCE_IO | IORESOURCE_MEM;
455 struct resource *devr = &dev->resource[idx]; 452 struct resource *devr = &dev->resource[idx], *busr;
456 453
457 if (!dev->bus) 454 if (!dev->bus)
458 return 0; 455 return 0;
459 for (i=0; i<PCI_BUS_NUM_RESOURCES; i++) {
460 struct resource *busr = dev->bus->resource[i];
461 456
457 pci_bus_for_each_resource(dev->bus, busr, i) {
462 if (!busr || ((busr->flags ^ devr->flags) & type_mask)) 458 if (!busr || ((busr->flags ^ devr->flags) & type_mask))
463 continue; 459 continue;
464 if ((devr->start) && (devr->start >= busr->start) && 460 if ((devr->start) && (devr->start >= busr->start) &&
@@ -547,10 +543,11 @@ pcibios_disable_device (struct pci_dev *dev)
547 acpi_pci_irq_disable(dev); 543 acpi_pci_irq_disable(dev);
548} 544}
549 545
550void 546resource_size_t
551pcibios_align_resource (void *data, struct resource *res, 547pcibios_align_resource (void *data, const struct resource *res,
552 resource_size_t size, resource_size_t align) 548 resource_size_t size, resource_size_t align)
553{ 549{
550 return res->start;
554} 551}
555 552
556/* 553/*
diff --git a/arch/ia64/sn/kernel/bte.c b/arch/ia64/sn/kernel/bte.c
index c6d6b62db66c..cad775a1a157 100644
--- a/arch/ia64/sn/kernel/bte.c
+++ b/arch/ia64/sn/kernel/bte.c
@@ -19,6 +19,7 @@
19#include <linux/bootmem.h> 19#include <linux/bootmem.h>
20#include <linux/string.h> 20#include <linux/string.h>
21#include <linux/sched.h> 21#include <linux/sched.h>
22#include <linux/slab.h>
22 23
23#include <asm/sn/bte.h> 24#include <asm/sn/bte.h>
24 25
diff --git a/arch/ia64/sn/kernel/io_acpi_init.c b/arch/ia64/sn/kernel/io_acpi_init.c
index 66f633bff059..8cdcb173a138 100644
--- a/arch/ia64/sn/kernel/io_acpi_init.c
+++ b/arch/ia64/sn/kernel/io_acpi_init.c
@@ -13,6 +13,7 @@
13#include <asm/sn/sn_sal.h> 13#include <asm/sn/sn_sal.h>
14#include "xtalk/hubdev.h" 14#include "xtalk/hubdev.h"
15#include <linux/acpi.h> 15#include <linux/acpi.h>
16#include <linux/slab.h>
16 17
17 18
18/* 19/*
diff --git a/arch/ia64/sn/kernel/io_common.c b/arch/ia64/sn/kernel/io_common.c
index 308e6595110e..4433dd019d3c 100644
--- a/arch/ia64/sn/kernel/io_common.c
+++ b/arch/ia64/sn/kernel/io_common.c
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include <linux/bootmem.h> 9#include <linux/bootmem.h>
10#include <linux/slab.h>
10#include <asm/sn/types.h> 11#include <asm/sn/types.h>
11#include <asm/sn/addrs.h> 12#include <asm/sn/addrs.h>
12#include <asm/sn/sn_feature_sets.h> 13#include <asm/sn/sn_feature_sets.h>
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index ee774c366a06..98079f29d9a9 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -6,6 +6,7 @@
6 * Copyright (C) 1992 - 1997, 2000-2006 Silicon Graphics, Inc. All rights reserved. 6 * Copyright (C) 1992 - 1997, 2000-2006 Silicon Graphics, Inc. All rights reserved.
7 */ 7 */
8 8
9#include <linux/slab.h>
9#include <asm/sn/types.h> 10#include <asm/sn/types.h>
10#include <asm/sn/addrs.h> 11#include <asm/sn/addrs.h>
11#include <asm/sn/io.h> 12#include <asm/sn/io.h>
diff --git a/arch/ia64/sn/kernel/irq.c b/arch/ia64/sn/kernel/irq.c
index 40d6eeda1c4b..13c15d968098 100644
--- a/arch/ia64/sn/kernel/irq.c
+++ b/arch/ia64/sn/kernel/irq.c
@@ -12,6 +12,7 @@
12#include <linux/spinlock.h> 12#include <linux/spinlock.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/rculist.h> 14#include <linux/rculist.h>
15#include <linux/slab.h>
15#include <asm/sn/addrs.h> 16#include <asm/sn/addrs.h>
16#include <asm/sn/arch.h> 17#include <asm/sn/arch.h>
17#include <asm/sn/intr.h> 18#include <asm/sn/intr.h>
diff --git a/arch/ia64/sn/kernel/msi_sn.c b/arch/ia64/sn/kernel/msi_sn.c
index fbbfb9701201..ebfdd6a9ae1a 100644
--- a/arch/ia64/sn/kernel/msi_sn.c
+++ b/arch/ia64/sn/kernel/msi_sn.c
@@ -11,6 +11,7 @@
11#include <linux/pci.h> 11#include <linux/pci.h>
12#include <linux/cpumask.h> 12#include <linux/cpumask.h>
13#include <linux/msi.h> 13#include <linux/msi.h>
14#include <linux/slab.h>
14 15
15#include <asm/sn/addrs.h> 16#include <asm/sn/addrs.h>
16#include <asm/sn/intr.h> 17#include <asm/sn/intr.h>
diff --git a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c
index ece1bf994499..d00dfc180021 100644
--- a/arch/ia64/sn/kernel/setup.c
+++ b/arch/ia64/sn/kernel/setup.c
@@ -71,7 +71,7 @@ EXPORT_SYMBOL(sn_rtc_cycles_per_second);
71DEFINE_PER_CPU(struct sn_hub_info_s, __sn_hub_info); 71DEFINE_PER_CPU(struct sn_hub_info_s, __sn_hub_info);
72EXPORT_PER_CPU_SYMBOL(__sn_hub_info); 72EXPORT_PER_CPU_SYMBOL(__sn_hub_info);
73 73
74DEFINE_PER_CPU(short [MAX_COMPACT_NODES], __sn_cnodeid_to_nasid); 74DEFINE_PER_CPU(short, __sn_cnodeid_to_nasid[MAX_COMPACT_NODES]);
75EXPORT_PER_CPU_SYMBOL(__sn_cnodeid_to_nasid); 75EXPORT_PER_CPU_SYMBOL(__sn_cnodeid_to_nasid);
76 76
77DEFINE_PER_CPU(struct nodepda_s *, __sn_nodepda); 77DEFINE_PER_CPU(struct nodepda_s *, __sn_nodepda);
@@ -241,7 +241,7 @@ static void __cpuinit sn_check_for_wars(void)
241 * Note: This stuff is duped here because Altix requires the PCDP to 241 * Note: This stuff is duped here because Altix requires the PCDP to
242 * locate a usable VGA device due to lack of proper ACPI support. Structures 242 * locate a usable VGA device due to lack of proper ACPI support. Structures
243 * could be used from drivers/firmware/pcdp.h, but it was decided that moving 243 * could be used from drivers/firmware/pcdp.h, but it was decided that moving
244 * this file to a more public location just for Altix use was undesireable. 244 * this file to a more public location just for Altix use was undesirable.
245 */ 245 */
246 246
247struct hcdp_uart_desc { 247struct hcdp_uart_desc {
diff --git a/arch/ia64/sn/kernel/sn2/sn_hwperf.c b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
index 55ac3c4e11d2..fa1eceed0d23 100644
--- a/arch/ia64/sn/kernel/sn2/sn_hwperf.c
+++ b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
@@ -30,7 +30,6 @@
30#include <linux/miscdevice.h> 30#include <linux/miscdevice.h>
31#include <linux/utsname.h> 31#include <linux/utsname.h>
32#include <linux/cpumask.h> 32#include <linux/cpumask.h>
33#include <linux/smp_lock.h>
34#include <linux/nodemask.h> 33#include <linux/nodemask.h>
35#include <linux/smp.h> 34#include <linux/smp.h>
36#include <linux/mutex.h> 35#include <linux/mutex.h>
@@ -629,9 +628,9 @@ static int sn_hwperf_op_cpu(struct sn_hwperf_op_info *op_info)
629 else { 628 else {
630 /* migrate the task before calling SAL */ 629 /* migrate the task before calling SAL */
631 save_allowed = current->cpus_allowed; 630 save_allowed = current->cpus_allowed;
632 set_cpus_allowed(current, cpumask_of_cpu(cpu)); 631 set_cpus_allowed_ptr(current, cpumask_of(cpu));
633 sn_hwperf_call_sal(op_info); 632 sn_hwperf_call_sal(op_info);
634 set_cpus_allowed(current, save_allowed); 633 set_cpus_allowed_ptr(current, &save_allowed);
635 } 634 }
636 } 635 }
637 r = op_info->ret; 636 r = op_info->ret;
@@ -682,8 +681,7 @@ static int sn_hwperf_map_err(int hwperf_err)
682/* 681/*
683 * ioctl for "sn_hwperf" misc device 682 * ioctl for "sn_hwperf" misc device
684 */ 683 */
685static int 684static long sn_hwperf_ioctl(struct file *fp, u32 op, unsigned long arg)
686sn_hwperf_ioctl(struct inode *in, struct file *fp, u32 op, unsigned long arg)
687{ 685{
688 struct sn_hwperf_ioctl_args a; 686 struct sn_hwperf_ioctl_args a;
689 struct cpuinfo_ia64 *cdata; 687 struct cpuinfo_ia64 *cdata;
@@ -699,8 +697,6 @@ sn_hwperf_ioctl(struct inode *in, struct file *fp, u32 op, unsigned long arg)
699 int i; 697 int i;
700 int j; 698 int j;
701 699
702 unlock_kernel();
703
704 /* only user requests are allowed here */ 700 /* only user requests are allowed here */
705 if ((op & SN_HWPERF_OP_MASK) < 10) { 701 if ((op & SN_HWPERF_OP_MASK) < 10) {
706 r = -EINVAL; 702 r = -EINVAL;
@@ -859,12 +855,11 @@ sn_hwperf_ioctl(struct inode *in, struct file *fp, u32 op, unsigned long arg)
859error: 855error:
860 vfree(p); 856 vfree(p);
861 857
862 lock_kernel();
863 return r; 858 return r;
864} 859}
865 860
866static const struct file_operations sn_hwperf_fops = { 861static const struct file_operations sn_hwperf_fops = {
867 .ioctl = sn_hwperf_ioctl, 862 .unlocked_ioctl = sn_hwperf_ioctl,
868}; 863};
869 864
870static struct miscdevice sn_hwperf_dev = { 865static struct miscdevice sn_hwperf_dev = {
diff --git a/arch/ia64/sn/pci/pci_dma.c b/arch/ia64/sn/pci/pci_dma.c
index 98b684928e12..a9d310de57da 100644
--- a/arch/ia64/sn/pci/pci_dma.c
+++ b/arch/ia64/sn/pci/pci_dma.c
@@ -9,6 +9,7 @@
9 * a description of how these routines should be used. 9 * a description of how these routines should be used.
10 */ 10 */
11 11
12#include <linux/gfp.h>
12#include <linux/module.h> 13#include <linux/module.h>
13#include <linux/dma-mapping.h> 14#include <linux/dma-mapping.h>
14#include <asm/dma.h> 15#include <asm/dma.h>
diff --git a/arch/ia64/sn/pci/pcibr/pcibr_provider.c b/arch/ia64/sn/pci/pcibr/pcibr_provider.c
index d13e5a22a558..3cb5cf377644 100644
--- a/arch/ia64/sn/pci/pcibr/pcibr_provider.c
+++ b/arch/ia64/sn/pci/pcibr/pcibr_provider.c
@@ -8,6 +8,7 @@
8 8
9#include <linux/interrupt.h> 9#include <linux/interrupt.h>
10#include <linux/types.h> 10#include <linux/types.h>
11#include <linux/slab.h>
11#include <linux/pci.h> 12#include <linux/pci.h>
12#include <asm/sn/addrs.h> 13#include <asm/sn/addrs.h>
13#include <asm/sn/geo.h> 14#include <asm/sn/geo.h>
diff --git a/arch/ia64/sn/pci/tioca_provider.c b/arch/ia64/sn/pci/tioca_provider.c
index efb454534e52..4d4536e3b6f3 100644
--- a/arch/ia64/sn/pci/tioca_provider.c
+++ b/arch/ia64/sn/pci/tioca_provider.c
@@ -10,6 +10,7 @@
10#include <linux/interrupt.h> 10#include <linux/interrupt.h>
11#include <linux/pci.h> 11#include <linux/pci.h>
12#include <linux/bitmap.h> 12#include <linux/bitmap.h>
13#include <linux/slab.h>
13#include <asm/sn/sn_sal.h> 14#include <asm/sn/sn_sal.h>
14#include <asm/sn/addrs.h> 15#include <asm/sn/addrs.h>
15#include <asm/sn/io.h> 16#include <asm/sn/io.h>
diff --git a/arch/ia64/sn/pci/tioce_provider.c b/arch/ia64/sn/pci/tioce_provider.c
index 012f3b82ee55..27faba035f3a 100644
--- a/arch/ia64/sn/pci/tioce_provider.c
+++ b/arch/ia64/sn/pci/tioce_provider.c
@@ -8,6 +8,7 @@
8 8
9#include <linux/types.h> 9#include <linux/types.h>
10#include <linux/interrupt.h> 10#include <linux/interrupt.h>
11#include <linux/slab.h>
11#include <linux/pci.h> 12#include <linux/pci.h>
12#include <asm/sn/sn_sal.h> 13#include <asm/sn/sn_sal.h>
13#include <asm/sn/addrs.h> 14#include <asm/sn/addrs.h>
diff --git a/arch/ia64/uv/kernel/setup.c b/arch/ia64/uv/kernel/setup.c
index 7a5ae633198b..f1490657bafc 100644
--- a/arch/ia64/uv/kernel/setup.c
+++ b/arch/ia64/uv/kernel/setup.c
@@ -104,7 +104,7 @@ void __init uv_setup(char **cmdline_p)
104 uv_cpu_hub_info(cpu)->lowmem_remap_top = 104 uv_cpu_hub_info(cpu)->lowmem_remap_top =
105 lowmem_redir_base + lowmem_redir_size; 105 lowmem_redir_base + lowmem_redir_size;
106 uv_cpu_hub_info(cpu)->m_val = m_val; 106 uv_cpu_hub_info(cpu)->m_val = m_val;
107 uv_cpu_hub_info(cpu)->n_val = m_val; 107 uv_cpu_hub_info(cpu)->n_val = n_val;
108 uv_cpu_hub_info(cpu)->pnode_mask = (1 << n_val) -1; 108 uv_cpu_hub_info(cpu)->pnode_mask = (1 << n_val) -1;
109 uv_cpu_hub_info(cpu)->gpa_mask = (1 << (m_val + n_val)) - 1; 109 uv_cpu_hub_info(cpu)->gpa_mask = (1 << (m_val + n_val)) - 1;
110 uv_cpu_hub_info(cpu)->gnode_upper = gnode_upper; 110 uv_cpu_hub_info(cpu)->gnode_upper = gnode_upper;
diff --git a/arch/ia64/xen/grant-table.c b/arch/ia64/xen/grant-table.c
index 777dd9a9108b..48cca37625eb 100644
--- a/arch/ia64/xen/grant-table.c
+++ b/arch/ia64/xen/grant-table.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/vmalloc.h> 24#include <linux/vmalloc.h>
25#include <linux/slab.h>
25#include <linux/mm.h> 26#include <linux/mm.h>
26 27
27#include <xen/interface/xen.h> 28#include <xen/interface/xen.h>
diff --git a/arch/ia64/xen/hypercall.S b/arch/ia64/xen/hypercall.S
index e32dae444dd6..08847aa12583 100644
--- a/arch/ia64/xen/hypercall.S
+++ b/arch/ia64/xen/hypercall.S
@@ -58,11 +58,6 @@ __HCALL2(xen_ptcga, HYPERPRIVOP_PTC_GA)
58__HCALL2(xen_set_rr, HYPERPRIVOP_SET_RR) 58__HCALL2(xen_set_rr, HYPERPRIVOP_SET_RR)
59__HCALL2(xen_set_kr, HYPERPRIVOP_SET_KR) 59__HCALL2(xen_set_kr, HYPERPRIVOP_SET_KR)
60 60
61#ifdef CONFIG_IA32_SUPPORT
62__HCALL0(xen_get_eflag, HYPERPRIVOP_GET_EFLAG)
63__HCALL1(xen_set_eflag, HYPERPRIVOP_SET_EFLAG) // refer SDM vol1 3.1.8
64#endif /* CONFIG_IA32_SUPPORT */
65
66GLOBAL_ENTRY(xen_set_rr0_to_rr4) 61GLOBAL_ENTRY(xen_set_rr0_to_rr4)
67 mov r8=r32 62 mov r8=r32
68 mov r9=r33 63 mov r9=r33
diff --git a/arch/ia64/xen/xen_pv_ops.c b/arch/ia64/xen/xen_pv_ops.c
index 5e2270a999fa..8adc6a14272a 100644
--- a/arch/ia64/xen/xen_pv_ops.c
+++ b/arch/ia64/xen/xen_pv_ops.c
@@ -301,11 +301,6 @@ static void xen_setreg(int regnum, unsigned long val)
301 case _IA64_REG_AR_KR0 ... _IA64_REG_AR_KR7: 301 case _IA64_REG_AR_KR0 ... _IA64_REG_AR_KR7:
302 xen_set_kr(regnum - _IA64_REG_AR_KR0, val); 302 xen_set_kr(regnum - _IA64_REG_AR_KR0, val);
303 break; 303 break;
304#ifdef CONFIG_IA32_SUPPORT
305 case _IA64_REG_AR_EFLAG:
306 xen_set_eflag(val);
307 break;
308#endif
309 case _IA64_REG_AR_ITC: 304 case _IA64_REG_AR_ITC:
310 xen_set_itc(val); 305 xen_set_itc(val);
311 break; 306 break;
@@ -332,11 +327,6 @@ static unsigned long xen_getreg(int regnum)
332 case _IA64_REG_PSR: 327 case _IA64_REG_PSR:
333 res = xen_get_psr(); 328 res = xen_get_psr();
334 break; 329 break;
335#ifdef CONFIG_IA32_SUPPORT
336 case _IA64_REG_AR_EFLAG:
337 res = xen_get_eflag();
338 break;
339#endif
340 case _IA64_REG_AR_ITC: 330 case _IA64_REG_AR_ITC:
341 res = xen_get_itc(); 331 res = xen_get_itc();
342 break; 332 break;
@@ -710,9 +700,6 @@ extern unsigned long xen_getreg(int regnum);
710 700
711__DEFINE_FUNC(getreg, 701__DEFINE_FUNC(getreg,
712 __DEFINE_GET_REG(PSR, PSR) 702 __DEFINE_GET_REG(PSR, PSR)
713#ifdef CONFIG_IA32_SUPPORT
714 __DEFINE_GET_REG(AR_EFLAG, EFLAG)
715#endif
716 703
717 /* get_itc */ 704 /* get_itc */
718 "mov r2 = " __stringify(_IA64_REG_AR_ITC) "\n" 705 "mov r2 = " __stringify(_IA64_REG_AR_ITC) "\n"
@@ -789,9 +776,6 @@ __DEFINE_FUNC(setreg,
789 ";;\n" 776 ";;\n"
790 "(p6) br.cond.spnt xen_set_itc\n" 777 "(p6) br.cond.spnt xen_set_itc\n"
791 778
792#ifdef CONFIG_IA32_SUPPORT
793 __DEFINE_SET_REG(AR_EFLAG, SET_EFLAG)
794#endif
795 __DEFINE_SET_REG(CR_TPR, SET_TPR) 779 __DEFINE_SET_REG(CR_TPR, SET_TPR)
796 __DEFINE_SET_REG(CR_EOI, EOI) 780 __DEFINE_SET_REG(CR_EOI, EOI)
797 781