direct-io.hg

changeset 3775:09ef8bf5a916

bitkeeper revision 1.1171 (420b98ac0B3ughFHARZwZjaceYNFUg)

Merge douglas.cl.cam.ac.uk:/auto/groups/xeno-xenod/BK/xen-unstable.bk
into douglas.cl.cam.ac.uk:/auto/groups/xeno/users/sos22/crashdb.bk
author sos22@douglas.cl.cam.ac.uk
date Thu Feb 10 17:23:56 2005 +0000 (2005-02-10)
parents 9ee09144e830 d8506fb506ed
children c37c674174f7
files xen/arch/x86/setup.c xen/arch/x86/smpboot.c xen/arch/x86/traps.c xen/arch/x86/x86_32/traps.c xen/arch/x86/x86_64/traps.c
line diff
     1.1 --- a/xen/arch/x86/setup.c	Thu Feb 10 17:16:20 2005 +0000
     1.2 +++ b/xen/arch/x86/setup.c	Thu Feb 10 17:23:56 2005 +0000
     1.3 @@ -67,7 +67,7 @@ extern void ac_timer_init(void);
     1.4  extern void initialize_keytable();
     1.5  extern int do_timer_lists_from_pit;
     1.6  
     1.7 -char ignore_irq13;		/* set if exception 16 works */
     1.8 +char ignore_irq13; /* set if exception 16 works */
     1.9  struct cpuinfo_x86 boot_cpu_data = { 0, 0, 0, 0, -1 };
    1.10  
    1.11  #if defined(__x86_64__)
    1.12 @@ -81,7 +81,7 @@ unsigned long wait_init_idle;
    1.13  
    1.14  struct exec_domain *idle_task[NR_CPUS] = { &idle0_exec_domain };
    1.15  
    1.16 -#ifdef	CONFIG_ACPI_INTERPRETER
    1.17 +#ifdef CONFIG_ACPI_INTERPRETER
    1.18  int acpi_disabled = 0;
    1.19  #else
    1.20  int acpi_disabled = 1;
    1.21 @@ -300,7 +300,6 @@ void __init cpu_init(void)
    1.22  {
    1.23      int nr = smp_processor_id();
    1.24      struct tss_struct *t = &init_tss[nr];
    1.25 -    unsigned char idt_load[10];
    1.26  
    1.27      if ( test_and_set_bit(nr, &cpu_initialized) )
    1.28          panic("CPU#%d already initialized!!!\n", nr);
    1.29 @@ -310,10 +309,6 @@ void __init cpu_init(void)
    1.30      SET_GDT_ADDRESS(current, DEFAULT_GDT_ADDRESS);
    1.31      __asm__ __volatile__ ( "lgdt %0" : "=m" (*current->arch.gdt) );
    1.32  
    1.33 -    *(unsigned short *)(&idt_load[0]) = (IDT_ENTRIES*sizeof(idt_entry_t))-1;
    1.34 -    *(unsigned long  *)(&idt_load[2]) = (unsigned long)idt_tables[nr];
    1.35 -    __asm__ __volatile__ ( "lidt %0" : "=m" (idt_load) );
    1.36 -
    1.37      /* No nested task. */
    1.38      __asm__ __volatile__ ( "pushf ; andw $0xbfff,(%"__OP"sp) ; popf" );
    1.39  
    1.40 @@ -410,7 +405,7 @@ static void __init start_of_day(void)
    1.41      APIC_init_uniprocessor();
    1.42  #else
    1.43      if ( opt_nosmp )
    1.44 -	APIC_init_uniprocessor();
    1.45 +        APIC_init_uniprocessor();
    1.46      else
    1.47      	smp_boot_cpus(); 
    1.48      /*
     2.1 --- a/xen/arch/x86/smpboot.c	Thu Feb 10 17:16:20 2005 +0000
     2.2 +++ b/xen/arch/x86/smpboot.c	Thu Feb 10 17:23:56 2005 +0000
     2.3 @@ -382,6 +382,20 @@ void __init smp_callin(void)
     2.4  
     2.5  static int cpucount;
     2.6  
     2.7 +#ifdef __i386__
     2.8 +static void construct_percpu_idt(unsigned int cpu)
     2.9 +{
    2.10 +    unsigned char idt_load[10];
    2.11 +
    2.12 +    idt_tables[cpu] = xmalloc_array(idt_entry_t, IDT_ENTRIES);
    2.13 +    memcpy(idt_tables[cpu], idt_table, IDT_ENTRIES*sizeof(idt_entry_t));
    2.14 +
    2.15 +    *(unsigned short *)(&idt_load[0]) = (IDT_ENTRIES*sizeof(idt_entry_t))-1;
    2.16 +    *(unsigned long  *)(&idt_load[2]) = (unsigned long)idt_tables[cpu];
    2.17 +    __asm__ __volatile__ ( "lidt %0" : "=m" (idt_load) );
    2.18 +}
    2.19 +#endif
    2.20 +
    2.21  /*
    2.22   * Activate a secondary processor.
    2.23   */
    2.24 @@ -394,13 +408,6 @@ void __init start_secondary(void)
    2.25  
    2.26      set_current(idle_task[cpu]);
    2.27  
    2.28 -    /*
    2.29 -     * At this point, boot CPU has fully initialised the IDT. It is
    2.30 -     * now safe to make ourselves a private copy.
    2.31 -     */
    2.32 -    idt_tables[cpu] = xmalloc_array(idt_entry_t, IDT_ENTRIES);
    2.33 -    memcpy(idt_tables[cpu], idt_table, IDT_ENTRIES*sizeof(idt_entry_t));
    2.34 -
    2.35      percpu_traps_init();
    2.36  
    2.37      cpu_init();
    2.38 @@ -410,10 +417,14 @@ void __init start_secondary(void)
    2.39      while (!atomic_read(&smp_commenced))
    2.40          rep_nop();
    2.41  
    2.42 +#ifdef __i386__
    2.43      /*
    2.44 -     * low-memory mappings have been cleared, flush them from the local TLBs 
    2.45 -     * too.
    2.46 +     * At this point, boot CPU has fully initialised the IDT. It is
    2.47 +     * now safe to make ourselves a private copy.
    2.48       */
    2.49 +    construct_percpu_idt(cpu);
    2.50 +#endif
    2.51 +
    2.52      local_flush_tlb();
    2.53  
    2.54      startup_cpu_idle_loop();
     3.1 --- a/xen/arch/x86/traps.c	Thu Feb 10 17:16:20 2005 +0000
     3.2 +++ b/xen/arch/x86/traps.c	Thu Feb 10 17:23:56 2005 +0000
     3.3 @@ -67,12 +67,8 @@ char opt_nmi[10] = "fatal";
     3.4  #endif
     3.5  string_param("nmi", opt_nmi);
     3.6  
     3.7 -asmlinkage int hypercall(void);
     3.8 -
     3.9 -/* Master table, and the one used by CPU0. */
    3.10 +/* Master table, used by all CPUs on x86/64, and by CPU0 on x86/32.*/
    3.11  idt_entry_t idt_table[IDT_ENTRIES] = { {0, 0}, };
    3.12 -/* All other CPUs have their own copy. */
    3.13 -idt_entry_t *idt_tables[NR_CPUS] = { 0 };
    3.14  
    3.15  asmlinkage void divide_error(void);
    3.16  asmlinkage void debug(void);
    3.17 @@ -716,13 +712,6 @@ asmlinkage int do_spurious_interrupt_bug
    3.18      return EXCRET_not_a_fault;
    3.19  }
    3.20  
    3.21 -BUILD_SMP_INTERRUPT(deferred_nmi, TRAP_deferred_nmi)
    3.22 -asmlinkage void smp_deferred_nmi(struct xen_regs regs)
    3.23 -{
    3.24 -    ack_APIC_irq();
    3.25 -    do_nmi(&regs, 0);
    3.26 -}
    3.27 -
    3.28  void set_intr_gate(unsigned int n, void *addr)
    3.29  {
    3.30      _set_gate(idt_table+n,14,0,addr);
    3.31 @@ -780,14 +769,6 @@ void __init trap_init(void)
    3.32      set_intr_gate(TRAP_alignment_check,&alignment_check);
    3.33      set_intr_gate(TRAP_machine_check,&machine_check);
    3.34      set_intr_gate(TRAP_simd_error,&simd_coprocessor_error);
    3.35 -    set_intr_gate(TRAP_deferred_nmi,&deferred_nmi);
    3.36 -
    3.37 -#if defined(__i386__)
    3.38 -    _set_gate(idt_table+HYPERCALL_VECTOR, 14, 1, &hypercall);
    3.39 -#endif
    3.40 -
    3.41 -    /* CPU0 uses the master IDT. */
    3.42 -    idt_tables[0] = idt_table;
    3.43  
    3.44      percpu_traps_init();
    3.45  
     4.1 --- a/xen/arch/x86/x86_32/traps.c	Thu Feb 10 17:16:20 2005 +0000
     4.2 +++ b/xen/arch/x86/x86_32/traps.c	Thu Feb 10 17:23:56 2005 +0000
     4.3 @@ -9,6 +9,9 @@
     4.4  #include <xen/irq.h>
     4.5  #include <asm/flushtlb.h>
     4.6  
     4.7 +/* All CPUs have their own IDT to allow set_fast_trap(). */
     4.8 +idt_entry_t *idt_tables[NR_CPUS] = { 0 };
     4.9 +
    4.10  static int kstack_depth_to_print = 8*20;
    4.11  
    4.12  static inline int kernel_text_address(unsigned long addr)
    4.13 @@ -177,29 +180,47 @@ asmlinkage void do_double_fault(void)
    4.14          __asm__ __volatile__ ( "hlt" );
    4.15  }
    4.16  
    4.17 +BUILD_SMP_INTERRUPT(deferred_nmi, TRAP_deferred_nmi)
    4.18 +asmlinkage void smp_deferred_nmi(struct xen_regs regs)
    4.19 +{
    4.20 +    asmlinkage void do_nmi(struct xen_regs *, unsigned long);
    4.21 +    ack_APIC_irq();
    4.22 +    do_nmi(&regs, 0);
    4.23 +}
    4.24 +
    4.25  void __init percpu_traps_init(void)
    4.26  {
    4.27 -    if ( smp_processor_id() == 0 )
    4.28 -    {
    4.29 -        /*
    4.30 -         * Make a separate task for double faults. This will get us debug
    4.31 -         * output if we blow the kernel stack.
    4.32 -         */
    4.33 -        struct tss_struct *tss = &doublefault_tss;
    4.34 -        memset(tss, 0, sizeof(*tss));
    4.35 -        tss->ds     = __HYPERVISOR_DS;
    4.36 -        tss->es     = __HYPERVISOR_DS;
    4.37 -        tss->ss     = __HYPERVISOR_DS;
    4.38 -        tss->esp    = (unsigned long)
    4.39 -            &doublefault_stack[DOUBLEFAULT_STACK_SIZE];
    4.40 -        tss->__cr3  = __pa(idle_pg_table);
    4.41 -        tss->cs     = __HYPERVISOR_CS;
    4.42 -        tss->eip    = (unsigned long)do_double_fault;
    4.43 -        tss->eflags = 2;
    4.44 -        tss->bitmap = IOBMP_INVALID_OFFSET;
    4.45 -        _set_tssldt_desc(gdt_table+__DOUBLEFAULT_TSS_ENTRY,
    4.46 -                         (unsigned long)tss, 235, 9);
    4.47 -    }
    4.48 +    asmlinkage int hypercall(void);
    4.49 +
    4.50 +    if ( smp_processor_id() != 0 )
    4.51 +        return;
    4.52 +
    4.53 +    /* CPU0 uses the master IDT. */
    4.54 +    idt_tables[0] = idt_table;
    4.55 +
    4.56 +    /* The hypercall entry vector is only accessible from ring 1. */
    4.57 +    _set_gate(idt_table+HYPERCALL_VECTOR, 14, 1, &hypercall);
    4.58 +
    4.59 +    set_intr_gate(TRAP_deferred_nmi, &deferred_nmi);
    4.60 +
    4.61 +    /*
    4.62 +     * Make a separate task for double faults. This will get us debug output if
    4.63 +     * we blow the kernel stack.
    4.64 +     */
    4.65 +    struct tss_struct *tss = &doublefault_tss;
    4.66 +    memset(tss, 0, sizeof(*tss));
    4.67 +    tss->ds     = __HYPERVISOR_DS;
    4.68 +    tss->es     = __HYPERVISOR_DS;
    4.69 +    tss->ss     = __HYPERVISOR_DS;
    4.70 +    tss->esp    = (unsigned long)
    4.71 +        &doublefault_stack[DOUBLEFAULT_STACK_SIZE];
    4.72 +    tss->__cr3  = __pa(idle_pg_table);
    4.73 +    tss->cs     = __HYPERVISOR_CS;
    4.74 +    tss->eip    = (unsigned long)do_double_fault;
    4.75 +    tss->eflags = 2;
    4.76 +    tss->bitmap = IOBMP_INVALID_OFFSET;
    4.77 +    _set_tssldt_desc(gdt_table+__DOUBLEFAULT_TSS_ENTRY,
    4.78 +                     (unsigned long)tss, 235, 9);
    4.79  
    4.80      set_task_gate(TRAP_double_fault, __DOUBLEFAULT_TSS_ENTRY<<3);
    4.81  }
     5.1 --- a/xen/arch/x86/x86_64/traps.c	Thu Feb 10 17:16:20 2005 +0000
     5.2 +++ b/xen/arch/x86/x86_64/traps.c	Thu Feb 10 17:23:56 2005 +0000
     5.3 @@ -159,17 +159,22 @@ void __init percpu_traps_init(void)
     5.4      char *stack_bottom, *stack;
     5.5      int   cpu = smp_processor_id();
     5.6  
     5.7 +    if ( cpu == 0 )
     5.8 +    {
     5.9 +        /* Specify dedicated interrupt stacks for NMIs and double faults. */
    5.10 +        set_intr_gate(TRAP_double_fault, &double_fault);
    5.11 +        idt_table[TRAP_double_fault].a |= 1UL << 32; /* IST1 */
    5.12 +        idt_table[TRAP_nmi].a          |= 2UL << 32; /* IST2 */
    5.13 +    }
    5.14 +
    5.15      stack_bottom = (char *)get_stack_bottom();
    5.16      stack        = (char *)((unsigned long)stack_bottom & ~(STACK_SIZE - 1));
    5.17  
    5.18      /* Double-fault handler has its own per-CPU 1kB stack. */
    5.19      init_tss[cpu].ist[0] = (unsigned long)&stack[1024];
    5.20 -    set_intr_gate(TRAP_double_fault, &double_fault);
    5.21 -    idt_tables[cpu][TRAP_double_fault].a |= 1UL << 32; /* IST1 */
    5.22  
    5.23      /* NMI handler has its own per-CPU 1kB stack. */
    5.24      init_tss[cpu].ist[1] = (unsigned long)&stack[2048];
    5.25 -    idt_tables[cpu][TRAP_nmi].a          |= 2UL << 32; /* IST2 */
    5.26  
    5.27      /*
    5.28       * Trampoline for SYSCALL entry from long mode.