# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1172052820 0
# Node ID bca284f67702cf46502809f29eb634e2ab6d294f
# Parent 2840b5e7f585ad20f3de72592ec5a0fcaa945ed6
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@xxxxxxxxxxxxx>
---
xen/arch/x86/traps.c | 10 +++++++---
xen/arch/x86/x86_32/entry.S | 4 ++--
xen/arch/x86/x86_64/entry.S | 4 ++--
3 files changed, 11 insertions(+), 7 deletions(-)
diff -r 2840b5e7f585 -r bca284f67702 xen/arch/x86/traps.c
--- a/xen/arch/x86/traps.c Wed Feb 21 00:04:59 2007 +0000
+++ b/xen/arch/x86/traps.c Wed Feb 21 10:13:40 2007 +0000
@@ -625,7 +625,8 @@ asmlinkage int do_invalid_op(struct cpu_
if ( unlikely(!guest_mode(regs)) )
{
struct bug_frame bug;
- if ( (__copy_from_user(&bug, (char *)regs->eip, sizeof(bug)) == 0) &&
+ if ( is_kernel(regs->eip) &&
+ (__copy_from_user(&bug, (char *)regs->eip, sizeof(bug)) == 0) &&
(memcmp(bug.ud2, "\xf\xb", sizeof(bug.ud2)) == 0) &&
(memcmp(bug.mov, BUG_MOV_STR, sizeof(bug.mov)) == 0) &&
(bug.ret == 0xc2) )
@@ -877,6 +878,9 @@ static int fixup_page_fault(unsigned lon
return 0;
}
+ ASSERT(!in_irq());
+ ASSERT(regs->eflags & X86_EFLAGS_IF);
+
if ( VM_ASSIST(d, VMASST_TYPE_writable_pagetables) &&
guest_kernel_mode(v, regs) &&
/* Do not check if access-protection fault since the page may
@@ -903,8 +907,6 @@ asmlinkage int do_page_fault(struct cpu_
{
unsigned long addr, fixup;
int rc;
-
- ASSERT(!in_irq());
addr = read_cr2();
@@ -1916,6 +1918,8 @@ void unset_nmi_callback(void)
asmlinkage int math_state_restore(struct cpu_user_regs *regs)
{
+ BUG_ON(!guest_mode(regs));
+
setup_fpu(current);
if ( current->arch.guest_context.ctrlreg[0] & X86_CR0_TS )
diff -r 2840b5e7f585 -r bca284f67702 xen/arch/x86/x86_32/entry.S
--- a/xen/arch/x86/x86_32/entry.S Wed Feb 21 00:04:59 2007 +0000
+++ b/xen/arch/x86/x86_32/entry.S Wed Feb 21 10:13:40 2007 +0000
@@ -424,7 +424,7 @@ handle_exception:
testb $X86_EFLAGS_IF>>8,UREGS_eflags+1(%esp)
jz exception_with_ints_disabled
sti # re-enable interrupts
- xorl %eax,%eax
+1: xorl %eax,%eax
movw UREGS_entry_vector(%esp),%ax
movl %esp,%edx
pushl %edx # push the cpu_user_regs pointer
@@ -451,7 +451,7 @@ exception_with_ints_disabled:
call search_pre_exception_table
addl $4,%esp
testl %eax,%eax # no fixup code for faulting EIP?
- jz FATAL_exception_with_ints_disabled
+ jz 1b
movl %eax,UREGS_eip(%esp)
movl %esp,%esi
subl $4,%esp
diff -r 2840b5e7f585 -r bca284f67702 xen/arch/x86/x86_64/entry.S
--- a/xen/arch/x86/x86_64/entry.S Wed Feb 21 00:04:59 2007 +0000
+++ b/xen/arch/x86/x86_64/entry.S Wed Feb 21 10:13:40 2007 +0000
@@ -362,7 +362,7 @@ ENTRY(handle_exception)
testb $X86_EFLAGS_IF>>8,UREGS_eflags+1(%rsp)
jz exception_with_ints_disabled
sti
- movq %rsp,%rdi
+1: movq %rsp,%rdi
movl UREGS_entry_vector(%rsp),%eax
leaq exception_table(%rip),%rdx
GET_CURRENT(%rbx)
@@ -388,7 +388,7 @@ exception_with_ints_disabled:
movq %rsp,%rdi
call search_pre_exception_table
testq %rax,%rax # no fixup code for faulting EIP?
- jz FATAL_exception_with_ints_disabled
+ jz 1b
movq %rax,UREGS_rip(%rsp)
subq $8,UREGS_rsp(%rsp) # add ec/ev to previous stack frame
testb $15,UREGS_rsp(%rsp) # return %rsp is now aligned?
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|