ia64/xen-unstable

changeset 9930:62c8e97d56cf

Fix fault handler for both 32 and 64 bit architecture. Clean up unused code.
Signed-off-by: Grzegorz Milos <gm281@cam.ac.uk>
Signed-off-by: Aravindh Puthiyaparambil
<aravindh.puthiyaparambil@unisys.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu May 04 11:19:27 2006 +0100 (2006-05-04)
parents e1a47a269600
children 6719dae17b6a
files .hgignore extras/mini-os/Makefile extras/mini-os/sched.c extras/mini-os/traps.c extras/mini-os/x86_32.S extras/mini-os/x86_64.S
line diff
     1.1 --- a/.hgignore	Thu May 04 11:14:45 2006 +0100
     1.2 +++ b/.hgignore	Thu May 04 11:19:27 2006 +0100
     1.3 @@ -14,6 +14,7 @@
     1.4  .*\.orig$
     1.5  .*\.rej$
     1.6  .*/a\.out$
     1.7 +.*cscope\.*$
     1.8  ^[^/]*\.bz2$
     1.9  ^TAGS$
    1.10  ^dist/.*$
    1.11 @@ -184,7 +185,6 @@
    1.12  ^tools/xm-test/ramdisk/buildroot
    1.13  ^xen/BLOG$
    1.14  ^xen/TAGS$
    1.15 -^xen/cscope\.*$
    1.16  ^xen/arch/x86/asm-offsets\.s$
    1.17  ^xen/arch/x86/boot/mkelf32$
    1.18  ^xen/arch/x86/xen\.lds$
     2.1 --- a/extras/mini-os/Makefile	Thu May 04 11:14:45 2006 +0100
     2.2 +++ b/extras/mini-os/Makefile	Thu May 04 11:19:27 2006 +0100
     2.3 @@ -60,4 +60,12 @@ clean:
     2.4  %.o: %.S $(HDRS) Makefile
     2.5  	$(CC) $(CFLAGS) -D__ASSEMBLY__ -c $< -o $@
     2.6  
     2.7 +define all_sources
     2.8 +     ( find . -follow -name SCCS -prune -o -name '*.[chS]' -print )
     2.9 +endef
    2.10  
    2.11 +.PHONY: cscope
    2.12 +cscope:
    2.13 +	$(all_sources) > cscope.files
    2.14 +	cscope -k -b -q
    2.15 +
     3.1 --- a/extras/mini-os/sched.c	Thu May 04 11:14:45 2006 +0100
     3.2 +++ b/extras/mini-os/sched.c	Thu May 04 11:19:27 2006 +0100
     3.3 @@ -324,7 +324,7 @@ void th_f2(void *data)
     3.4  
     3.5  void init_sched(void)
     3.6  {
     3.7 -    printk("Initialising scheduler, idle_thread %p\n", idle_thread);
     3.8 +    printk("Initialising scheduler\n");
     3.9  
    3.10      idle_thread = create_thread("Idle", idle_thread_fn, NULL);
    3.11      INIT_LIST_HEAD(&idle_thread->thread_list);
     4.1 --- a/extras/mini-os/traps.c	Thu May 04 11:14:45 2006 +0100
     4.2 +++ b/extras/mini-os/traps.c	Thu May 04 11:19:27 2006 +0100
     4.3 @@ -123,8 +123,13 @@ void page_walk(unsigned long virt_addres
     4.4  void do_page_fault(struct pt_regs *regs, unsigned long error_code)
     4.5  {
     4.6      unsigned long addr = read_cr2();
     4.7 -    printk("Page fault at linear address %p, regs %p, code %lx\n", addr, regs,
     4.8 -	   error_code);
     4.9 +#if defined(__x86_64__)
    4.10 +    printk("Page fault at linear address %p, rip %p, code %lx\n",
    4.11 +           addr, regs->rip, error_code);
    4.12 +#else
    4.13 +    printk("Page fault at linear address %p, eip %p, code %lx\n",
    4.14 +           addr, regs->eip, error_code);
    4.15 +#endif
    4.16      dump_regs(regs);
    4.17      page_walk(addr);
    4.18      do_exit();
    4.19 @@ -195,7 +200,6 @@ static trap_info_t trap_table[] = {
    4.20      { 15, 0, __KERNEL_CS, (unsigned long)spurious_interrupt_bug      },
    4.21      { 16, 0, __KERNEL_CS, (unsigned long)coprocessor_error           },
    4.22      { 17, 0, __KERNEL_CS, (unsigned long)alignment_check             },
    4.23 -    { 18, 0, __KERNEL_CS, (unsigned long)machine_check               },
    4.24      { 19, 0, __KERNEL_CS, (unsigned long)simd_coprocessor_error      },
    4.25      {  0, 0,           0, 0                           }
    4.26  };
     5.1 --- a/extras/mini-os/x86_32.S	Thu May 04 11:14:45 2006 +0100
     5.2 +++ b/extras/mini-os/x86_32.S	Thu May 04 11:19:27 2006 +0100
     5.3 @@ -30,10 +30,10 @@ shared_info:
     5.4  hypercall_page:
     5.5          .org 0x3000
     5.6  
     5.7 -ES		= 0x1c
     5.8 -ORIG_EAX	= 0x20
     5.9 -EIP		= 0x24
    5.10 -CS		= 0x28
    5.11 +ES		= 0x20
    5.12 +ORIG_EAX	= 0x24
    5.13 +EIP		= 0x28
    5.14 +CS		= 0x2C
    5.15  
    5.16  #define ENTRY(X) .globl X ; X :
    5.17  
    5.18 @@ -69,7 +69,7 @@ ENTRY(divide_error)
    5.19  	pushl $0		# no error code
    5.20  	pushl $do_divide_error
    5.21  do_exception:
    5.22 -	pushl %ds
    5.23 +    pushl %ds
    5.24  	pushl %eax
    5.25  	xorl %eax, %eax
    5.26  	pushl %ebp
    5.27 @@ -92,7 +92,7 @@ do_exception:
    5.28      pushl %edx
    5.29      pushl %eax
    5.30  	call *%edi
    5.31 -    addl $8,%esp
    5.32 +    jmp ret_from_exception
    5.33      
    5.34  ret_from_exception:
    5.35          movb CS(%esp),%cl
    5.36 @@ -223,70 +223,55 @@ ENTRY(invalid_op)
    5.37  	pushl $do_invalid_op
    5.38  	jmp do_exception
    5.39  
    5.40 +
    5.41  ENTRY(coprocessor_segment_overrun)
    5.42  	pushl $0
    5.43  	pushl $do_coprocessor_segment_overrun
    5.44  	jmp do_exception
    5.45  
    5.46 +
    5.47  ENTRY(invalid_TSS)
    5.48  	pushl $do_invalid_TSS
    5.49  	jmp do_exception
    5.50  
    5.51 +
    5.52  ENTRY(segment_not_present)
    5.53  	pushl $do_segment_not_present
    5.54  	jmp do_exception
    5.55  
    5.56 +
    5.57  ENTRY(stack_segment)
    5.58  	pushl $do_stack_segment
    5.59  	jmp do_exception
    5.60  
    5.61 +
    5.62  ENTRY(general_protection)
    5.63  	pushl $do_general_protection
    5.64  	jmp do_exception
    5.65  
    5.66 +
    5.67  ENTRY(alignment_check)
    5.68  	pushl $do_alignment_check
    5.69  	jmp do_exception
    5.70  
    5.71 -# This handler is special, because it gets an extra value on its stack,
    5.72 -# which is the linear faulting address.
    5.73 -# fastcall register usage:  %eax = pt_regs, %edx = error code,
    5.74 -#			    %ecx = fault address
    5.75 +
    5.76  ENTRY(page_fault)
    5.77 -	pushl %ds
    5.78 -	pushl %eax
    5.79 -	xorl %eax, %eax
    5.80 -	pushl %ebp
    5.81 -	pushl %edi
    5.82 -	pushl %esi
    5.83 -	pushl %edx
    5.84 -	decl %eax			/* eax = -1 */
    5.85 -	pushl %ecx
    5.86 -	pushl %ebx
    5.87 -	cld
    5.88 -	movl ORIG_EAX(%esp), %edi
    5.89 -	movl %eax, ORIG_EAX(%esp)
    5.90 -	movl %es, %ecx
    5.91 -	movl %ecx, ES(%esp)
    5.92 -	movl $(__KERNEL_DS),%eax
    5.93 -	movl %eax, %ds
    5.94 -	movl %eax, %es
    5.95 -	pushl %edi
    5.96 -	movl %esp, %eax
    5.97 -	pushl %eax
    5.98 -	call do_page_fault
    5.99 -	jmp ret_from_exception
   5.100 -
   5.101 +    pushl $do_page_fault
   5.102 +    jmp do_exception
   5.103 +    
   5.104  ENTRY(machine_check)
   5.105  	pushl $0
   5.106  	pushl $do_machine_check
   5.107  	jmp do_exception
   5.108  
   5.109 +
   5.110  ENTRY(spurious_interrupt_bug)
   5.111  	pushl $0
   5.112  	pushl $do_spurious_interrupt_bug
   5.113  	jmp do_exception
   5.114  
   5.115 +
   5.116 +
   5.117  ENTRY(thread_starter)
   5.118      popl %eax
   5.119      popl %ebx
     6.1 --- a/extras/mini-os/x86_64.S	Thu May 04 11:14:45 2006 +0100
     6.2 +++ b/extras/mini-os/x86_64.S	Thu May 04 11:19:27 2006 +0100
     6.3 @@ -13,40 +13,6 @@
     6.4  #define ENTRY(X) .globl X ; X :
     6.5  .globl _start, shared_info, hypercall_page
     6.6  
     6.7 -#define SAVE_ALL \
     6.8 -        cld; \
     6.9 -        pushq %rdi; \
    6.10 -        pushq %rsi; \
    6.11 -        pushq %rdx; \
    6.12 -        pushq %rcx; \
    6.13 -        pushq %rax; \
    6.14 -        pushq %r8; \
    6.15 -        pushq %r9; \
    6.16 -        pushq %r10; \
    6.17 -        pushq %r11; \
    6.18 -        pushq %rbx; \
    6.19 -        pushq %rbp; \
    6.20 -        pushq %r12; \
    6.21 -        pushq %r13; \
    6.22 -        pushq %r14; \
    6.23 -        pushq %r15;
    6.24 -
    6.25 -#define RESTORE_ALL \
    6.26 -        popq  %r15; \
    6.27 -        popq  %r14; \
    6.28 -        popq  %r13; \
    6.29 -        popq  %r12; \
    6.30 -        popq  %rbp; \
    6.31 -        popq  %rbx; \
    6.32 -        popq  %r11; \
    6.33 -        popq  %r10; \
    6.34 -        popq  %r9; \
    6.35 -        popq  %r8; \
    6.36 -        popq  %rax; \
    6.37 -        popq  %rcx; \
    6.38 -        popq  %rdx; \
    6.39 -        popq  %rsi; \
    6.40 -        popq  %rdi
    6.41  
    6.42  _start:
    6.43          cld
    6.44 @@ -240,7 +206,17 @@ error_call_handler:
    6.45  #	CFI_ENDPROC
    6.46  .endm	
    6.47  
    6.48 -
    6.49 +.macro errorentry sym
    6.50 +#	XCPT_FRAME
    6.51 +        movq (%rsp),%rcx
    6.52 +        movq 8(%rsp),%r11
    6.53 +        addq $0x10,%rsp /* rsp points to the error code */
    6.54 +	pushq %rax
    6.55 +#	CFI_ADJUST_CFA_OFFSET 8
    6.56 +	leaq  \sym(%rip),%rax
    6.57 +	jmp error_entry
    6.58 +#	CFI_ENDPROC
    6.59 +.endm
    6.60  
    6.61  #define XEN_GET_VCPU_INFO(reg)	movq HYPERVISOR_shared_info,reg
    6.62  #define XEN_PUT_VCPU_INFO(reg)
    6.63 @@ -319,159 +295,84 @@ ENTRY(failsafe_callback)
    6.64          popq  %r11
    6.65          iretq
    6.66  
    6.67 -error_code:
    6.68 -        SAVE_ALL
    6.69 -        movq  %rsp,%rdi
    6.70 -        movl  15*8+4(%rsp),%eax
    6.71 -        leaq  exception_table(%rip),%rdx
    6.72 -        callq *(%rdx,%rax,8)
    6.73 -        RESTORE_ALL
    6.74 -        addq  $8,%rsp
    6.75 -        iretq
    6.76 -                        
    6.77 -ENTRY(divide_error)
    6.78 -        popq  %rcx
    6.79 -        popq  %r11
    6.80 -	pushq $0
    6.81 -        movl  $TRAP_divide_error,4(%rsp)
    6.82 -        jmp   error_code
    6.83 -        
    6.84 +
    6.85  ENTRY(coprocessor_error)
    6.86 -        popq  %rcx
    6.87 -        popq  %r11
    6.88 -	pushq $0
    6.89 -        movl  $TRAP_copro_error,4(%rsp)
    6.90 -        jmp   error_code
    6.91 +        zeroentry do_coprocessor_error
    6.92 +
    6.93  
    6.94  ENTRY(simd_coprocessor_error)
    6.95 -        popq  %rcx
    6.96 -        popq  %r11
    6.97 -	pushq $0
    6.98 -        movl  $TRAP_simd_error,4(%rsp)
    6.99 -        jmp   error_code
   6.100 +        zeroentry do_simd_coprocessor_error
   6.101 +
   6.102  
   6.103  ENTRY(device_not_available)
   6.104 -        popq  %rcx
   6.105 -        popq  %r11
   6.106 -        movl  $TRAP_no_device,4(%rsp)
   6.107 -        jmp   error_code
   6.108 +        zeroentry do_device_not_available
   6.109 +
   6.110  
   6.111  ENTRY(debug)
   6.112 -        popq  %rcx
   6.113 -        popq  %r11
   6.114 -	pushq $0
   6.115 -        movl  $TRAP_debug,4(%rsp)
   6.116 -        jmp   error_code
   6.117 +#       INTR_FRAME
   6.118 +#       CFI_ADJUST_CFA_OFFSET 8 */
   6.119 +        zeroentry do_debug
   6.120 +#       CFI_ENDPROC
   6.121 +
   6.122  
   6.123  ENTRY(int3)
   6.124 -        popq  %rcx
   6.125 -        popq  %r11
   6.126 -	pushq $0
   6.127 -        movl  $TRAP_int3,4(%rsp)
   6.128 -        jmp   error_code
   6.129 +#       INTR_FRAME
   6.130 +#       CFI_ADJUST_CFA_OFFSET 8 */
   6.131 +        zeroentry do_int3
   6.132 +#       CFI_ENDPROC
   6.133  
   6.134  ENTRY(overflow)
   6.135 -        popq  %rcx
   6.136 -        popq  %r11
   6.137 -	pushq $0
   6.138 -        movl  $TRAP_overflow,4(%rsp)
   6.139 -        jmp   error_code
   6.140 +        zeroentry do_overflow
   6.141 +
   6.142  
   6.143  ENTRY(bounds)
   6.144 -        popq  %rcx
   6.145 -        popq  %r11
   6.146 -	pushq $0
   6.147 -        movl  $TRAP_bounds,4(%rsp)
   6.148 -        jmp   error_code
   6.149 +        zeroentry do_bounds
   6.150 +    
   6.151 +    
   6.152 +ENTRY(invalid_op)
   6.153 +        zeroentry do_invalid_op
   6.154  
   6.155 -ENTRY(invalid_op)
   6.156 -        popq  %rcx
   6.157 -        popq  %r11
   6.158 -	pushq $0
   6.159 -        movl  $TRAP_invalid_op,4(%rsp)
   6.160 -        jmp   error_code
   6.161  
   6.162  ENTRY(coprocessor_segment_overrun)
   6.163 -        popq  %rcx
   6.164 -        popq  %r11
   6.165 -	pushq $0
   6.166 -        movl  $TRAP_copro_seg,4(%rsp)
   6.167 -        jmp   error_code
   6.168 +        zeroentry do_coprocessor_segment_overrun
   6.169 +
   6.170  
   6.171  ENTRY(invalid_TSS)
   6.172 -        popq  %rcx
   6.173 -        popq  %r11
   6.174 -        movl  $TRAP_invalid_tss,4(%rsp)
   6.175 -        jmp   error_code
   6.176 +        errorentry do_invalid_TSS
   6.177 +
   6.178  
   6.179  ENTRY(segment_not_present)
   6.180 -        popq  %rcx
   6.181 -        popq  %r11
   6.182 -        movl  $TRAP_no_segment,4(%rsp)
   6.183 -        jmp   error_code
   6.184 +        errorentry do_segment_not_present
   6.185 +
   6.186  
   6.187 +/* runs on exception stack */
   6.188  ENTRY(stack_segment)
   6.189 -        popq  %rcx
   6.190 -        popq  %r11
   6.191 -        movl  $TRAP_stack_error,4(%rsp)
   6.192 -        jmp   error_code
   6.193 +#       XCPT_FRAME
   6.194 +        errorentry do_stack_segment
   6.195 +#       CFI_ENDPROC
   6.196 +                    
   6.197  
   6.198  ENTRY(general_protection)
   6.199 -        popq  %rcx
   6.200 -        popq  %r11
   6.201 -        movl  $TRAP_gp_fault,4(%rsp)
   6.202 -        jmp   error_code
   6.203 +        errorentry do_general_protection
   6.204 +
   6.205  
   6.206  ENTRY(alignment_check)
   6.207 -        popq  %rcx
   6.208 -        popq  %r11
   6.209 -        movl  $TRAP_alignment_check,4(%rsp)
   6.210 -        jmp   error_code
   6.211 +        errorentry do_alignment_check
   6.212 +
   6.213  
   6.214 -ENTRY(virt_cr2)
   6.215 -        .quad 0
   6.216 -ENTRY(page_fault)
   6.217 -        popq  %rcx
   6.218 -        popq  %r11
   6.219 -        popq  virt_cr2(%rip)
   6.220 -        movl  $TRAP_page_fault,4(%rsp)
   6.221 -        jmp   error_code
   6.222 -        
   6.223 -ENTRY(machine_check)
   6.224 -        popq  %rcx
   6.225 -        popq  %r11
   6.226 -	pushq $0
   6.227 -        movl  $TRAP_machine_check,4(%rsp)
   6.228 -        jmp   error_code
   6.229 +ENTRY(divide_error)
   6.230 +        zeroentry do_divide_error
   6.231 +
   6.232  
   6.233  ENTRY(spurious_interrupt_bug)
   6.234 -        popq  %rcx
   6.235 -        popq  %r11
   6.236 -	pushq $0
   6.237 -        movl  $TRAP_spurious_int,4(%rsp)
   6.238 -        jmp   error_code
   6.239 +        zeroentry do_spurious_interrupt_bug
   6.240 +            
   6.241  
   6.242 -ENTRY(exception_table)
   6.243 -        .quad do_divide_error
   6.244 -        .quad do_debug
   6.245 -        .quad 0 # nmi
   6.246 -        .quad do_int3
   6.247 -        .quad do_overflow
   6.248 -        .quad do_bounds
   6.249 -        .quad do_invalid_op
   6.250 -        .quad 0
   6.251 -        .quad 0
   6.252 -        .quad do_coprocessor_segment_overrun
   6.253 -        .quad do_invalid_TSS
   6.254 -        .quad do_segment_not_present
   6.255 -        .quad do_stack_segment
   6.256 -        .quad do_general_protection
   6.257 -        .quad do_page_fault
   6.258 -        .quad do_spurious_interrupt_bug
   6.259 -        .quad do_coprocessor_error
   6.260 -        .quad do_alignment_check
   6.261 -        .quad do_machine_check
   6.262 -        .quad do_simd_coprocessor_error
   6.263 +ENTRY(page_fault)
   6.264 +        errorentry do_page_fault
   6.265 +
   6.266 +
   6.267 +
   6.268  
   6.269  
   6.270  ENTRY(thread_starter)