fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / arch / ia64 / ia32 / ia32_support.c
index c56fd9f..6af400a 100644 (file)
@@ -33,6 +33,7 @@ struct exec_domain ia32_exec_domain;
 struct page *ia32_shared_page[NR_CPUS];
 unsigned long *ia32_boot_gdt;
 unsigned long *cpu_gdt_table[NR_CPUS];
+struct page *ia32_gate_page;
 
 static unsigned long
 load_desc (u16 selector)
@@ -57,7 +58,7 @@ load_desc (u16 selector)
 void
 ia32_load_segment_descriptors (struct task_struct *task)
 {
-       struct pt_regs *regs = ia64_task_regs(task);
+       struct pt_regs *regs = task_pt_regs(task);
 
        /* Setup the segment descriptors */
        regs->r24 = load_desc(regs->r16 >> 16);         /* ESD */
@@ -75,7 +76,7 @@ ia32_clone_tls (struct task_struct *child, struct pt_regs *childregs)
        struct ia32_user_desc info;
        int idx;
 
-       if (copy_from_user(&info, (void *)(childregs->r14 & 0xffffffff), sizeof(info)))
+       if (copy_from_user(&info, (void __user *)(childregs->r14 & 0xffffffff), sizeof(info)))
                return -EFAULT;
        if (LDT_empty(&info))
                return -EINVAL;
@@ -112,7 +113,7 @@ void
 ia32_load_state (struct task_struct *t)
 {
        unsigned long eflag, fsr, fcr, fir, fdr, tssd;
-       struct pt_regs *regs = ia64_task_regs(t);
+       struct pt_regs *regs = task_pt_regs(t);
 
        eflag = t->thread.eflag;
        fsr = t->thread.fsr;
@@ -145,6 +146,9 @@ ia32_gdt_init (void)
        int cpu = smp_processor_id();
 
        ia32_shared_page[cpu] = alloc_page(GFP_KERNEL);
+       if (!ia32_shared_page[cpu])
+               panic("failed to allocate ia32_shared_page[%d]\n", cpu);
+
        cpu_gdt_table[cpu] = page_address(ia32_shared_page[cpu]);
 
        /* Copy from the boot cpu's GDT */
@@ -155,23 +159,26 @@ ia32_gdt_init (void)
 /*
  * Setup IA32 GDT and TSS
  */
-void
+static void
 ia32_boot_gdt_init (void)
 {
        unsigned long ldt_size;
 
        ia32_shared_page[0] = alloc_page(GFP_KERNEL);
+       if (!ia32_shared_page[0])
+               panic("failed to allocate ia32_shared_page[0]\n");
+
        ia32_boot_gdt = page_address(ia32_shared_page[0]);
        cpu_gdt_table[0] = ia32_boot_gdt;
 
        /* CS descriptor in IA-32 (scrambled) format */
        ia32_boot_gdt[__USER_CS >> 3]
-               = IA32_SEG_DESCRIPTOR(0, (IA32_PAGE_OFFSET-1) >> IA32_PAGE_SHIFT,
+               = IA32_SEG_DESCRIPTOR(0, (IA32_GATE_END-1) >> IA32_PAGE_SHIFT,
                                      0xb, 1, 3, 1, 1, 1, 1);
 
        /* DS descriptor in IA-32 (scrambled) format */
        ia32_boot_gdt[__USER_DS >> 3]
-               = IA32_SEG_DESCRIPTOR(0, (IA32_PAGE_OFFSET-1) >> IA32_PAGE_SHIFT,
+               = IA32_SEG_DESCRIPTOR(0, (IA32_GATE_END-1) >> IA32_PAGE_SHIFT,
                                      0x3, 1, 3, 1, 1, 1, 1);
 
        ldt_size = PAGE_ALIGN(IA32_LDT_ENTRIES*IA32_LDT_ENTRY_SIZE);
@@ -181,6 +188,27 @@ ia32_boot_gdt_init (void)
                                                       0x2, 0, 3, 1, 1, 1, 0);
 }
 
+static void
+ia32_gate_page_init(void)
+{
+       unsigned long *sr;
+
+       ia32_gate_page = alloc_page(GFP_KERNEL);
+       sr = page_address(ia32_gate_page);
+       /* This is popl %eax ; movl $,%eax ; int $0x80 */
+       *sr++ = 0xb858 | (__IA32_NR_sigreturn << 16) | (0x80cdUL << 48);
+
+       /* This is movl $,%eax ; int $0x80 */
+       *sr = 0xb8 | (__IA32_NR_rt_sigreturn << 8) | (0x80cdUL << 40);
+}
+
+void
+ia32_mem_init(void)
+{
+       ia32_boot_gdt_init();
+       ia32_gate_page_init();
+}
+
 /*
  * Handle bad IA32 interrupt via syscall
  */
@@ -195,7 +223,7 @@ ia32_bad_interrupt (unsigned long int_num, struct pt_regs *regs)
        siginfo.si_errno = int_num;     /* XXX is it OK to abuse si_errno like this? */
        siginfo.si_flags = 0;
        siginfo.si_isr = 0;
-       siginfo.si_addr = 0;
+       siginfo.si_addr = NULL;
        siginfo.si_imm = 0;
        siginfo.si_code = TRAP_BRKPT;
        force_sig_info(SIGTRAP, &siginfo, current);
@@ -218,6 +246,18 @@ ia32_init (void)
        ia32_exec_domain.signal_map = default_exec_domain.signal_map;
        ia32_exec_domain.signal_invmap = default_exec_domain.signal_invmap;
        register_exec_domain(&ia32_exec_domain);
+
+#if PAGE_SHIFT > IA32_PAGE_SHIFT
+       {
+               extern struct kmem_cache *partial_page_cachep;
+
+               partial_page_cachep = kmem_cache_create("partial_page_cache",
+                                                       sizeof(struct partial_page), 0, 0,
+                                                       NULL, NULL);
+               if (!partial_page_cachep)
+                       panic("Cannot create partial page SLAB cache");
+       }
+#endif
        return 0;
 }