direct-io.hg

changeset 822:c980231846cc

bitkeeper revision 1.507 (3f8ad9d51NEWhiPGDd2jxu-ez0fnOA)

i386_ksyms.c, sched.h, ide-cd.h, memory.c, traps.c, process.c, entry.S:
Fix LDT bug when switching domains.
author kaf24@scramble.cl.cam.ac.uk
date Mon Oct 13 16:59:01 2003 +0000 (2003-10-13)
parents f0194709226e
children 184d4534da0f 8e5d44ac40b3
files xen/arch/i386/entry.S xen/arch/i386/process.c xen/arch/i386/traps.c xen/common/memory.c xen/drivers/ide/ide-cd.h xen/include/xeno/sched.h xenolinux-2.4.22-sparse/arch/xeno/kernel/i386_ksyms.c
line diff
     1.1 --- a/xen/arch/i386/entry.S	Sat Oct 11 14:41:02 2003 +0000
     1.2 +++ b/xen/arch/i386/entry.S	Mon Oct 13 16:59:01 2003 +0000
     1.3 @@ -490,15 +490,6 @@ ENTRY(ret_from_intr)
     1.4  	jne test_all_events
     1.5  	jmp restore_all
     1.6  
     1.7 -        ALIGN
     1.8 -ret_from_exception:
     1.9 -        movb CS(%esp),%al
    1.10 -	testb $3,%al	# return to non-supervisor?
    1.11 -	jne process_guest_exception_and_events
    1.12 -        jmp restore_all
    1.13 -
    1.14 -	ALIGN
    1.15 -
    1.16  ENTRY(divide_error)
    1.17  	pushl $0		# no error code
    1.18  	pushl $ SYMBOL_NAME(do_divide_error)
    1.19 @@ -530,11 +521,11 @@ error_code:
    1.20  	movl  %edx,%es
    1.21  	GET_CURRENT(%ebx)
    1.22  	call  *%edi
    1.23 -        # NB. We reenable interrupts AFTER exception processing, as that is
    1.24 -        #     required by the page fault handler (needs to save %cr2)
    1.25 -        sti
    1.26          addl  $8,%esp
    1.27 -	jmp ret_from_exception
    1.28 +        movb  CS(%esp),%al
    1.29 +	testb $3,%al
    1.30 +	je    restore_all
    1.31 +        jmp   process_guest_exception_and_events
    1.32  
    1.33  ENTRY(coprocessor_error)
    1.34  	pushl $0
    1.35 @@ -564,7 +555,7 @@ ENTRY(nmi)
    1.36  	pushl %edx
    1.37  	call SYMBOL_NAME(do_nmi)
    1.38  	addl $8,%esp
    1.39 -	RESTORE_ALL
    1.40 +        jmp  restore_all
    1.41  
    1.42  ENTRY(int3)
    1.43  	pushl $0
     2.1 --- a/xen/arch/i386/process.c	Sat Oct 11 14:41:02 2003 +0000
     2.2 +++ b/xen/arch/i386/process.c	Mon Oct 13 16:59:01 2003 +0000
     2.3 @@ -288,7 +288,7 @@ void switch_to(struct task_struct *prev_
     2.4  
     2.5      /* Switch GDT and LDT. */
     2.6      __asm__ __volatile__ ("lgdt %0" : "=m" (*next_p->mm.gdt));
     2.7 -    load_LDT();
     2.8 +    load_LDT(next_p);
     2.9  
    2.10      /* Maybe switch the debug registers. */
    2.11      if ( next->debugreg[7] )
     3.1 --- a/xen/arch/i386/traps.c	Sat Oct 11 14:41:02 2003 +0000
     3.2 +++ b/xen/arch/i386/traps.c	Mon Oct 13 16:59:01 2003 +0000
     3.3 @@ -185,13 +185,47 @@ void die(const char * str, struct pt_reg
     3.4      panic("HYPERVISOR DEATH!!\n");
     3.5  }
     3.6  
     3.7 -static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err)
     3.8 +#define check_selector(_s)                    \
     3.9 +  ({ int err;                                 \
    3.10 +     __asm__ __volatile__ (                   \
    3.11 +             "1: movl %2,%%gs       \n"       \
    3.12 +             "2:                    \n"       \
    3.13 +             ".section .fixup,\"ax\"\n"       \
    3.14 +             "3: incl %0            \n"       \
    3.15 +             "   jmp  2b            \n"       \
    3.16 +             ".previous             \n"       \
    3.17 +             ".section __ex_table,\"a\"\n"    \
    3.18 +             ".align 4              \n"       \
    3.19 +             ".long 1b,3b           \n"       \
    3.20 +             ".previous               "       \
    3.21 +             : "=&r" (err) : "0" (0),         \
    3.22 +               "m" (*(unsigned int *)&(_s))); \
    3.23 +     err; })
    3.24 +
    3.25 +static inline void check_saved_selectors(struct pt_regs *regs)
    3.26  {
    3.27 -    if (!(3 & regs->xcs)) die(str, regs, err);
    3.28 +    /* Prevent recursion. */
    3.29 +    __asm__ __volatile__ ( 
    3.30 +        "movl %0,%%fs; movl %0,%%gs" 
    3.31 +        : : "r" (0) );
    3.32 +
    3.33 +    /*
    3.34 +     * NB. We need to check DS and ES as well, since we may have taken
    3.35 +     * an exception after they were restored in 
    3.36 +     */
    3.37 +    if ( check_selector(regs->xds) )
    3.38 +        regs->xds = 0;
    3.39 +    if ( check_selector(regs->xes) )
    3.40 +        regs->xes = 0;
    3.41 +    if ( check_selector(regs->xfs) )
    3.42 +        regs->xfs = 0;
    3.43 +    if ( check_selector(regs->xgs) )
    3.44 +        regs->xgs = 0;
    3.45  }
    3.46  
    3.47 -static void inline do_trap(int trapnr, char *str,
    3.48 -			   struct pt_regs * regs, 
    3.49 +
    3.50 +static inline void do_trap(int trapnr, char *str,
    3.51 +			   struct pt_regs *regs, 
    3.52                             long error_code, int use_error_code)
    3.53  {
    3.54      struct task_struct *p = current;
    3.55 @@ -216,7 +250,7 @@ static void inline do_trap(int trapnr, c
    3.56      if ( (fixup = search_exception_table(regs->eip)) != 0 )
    3.57      {
    3.58          regs->eip = fixup;
    3.59 -        regs->xfs = regs->xgs = 0;
    3.60 +        check_saved_selectors(regs);
    3.61          return;
    3.62      }
    3.63  
    3.64 @@ -380,7 +414,7 @@ asmlinkage void do_page_fault(struct pt_
    3.65      if ( (fixup = search_exception_table(regs->eip)) != 0 )
    3.66      {
    3.67          regs->eip = fixup;
    3.68 -        regs->xfs = regs->xgs = 0;
    3.69 +        check_saved_selectors(regs);
    3.70          return;
    3.71      }
    3.72  
    3.73 @@ -463,7 +497,7 @@ asmlinkage void do_general_protection(st
    3.74      if ( (fixup = search_exception_table(regs->eip)) != 0 )
    3.75      {
    3.76          regs->eip = fixup;
    3.77 -        regs->xfs = regs->xgs = 0;
    3.78 +        check_saved_selectors(regs);
    3.79          return;
    3.80      }
    3.81  
     4.1 --- a/xen/common/memory.c	Sat Oct 11 14:41:02 2003 +0000
     4.2 +++ b/xen/common/memory.c	Mon Oct 13 16:59:01 2003 +0000
     4.3 @@ -231,7 +231,12 @@ static void __invalidate_shadow_ldt(void
     4.4          put_page_type(page);
     4.5          put_page_tot(page);                
     4.6      }
     4.7 +
     4.8 +    /* Dispose of the (now possibly invalid) mappings from the TLB.  */
     4.9 +    flush_tlb[smp_processor_id()] = 1;
    4.10  }
    4.11 +
    4.12 +
    4.13  static inline void invalidate_shadow_ldt(void)
    4.14  {
    4.15      if ( current->mm.shadow_ldt_mapcnt != 0 )
    4.16 @@ -720,13 +725,10 @@ static int do_extended_command(unsigned 
    4.17                    (current->mm.ldt_base != ptr) )
    4.18          {
    4.19              if ( current->mm.ldt_ents != 0 )
    4.20 -            {
    4.21                  invalidate_shadow_ldt();
    4.22 -                flush_tlb[smp_processor_id()] = 1;
    4.23 -            }
    4.24              current->mm.ldt_base = ptr;
    4.25              current->mm.ldt_ents = ents;
    4.26 -            load_LDT();
    4.27 +            load_LDT(current);
    4.28          }
    4.29          break;
    4.30      }
     5.1 --- a/xen/drivers/ide/ide-cd.h	Sat Oct 11 14:41:02 2003 +0000
     5.2 +++ b/xen/drivers/ide/ide-cd.h	Mon Oct 13 16:59:01 2003 +0000
     5.3 @@ -439,7 +439,7 @@ struct atapi_mechstat_header {
     5.4  
     5.5  	byte     curlba[3];
     5.6  	byte     nslots;
     5.7 -	__u8 short slot_tablelen;
     5.8 +	__u16 slot_tablelen;
     5.9  };
    5.10  
    5.11  
     6.1 --- a/xen/include/xeno/sched.h	Sat Oct 11 14:41:02 2003 +0000
     6.2 +++ b/xen/include/xeno/sched.h	Mon Oct 13 16:59:01 2003 +0000
     6.3 @@ -311,20 +311,20 @@ struct task_struct *task_hash[TASK_HASH_
     6.4  extern void update_process_times(int user);
     6.5  
     6.6  #include <asm/desc.h>
     6.7 -static inline void load_LDT(void)
     6.8 +static inline void load_LDT(struct task_struct *p)
     6.9  {
    6.10      unsigned int cpu;
    6.11      struct desc_struct *desc;
    6.12      unsigned long ents;
    6.13  
    6.14 -    if ( (ents = current->mm.ldt_ents) == 0 )
    6.15 +    if ( (ents = p->mm.ldt_ents) == 0 )
    6.16      {
    6.17          __asm__ __volatile__ ( "lldt %%ax" : : "a" (0) );
    6.18      }
    6.19      else
    6.20      {
    6.21          cpu = smp_processor_id();
    6.22 -        desc = (struct desc_struct *)GET_GDT_ADDRESS(current) + __LDT(cpu);
    6.23 +        desc = (struct desc_struct *)GET_GDT_ADDRESS(p) + __LDT(cpu);
    6.24          desc->a = ((LDT_VIRT_START&0xffff)<<16) | (ents*8-1);
    6.25          desc->b = (LDT_VIRT_START&(0xff<<24)) | 0x8200 | 
    6.26              ((LDT_VIRT_START&0xff0000)>>16);
     7.1 --- a/xenolinux-2.4.22-sparse/arch/xeno/kernel/i386_ksyms.c	Sat Oct 11 14:41:02 2003 +0000
     7.2 +++ b/xenolinux-2.4.22-sparse/arch/xeno/kernel/i386_ksyms.c	Mon Oct 13 16:59:01 2003 +0000
     7.3 @@ -159,3 +159,5 @@ EXPORT_SYMBOL(xquad_portio);
     7.4  EXPORT_SYMBOL(create_xeno_proc_entry);
     7.5  EXPORT_SYMBOL(remove_xeno_proc_entry);
     7.6  
     7.7 +EXPORT_SYMBOL(do_hypervisor_callback)
     7.8 +EXPORT_SYMBOL(HYPERVISOR_shared_info)