ia64/xen-unstable

changeset 2992:4c4ec1d8c1f1

bitkeeper revision 1.1159.170.31 (419a3a86bSLSt5jRubDsLFc4VXWrkQ)

Sanitise failsafe callback. The safe pf handler stuff was madness.
If it turns out to be needed, there must be a better way.
author kaf24@freefall.cl.cam.ac.uk
date Tue Nov 16 17:36:06 2004 +0000 (2004-11-16)
parents 00823b8a8bfb
children a4f8b0734492
files linux-2.4.27-xen-sparse/arch/xen/kernel/entry.S linux-2.4.27-xen-sparse/arch/xen/kernel/traps.c linux-2.6.9-xen-sparse/arch/xen/i386/kernel/entry.S linux-2.6.9-xen-sparse/arch/xen/i386/kernel/traps.c
line diff
     1.1 --- a/linux-2.4.27-xen-sparse/arch/xen/kernel/entry.S	Tue Nov 16 16:18:43 2004 +0000
     1.2 +++ b/linux-2.4.27-xen-sparse/arch/xen/kernel/entry.S	Tue Nov 16 17:36:06 2004 +0000
     1.3 @@ -369,28 +369,19 @@ critical_fixup_table:
     1.4  
     1.5  # Hypervisor uses this for application faults while it executes.
     1.6  ENTRY(failsafe_callback)
     1.7 -        pushal
     1.8 -        call SYMBOL_NAME(install_safe_pf_handler)
     1.9 -        movl 32(%esp),%ebx
    1.10 -1:      movl %ebx,%ds
    1.11 -        movl 36(%esp),%ebx
    1.12 -2:      movl %ebx,%es
    1.13 -        movl 40(%esp),%ebx
    1.14 -3:      movl %ebx,%fs
    1.15 -        movl 44(%esp),%ebx
    1.16 -4:      movl %ebx,%gs
    1.17 -        call SYMBOL_NAME(install_normal_pf_handler)
    1.18 -        popal
    1.19 -        addl $16,%esp
    1.20 +1:      popl %ds
    1.21 +2:      popl %es
    1.22 +3:      popl %fs
    1.23 +4:      popl %gs
    1.24  5:      iret
    1.25  .section .fixup,"ax";	\
    1.26 -6:	xorl %ebx,%ebx;	\
    1.27 +6:	movl $0,(%esp);	\
    1.28  	jmp 1b;		\
    1.29 -7:	xorl %ebx,%ebx;	\
    1.30 +7:	movl $0,(%esp);	\
    1.31  	jmp 2b;		\
    1.32 -8:	xorl %ebx,%ebx;	\
    1.33 +8:	movl $0,(%esp);	\
    1.34  	jmp 3b;		\
    1.35 -9:	xorl %ebx,%ebx;	\
    1.36 +9:	movl $0,(%esp);	\
    1.37  	jmp 4b;		\
    1.38  10:	pushl %ss;	\
    1.39  	popl %ds;	\
    1.40 @@ -511,7 +502,6 @@ ENTRY(_name1)                           
    1.41  	addl $12,%esp                                                  ; \
    1.42  	jmp ret_from_exception                                         ;
    1.43  PAGE_FAULT_STUB(page_fault, do_page_fault)
    1.44 -PAGE_FAULT_STUB(safe_page_fault, do_safe_page_fault)
    1.45  
    1.46  ENTRY(machine_check)
    1.47  	pushl $0
     2.1 --- a/linux-2.4.27-xen-sparse/arch/xen/kernel/traps.c	Tue Nov 16 16:18:43 2004 +0000
     2.2 +++ b/linux-2.4.27-xen-sparse/arch/xen/kernel/traps.c	Tue Nov 16 17:36:06 2004 +0000
     2.3 @@ -59,7 +59,6 @@ asmlinkage void segment_not_present(void
     2.4  asmlinkage void stack_segment(void);
     2.5  asmlinkage void general_protection(void);
     2.6  asmlinkage void page_fault(void);
     2.7 -asmlinkage void safe_page_fault(void);
     2.8  asmlinkage void coprocessor_error(void);
     2.9  asmlinkage void simd_coprocessor_error(void);
    2.10  asmlinkage void alignment_check(void);
    2.11 @@ -627,65 +626,3 @@ void __init trap_init(void)
    2.12  
    2.13      cpu_init();
    2.14  }
    2.15 -
    2.16 -
    2.17 -/*
    2.18 - * install_safe_pf_handler / install_normal_pf_handler:
    2.19 - * 
    2.20 - * These are used within the failsafe_callback handler in entry.S to avoid
    2.21 - * taking a full page fault when reloading FS and GS. This is because FS and 
    2.22 - * GS could be invalid at pretty much any point while Xenolinux executes (we 
    2.23 - * don't set them to safe values on entry to the kernel). At *any* point Xen 
    2.24 - * may be entered due to a hardware interrupt --- on exit from Xen an invalid 
    2.25 - * FS/GS will cause our failsafe_callback to be executed. This could occur, 
    2.26 - * for example, while the mmu_update_queue is in an inconsistent state. This
    2.27 - * is disastrous because the normal page-fault handler touches the update
    2.28 - * queue!
    2.29 - * 
    2.30 - * Fortunately, within the failsafe handler it is safe to force DS/ES/FS/GS
    2.31 - * to zero if they cannot be reloaded -- at this point executing a normal
    2.32 - * page fault would not change this effect. The safe page-fault handler
    2.33 - * ensures this end result (blow away the selector value) without the dangers
    2.34 - * of the normal page-fault handler.
    2.35 - * 
    2.36 - * NB. Perhaps this can all go away after we have implemented writable
    2.37 - * page tables. :-)
    2.38 - */
    2.39 -
    2.40 -asmlinkage void do_safe_page_fault(struct pt_regs *regs, 
    2.41 -                                   unsigned long error_code,
    2.42 -                                   unsigned long address)
    2.43 -{
    2.44 -    unsigned long fixup;
    2.45 -
    2.46 -    if ( (fixup = search_exception_table(regs->eip)) != 0 )
    2.47 -    {
    2.48 -        regs->eip = fixup;
    2.49 -        return;
    2.50 -    }
    2.51 -
    2.52 -    die("Unhandleable 'safe' page fault!", regs, error_code);
    2.53 -}
    2.54 -
    2.55 -unsigned long install_safe_pf_handler(void)
    2.56 -{
    2.57 -    static trap_info_t safe_pf[] = { 
    2.58 -        { 14, 0, __KERNEL_CS, (unsigned long)safe_page_fault },
    2.59 -        {  0, 0,           0, 0                              }
    2.60 -    };
    2.61 -    unsigned long flags;
    2.62 -    local_irq_save(flags);
    2.63 -    HYPERVISOR_set_trap_table(safe_pf);
    2.64 -    return flags; /* This is returned in %%eax */
    2.65 -}
    2.66 -
    2.67 -__attribute__((regparm(3))) /* This function take its arg in %%eax */
    2.68 -void install_normal_pf_handler(unsigned long flags)
    2.69 -{
    2.70 -    static trap_info_t normal_pf[] = { 
    2.71 -        { 14, 0, __KERNEL_CS, (unsigned long)page_fault },
    2.72 -        {  0, 0,           0, 0                         }
    2.73 -    };
    2.74 -    HYPERVISOR_set_trap_table(normal_pf);
    2.75 -    local_irq_restore(flags);
    2.76 -}
     3.1 --- a/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/entry.S	Tue Nov 16 16:18:43 2004 +0000
     3.2 +++ b/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/entry.S	Tue Nov 16 17:36:06 2004 +0000
     3.3 @@ -510,28 +510,19 @@ critical_fixup_table:
     3.4  
     3.5  # Hypervisor uses this for application faults while it executes.
     3.6  ENTRY(failsafe_callback)
     3.7 -	pushal
     3.8 -	call install_safe_pf_handler
     3.9 -	movl 32(%esp),%ebx
    3.10 -1:	movl %ebx,%ds
    3.11 -	movl 36(%esp),%ebx
    3.12 -2:	movl %ebx,%es
    3.13 -	movl 40(%esp),%ebx
    3.14 -3:	movl %ebx,%fs
    3.15 -	movl 44(%esp),%ebx
    3.16 -4:	movl %ebx,%gs
    3.17 -	call install_normal_pf_handler
    3.18 -	popal
    3.19 -	addl $16,%esp
    3.20 +1:      popl %ds
    3.21 +2:      popl %es
    3.22 +3:      popl %fs
    3.23 +4:      popl %gs
    3.24  5:	iret
    3.25  .section .fixup,"ax";	\
    3.26 -6:	xorl %ebx,%ebx;	\
    3.27 +6:	movl $0,(%esp);	\
    3.28  	jmp 1b;		\
    3.29 -7:	xorl %ebx,%ebx;	\
    3.30 +7:	movl $0,(%esp);	\
    3.31  	jmp 2b;		\
    3.32 -8:	xorl %ebx,%ebx;	\
    3.33 +8:	movl $0,(%esp);	\
    3.34  	jmp 3b;		\
    3.35 -9:	xorl %ebx,%ebx;	\
    3.36 +9:	movl $0,(%esp);	\
    3.37  	jmp 4b;		\
    3.38  10:	pushl %ss;	\
    3.39  	popl %ds;	\
    3.40 @@ -726,7 +717,6 @@ ENTRY(_name1)								  \
    3.41  	addl $12,%esp							; \
    3.42  	jmp ret_from_exception						;
    3.43  PAGE_FAULT_STUB(page_fault, do_page_fault)
    3.44 -PAGE_FAULT_STUB(safe_page_fault, do_safe_page_fault)
    3.45  
    3.46  #ifdef CONFIG_X86_MCE
    3.47  ENTRY(machine_check)
     4.1 --- a/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/traps.c	Tue Nov 16 16:18:43 2004 +0000
     4.2 +++ b/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/traps.c	Tue Nov 16 17:36:06 2004 +0000
     4.3 @@ -60,8 +60,6 @@ asmlinkage int system_call(void);
     4.4  asmlinkage void lcall7(void);
     4.5  asmlinkage void lcall27(void);
     4.6  
     4.7 -asmlinkage void safe_page_fault(void);
     4.8 -
     4.9  /* Do we ignore FPU interrupts ? */
    4.10  char ignore_fpu_irq = 0;
    4.11  
    4.12 @@ -1072,58 +1070,3 @@ void __init trap_init(void)
    4.13  	 */
    4.14  	cpu_init();
    4.15  }
    4.16 -
    4.17 -
    4.18 -/*
    4.19 - * install_safe_pf_handler / install_normal_pf_handler:
    4.20 - * 
    4.21 - * These are used within the failsafe_callback handler in entry.S to avoid
    4.22 - * taking a full page fault when reloading FS and GS. This is because FS and 
    4.23 - * GS could be invalid at pretty much any point while Xen Linux executes (we 
    4.24 - * don't set them to safe values on entry to the kernel). At *any* point Xen 
    4.25 - * may be entered due to a hardware interrupt --- on exit from Xen an invalid 
    4.26 - * FS/GS will cause our failsafe_callback to be executed. This could occur, 
    4.27 - * for example, while the mmmu_update_queue is in an inconsistent state. This
    4.28 - * is disastrous because the normal page-fault handler touches the update
    4.29 - * queue!
    4.30 - * 
    4.31 - * Fortunately, within the failsafe handler it is safe to force DS/ES/FS/GS
    4.32 - * to zero if they cannot be reloaded -- at this point executing a normal
    4.33 - * page fault would not change this effect. The safe page-fault handler
    4.34 - * ensures this end result (blow away the selector value) without the dangers
    4.35 - * of the normal page-fault handler.
    4.36 - * 
    4.37 - * NB. Perhaps this can all go away after we have implemented writable
    4.38 - * page tables. :-)
    4.39 - */
    4.40 -
    4.41 -asmlinkage void do_safe_page_fault(struct pt_regs *regs, 
    4.42 -                                   unsigned long error_code,
    4.43 -                                   unsigned long address)
    4.44 -{
    4.45 -	if (!fixup_exception(regs))
    4.46 -		die("Unhandleable 'safe' page fault!", regs, error_code);
    4.47 -}
    4.48 -
    4.49 -unsigned long install_safe_pf_handler(void)
    4.50 -{
    4.51 -	static trap_info_t safe_pf[] = { 
    4.52 -		{ 14, 0, __KERNEL_CS, (unsigned long)safe_page_fault },
    4.53 -		{  0, 0,           0, 0                              }
    4.54 -	};
    4.55 -	unsigned long flags;
    4.56 -	local_irq_save(flags);
    4.57 -	HYPERVISOR_set_trap_table(safe_pf);
    4.58 -	return flags; /* This is returned in %%eax */
    4.59 -}
    4.60 -
    4.61 -__attribute__((regparm(3))) /* This function take its arg in %%eax */
    4.62 -void install_normal_pf_handler(unsigned long flags)
    4.63 -{
    4.64 -	static trap_info_t normal_pf[] = { 
    4.65 -		{ 14, 0, __KERNEL_CS, (unsigned long)page_fault },
    4.66 -		{  0, 0,           0, 0                         }
    4.67 -	};
    4.68 -	HYPERVISOR_set_trap_table(normal_pf);
    4.69 -	local_irq_restore(flags);
    4.70 -}