ia64/xen-unstable

changeset 14053:bca284f67702

x86: Allow exceptions to be handled while interrupts are
disabled. Handlers must take special care if necessary.
Fixes the debug 'd' key.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Feb 21 10:13:40 2007 +0000 (2007-02-21)
parents 2840b5e7f585
children 43e9952b07ea fe3e024e38f8
files xen/arch/x86/traps.c xen/arch/x86/x86_32/entry.S xen/arch/x86/x86_64/entry.S
line diff
     1.1 --- a/xen/arch/x86/traps.c	Wed Feb 21 00:04:59 2007 +0000
     1.2 +++ b/xen/arch/x86/traps.c	Wed Feb 21 10:13:40 2007 +0000
     1.3 @@ -625,7 +625,8 @@ asmlinkage int do_invalid_op(struct cpu_
     1.4      if ( unlikely(!guest_mode(regs)) )
     1.5      {
     1.6          struct bug_frame bug;
     1.7 -        if ( (__copy_from_user(&bug, (char *)regs->eip, sizeof(bug)) == 0) &&
     1.8 +        if ( is_kernel(regs->eip) &&
     1.9 +             (__copy_from_user(&bug, (char *)regs->eip, sizeof(bug)) == 0) &&
    1.10               (memcmp(bug.ud2, "\xf\xb",    sizeof(bug.ud2)) == 0) &&
    1.11               (memcmp(bug.mov, BUG_MOV_STR, sizeof(bug.mov)) == 0) &&
    1.12               (bug.ret == 0xc2) )
    1.13 @@ -877,6 +878,9 @@ static int fixup_page_fault(unsigned lon
    1.14          return 0;
    1.15      }
    1.16  
    1.17 +    ASSERT(!in_irq());
    1.18 +    ASSERT(regs->eflags & X86_EFLAGS_IF);
    1.19 +
    1.20      if ( VM_ASSIST(d, VMASST_TYPE_writable_pagetables) &&
    1.21           guest_kernel_mode(v, regs) &&
    1.22           /* Do not check if access-protection fault since the page may 
    1.23 @@ -904,8 +908,6 @@ asmlinkage int do_page_fault(struct cpu_
    1.24      unsigned long addr, fixup;
    1.25      int rc;
    1.26  
    1.27 -    ASSERT(!in_irq());
    1.28 -
    1.29      addr = read_cr2();
    1.30  
    1.31      DEBUGGER_trap_entry(TRAP_page_fault, regs);
    1.32 @@ -1916,6 +1918,8 @@ void unset_nmi_callback(void)
    1.33  
    1.34  asmlinkage int math_state_restore(struct cpu_user_regs *regs)
    1.35  {
    1.36 +    BUG_ON(!guest_mode(regs));
    1.37 +
    1.38      setup_fpu(current);
    1.39  
    1.40      if ( current->arch.guest_context.ctrlreg[0] & X86_CR0_TS )
     2.1 --- a/xen/arch/x86/x86_32/entry.S	Wed Feb 21 00:04:59 2007 +0000
     2.2 +++ b/xen/arch/x86/x86_32/entry.S	Wed Feb 21 10:13:40 2007 +0000
     2.3 @@ -424,7 +424,7 @@ handle_exception:
     2.4          testb $X86_EFLAGS_IF>>8,UREGS_eflags+1(%esp)
     2.5          jz    exception_with_ints_disabled
     2.6          sti                             # re-enable interrupts
     2.7 -        xorl  %eax,%eax
     2.8 +1:      xorl  %eax,%eax
     2.9          movw  UREGS_entry_vector(%esp),%ax
    2.10          movl  %esp,%edx
    2.11          pushl %edx                      # push the cpu_user_regs pointer
    2.12 @@ -451,7 +451,7 @@ exception_with_ints_disabled:
    2.13          call  search_pre_exception_table
    2.14          addl  $4,%esp
    2.15          testl %eax,%eax                 # no fixup code for faulting EIP?
    2.16 -        jz    FATAL_exception_with_ints_disabled
    2.17 +        jz    1b
    2.18          movl  %eax,UREGS_eip(%esp)
    2.19          movl  %esp,%esi
    2.20          subl  $4,%esp
     3.1 --- a/xen/arch/x86/x86_64/entry.S	Wed Feb 21 00:04:59 2007 +0000
     3.2 +++ b/xen/arch/x86/x86_64/entry.S	Wed Feb 21 10:13:40 2007 +0000
     3.3 @@ -362,7 +362,7 @@ ENTRY(handle_exception)
     3.4          testb $X86_EFLAGS_IF>>8,UREGS_eflags+1(%rsp)
     3.5          jz    exception_with_ints_disabled
     3.6          sti
     3.7 -        movq  %rsp,%rdi
     3.8 +1:      movq  %rsp,%rdi
     3.9          movl  UREGS_entry_vector(%rsp),%eax
    3.10          leaq  exception_table(%rip),%rdx
    3.11          GET_CURRENT(%rbx)
    3.12 @@ -388,7 +388,7 @@ exception_with_ints_disabled:
    3.13          movq  %rsp,%rdi
    3.14          call  search_pre_exception_table
    3.15          testq %rax,%rax                 # no fixup code for faulting EIP?
    3.16 -        jz    FATAL_exception_with_ints_disabled
    3.17 +        jz    1b
    3.18          movq  %rax,UREGS_rip(%rsp)
    3.19          subq  $8,UREGS_rsp(%rsp)        # add ec/ev to previous stack frame
    3.20          testb $15,UREGS_rsp(%rsp)       # return %rsp is now aligned?