From: BitKeeper B. <ri...@su...> - 2005-02-02 19:02:26
|
ChangeSet 1.1756, 2005/02/02 18:27:05+00:00, ka...@sc... More x86/64. Now boot secondary CPUs, but I seem to have problems executing IRET, so interrupts are fatal. Signed-off-by: kei...@cl... b/xen/arch/x86/Rules.mk | 2 b/xen/arch/x86/boot/x86_64.S | 23 +++- b/xen/arch/x86/irq.c | 10 -- b/xen/arch/x86/smpboot.c | 17 ++- b/xen/arch/x86/traps.c | 31 ++---- b/xen/arch/x86/x86_32/traps.c | 24 ++-- b/xen/arch/x86/x86_64/entry.S | 154 +++++++++++++++++++++++++++++++ b/xen/arch/x86/x86_64/traps.c | 30 +++--- b/xen/include/asm-x86/config.h | 10 +- b/xen/include/asm-x86/desc.h | 14 ++ b/xen/include/asm-x86/irq.h | 78 ++------------- b/xen/include/asm-x86/smp.h | 5 - b/xen/include/asm-x86/x86_32/asm_defns.h | 47 +++++++++ b/xen/include/asm-x86/x86_64/asm_defns.h | 89 +++++++++++++++++ b/xen/include/asm-x86/x86_64/current.h | 21 +--- xen/include/asm-x86/pda.h | 63 ------------ 16 files changed, 397 insertions(+), 221 deletions(-) diff -Nru a/xen/arch/x86/Rules.mk b/xen/arch/x86/Rules.mk --- a/xen/arch/x86/Rules.mk 2005-02-02 14:02:11 -05:00 +++ b/xen/arch/x86/Rules.mk 2005-02-02 14:02:11 -05:00 @@ -5,7 +5,7 @@ LD := ld CFLAGS := -nostdinc -fno-builtin -fno-common -fno-strict-aliasing -CFLAGS += -iwithprefix include -Wall -Werror -pipe +CFLAGS += -iwithprefix include -Wall -Werror -Wno-format -pipe CFLAGS += -I$(BASEDIR)/include -Wno-pointer-arith -Wredundant-decls ifeq ($(optimize),y) diff -Nru a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S --- a/xen/arch/x86/boot/x86_64.S 2005-02-02 14:02:11 -05:00 +++ b/xen/arch/x86/boot/x86_64.S 2005-02-02 14:02:11 -05:00 @@ -52,16 +52,16 @@ /* Set up a few descriptors: on entry only CS is guaranteed good. */ lgdt %cs:0x1001f0 - mov $(__HYPERVISOR_DS),%ecx + mov $(__HYPERVISOR_DS32),%ecx mov %ecx,%ds mov %ecx,%es - /* Check for Multiboot bootloader */ cmp $(SECONDARY_CPU_FLAG),%ebx - je skip_multiboot_check + je skip_boot_checks + + /* Check for Multiboot bootloader */ cmp $0x2BADB002,%eax jne not_multiboot -skip_multiboot_check: /* Save the Multiboot info structure for later use. */ mov %ebx,0x1001e0 @@ -75,7 +75,8 @@ cpuid bt $29,%edx # Long mode feature? jnc bad_cpu - +skip_boot_checks: + /* Set up FPU. */ fninit @@ -123,6 +124,13 @@ ret __high_start: + mov $(__HYPERVISOR_DS64),%ecx + mov %ecx,%ds + mov %ecx,%es + mov %ecx,%fs + mov %ecx,%gs + mov %ecx,%ss + lidt idt_descr(%rip) cmp $(SECONDARY_CPU_FLAG),%ebx @@ -203,7 +211,7 @@ .quad SYMBOL_NAME(idt_table) ENTRY(stack_start) - .quad SYMBOL_NAME(cpu0_stack) + 8100 + .quad SYMBOL_NAME(cpu0_stack) + 8000 high_start: .quad __high_start @@ -241,9 +249,8 @@ ENTRY(stext) ENTRY(_stext) -.globl switch_to, ret_from_intr, do_iopl +.globl switch_to, do_iopl switch_to: -ret_from_intr: do_iopl: .globl copy_from_user, copy_to_user, copy_user_generic, new_thread copy_from_user: diff -Nru a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c --- a/xen/arch/x86/irq.c 2005-02-02 14:02:11 -05:00 +++ b/xen/arch/x86/irq.c 2005-02-02 14:02:11 -05:00 @@ -87,13 +87,9 @@ spin_unlock_irqrestore(&desc->lock, flags); } -asmlinkage void do_IRQ(struct xen_regs regs) +asmlinkage void do_IRQ(struct xen_regs *regs) { -#if defined(__i386__) - unsigned int irq = regs.entry_vector; -#else - unsigned int irq = 0; /* XXX */ -#endif + unsigned int irq = regs->entry_vector; irq_desc_t *desc = &irq_desc[irq]; struct irqaction *action; @@ -127,7 +123,7 @@ desc->status &= ~IRQ_PENDING; irq_enter(smp_processor_id(), irq); spin_unlock_irq(&desc->lock); - action->handler(irq, action->dev_id, ®s); + action->handler(irq, action->dev_id, regs); spin_lock_irq(&desc->lock); irq_exit(smp_processor_id(), irq); } diff -Nru a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c --- a/xen/arch/x86/smpboot.c 2005-02-02 14:02:11 -05:00 +++ b/xen/arch/x86/smpboot.c 2005-02-02 14:02:11 -05:00 @@ -409,7 +409,7 @@ * At this point, boot CPU has fully initialised the IDT. It is * now safe to make ourselves a private copy. */ - idt_tables[cpu] = xmalloc_array(struct desc_struct, IDT_ENTRIES); + idt_tables[cpu] = xmalloc_array(idt_entry_t, IDT_ENTRIES); memcpy(idt_tables[cpu], idt_table, IDT_ENTRIES*8); *(unsigned short *)(&idt_load[0]) = (IDT_ENTRIES*8)-1; *(unsigned long *)(&idt_load[2]) = (unsigned long)idt_tables[cpu]; @@ -650,7 +650,8 @@ struct exec_domain *ed; unsigned long boot_error = 0; int timeout, cpu; - unsigned long start_eip, stack; + unsigned long start_eip; + void *stack; cpu = ++cpucount; @@ -673,11 +674,15 @@ /* So we see what's up. */ printk("Booting processor %d/%d eip %lx\n", cpu, apicid, start_eip); - stack = __pa(alloc_xenheap_pages(1)); - stack_start.esp = stack + STACK_SIZE - STACK_RESERVED; + stack = (void *)alloc_xenheap_pages(1); +#if defined(__i386__) + stack_start.esp = __pa(stack) + STACK_SIZE - STACK_RESERVED; +#elif defined(__x86_64__) + stack_start.esp = (unsigned long)stack + STACK_SIZE - STACK_RESERVED; +#endif /* Debug build: detect stack overflow by setting up a guard page. */ - memguard_guard_range(__va(stack), PAGE_SIZE); + memguard_guard_range(stack, PAGE_SIZE); /* * This grunge runs the startup process for @@ -739,7 +744,7 @@ printk("CPU%d has booted.\n", cpu); } else { boot_error= 1; - if (*((volatile unsigned long *)phys_to_virt(start_eip)) + if (*((volatile unsigned int *)phys_to_virt(start_eip)) == 0xA5A5A5A5) /* trampoline started but...? */ printk("Stuck ??\n"); diff -Nru a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c --- a/xen/arch/x86/traps.c 2005-02-02 14:02:13 -05:00 +++ b/xen/arch/x86/traps.c 2005-02-02 14:02:14 -05:00 @@ -116,7 +116,7 @@ if ( trapnr == TRAP_page_fault ) { __asm__ __volatile__ ("mov %%cr2,%0" : "=r" (cr2) : ); - printk("Faulting linear address might be %08lx\n", cr2); + printk("Faulting linear address might be %0lx %lx\n", cr2, cr2); } printk("************************************\n"); @@ -165,7 +165,7 @@ if ( likely((fixup = search_exception_table(regs->eip)) != 0) ) { - DPRINTK("Trap %d: %08lx -> %08lx\n", trapnr, regs->eip, fixup); + DPRINTK("Trap %d: %p -> %p\n", trapnr, regs->eip, fixup); regs->eip = fixup; return 0; } @@ -322,7 +322,7 @@ { perfc_incrc(copy_user_faults); if ( !ed->mm.shadow_mode ) - DPRINTK("Page fault: %08lx -> %08lx\n", regs->eip, fixup); + DPRINTK("Page fault: %p -> %p\n", regs->eip, fixup); regs->eip = fixup; return 0; } @@ -334,12 +334,12 @@ { unsigned long page; page = l2_pgentry_val(idle_pg_table[addr >> L2_PAGETABLE_SHIFT]); - printk("*pde = %08lx\n", page); + printk("*pde = %p\n", page); if ( page & _PAGE_PRESENT ) { page &= PAGE_MASK; page = ((unsigned long *) __va(page))[(addr&0x3ff000)>>PAGE_SHIFT]; - printk(" *pte = %08lx\n", page); + printk(" *pte = %p\n", page); } #ifdef MEMORY_GUARD if ( !(regs->error_code & 1) ) @@ -351,7 +351,7 @@ show_registers(regs); panic("CPU%d FATAL PAGE FAULT\n" "[error_code=%04x]\n" - "Faulting linear address might be %08lx\n", + "Faulting linear address might be %p\n", smp_processor_id(), regs->error_code, addr); return 0; } @@ -555,7 +555,7 @@ if ( likely((fixup = search_exception_table(regs->eip)) != 0) ) { - DPRINTK("GPF (%04x): %08lx -> %08lx\n", + DPRINTK("GPF (%04x): %p -> %p\n", regs->error_code, regs->eip, fixup); regs->eip = fixup; return 0; @@ -705,16 +705,6 @@ idt_table[n].b = 0x8500; } -#define _set_seg_desc(gate_addr,type,dpl,base,limit) {\ - *((gate_addr)+1) = ((base) & 0xff000000) | \ - (((base) & 0x00ff0000)>>16) | \ - ((limit) & 0xf0000) | \ - ((dpl)<<13) | \ - (0x00408000) | \ - ((type)<<8); \ - *(gate_addr) = (((base) & 0x0000ffff)<<16) | \ - ((limit) & 0x0ffff); } - void set_tss_desc(unsigned int n, void *addr) { _set_tssldt_desc( @@ -729,7 +719,6 @@ extern void doublefault_init(void); doublefault_init(); -#ifdef __i386__ /* * Note that interrupt gates are always used, rather than trap gates. We * must have interrupts disabled until DS/ES/FS/GS are saved because the @@ -760,8 +749,10 @@ set_intr_gate(TRAP_simd_error,&simd_coprocessor_error); set_intr_gate(TRAP_deferred_nmi,&nmi); |