From: Keir Fraser Date: Mon, 29 Nov 2010 14:40:55 +0000 (+0000) Subject: x86: tighten filter on ptwr_do_page_fault() X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~11194 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=3604b2eafb379357ab63e6081e55ff18327ad07b;p=xen.git x86: tighten filter on ptwr_do_page_fault() Even not-so-recent Linux may, due to post-2.6.18 changes to the process creation code, cause quite a number (depending on environment and argument size) of faulting accesses to user space originating from kernel mode. Generally those happen for non-present pages and would lead to a nested page fault from guest_get_eff_l1e(). They can be avoided by checking for PFEC_page_present as long as the guest isn't running on shadow page tables. Signed-off-by: Jan Beulich Signed-off-by: Keir Fraser --- diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 08cdff97ee..63ab58ccd4 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -1250,13 +1250,20 @@ static int fixup_page_fault(unsigned long addr, struct cpu_user_regs *regs) } if ( VM_ASSIST(d, VMASST_TYPE_writable_pagetables) && - guest_kernel_mode(v, regs) && - /* Do not check if access-protection fault since the page may - legitimately be not present in shadow page tables */ - ((regs->error_code & (PFEC_write_access|PFEC_reserved_bit)) == - PFEC_write_access) && - ptwr_do_page_fault(v, addr, regs) ) - return EXCRET_fault_fixed; + guest_kernel_mode(v, regs) ) + { + unsigned int mbs = PFEC_write_access; + unsigned int mbz = PFEC_reserved_bit | PFEC_insn_fetch; + + /* Do not check if access-protection fault since the page may + legitimately be not present in shadow page tables */ + if ( !paging_mode_enabled(d) ) + mbs |= PFEC_page_present; + + if ( ((regs->error_code & (mbs | mbz)) == mbs) && + ptwr_do_page_fault(v, addr, regs) ) + return EXCRET_fault_fixed; + } /* For non-external shadowed guests, we fix up both their own * pagefaults and Xen's, since they share the pagetables. */