From: Tim Deegan Subject: [PATCH] use the right error code when testing for spurious pagefaults Date: Thu, 30 Oct 2008 15:48:28 +0100 Message-ID: <20081030144828.GA25331@york.uk.xensource.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="ReaqsoxgOBHFXBhH" Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --ReaqsoxgOBHFXBhH Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Shadowed PV domains may take pagefaults with PFEC_reserved_bit bit set, which are then turned into page-not-present faults by the shadow code. Since that changes the error code in the regs structure, we need to remember the old error code when we later check for spurious page faults or we'll get false positives. Signed-off-by: Tim Deegan --ReaqsoxgOBHFXBhH Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: attachment; filename=errorcode diff -r c9e9ac3f0d69 xen/arch/x86/traps.c --- a/xen/arch/x86/traps.c Thu Oct 30 11:56:47 2008 +0000 +++ b/xen/arch/x86/traps.c Thu Oct 30 14:37:26 2008 +0000 @@ -1042,7 +1042,7 @@ static int handle_gdt_ldt_mapping_fault( #endif static int __spurious_page_fault( - unsigned long addr, struct cpu_user_regs *regs) + unsigned long addr, unsigned int error_code) { unsigned long mfn, cr3 = read_cr3(); #if CONFIG_PAGING_LEVELS >= 4 @@ -1064,17 +1064,17 @@ static int __spurious_page_fault( return 0; /* Reserved bit violations are never spurious faults. */ - if ( regs->error_code & PFEC_reserved_bit ) + if ( error_code & PFEC_reserved_bit ) return 0; required_flags = _PAGE_PRESENT; - if ( regs->error_code & PFEC_write_access ) + if ( error_code & PFEC_write_access ) required_flags |= _PAGE_RW; - if ( regs->error_code & PFEC_user_mode ) + if ( error_code & PFEC_user_mode ) required_flags |= _PAGE_USER; disallowed_flags = 0; - if ( regs->error_code & PFEC_insn_fetch ) + if ( error_code & PFEC_insn_fetch ) disallowed_flags |= _PAGE_NX; mfn = cr3 >> PAGE_SHIFT; @@ -1132,7 +1132,7 @@ static int __spurious_page_fault( dprintk(XENLOG_WARNING, "Spurious fault in domain %u:%u " "at addr %lx, e/c %04x\n", current->domain->domain_id, current->vcpu_id, - addr, regs->error_code); + addr, error_code); #if CONFIG_PAGING_LEVELS >= 4 dprintk(XENLOG_WARNING, " l4e = %"PRIpte"\n", l4e_get_intpte(l4e)); #endif @@ -1141,14 +1141,11 @@ static int __spurious_page_fault( #endif dprintk(XENLOG_WARNING, " l2e = %"PRIpte"\n", l2e_get_intpte(l2e)); dprintk(XENLOG_WARNING, " l1e = %"PRIpte"\n", l1e_get_intpte(l1e)); -#ifndef NDEBUG - show_registers(regs); -#endif return 1; } static int spurious_page_fault( - unsigned long addr, struct cpu_user_regs *regs) + unsigned long addr, unsigned int error_code) { unsigned long flags; int is_spurious; @@ -1158,7 +1155,7 @@ static int spurious_page_fault( * page tables from becoming invalid under our feet during the walk. */ local_irq_save(flags); - is_spurious = __spurious_page_fault(addr, regs); + is_spurious = __spurious_page_fault(addr, error_code); local_irq_restore(flags); return is_spurious; @@ -1220,8 +1217,10 @@ asmlinkage void do_page_fault(struct cpu asmlinkage void do_page_fault(struct cpu_user_regs *regs) { unsigned long addr, fixup; + unsigned int error_code; addr = read_cr2(); + error_code = regs->error_code; /* fixup_page_fault might change regs */ DEBUGGER_trap_entry(TRAP_page_fault, regs); @@ -1232,7 +1231,7 @@ asmlinkage void do_page_fault(struct cpu if ( unlikely(!guest_mode(regs)) ) { - if ( spurious_page_fault(addr, regs) ) + if ( spurious_page_fault(addr, error_code) ) return; if ( likely((fixup = search_exception_table(regs->eip)) != 0) ) @@ -1251,11 +1250,11 @@ asmlinkage void do_page_fault(struct cpu panic("FATAL PAGE FAULT\n" "[error_code=%04x]\n" "Faulting linear address: %p\n", - regs->error_code, _p(addr)); + error_code, _p(addr)); } if ( unlikely(current->domain->arch.suppress_spurious_page_faults - && spurious_page_fault(addr, regs)) ) + && spurious_page_fault(addr, error_code)) ) return; propagate_page_fault(addr, regs->error_code); --ReaqsoxgOBHFXBhH Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --ReaqsoxgOBHFXBhH--